// JavaScript Document

var streamId
//  alert to show the flash is passing the add Id properly
var htmlHTTP;

function updateRelatedMediaAd(adId)
{ 

}


function stateChangedNowPlaying()
{
	if (htmlHTTP.readyState==4 || htmlHTTP.readyState=="complete"){
		document.getElementById("nowplaying").innerHTML=htmlHTTP.responseText;
		
	 }
}
 
function stateChanged() 
{ 
	if (htmlHTTP.readyState==4 || htmlHTTP.readyState=="complete")
	{
			
 	 	//document.getElementById("relatedAdBlock").innerHTML ='asdf';//
		document.getElementById("relatedAdBlock").innerHTML=htmlHTTP.responseText;

		//alert(htmlHTTP.responseText);
 	}
} 

function GetXmlHttpObject()
{ 
	var objXMLHttp=null
 	if (window.XMLHttpRequest)
  	{
  		objXMLHttp=new XMLHttpRequest()
  	}
 	else if (window.ActiveXObject)
  	{
  		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
  	}
 	return objXMLHttp
}



//  sets the stream id
function set(sid) {	streamId = sid;	}
//  function used by flash to get the current stream id.
//  this id equals the current stream id then flash does nothing
function getsid() {	return streamId;}

function loadNewFlash(id){
	obj = document.getElementById("flashHolder");

	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	
	outVar = "<center>";
	
	outVar += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="251" height="211" wmode="transparent" allowFullScreen="true">';
	outVar += '<param name="movie" value="/flash/media_center.swf?vnum=1&sid=' + id + '" />';
	outVar += '<param name="allowScriptAccess" value="always" />';
	outVar += '<param name="quality" value="high" />';
	outVar += '<param NAME="wmode" VALUE="transparent" />';
	if(!isIE){
		outVar += '<object type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" data="/flash/media_center.swf?vnum=1&sid=' + id + '" width="251" height="211" wmode="transparent">';
		outVar += '</object>';
	}else{
		outVar += '<embed type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" data="/flash/media_center.swf?vnum=1&sid=' + id + '" width="251" height="211" wmode="transparent">';
		outVar += '</embed>';
	}
	outVar += '</object></center>';
	
	obj.innerHTML = outVar;
	
	//location.href = '#anchor_media_center';
}

currentSlidingAd = 0;
adWaitTime = 5000;
function animateSlidingAd(){
	
	setTimeout ( animateNextSlideAd, adWaitTime );
	if(adWaitTime == 25000){
		adWaitTime = 5000;	
	}
}

function animateNextSlideAd(){
	//alert("num: " + numSlidingAds + " current: " + currentSlidingAd);
	if(adWaitTime != 25000){
		if(currentSlidingAd < numSlidingAds){
			sp100.showNextPanel();
			highlightLink('ad_link_', (adIndex+1), adIndex);
			currentSlidingAd++;
			if(currentSlidingAd < numSlidingAds){
				adWaitTime = 5000;
			}else{
				adWaitTime = 1;	
			}
		}else{
			currentSlidingAd = 0;
			sp100.showPanel(currentSlidingAd)
			highlightLink('ad_link_', 0, adIndex);
			adWaitTime = 5000;
		}
	}
	animateSlidingAd();
	
}