function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq(action,month,year,style_id) {
    http.open('get', 'make_calendar.php?action='+action+'&style_id='+style_id+'&month='+month+'&year='+year);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
        }
    }
}

function show_hide(display, style_id)
{
	if(display == 'hide')
	{
		document.getElementById(style_id).style.height='0'; 
		document.getElementById(style_id).style.width='0'; 
		document.getElementById(style_id).style.visibility='hidden';
		document.getElementById(style_id).style.overflow='hidden';
		
		//document.getElementById('shrink').style.display='none';
		//document.getElementById('expand').style.display='inline';
	}
	
	if(display == 'show')
	{
		document.getElementById(style_id).style.height='80px'; 
		document.getElementById(style_id).style.overflow='auto';
		document.getElementById(style_id).style.visibility='visible';
		document.getElementById(style_id).style.display='inline';
		
		//document.getElementById('expand').style.display='none';
		//document.getElementById('shrink').style.display='inline';
	}

}

function update(id, size)
{
	if(size == 1)
		document.getElementById(id).innerHTML = "<img src='/images/marker3.gif' class='marker1'>";
	if(size == 2)
		document.getElementById(id).innerHTML = "<img src='/images/marker1.gif' class='marker1'>";
}

function untruncate(text, id)
{
	document.getElementById(id).innerHTML = text;
}

function showVideo(video)
{
	$("body").prepend("<div id='whiteout'></div>");
	$("#whiteout").prepend("<div id='qcVideoPlayer' name='qcVideoPlayer'></div>");
	$("#whiteout").prepend("<span id='close_qcVideoPlayer'> </span>");

	$("#close_qcVideoPlayer").click(function ()
	{	
		document.getElementById('qcVideoPlayer').innerHTML = '';
		$("#qcVideoPlayer").slideUp('slow', function() {
				//$("#qcVideoPlayer").remove();
				$("#whiteout").hide('slow', function() {
						$("#whiteout").remove();
					});
			});

		$("#close_qcVideoPlayer").remove();
	});	

	var whiteout = document.getElementById('whiteout').style;
	var qcVideoPlayer = document.getElementById('qcVideoPlayer').style;
	var close_qcVideoPlayer = document.getElementById('close_qcVideoPlayer').style;
	
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) 
	{
	//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	whiteout.width = myWidth+'px';
	whiteout.height = myHeight+'px'; 
	
	var scroll = (document.all)?document.body.scrollTop:window.pageYOffset; 
	whiteout.top = scroll+'px';
	
	var top = myHeight / 2 - 163;
	qcVideoPlayer.top = top+'px';	
	close_qcVideoPlayer.top = top-21+'px';	
	
	$("#whiteout").show('normal', function (){ whiteout.filter = 'alpha(opacity=70)';});
	$("#qcVideoPlayer").slideDown('normal');
	whiteout.visibility = 'visible';
	var so2 = new SWFObject('player.swf', 'mymovie', '320', '276', '8', '');
	so2.addVariable('movie_file', video);
	so2.write('qcVideoPlayer');
}


function changeButton(id, thisVar){		// this var changes the text of the Anchor tag... may not necessesarily be the link calling it however it should always be the link that we want the text to change

	var divID = "testimonialDiv-" + id;
	var showVar = show[id];
	
	
	if(showVar == true){
		$('#' + divID + ':hidden').slideDown('fast');
	//	thisVar.setAttribute('onclick',"changeButton(false, 'testing', this); return false;");
		show[id] = false;
		thisVar.innerHTML = 'Hide Testimonial';
	} else {
	//alert("HERE");

		$('#' + divID + ':visible').slideUp('fast');
	//	thisVar.setAttribute('onclick',"changeButton(true, 'testing', this); return false;");
		show[id] = true;
		thisVar.innerHTML = 'Read Testimonial';
	}
	
}