function showHide(s){
	if(document.getElementById(s)) document.getElementById(s).style.display = "";
	for (x=1;x<arguments.length;x++){
		if(document.getElementById(arguments[x])) {
			document.getElementById(arguments[x]).style.display = "none";}}
}
function showHideParent(s){
	if(parent.document.getElementById(s)) parent.document.getElementById(s).style.display = "";
	for (x=1;x<arguments.length;x++){
		if(parent.document.getElementById(arguments[x])) {
			parent.document.getElementById(arguments[x]).style.display = "none";}}
}
function showDivParent(){
	for (x=0;x<arguments.length;x++){
		if(parent.document.getElementById(arguments[x])) parent.document.getElementById(arguments[x]).style.display = "";}
}
function hideDivParent(){
	for (x=0;x<arguments.length;x++){
		if(parent.document.getElementById(arguments[x])) parent.document.getElementById(arguments[x]).style.display = "none";}
}
function showDiv(){
	for (x=0;x<arguments.length;x++){
		if(document.getElementById(arguments[x])) document.getElementById(arguments[x]).style.display = "";}
}
function hideDiv(){
	for (x=0;x<arguments.length;x++){
		if(document.getElementById(arguments[x])) document.getElementById(arguments[x]).style.display = "none";}
}

function formatShowDate(strDate){
	if(strDate>""){
		var showdate = new Date(strDate);
		var year = showdate.getFullYear();
		var month = showdate.getMonth()+1;
		month = month.toString();
		var day = showdate.getDate();
		day = day.toString();	
		if(month.length < 2) month = "0"+month;
		if(day.length < 2) day = "0"+day;
		return(year + "_" + month + "_" + day);
	}
}

function checkPlayer(type) {
	//check browser plugins
	hasVal = false;
	for (i = 0; i < navigator.plugins.length; i++) {
		if (navigator.plugins[i].name.indexOf(type) != -1) {
			hasVal = true;}
	} 
	return(hasVal);
} 

function checkBrowser(type,ver)
{
	//check browser 
	hasVal = false;

	browsType = navigator.userAgent
	temp=browsType.split(type);
	browsVer=parseInt(temp[1]);

	if (browsType.indexOf(type)>-1 && browsVer == ver) hasVal = true;
	return(hasVal);
}

function showPlayer(div, id, useparent){
	var src;
	if (id == "") { id = 0; }
	src = playerURL;
	src = src.replace('archiveIDVal', id);
	var str = '';

	var url = rootURL + "live/playshow.asp";
	url += "?id=" + id;
	var swfURL = imagesURL + 'gdtv/swf/mp3Player2.swf';
	var xmlHttp = GetXmlHttpObject();
	if (xmlHttp != null) {
	  xmlHttp.onreadystatechange = function() {
	    if (xmlHttp.readyState == 4) {
	      str = xmlHttp.responseText;
	      str = str.replace(/'/g, "");
	      str = str.replace(/"/g, "'");	      
	      
	      displayStr = '<object id="mediaplayer" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="' + playerwidth + '" height="' + playerheight + '" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" align="middle">';
	      displayStr += '<param name="allowScriptAccess" value="sameDomain" \/>';
	      displayStr += '<param name="allowFullScreen" value="false" \/>';
	      displayStr += '<param name="movie" value="' + swfURL + '?xmlVar=' + str + '" \/>';
	      displayStr += '<param name="quality" value="high" \/>';
	      displayStr += '<param name="bgcolor" value="#000000" \/>';


	      displayStr += '<embed src="' + swfURL + '?xmlVar=' + str + '" ';
	      displayStr += 'quality="high" bgcolor="#000000" width="' + playerwidth + '" height="' + playerheight + '" name="mediaplayer" align="middle" ';
	      displayStr += 'allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" ';
	      displayStr += 'pluginspage="http:\/\/www.macromedia.com\/go\/getflashplayer" \/>';
	      displayStr += '<\/embed><\/object>'

	      if (useparent) {
	        if (parent.document.getElementById(div)) {
	          parent.document.getElementById(div).innerHTML = displayStr;
	        }
	      }
	      else {
	        if (document.getElementById(div)) {
	          document.getElementById(div).innerHTML = displayStr;
	        }
	      }
	    }
	  }
	  xmlHttp.open("GET", url, true);
	  xmlHttp.send(null);
	}	
}

function stopIt(playerObj) 
{ 
	if(playerObj){
		playerObj.Stop(); 
		}
	
} 

function displayNowPlaying(div, showDate, desc, useparent){
	displayStr = '<div class="s4">&nbsp;</div>';
	displayStr += '<table class="subText" border="0" cellpadding="0" cellspacing="0" width="100%">';
	displayStr += '<td rowspan="3" valign="top" style="width:180px;"><b>' + showDate + '</b></td>';
	displayStr += '<td valign="top" style="width:100px;"><div id="ratingDiv" style="white-space:nowrap;color:#FF6600;vertical-align:top;">&nbsp;</div>';
	displayStr += '</td>';
	displayStr += '<td valign="center" style="">&nbsp;';
	displayStr += '</td></tr>';	
	displayStr += '<tr><td colspan="2"></td></tr>';
	displayStr += '</table>';
	displayStr += '<div style="line-height:4px;">&nbsp;</div>';
	displayStr += '<div style="padding-right:4px;">' + desc + '</div>';

	if(useparent){
		if(parent.document.getElementById(div)) {
			parent.document.getElementById(div).innerHTML = displayStr;}}
	else{
		if(document.getElementById(div)){
			document.getElementById(div).innerHTML = displayStr;}}
}

function addRating(useparent){
	var bOK = true;
	if(frmShow) archiveID = frmShow.archiveID.value;
	if(document.frmRating){
		if(document.frmRating.optRating.selectedIndex > 0){
			rating = document.frmRating.optRating.options[document.frmRating.optRating.selectedIndex].value;}
		else{
			alert("Choose a show rating.");
			bOK = false;}
	}	
	if(bOK){
		var url= rootURL + "live/ajax_process.asp";		
		url+="?t=r&r="+rating+"&id="+archiveID;
		url+="&a="+Math.random();
		var xmlHttp = GetXmlHttpObject();
		if(xmlHttp!=null){
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=function(){
				if (xmlHttp.readyState==4)
				{ 
					return eval(xmlHttp.responseText);
				}
			}
			xmlHttp.send(null);
		}
	}
}

function displayNowPlayingLive(div, showDate, desc, useparent){
	var displayStr = "";
	if(showDate>""){
		displayStr += '<b>' + showDate + '</b><br>'}
	displayStr += desc;
	if(useparent){
		if(parent.document.getElementById(div)) {
			parent.document.getElementById(div).innerHTML = displayStr;}}
	else{
		if(document.getElementById(div)) {
			document.getElementById(div).innerHTML = displayStr;}}
}

function getShowVidSeg(id, div, useparent){
	var url= rootURL + "live/ajax_process.asp";		
	url+="?t=s&id="+id;
	url+="&a="+Math.random();
	var xmlHttp = GetXmlHttpObject();
	if(xmlHttp!=null){
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange=function(){
			if (xmlHttp.readyState==4)
			{ 
				if(useparent){
					if(parent.document.getElementById(div)) {
						parent.document.getElementById(div).innerHTML = parent.document.getElementById(div).innerHTML + xmlHttp.responseText;}}
				else{
					if(document.getElementById(div)) {
						document.getElementById(div).innerHTML = document.getElementById(div).innerHTML + xmlHttp.responseText;}}
				//xmlHttp.abort();
			}
		}
		xmlHttp.send(null);
	}
}

function clearDiv(div, useparent){
	if(useparent){
		if(parent.document.getElementById(div)) {
			parent.document.getElementById(div).innerHTML = "";}}
	else{
		if(document.getElementById(div)){
			document.getElementById(div).innerHTML = "";}}
}

function goVideo(file, useparent){
	if (useparent){
		showHideParent('showControls2','showControls1');
		//showDivParent('verifyDiv');
		showHideParent('videoDiv','playerAnimDiv');
		}
	else{
		showHide('showControls2','showControls1');
		//showDiv('verifyDiv');
		showHide('videoDiv','playerAnimDiv');
		}
	clearDiv('playerDiv',useparent);
	
	if(useparent){
		parent.document.frmVerify.vid.value=file;}
	else{
		document.frmVerify.vid.value=file;}
	if(file>"") verifyCode("", file, useparent);
}

function goVideo2(file, useparent){
	if (useparent){
		showHideParent('videoDiv','playerAnimDiv');}
	else{
		showHide('videoDiv','playerAnimDiv');}
	clearDiv('playerDiv',false);
	
	if(file>"") verifyCode("", file, useparent);
}

function goStream(id, useparent){
	if (useparent){
		showHideParent('playerAnimDiv','videoDiv');
		hideDivParent('verifyDiv');
		showHideParent('showControls1','showControls2');}
	else{
		showHide('playerAnimDiv','videoDiv');
		hideDiv('verifyDiv');
		showHide('showControls1','showControls2');}
	clearDiv('videoDiv',useparent);
	showPlayer('playerDiv', id, useparent);
}

function captchaEntry(e){
	var keynum;
	if(window.event){
		keynum = e.keyCode;}
	else if(e.which){
		keynum = e.which;}

	if (keynum==13 || keynum==3){				
		verifyCode(document.frmVerify.displaycode.value, document.frmVerify.vid.value, false);
		e.keyCode = 0;}	
}

function verifyCode(code, file, useparent){
	var url= rootURL + "live/ajax_process.asp";		
	url+="?t=v&code="+code+"&file="+file+"&p="+useparent;
	url+="&a="+Math.random();
	var xmlHttp = GetXmlHttpObject();
	if(xmlHttp!=null){
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange=function(){
			if (xmlHttp.readyState==4)
			{ 
				return eval(xmlHttp.responseText);
			}
		}
		xmlHttp.send(null);
	}
}

function playVideo(file){
	if (AC_FL_RunContent == 0) {
	} else {		
		if (file.indexOf("http") > -1){
			AC_FL_RunContent(
				'codebase', sGlobal_secPrefix + '://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
				'width', viddimensions,
				'height', viddimensions,
				'src', file,
				'movie', file,
				'quality', 'high',
				'pluginspage', sGlobal_secPrefix + '://www.macromedia.com/go/getflashplayer',
				'align', 'middle',
				'play', 'true',
				'loop', 'true',
				'scale', 'showall',
				'wmode', 'window',
				'devicefont', 'false',
				'id', 'video',
				'bgcolor', '#DDDDDD',
				'name', 'video',
				'menu', 'true',
				'allowFullScreen', 'false',
				'allowScriptAccess','sameDomain',
				'salign', ''
				); //end AC code
			}else{
			file = file.slice(0, file.indexOf("."));
			AC_FL_RunContent(
				'codebase', sGlobal_secPrefix + '://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
				'width', viddimensions,
				'height', viddimensions,
				'src', file,
				'movie', file,
				'quality', 'high',
				'pluginspage', sGlobal_secPrefix + '://www.macromedia.com/go/getflashplayer',
				'align', 'middle',
				'play', 'true',
				'loop', 'true',
				'scale', 'showall',
				'wmode', 'window',
				'devicefont', 'false',
				'id', 'video',
				'bgcolor', '#DDDDDD',
				'name', 'video',
				'menu', 'true',
				'allowFullScreen', 'false',
				'allowScriptAccess','sameDomain',
				'salign', ''
				); //end AC code
			}
	}
}

function ratingView(lvl, img, show, title)
{
	if (document.images)
	{
		if(show)
		{
			document.images[img].src = eval("r"+lvl+".src");
			document.getElementById('showRating').innerHTML = title;
		}
		else
		{
			document.images[img].src = eval("r0.src");
			document.getElementById('showRating').innerHTML = '';
		} 
	}
}

function checkAppRefresh(p,s){
	var url= rootURL + "live/ajax_process.asp";		
	url+="?t=a&p="+p+"&s="+s;
	url+="&a="+Math.random();
	var xmlHttp = GetXmlHttpObject();
	if(xmlHttp!=null){
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange=function(){
			if (xmlHttp.readyState==4)
			{ 
				//alert(xmlHttp.responseText);
				return eval(xmlHttp.responseText);
			}
		}
		xmlHttp.send(null);
	}
}

function displayNowPlayingHeader(div, title, rating, useparent){
	var displayStr = "";
	displayStr += '<table class="subText" width="360" cellpadding="0" cellspacing="0" border="0">';
	displayStr += '	<tr>';
	displayStr += '		<td width="219" bgcolor="#dddddd" style="padding-left:10px;width:219px;"><b>' + title + '</b></td>';
	displayStr += '		<td nowrap width="141" bgcolor="#dddddd" style="background-image:url(\'' + imagesURL + 'aaa/live/lol_rating_back.gif\');background-repeat:no-repeat;width:202px;height:48px;"><div style="font-weight:bold;padding:6px 4px 0px 26px;">';
	displayStr += rating;
	displayStr += '<form style="margin:0px;" name="frmRating">';
	displayStr += '<select name="optRating" size="1" class="subText" style="width:130px;">';
	displayStr += '<option value="40">Rate this show...</option>';
	displayStr += '<option value="40">4 Stars - Hot Show!</option>';
	displayStr += '<option value="30">3 Stars - Great Show</option>';
	displayStr += '<option value="20">2 Stars - Good Show</option>';
	displayStr += '<option value="20">1 Star - So-so Show</option></select>';
	displayStr += '&nbsp;&nbsp;<a href="javascript:addRating(' + useparent + ');"><img src="' + imagesURL + 'aaa/live/bttn_ok_small_greenMatte.gif" width="28" height="17" border="0" style="vertical-align:top;padding-top:1px;"></a>';
	displayStr += '</form></div></td>';
	displayStr += '	</tr>';
	displayStr += '</table>';
	if(useparent){
		if(parent.document.getElementById(div)) {
			parent.document.getElementById(div).innerHTML = displayStr;}}
	else{
		if(document.getElementById(div)) {
			document.getElementById(div).innerHTML = displayStr;}}
}

function displayNowPlayingHeaderLive(div, title, useparent){
	var displayStr = "";
	displayStr += '<table class="subText" width="360" cellpadding="0" cellspacing="0" border="0">';
	displayStr += '	<tr>';
	displayStr += '		<td width="219" bgcolor="#EEEEEE" style="padding-left:10px;width:219px;"><b>' + title + '</b></td>';
	displayStr += '		<td width="141" bgcolor="#EEEEEE"><div style="padding:2px 4px 0px 26px;">';
	if(chatOn){
	  displayStr += '		<a href="javascript:openChat();"><img src="' + imagesURL + 'aaa/live/rgd_hp_button.gif" width="157" height="21" border="0"></a>';
	}
	displayStr += '		</div>';
	displayStr += '		</td>';	
	displayStr += '	</tr>';
	displayStr += '</table>';
	if(useparent){
		if(parent.document.getElementById(div)) {
			parent.document.getElementById(div).innerHTML = displayStr;}}
	else{
		if(document.getElementById(div)) {
			document.getElementById(div).innerHTML = displayStr;}}
}

function showArchives(yr,a){
	var src = archiveURL;
	src = src.replace('yryr', yr);
	src = src.replace('aa', a);
	window.open(src,"archiveFrame");
}

function WindowLeftForCenter(windowWidth){
	return (screen.availWidth - windowWidth) /2;
}
function WindowTopForCenter(windowHeight){
	return (screen.availHeight - windowHeight) /2;
}

function openWindow(url, winname, newWindowWidth, newWindowHeight){
	var win;
	var options;
	options = "resizable=yes,scrollbars=no,status=no,location=no,menubar=no,toolbar=no,";
	options += "width=" + newWindowWidth + ",";
	options += "height=" + newWindowHeight + ",";
	options += "screenY=" + WindowTopForCenter(newWindowHeight) + ",";
	options += "top=" + WindowTopForCenter(newWindowHeight) + ",";
	options += "screenX=" + WindowLeftForCenter(newWindowWidth) + ",";
	options += "left=" + WindowLeftForCenter(newWindowWidth) + ",";
	try{
		win = window.open(url, winname, options);
		if (win){
			win.focus();}
		else{
			throw "popupBlocker";}
	}
	catch(er){
		if (er == "popupBlocker"){
			window.alert("To view the chat please disable your popup blocker.");}
	}					
}

function GetXmlHttpObject(){
  var xmlHttp=null;
  try{
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }
  catch (e) {
    // IE
    try {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e){
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
  }
  return xmlHttp;
} 

function iTunesDownload(){
  try{
    win = window.open("http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=73331099", "iTunesDownload", "resizable=yes,scrollbars=no,status=no,location=no,menubar=no,toolbar=no,width=640,height=555");
    if(win){
      win.focus();
    }else{
      throw "popupBlocker";
    }
  }catch(er){
    if (er == "popupBlocker"){
      window.alert("To load iTunes for download please disable your popup blocker.");
    }    
  }
}

//cache mouseover images for rating so they display faster
if (document.images){
	r0 = new Image();r0.src = imagesURL + "aaa/live/starsv2/r00.gif";
	//r5 = new Image();r5.src = imagesURL + "aaa/live/stars/r5.gif";
	r10 = new Image();r10.src = imagesURL + "aaa/live/starsv2/r10.gif";
	//r15 = new Image();r15.src = imagesURL + "aaa/live/stars/r15.gif";
	r20 = new Image();r20.src = imagesURL + "aaa/live/starsv2/r20.gif";
	//r25 = new Image();r25.src = imagesURL + "aaa/live/stars/r25.gif";
	r30 = new Image();r30.src = imagesURL + "aaa/live/starsv2/r30.gif";
	//r35 = new Image();r35.src = imagesURL + "aaa/live/stars/r35.gif";
	r40 = new Image();r40.src = imagesURL + "aaa/live/starsv2/r40.gif";
	//r45 = new Image();r45.src = imagesURL + "aaa/live/stars/r45.gif";
	r50 = new Image();r50.src = imagesURL + "aaa/live/starsv2/r50.gif";}
	
	
