function showWelcomePopupForFirstTimeUser()
{
	//Shadowbox.init();
	Shadowbox.open( { content : '<div style="padding-top:22px; padding-left:22px"><div class="overlayCloseBtn"><a href="#" onClick="parent.Shadowbox.close()"><img src="/images/showPopupCloseBtn.png" /></a></div><div class="welcomePopupBox"><a href="#" onclick=\'Shadowbox.open({player:"flv",content:"swf/INTV_VID_TEST.flv", height:400, width:640});\'><img src="images/viewDemoBtn.png" onmouseover="Shadowbox.next();swapImage(this,\'viewDemoBtnOver.png\');" onmouseout="swapImage(this, \'viewDemoBtn.png\');" /></a></div></div>'
                         , player : 'html'
                         , width: '972px'
        				 , height: '522px'
                         }
                       ); 

return false;
}

function openYouTube(youTubeURL)
{
	Shadowbox.init();
	Shadowbox.open( { content : youTubeURL
                         , player : 'iframe'
                         , title : ''
						 ,width: '640px'
						 ,height: '400px'
                         }
                       ); 
}

function openSB(paramUrl, paramWidth, paramHeight)
{
	Shadowbox.init();
	Shadowbox.open( { content : paramUrl
                         , player : 'iframe'
                         , title : ''
						 ,width:paramWidth + 'px'
						 ,height:paramHeight + 'px'
                         }
                       ); 
}

function openShadowboxForSendToFriend(paramId) {
	Shadowbox.init();
	Shadowbox.open( { content : '/sendToFriend.html?progId='+paramId
                         , player : 'iframe'
                         , title : ''
						 ,width:'550px'
						 ,height:'400px'
                         }
                       ); 
}

function showServiceTire(value){
	$.ajax({'type': 'get', 'url': 'serviceTire.html?id='+value, async:false, success:function(data){$('#listOfserviceTire').html(data);}});
}

function openShadowboxForInvalidPassword()
{
	Shadowbox.init();
	Shadowbox.open( { content : '<table width="353" border="0" cellspacing="0" cellpadding="0">'+
  '<tr>'+
    '<td width="8" height="8" style="background:url(images/overlayLT.png) no-repeat"></td>'+
    '<td style="background:#363636"></td>'+
   '<td width="8" style="background:url(images/overlayRT.png) no-repeat"></td>'+
  '</tr>'+
  '<tr>'+
    '<td style="background:#363636">&nbsp;</td>'+
    '<td align="center" class="registrationTitle" style="background:#000"><div class="clearBoth"><div class="right" style="margin-top:-5px; margin-right:5px"><a href="#" onClick="parent.Shadowbox.close()"><img src="images/overlayCloseX.png" style="margin-top:5px" /></a></div></div>'+
    '<div class="c9a9a9a bigFontBold" style="padding:30px 0px 15px 0px">Invalid reset password request!</div>'+
      '<div class="vert-align-top" style="padding:15px 0px 15px 0px"><a href="#" onClick="parent.Shadowbox.close()"><img src="images/closeBtn.png" /></a></div></td>'+
   ' <td style="background:#363636">&nbsp;</td>'+
  '</tr>'+
 ' <tr>'+
    '<td width="8" height="8" style="background:url(images/overlayBL.png) no-repeat"></td>'+
    '<td style="background:#363636"></td>'+
    '<td style="background:url(images/overlayBR.png) no-repeat"></td>'+
 ' </tr>'+
'</table>'
                         , player : 'html'
                         , title : ''
                         }
                       ); 
}

function openShadowboxForOverlayTest(overlayHTML)
{
	Shadowbox.init();
	Shadowbox.open( { content : overlayHTML
                         , player : 'html'
                         , title : ''
						 ,width:'596px'
						 ,height:'355px'
                         }
                       ); 
	document.getElementById('allOverlayBox').innerHTML = '';
}

function openShadowboxToResetPassword(guid)
{
	Shadowbox.init();
	//alert(guid);
	Shadowbox.open( { content : 'resetPassword.html?guid='+guid
                         , player : 'iframe'
                         , title : ''
						 ,width:'625px'
						 ,height:'450px'
                         }
                       ); 
}

function openShadowboxFromEmail()
{
	Shadowbox.init();
	Shadowbox.open( { content : '<table width="400" border="0" cellspacing="0" cellpadding="0">'+
  '<tr>'+
    '<td width="8" height="8" style="background:url(images/overlayLT.png) no-repeat"></td>'+
    '<td style="background:#363636"></td>'+
   '<td width="8" style="background:url(images/overlayRT.png) no-repeat"></td>'+
  '</tr>'+
  '<tr>'+
    '<td style="background:#363636">&nbsp;</td>'+
    '<td align="center" class="registrationTitle" style="background:#000"><div class="right" style="margin-top:8px; margin-right:8px"><a href="#" onClick="parent.Shadowbox.close()"><img src="images/overlayCloseX.png" /></a></div>'+
    '<div class="c9a9a9a" style="padding:30px 0px 15px 0px; font:bold 14px Arial">Congratulations, your account has been created!</div>'+
      '<div class="vert-align-top" style="padding:15px 0px 15px 0px"><a href="#" onClick="parent.Shadowbox.close()"><img src="images/closeBtn.png" /></a></div></td>'+
   ' <td style="background:#363636">&nbsp;</td>'+
  '</tr>'+
 ' <tr>'+
    '<td width="8" height="8" style="background:url(images/overlayBL.png) no-repeat"></td>'+
    '<td style="background:#363636"></td>'+
    '<td style="background:url(images/overlayBR.png) no-repeat"></td>'+
 ' </tr>'+
'</table>'
                         , player : 'html'
                         , title : ''
                         }
                       ); 
}

function openOverlay(overLayContentUrl)
{
	var overlayContent = '';
	$.ajax({'type': 'get', 'url': overLayContentUrl, async:false, success:function(data){overlayContent = data;}});

	Shadowbox.init();
	Shadowbox.open( { content : '<table width="400" border="0" cellspacing="0" cellpadding="0">'+
  '<tr>'+
    '<td width="8" height="8" style="background:url(images/overlayLT.png) no-repeat"></td>'+
    '<td style="background:#363636"></td>'+
   '<td width="8" style="background:url(images/overlayRT.png) no-repeat"></td>'+
  '</tr>'+
  '<tr>'+
    '<td style="background:#363636">&nbsp;</td>'+
    '<td align="center" class="registrationTitle" style="background:#000"><div class="right" style="margin-top:8px; margin-right:8px"><a href="#" onClick="parent.Shadowbox.close()"><img src="images/overlayCloseX.png" /></a></div>'+
    '<div class="c9a9a9a" style="padding:30px 0px 15px 0px; font:bold 14px Arial">' + overlayContent + '</div>'+
      '<div class="vert-align-top" style="padding:15px 0px 15px 0px"><a href="#" onClick="parent.Shadowbox.close()"><img src="images/closeBtn.png" /></a></div></td>'+
   ' <td style="background:#363636">&nbsp;</td>'+
  '</tr>'+
 ' <tr>'+
    '<td width="8" height="8" style="background:url(images/overlayBL.png) no-repeat"></td>'+
    '<td style="background:#363636"></td>'+
    '<td style="background:url(images/overlayBR.png) no-repeat"></td>'+
 ' </tr>'+
'</table>'
                         , player : 'html'
                         , title : ''
                         }
                       ); 
}


function openShadowboxToUploadImage()
{
	Shadowbox.init();
	Shadowbox.open( { content : 'uploadGraphicOverlay.html'
                         , player : 'iframe'
                         , title : ''
						 ,width:'700px'
						 ,height:'592px'
                         }
                       ); 
}

function openShadowboxToLogin()
{
	Shadowbox.init();
	Shadowbox.open( { content : '/login.html'
                         , player : 'iframe'
                         , title : ''
						 ,width:'700px'
						 ,height:'592px'
                         }
                       ); 
}

function openShadowboxToRegistration(link)
{
	/*Shadowbox.init();
	Shadowbox.open( { content : '/registrationWizard.html'
                         , player : 'iframe'
                         , title : ''
						 ,width:'700px'
						 ,height:'600px'
                         }
                       ); */
	var rand_no = Math.random();
	rand_no = rand_no *10000;
	rand_no = Math.ceil(rand_no);
	if(link == null || link != 'forSendToFriend')
		window.location='/integratedRegistration.html?msgType=alarmRegLink&randomNo='+rand_no;
	else
		window.location='/integratedRegistration.html?msgType=sendToFrnRegLink&randomNo='+rand_no;
}

function getFriendSearch()
{
   var searchText = document.getElementById('frndsearch').value;
   var queryString = "friends.html?userSearchText="+escape(searchText);
   window.location=queryString;
}

function getSearchResult()
{
   var searchText = document.getElementById('search').value;
   var queryString = "/search.html?searchText="+escape(searchText);
   window.location=queryString;
}

function getSearchResultFromHeader()
{
   var searchText = document.getElementById('search1').value;
   var queryString = "/search.html?searchText="+escape(searchText);
   window.location=queryString;
}

function checkKeyForSearch(event, type)
{
   	var code;
	if (!event) var event = window.event;
	if (event.keyCode) code = event.keyCode;
	else if (event.which) code = event.which;
	else return true;

    if(code == 13 || code == 3)
	{
	    if(type=='programSearch')
	    {
		  getSearchResult();
		}
		else if(type=='friendSearch')
	    {
		  getFriendSearch();
		}
		return false;
	}
}

function checkKeyForSearchFromHeader(event, type)
{
   	var code;
	if (!event) var event = window.event;
	if (event.keyCode) code = event.keyCode;
	else if (event.which) code = event.which;
	else return true;

    if(code == 13 || code == 3)
	{
	    if(type=='programSearch')
	    {
	    	getSearchResultFromHeader();
		}
		else if(type=='friendSearch')
	    {
		  getFriendSearch();
		}
		return false;
	}
}

function renderFooterPosition()
{
	document.getElementsByTagName('body')[0].style.height='100%';document.getElementById('footerBox').style.bottom='0px';
}

function getFriends(pageName, id2, id3, id4, pgNum)
{
    var temp = null;
   	if(pageName!=null && pageName=="search")
	{
	  var searchText = document.getElementById('search').value;
	  if (searchText=='')
	  {
	    temp = window.location+"";
	    if(temp.indexOf("=")>0)
	    {
          searchText = temp.substring(temp.indexOf("=")+1)
          document.getElementById('search').value=searchText;   
        }
	  }
   	  var queryString = "search.html?ajaxCall=true&searchText="+escape(searchText)+"&pageNo="+pgNum;
      $('#programList').load(queryString, function(){renderFooterPosition();});
	}
	else
	{
	  id4 = escape(id4);
	  id3 = escape(id3);
	  id2 = escape(id2);
	
	  $('#programList').load(urlEncode("friends.html?ajaxCall=true&pageNo="+pgNum+"&filter2="+id2+"&filter3="+id3+"&filter4="+id4), function(){renderFooterPosition();});
	}		
}

function urlEncode(string) {
    
	string = string.replace(/\r\n/g,"\n");
    var utftext = "";

    for (var n = 0; n < string.length; n++) {

        var c = string.charCodeAt(n);

        if (c < 128) {
            utftext += String.fromCharCode(c);
        }
        else if((c > 127) && (c < 2048)) {
            utftext += String.fromCharCode((c >> 6) | 192);
            utftext += String.fromCharCode((c & 63) | 128);
        }
        else {
            utftext += String.fromCharCode((c >> 12) | 224);
            utftext += String.fromCharCode(((c >> 6) & 63) | 128);
            utftext += String.fromCharCode((c & 63) | 128);
        }

    }
    return utftext;
}

function renderFilters(modeName, currIndex)
{
	var primarySelectBoxTxt = "";
	var timeSelectBoxTxt = "";
	var categorySelectBoxTxt = "";
	var sortBySelectBoxTxt = "";
	
	var primarySelectBoxVar = modeName + "PrimaryFilter" + currIndex;
	var timeSelectBoxVar = modeName + "TimeFilter" + currIndex;
	var categorySelectBoxVar = modeName + "CategoryFilter" + currIndex;
	var sortBySelectBoxVar = modeName + "SortByFilter" + currIndex;
	
	if(primarySelectBoxVar != null && primarySelectBoxVar != undefined && primarySelectBoxVar != "undefined")
	{
		try
		{
		primarySelectBoxVar = eval(primarySelectBoxVar);
		} 
		catch (error)
		{
			try
			{
				primarySelectBoxVar = eval(modeName + "PrimaryFilter0");
			} 
			catch (error) 
			{
				alert("an undefined error occured");
			}
		}
	}
	else
		primarySelectBoxVar = eval(modeName + "PrimaryFilters0");
		
	if(timeSelectBoxVar != null && timeSelectBoxVar != undefined && timeSelectBoxVar != "undefined")
	{
		try
		{
		timeSelectBoxVar = eval(timeSelectBoxVar);
		} 
		catch (error)
		{
			try
			{
				timeSelectBoxVar = eval(modeName + "TimeFilter0");
			} 
			catch (error) 
			{
				alert("an undefined error occured");
			}
		}
	}
	else
		timeSelectBoxVar = eval(modeName + "TimeFilters0");
		
	if(categorySelectBoxVar != null && categorySelectBoxVar != undefined && categorySelectBoxVar != "undefined")
	{
		try
		{
		categorySelectBoxVar = eval(categorySelectBoxVar);
		} 
		catch (error)
		{
			try
			{
				categorySelectBoxVar = eval(modeName + "CategoryFilter0");
			} 
			catch (error) 
			{
				alert("an undefined error occured");
			}
		}
	}
	else
		categorySelectBoxVar = eval(modeName + "CategoryFilters0");
		
	if(sortBySelectBoxVar != null && sortBySelectBoxVar != undefined && sortBySelectBoxVar != "undefined")
	{
		try
		{
		sortBySelectBoxVar = eval(sortBySelectBoxVar);
		} 
		catch (error)
		{
			try
			{
				sortBySelectBoxVar = eval(modeName + "SortByFilter0");
			} 
			catch (error) 
			{
				alert("an undefined error occured");
			}
		}
	}
	else
		sortBySelectBoxVar = eval(modeName + "SortByFilters0");
	
	var primarySelectListLength = primarySelectBoxVar.length;
	var timeSelectListLength = timeSelectBoxVar.length;
	var categorySelectListLength = categorySelectBoxVar.length;
	var sortBySelectListLength = sortBySelectBoxVar.length;	

	document.getElementById('filterBox1').innerHTML = getDropDownHTML(1, primarySelectListLength, primarySelectBoxVar);
	document.getElementById('filterBox2').innerHTML = getDropDownHTML(2, timeSelectListLength, timeSelectBoxVar);
	document.getElementById('filterBox3').innerHTML = getDropDownHTML(3, categorySelectListLength, categorySelectBoxVar);
	document.getElementById('filterBox4').innerHTML = getDropDownHTML(4, sortBySelectListLength, sortBySelectBoxVar);
}

function getDropDownHTML(filterBoxId, listLength, selectBoxVar)
{
	if(filterBoxId != 4)
	{
		var tempHTML = '<div class="filterDropDownBox" id="filterDropDownBox' + filterBoxId + '" onmouseover="toggleSelectDropDown(\'filterDropDownBox' + filterBoxId +'\', \'block\', this.id)" onmouseout="toggleSelectDropDown(\'filterDropDownBox' + filterBoxId +'\', \'none\', this.id);" style="display:none">'
	+ '<table width="100%" border="0" cellspacing="0" cellpadding="0">';

		for(var i = 0; i < listLength; i++)
		{
				var optionsFunction = "";
				if(selectBoxVar[i].clickEvent)
					var optionsFunction = selectBoxVar[i].clickEvent;
				
				tempHTML += '<tr>'
								+	'<td height="21" class="filterDropDownOptions"><a href="#" class="filterSelectBox" onclick="setTextOfSelectBox(\'filterBox' + filterBoxId +'\',this);' + optionsFunction + ';setvar();"><div>' + selectBoxVar[i].text +'</div></a></td>'
								+ '</tr>';
		}
	}
	else
	{
		var tempHTML = '<div class="sortByFilterDropDownBox" id="filterDropDownBox' + filterBoxId + '" onmouseover="toggleSelectDropDown(\'filterDropDownBox' + filterBoxId +'\', \'block\', this.id)" onmouseout="toggleSelectDropDown(\'filterDropDownBox' + filterBoxId +'\', \'none\', this.id);" style="display:none">'
	+ '<table width="100%" border="0" cellspacing="0" cellpadding="0">';

		for(var i = 0; i < listLength; i++)
		{
				var optionsFunction = "";
				if(selectBoxVar[i].clickEvent)
					var optionsFunction = selectBoxVar[i].clickEvent;
					
				tempHTML += '<tr>'
								+	'<td height="21" class="filterSortByDropDownOptions"><a href="#" class="filterSelectBox" onclick="setTextOfSelectBox(\'filterBox' + filterBoxId +'\',this);' + optionsFunction + '"><div>' + selectBoxVar[i].text +'</div></a></td>'
								+ '</tr>';
		}
	}	
	tempHTML += '</table>'
						+ '</div>'
							+ selectBoxVar[0].text ;
							
	return tempHTML;
}

function toggleSelectDropDown(elementId, propValue, srcElementId, eventFired)
{
	if(propValue == 'none' && elementId != srcElementId)
	{
		document.getElementById(srcElementId).style.color = '#a4a4a4';
	}
	

	if(eventFired == 'click')
	{
	
		if(document.getElementById(elementId).style.display == 'none')
		{
			MM_changeProp(elementId,'','display','block','DIV');
		}
		else
		{
			MM_changeProp(elementId,'','display','none','DIV');
		}
		return;
		
	}
	
	MM_changeProp(elementId,'','display',propValue,'DIV');
}

function setTextOfSelectBox(targetElementId, srcElement)
{
	document.getElementById(targetElementId).lastChild.nodeValue=srcElement.childNodes[0].innerHTML;
    //document.getElementById(targetElementId).lastChild.nodeValue=srcElement.innerHTML;
}

function MM_changeProp(objId,x,theProp,theValue) { //v9.0
  var obj = null; with (document){ if (getElementById)
  obj = getElementById(objId); }
  if (obj){
    if (theValue == true || theValue == false)
      eval("obj.style."+theProp+"="+theValue);
    else eval("obj.style."+theProp+"='"+theValue+"'");
  }
}

function submitform()
{
  document.onTrialWindow.submit();
}

function enableSubmit(val)
{
	if(val.value != "")
	{
		document.getElementById('zipSubmitBtn').style.display = 'none';
		document.getElementById('zipSubmitBtnEnable').style.display = 'block';
	}
	else
	{
		document.getElementById('zipSubmitBtn').style.display = 'block';
		document.getElementById('zipSubmitBtnEnable').style.display = 'none';
	}
}

function hideWhy() 
{
	document.getElementById('whyBox').style.display='none';
	document.getElementById('zipcode').readOnly=true;
	document.getElementById('zipcode').style.color='#aaa';
}
function checkKey(event)
{
	var code;
	if (!event) var event = window.event;
	if (event.keyCode) code = event.keyCode;
	else if (event.which) code = event.which;
	else return true;

	if(code == 13 || code == 3)
	{
		$.ajax({'type': 'post', 'url': 'onTrialWindow.html', 'data': $('#onTrialWindow').serialize(), async:false, success:function(data){$('#basicModalContent').html(data); Custom.init();}});
		return false;
	}
}

function enableFinalSubmit(elem)
{
	var inputElement = elem.nextSibling;
	if(inputElement.checked)
	{
		if(document.getElementById('lastSubmit'))
		{
			document.getElementById('lastSubmit').src='images/submitBtnReg.png';
		}
	}
	else
	{
		if(document.getElementById('lastSubmit'))
		{
			document.getElementById('lastSubmit').src='images/submitBtnRegDisabled.png';
		}
	}
}

Shadowbox.loadSkin('classic', 'js'); // use the "classic" skin
Shadowbox.loadLanguage('en', 'js'); // use the English language
Shadowbox.loadPlayer(['img', 'qt','html','iframe','swf','flv'], 'js'); // use img and qt players

function blink(guidboxId, programId, anchorObj, loopId)
{
	
	var currentGuideTxt = document.getElementById('guideTxt'+loopId).innerHTML;
	var newGuideTxt = "";
	var guideImgSrc = "";
	var controllerUrl = "";
	
	if(currentGuideTxt == "Add to my favorites")
	{
		newGuideTxt = "Remove from my favorites";
		guideImgSrc = "/images/minus.png";
		controllerUrl = "/removeProgramInGuide.html";
		
	}
	else if(currentGuideTxt =="Remove from my favorites")
	{
		newGuideTxt = "Add to my favorites";
		guideImgSrc = "/images/plus.png";
		controllerUrl = "/addProgramInGuide.html";
	}
		
	setTimeout(function(){document.getElementById(guidboxId).style.visibility='hidden';
	setTimeout(function(){document.getElementById(guidboxId).style.visibility='visible';
	setTimeout(function(){document.getElementById(guidboxId).style.visibility='hidden';
	setTimeout(function(){document.getElementById(guidboxId).style.visibility='visible';
	setTimeout(function(){document.getElementById(guidboxId).style.visibility='hidden';
	setTimeout(function(){document.getElementById(guidboxId).style.visibility='visible';
	setTimeout(function(){document.getElementById(guidboxId).style.visibility='hidden';
	setTimeout(function(){document.getElementById(guidboxId).style.visibility='visible';
	/*document.getElementById('guideTxt'+programId).innerHTML = newGuideTxt;
	document.getElementById('addToGuideImgStatus'+programId).src = guideImgSrc;*/
	document.getElementById(guidboxId).innerHTML = '<img id="addToGuideImgStatus'+loopId+'" src="'+guideImgSrc+'" /><a id="guideAnchor'+ loopId +'" href="javascript:void(0)" class="cueBoxLinks" onclick="blink(\'guideBox'+ loopId +'\',\''+ programId +'\',this,'+loopId+');$(\'#addToGuide\').load(\''+ controllerUrl  +'?programId='+ programId +'\');"><span id="guideTxt'+ loopId +'">'+newGuideTxt+'</span></a>';
	},100);
	},100);
	},100);
	},100);
	},500);
	},500);
	},500);
	},100);
}
//change images of plus Minus
function blinkFriend(guidboxId, programId, anchorObj)
{
	
	var currentGuideTxt = document.getElementById('guideTxt'+programId).innerHTML;
	var newGuideTxt = "";
	var guideImgSrc = "";
	var controllerUrl = "";
	var imgId = "addToGuideImgStatus" + programId;
		
	if(currentGuideTxt == "Add as Friend")
	{
		newGuideTxt = "Pending";
		guideImgSrc = "/images/sectionMinus.png";
		controllerUrl = "/addRemoveFriend.html";
	}
	else if(currentGuideTxt == "Remove as Friend")
	{
		newGuideTxt = "Add as Friend";
		guideImgSrc = "/images/sectionPlus.png";
		controllerUrl = "/addRemoveFriend.html";
	}
		
    if(newGuideTxt == "Pending")
	{
		document.getElementById(guidboxId).innerHTML = '<img id="addToGuideImgStatus'+programId+'" src="'+guideImgSrc+'" /><span style="display:none"  id="guideTxt'+ programId +'" class="cueBoxLinks">Pending</span><div style="position: absolute; margin-left:-88px; _margin-left:-100px; margin-top:-25px; _margin-top:-10px; display: none;" class="RemoveFrd"><img id="friendOverLay" src="images/pendingCallout.png"/></div>';
	}
	else
	{
		document.getElementById(guidboxId).innerHTML = '<a id="guideAnchor'+ programId +'" href="javascript:void(0)" class="cueBoxLinks" onclick="blinkFriend(\'guideBox'+ programId +'\',\''+ programId +'\',this);$(\'#addToGuide\').load(\''+ controllerUrl  +'?friendId='+ programId +'\');"><img id="addToGuideImgStatus'+programId+'" src="'+guideImgSrc+'" /><span style="display:none" id="guideTxt'+ programId +'">'+newGuideTxt+'</span></a><div style="position:absolute; margin-left:-120px; _margin-left:-136px; margin-top:-25px; _margin-top:-10px; display: none;width:100px;" class="RemoveFrd"><img id="friendOverLay" src="images/addAsFriendCallout.png"/></div>';
	}

}

function changePlusMinus(guidboxId, programId, loopId)
{
	var currentGuideTxt = document.getElementById('guideTxt'+loopId).innerHTML;
	var guideImgSrc = "";
	var controllerUrl = "";
	var tempId = 'addToGuideImgStatus'+loopId;
	
	if(currentGuideTxt == "Add to my favorites")
	{
		guideImgSrc = "/images/plus.png";
		controllerUrl = "/addProgramInGuide.html";
	}
	else if(currentGuideTxt =="Remove from my favorites")
	{

		guideImgSrc = "/images/minus.png";
		controllerUrl = "/removeProgramInGuide.html";
	}
	document.getElementById('addToGuideImgStatus'+loopId).src = guideImgSrc;
	document.getElementById(guidboxId).innerHTML = '<img src="/images/spacer.gif" height="16" width="1" align="absmiddle" class="vert-align" /><img id="addToGuideImgStatus'+loopId+'" src="'+guideImgSrc+'" /><img src="images/spacer.gif" height="16" width="1" align="absmiddle" class="vert-align" /><a id="guideAnchor'+ loopId +'" href="javascript:void(0)" class="cueBoxLinks" onclick="blink(\'guideBox'+ loopId +'\',\''+ programId +'\',this,'+loopId+');$(\'#addToGuide\').load(\''+ controllerUrl  +'?programId='+ programId +'\');"><span id="guideTxt'+ loopId +'">'+currentGuideTxt+'</span></a>';
	
}

function changeFriendPlusMinus(guidboxId, programId)
{
	if(document.getElementById('guideTxt'+programId) != null)
	{
		var currentGuideTxt = document.getElementById('guideTxt'+programId).innerHTML;
		var guideImgSrc = "";
		var controllerUrl = "";
		var tempId = 'addToGuideImgStatus'+programId;
		if(currentGuideTxt == "Add as Friend")
		{
			guideImgSrc = "/images/sectionPlus.png";
			controllerUrl = "/addRemoveFriend.html";
			document.getElementById('addToGuideImgStatus'+programId).src = guideImgSrc;
			document.getElementById(guidboxId).innerHTML = '<a id="guideAnchor'+ programId +'" href="javascript:void(0)" class="cueBoxLinks" onclick="blinkFriend(\'guideBox'+ programId +'\',\''+ programId +'\',this);$(\'#addToGuide\').load(\''+ controllerUrl  +'?friendId='+ programId +'\');"><img id="addToGuideImgStatus'+programId+'" src="'+guideImgSrc+'" /><span style="display:none" id="guideTxt'+ programId +'">'+currentGuideTxt+'</span></a><div style="position: absolute; margin-left:-128px; margin-top:-25px; display: none;" class="RemoveFrd"><img id="friendOverLay" src="/images/addAsFriendCallout.png"/></div>';
		}
		else if(currentGuideTxt =="Remove as Friend")
		{
	
			guideImgSrc = "/images/sectionMinus.png";
			controllerUrl = "/addRemoveFriend.html";
			document.getElementById('addToGuideImgStatus'+programId).src = guideImgSrc;
			document.getElementById(guidboxId).innerHTML = '<a id="guideAnchor'+ programId +'" href="javascript:void(0)" class="cueBoxLinks" onclick="blinkFriend(\'guideBox'+ programId +'\',\''+ programId +'\',this);$(\'#addToGuide\').load(\''+ controllerUrl  +'?friendId='+ programId +'\');"><img id="addToGuideImgStatus'+programId+'" src="'+guideImgSrc+'" /><span style="display:none" id="guideTxt'+ programId +'">'+currentGuideTxt+'</span></a><div style="position: absolute; margin-left:-128px;_margin-left:-145px; margin-top:-25px;  _margin-top:-10px; display: none;" class="RemoveFrd"><img id="friendOverLay" src="/images/removeAsFriendCallout.png"/></div>';
		}
		else if(currentGuideTxt == "Pending")
		{
			guideImgSrc = "/images/sectionMinus.png";
			document.getElementById(guidboxId).innerHTML = '<img id="addToGuideImgStatus'+programId+'" src="'+guideImgSrc+'" /><span style="display:none" id="guideTxt'+ programId +'" class="cueBoxLinks">Pending</span><div style="position: absolute; margin-left:-88px;  _margin-left:-100px; margin-top:-25px; _margin-top:-10px; display: none;" class="RemoveFrd"><img id="friendOverLay" src="/images/pendingCallout.png"/></div>';
		}
		else if(currentGuideTxt == "PendingPending")
		{
			guideImgSrc = "/images/sectionMinus.png";
			document.getElementById(guidboxId).innerHTML = '<img id="addToGuideImgStatus'+programId+'" src="'+guideImgSrc+'" /><span  style="display:none" id="guideTxt'+ programId +'" class="cueBoxLinks">Pending</span><div style="position: absolute; margin-left:-88px;_margin-left:-100px; margin-top:-25px; _margin-top:-10px; display: none;" class="RemoveFrd"><img id="friendOverLay" src="/images/pendingCallout.png"/></div>';
		}
	}
}

function showHideSearchFriends(friendText, friendBoxId)
{
		if(friendText == "Add as Friend")
		{
			if(document.getElementById('addToGuideImgStatus'+friendBoxId))
				document.getElementById('addToGuideImgStatus'+friendBoxId).style.display = 'block';
			if(document.getElementById('removeToGuideImgStatus'+friendBoxId))
				document.getElementById('removeToGuideImgStatus'+friendBoxId).style.display = 'none';
			if(document.getElementById('pendingToGuideImgStatus'+friendBoxId))
				document.getElementById('pendingToGuideImgStatus'+friendBoxId).style.display = 'none';
			
			if(document.getElementById('addToGuideImgStatusHref'+friendBoxId))
				document.getElementById('addToGuideImgStatusHref'+friendBoxId).style.display = 'block';
			if(document.getElementById('removeToGuideImgStatusHref'+friendBoxId))
				document.getElementById('removeToGuideImgStatusHref'+friendBoxId).style.display = 'none';
			if(document.getElementById('pendingToGuideImgStatusHref'+friendBoxId))
				document.getElementById('pendingToGuideImgStatusHref'+friendBoxId).style.display = 'none';
		}
		else if(friendText == "Remove as Friend")
		{
			if(document.getElementById('addToGuideImgStatus'+friendBoxId))
				document.getElementById('addToGuideImgStatus'+friendBoxId).style.display = 'none';
			if(document.getElementById('removeToGuideImgStatus'+friendBoxId))
				document.getElementById('removeToGuideImgStatus'+friendBoxId).style.display = 'block';
			if(document.getElementById('pendingToGuideImgStatus'+friendBoxId))
				document.getElementById('pendingToGuideImgStatus'+friendBoxId).style.display = 'none';
			
			if(document.getElementById('addToGuideImgStatusHref'+friendBoxId))
				document.getElementById('addToGuideImgStatusHref'+friendBoxId).style.display = 'none';
			if(document.getElementById('removeToGuideImgStatusHref'+friendBoxId))
				document.getElementById('removeToGuideImgStatusHref'+friendBoxId).style.display = 'block';
			if(document.getElementById('pendingToGuideImgStatusHref'+friendBoxId))
				document.getElementById('pendingToGuideImgStatusHref'+friendBoxId).style.display = 'none';
		}
		else if(friendText == "Pending" || friendText == "PendingPending")
		{
			if(document.getElementById('addToGuideImgStatus'+friendBoxId))
				document.getElementById('addToGuideImgStatus'+friendBoxId).style.display = 'none';
			if(document.getElementById('removeToGuideImgStatus'+friendBoxId))
				document.getElementById('removeToGuideImgStatus'+friendBoxId).style.display = 'none';
			if(document.getElementById('pendingToGuideImgStatus'+friendBoxId))
				document.getElementById('pendingToGuideImgStatus'+friendBoxId).style.display = 'block';
			
			if(document.getElementById('addToGuideImgStatusHref'+friendBoxId))
				document.getElementById('addToGuideImgStatusHref'+friendBoxId).style.display = 'none';
			if(document.getElementById('removeToGuideImgStatusHref'+friendBoxId))
				document.getElementById('removeToGuideImgStatusHref'+friendBoxId).style.display = 'none';
			if(document.getElementById('pendingToGuideImgStatusHref'+friendBoxId))
				document.getElementById('pendingToGuideImgStatusHref'+friendBoxId).style.display = 'block';
		}
}

function setTime()
{
	setInterval  ("go()",60000);
}

var updateCommentMinutes = false;
function go()
{
	$('#timezone').load('/time.html');
	updateCommentMinutes = true;
}

//rating js
jQuery.fn.rating = function(url, options) {
	
	if(url == null) return;
	
	var settings = {
        url       : url, // post changes to 
        maxvalue  : 5,   // max number of stars
        curvalue  : 0    // number of selected stars
    };
	
    if(options) {
       jQuery.extend(settings, options);
    };
   jQuery.extend(settings, {cancel: (settings.maxvalue > 1) ? true : false});
   
   
   var container = jQuery(this);
	
	jQuery.extend(container, {
            averageRating: settings.curvalue,
            url: settings.url
        });

	for(var i= 0; i <= settings.maxvalue ; i++){
		var size = i
        if (i == 0) {
			if(settings.cancel == true){
	             var div = '<div class="cancel"><a href="#0" title="Cancel Rating">Cancel Rating</a></div>';
				 container.append(div);
			}
        } 
		else {
             var div = '<div class="star"><a href="#'+i+'" title="Give it '+i+'/5">'+i+'</a></div>';
			 container.append(div);

        }
 
		

	}
	
	var stars = jQuery(container).children('.star');
    var cancel = jQuery(container).children('.cancel');
	
    stars
	        .mouseover(function(){
                event.drain();
                event.fill(this);
            })
            .mouseout(function(){
                event.drain();
                event.reset();
            })
            .focus(function(){
                event.drain();
                event.fill(this)
            })
            .blur(function(){
                event.drain();
                event.reset();
            });

    stars.click(function(){
		if(settings.cancel == true){
            settings.curvalue = stars.index(this) + 1;
            jQuery.post(container.url, {
                "rating": jQuery(this).children('a')[0].href.split('#')[1] 
            });
			return false;
		}
		else if(settings.maxvalue == 1){
			settings.curvalue = (settings.curvalue == 0) ? 1 : 0;
			$(this).toggleClass('on');
			jQuery.post(container.url, {
                "rating": jQuery(this).children('a')[0].href.split('#')[1] 
            });
			return false;
		}
		return true;
			
    });

        // cancel button events
	if(cancel){
        cancel
            .mouseover(function(){
                event.drain();
                jQuery(this).addClass('on')
            })
            .mouseout(function(){
                event.reset();
                jQuery(this).removeClass('on')
            })
            .focus(function(){
                event.drain();
                jQuery(this).addClass('on')
            })
            .blur(function(){
                event.reset();
                jQuery(this).removeClass('on')
            });
        
        // click events.
        cancel.click(function(){
            event.drain();
			settings.curvalue = 0;
            jQuery.post(container.url, {
                "rating": jQuery(this).children('a')[0].href.split('#')[1] 
            });
            return false;
        });
	}
        
	var event = {
		fill: function(el){ // fill to the current mouse position.
			var index = stars.index(el) + 1;
			stars
				.children('a').css('width', '100%').end()
				.slice(0, index).addClass('hover').end();
		},
		drain: function() { // drain all the stars.
			stars
				.filter('.on').removeClass('on').end()
				.filter('.hover').removeClass('hover').end();
		},
		reset: function(){ // Reset the stars to the default index.
			stars.slice(0, settings.curvalue).addClass('on').end();
		}
	}        
	event.reset();
	
	return(this);	

}

function setCurrentMode(curModeName)
{
	$('#navHeader').removeClass('home');
	$('#navHeader').removeClass('programs');
	$('#navHeader').removeClass('friends');
	$('#navHeader').removeClass('connect');
	if(curModeName)
		$('#navHeader').addClass(curModeName);
}

function openRegistrationOverlay()
{
	window.location='/integratedRegistration.html';
	/*var iframeURL = hostName + "/registrationWizard.html";
	Shadowbox.open( { content : iframeURL
                         , player : 'iframe'
						 ,width:'700px'
						 ,height:'600px'
                         }); */
}

/*function openForgotPassOverlay()
{
	var iframeURL = hostName + "/forgotPassword.html";
	Shadowbox.open( { content : hostName + "/forgotPassword.html"
                         , player : 'iframe'
						 ,width:'600px'
						 ,height:'550px'
                         }); 
}
*/
function adjustTop()
{
	var sh = screen.height;
	var half_sh = sh / 2;
	var remainHt = half_sh - 250;
	var distanceFromTop = remainHt / 2;
	parent.document.getElementById('shadowbox').style.top =  distanceFromTop + 'px';
}

function demoGallery(){
 var img = {
 player: 'iframe',
 content: 'login.html',
 height: 600,
 width: 700
 };

 var video = {
 player: 'iframe',
 content: 'http://local.intelevision.com/forgotPassword.html',
 height: 550,
 width: 600
 };

 Shadowbox.open([img, video], {
 continuous: true
 });
};



function cueBtnOver(btn, path, imgObj, helpId)
{
	var helpText = document.getElementById(helpId);
	switch(btn)
	{
		case "1a": helpText.innerHTML = "Add to your favorites";
					helpText.style.paddingLeft = "10px";
					helpText.style.textAlign = "left";
					imgObj.src = "images/" + path + ".jpg";
					break;

		case "1b": helpText.innerHTML = "Remove from your favorites";
					helpText.style.paddingLeft = "10px";
					helpText.style.textAlign = "left";
					imgObj.src = "images/" + path + ".jpg";
					break;
			
		case "2": helpText.innerHTML = "Send to a friend";
					helpText.style.paddingLeft = "50px";
					helpText.style.textAlign = "left";
					imgObj.src = "images/" + path + ".jpg";
					break;
		
		case "3a": helpText.innerHTML = "Set reminder for program";
					helpText.style.paddingLeft = "90px";
					helpText.style.textAlign = "left";
					imgObj.src = "images/" + path + ".jpg";
					break;
					
		case "3b": helpText.innerHTML = "Remove program reminder";
					helpText.style.paddingLeft = "90px";
					helpText.style.textAlign = "left";
					imgObj.src = "images/" + path + ".jpg";
					break;	
					
		case "4": helpText.innerHTML = "Connect to program";
					helpText.style.paddingLeft = "130px";
					helpText.style.textAlign = "left";
					imgObj.src = "images/" + path + ".jpg";
					break;
					
		case "5a": helpText.innerHTML = "Remove this program from your listings";
					helpText.style.paddingRight = "10px";
					helpText.style.paddingLeft = "0px";
					helpText.style.textAlign = "right";
					imgObj.src = "images/" + path + ".jpg";
					break;
					
		case "5b": helpText.innerHTML = "Add this program back to your listings";
					helpText.style.paddingRight = "10px";
					helpText.style.textAlign = "right";
					imgObj.src = "images/" + path + ".jpg";
					break;
					
		case "6a": helpText.innerHTML = "Remove this station from your listings";
					helpText.style.paddingRight = "10px";
					helpText.style.textAlign = "right";
					imgObj.src = "images/" + path + ".jpg";
					break;
					
		case "6b": helpText.innerHTML = "Add this station back to your listings";
					helpText.style.paddingRight = "10px";
					helpText.style.textAlign = "right";
					imgObj.src = "images/" + path + ".jpg";
					break;
		
	}
}

function cueBtnOut(imgPath, imgObj, helpId)
{
	document.getElementById(helpId).innerHTML = "";
	imgObj.src = "images/" + imgPath + ".jpg";
}

function resetPreviousBtn(btn)
{
	switch(btn)
	{
		case "1a":document.getElementById("showAddProgFav").style.display = "block";
					break;
	}
}


var previousSelectedBtnId = "showAddProgFav";
var previousSelectedImgPath = "pCuePlusImg";


function cueBtnClick(btn, imgObj, showImgId)
{
	switch(btn)
	{
		case "1a":	imgObj.style.display = 'none';					
					document.getElementById('showRemoveProgFav' + showImgId).style.display = 'block';
					break;

		case "1b": imgObj.style.display = 'none';					
					document.getElementById('showAddProgFav' + showImgId).style.display = 'block';
					break;
		
		case "3a": imgObj.style.display = 'none';				
					document.getElementById('showRemoveReminder' + showImgId).style.display = 'block';
					break;
					
		case "3b": imgObj.style.display = 'none';					
					document.getElementById('showAddReminder' + showImgId).style.display = 'block';
					break;
					
		case "5a": imgObj.style.display = 'none';					
					document.getElementById('showAddProgList' + showImgId).style.display = 'block';
					break;
					
		case "5b": imgObj.style.display = 'none';					
					document.getElementById('showRemoveProgList' + showImgId).style.display = 'block';
					break;
					
		case "6a": imgObj.style.display = 'none';					
					document.getElementById('showAddStationList' + showImgId).style.display = 'block';
					break;
					
		case "6b": imgObj.style.display = 'none';					
					document.getElementById('showRemoveStationList' + showImgId).style.display = 'block';
					break;
		}
/*	previousSelectedBtnId = imgId;
	previousSelectedImgPath = imgPath;
	
	imgId.src = "images/" + imgPath + ".jpg";*/
}

function getBtnOptions()
{
	document.getElementById(previousSelectedBtnId).src = "images/" + previousSelectedImgPath + ".jpg";
}

function showProgramGuideBtn(favText, showAdd, showRemove)
{
	if(favText == "Add to my favorites")
	{
		document.getElementById(showAdd).style.display = "block";
		document.getElementById(showRemove).style.display = "none";
	}
	else if(favText == "Remove from my favorites")
	{
		document.getElementById(showAdd).style.display = "none";
		document.getElementById(showRemove).style.display = "block";
	}
}

function showReminderBtn(isReminderSet, showAdd, showRemove)
{
	if(isReminderSet == "false")
	{
		document.getElementById(showAdd).style.display = "block";
		document.getElementById(showRemove).style.display = "none";
	}
	else if(isReminderSet == "true")
	{
		document.getElementById(showAdd).style.display = "none";
		document.getElementById(showRemove).style.display = "block";
	}	
}

var programListingOverlayId = new Array();
function addProgramsToArray(overlayProgramId)
{
	programListingOverlayId.push(overlayProgramId);
}

function showOverlayProgramCueBlock(overlayId)
{
	//document.getElementById(overlayId).style.display = 'block';
	$('#'+overlayId).show(100, function(){
	for(var i = 0; i < programListingOverlayId.length; i++)
	{
		var currentElement = programListingOverlayId[i];
		if(currentElement != overlayId)
			$('#' + programListingOverlayId[i]).hide(100);
			//document.getElementById(programListingOverlayId[i]).style.display = 'none';	
	}});
	
	/*for(var i = 0; i < programListingOverlayId.length; i++)
	{
		var currentElement = programListingOverlayId[i];
		if(currentElement != overlayId)
			document.getElementById(programListingOverlayId[i]).style.display = 'none';	
	}*/

	//document.getElementById(overlayId).style.display = 'block';
}

function hideAllTooltips() {
for(var i = 0; i < programListingOverlayId.length; i++)
	{
		var currentElement = programListingOverlayId[i];
			$('#' + programListingOverlayId[i]).hide();
			//document.getElementById(programListingOverlayId[i]).style.display = 'none';	
	}
}

function refresh(programId)
{
   $.ajax({'type': 'get', 'url': 'removeProgramInGuide.html?programId='+programId, async:false, success:function(data){$('#addToGuide').html(data);}});
   window.location.reload();
}

$(document).ready(function() {
	$("table.searchShows21").css('border-collapse', 'separate');
	$("table.searchShows21 td").css('border-top', '1px solid #aaa');
	$("table.searchShows21 tr:odd td").css({'background-color': '#dde2eb'});
	
	$("table.searchChannel21").css('border-collapse', 'separate');
	$("table.searchChannel21 td").css('border-top', '1px solid #aaa');
	$("table.searchChannel21 tr:odd td").css({'background-color': '#dde2eb'});
	
	$("table.searchCastCredit21").css('border-collapse', 'separate');
	$("table.searchCastCredit21 td").css('border-top', '1px solid #aaa');
	$("table.searchCastCredit21 tr:odd td").css({'background-color': '#dde2eb'});
	
	$("table.searchFriends21").css('border-collapse', 'separate');
	$("table.searchFriends21 td").css('border-top', '1px solid #aaa');
	$("table.searchFriends21 tr:odd td").css({'background-color': '#dde2eb'});
	
	$("#nav-home a").click ( function () {
		$('#myTab').html('Shows').css({'padding-left':'34px', 'width':'125px'}).animate({'left': '0px'},1000,'easeOutBounce'); showHideSearchContainer('searchShowResults');
	});
	
	$("#nav-programs a").click ( function () {
		$('#myTab').html('Channels').css({'padding-left':'24px', 'width':'135px'}).animate({'left': '149px'},1000,'easeOutBounce'); showHideSearchContainer('searchChannelResults');
	});
	
	$("#nav-guides a").click ( function () {
		$('#myTab').html('Cast / Credits').css({'padding-left':'15px', 'width':'144px'}).animate({'left': '299px'},1000,'easeOutBounce'); showHideSearchContainer('searchCastCreditResults');
	});
	
	$("#nav-friends a").click ( function () {
		$('#myTab').html('Friends').css({'padding-left':'34px', 'width':'125px'}).animate({'left': '448px'},1000,'easeOutBounce'); showHideSearchContainer('searchFriendResults');
	});

});

function showHideSearchContainer(boxId)
{
	if(document.getElementById('searchShowResults').style.display != 'none')
	{
		$('#searchShowResults').slideUp('fast', function(){$('#' + boxId).slideDown('slow');});
		return false;
	}
	
	if(document.getElementById('searchChannelResults').style.display != 'none')
	{
		$('#searchChannelResults').slideUp('fast', function(){$('#' + boxId).slideDown('slow');});
		return false;
	}
	
	if(document.getElementById('searchCastCreditResults').style.display != 'none')
	{
		$('#searchCastCreditResults').slideUp('fast', function(){$('#' + boxId).slideDown('slow');});
		return false;
	}
	
	if(document.getElementById('searchFriendResults').style.display != 'none')
	{
		$('#searchFriendResults').slideUp('fast', function(){$('#' + boxId).slideDown('slow');});
		return false;
	}
}

function showHideFilters()
{
	document.getElementById('filterBox1').style.display = 'none';
	document.getElementById('filterBox2').style.marginLeft = '0px';
}

function setFocusOnZip(){
	if(document.getElementById('zipCode')){
		document.getElementById('zipCode').focus();
	}	
}
function showHideProductBox(boxId)
{
	if(boxId == 'amazon')
	{
		document.getElementById('amazonBox').style.display='block';
		document.getElementById('ebayBox').style.display='none';
	}
	else
	{
		document.getElementById('ebayBox').style.display='block';
		document.getElementById('amazonBox').style.display='none';
	}
}

function setPageName(pageName) 
{
	appPageName = pageName;
}

function setProgramId(id) 
{
	programId = id;
}

function onlineTracker()
{
	setInterval("trackOnlineUsers()",120000);
}

function trackOnlineUsers()
{
	var currentTime = new Date();
	var currentTimeInHours = currentTime.getHours();
	var currentTimeInMinutes = currentTime.getMinutes();	
	var hourDifference = currentTimeInHours - userLoginTimeInHours;
	if(hourDifference == 0)
	{
		var minuteDifference = currentTimeInMinutes - userLogintimeInMinutes;
		
		if(minuteDifference < 30)
		{
			$('#onlineTrackerBox').load('/onlineTracker.html?page='+appPageName+'&programId='+programId);
		}
	}
}

function slideTracker()
{
	updateSliderCheck();
	setInterval("updateSliderCheck()",60000);
}

function updateSliderCheck()
{
	if(typeof updateSlider == 'function')
	{
		updateSlider();
	}
}

var timeFromServerIs = "";
var userLoginDate = new Date();
var userLoginTimeInHours = userLoginDate.getHours();
var userLogintimeInMinutes = userLoginDate.getMinutes();

function updateUerLoginTime()
{
	userLoginDate = new Date();
	userLoginTimeInHours = userLoginDate.getHours();
	userLogintimeInMinutes = userLoginDate.getMinutes();
}


function getPercentComplete(startTime, endTime)
{
	if(currentTime<startTime)
	{
		return 0;
	}
	
	if(currentTime>endTime)
	{
		return 100;
	}

	var difference = endTime - startTime;
	var elapsedTime = currentTime - startTime;
	var percentValue = (elapsedTime*100)/difference;

	return percentValue;
}

function refreshSlider(sliderBoxId, sliderId, startTime, endTime, onNowId, onInId)
{
	var onIn = calculateOnIn(startTime, currentTime);

	if(onIn != null)
		if(document.getElementById(onInId))
			document.getElementById(onInId).innerHTML = onIn;
	
	var percentComplete = getPercentComplete(startTime, endTime);

	if(percentComplete <= 0 || percentComplete >= 100)
	{
		if (document.getElementById(onNowId)!=null)
		{
			document.getElementById(onNowId).style.display = 'none';
		}
		if (document.getElementById(sliderBoxId)!=null)
		{
			document.getElementById(sliderBoxId).style.display = 'none';
		}
	}
	else
	{
		if (document.getElementById(onNowId)!=null)
		{
			document.getElementById(onNowId).style.display = 'block';
		}
		if (document.getElementById(sliderBoxId)!=null)
		{
			document.getElementById(sliderBoxId).style.display = 'block';
			document.getElementById(sliderId).style.width = percentComplete + "%";
		}
	}
}

function calculateSelectedOnIn(startTime, onInId)
{
	var onIn = calculateOnIn(startTime, currentTime);

	if(onIn != null)
		if(document.getElementById(onInId))
			document.getElementById(onInId).innerHTML = onIn;
}

function calculateOnIn(startTime, currentTime)
{
	if(currentTime < startTime)
	{
		var elapsedTime = startTime - currentTime;
		var days = Math.floor(elapsedTime/(1000*60*60*24));
		var hours = Math.floor((elapsedTime%(1000*60*60*24))/(60*60*1000));
		var mins = Math.floor((elapsedTime%(1000*60*60*24))%(60*60*1000)/(1000*60));
		var returnValue="";
		if (days == 1)
		{
		   returnValue = "1 day";
		}
		else if (days > 1)
		{
		   returnValue = days + " days";
		}
		else
		{
			if (hours > 9)
			{
			  returnValue = hours; 
			}
			else
			{
			  returnValue = "0"+hours;
			}
			
			if (mins > 9)
			{
			  returnValue = returnValue+":"+mins+" hrs"; 
			}
			else
			{
			  returnValue = returnValue+":0"+mins+" hrs";
			}
		}
		return returnValue;
	}
	return null;
}

$(document).ready(function() {
	
$('#loadingMuziq').ajaxStart(function() {
var firedURL = $.ajax.arguments[0].url;

if(firedURL.indexOf('onlineTracker.html') == -1 && firedURL.indexOf('time.html') == -1)
{
	$(this).show();
}}).ajaxStop(function() {
$(this).hide();
});
});

function showWatchingCount(currentPage, onNow, watchingCount, id)
{
	if (currentPage == "programListPage")
	{
		if(onNow)
		{
			if (watchingCount > 0)
			{
				document.getElementById("watchingLabel"+id).style.display = "inline";
				document.getElementById("watchingCount"+id).style.display = "inline";
			}
		}
	}
	else if (currentPage == "programDetailPage")
	{
	    if(onNow)
		{
			if (watchingCount >0)
			{
				document.getElementById("watchingCount").style.display = "inline";
			}
		}
	}
}

function showReplies(programId, parentCommentId)
{ 
  $('#replyComment'+parentCommentId).load('/connect.html?programId='+programId+'&parentCommentId='+parentCommentId);   
}

function setParentCommentId(parentCommentId)
{ 
	document.getElementById("parentCommentId").value = parentCommentId;	
}

function postReply(formName, programId, textBoxId, lastCommentId)
{
	var temp = document.getElementById(textBoxId).value;
	var temp = $.trim(temp);

	if(temp == "")
	{
		return false;
	}
	
	if (formName != null)
	{
		$.ajax ({'type': 'POST', 'url': '/addComment.html', async: false, 'data': $('#'+formName).serialize(),success:function(data) {
		focussedElement = null;
		focussedCommentId = "";
		focusElementTxt = "";
		
		var tempCommentId = document.getElementById('latestCommentId').value;
		commentManager.getNewComments(programId, tempCommentId, updateAllComments);
		}});
		
		var parentCommentId = document.getElementById("parentCommentId").value;
		if (parentCommentId > 0)
		{
			document.getElementById("parentCommentId").value = 0;
		}
		document.getElementById(textBoxId).value = "";
		document.getElementById(textBoxId).focus();
		document.getElementById('commentcharcount').innerHTML = "250";		
	}		
}

function checkKeyForComment(event, formName, programId, textBoxId, lastCommentId)
{
	if(intervalId != "")
		clearInterval(intervalId);
		
	msgTimeBetKeypress = 0;
	intervalId = setInterval(function(){msgTimeBetKeypress++;},1000);
	
	var code;
	if (!event) var event = window.event;
	if (event.keyCode) code = event.keyCode;
	else if (event.which) code = event.which;
	else return true;
    var tempCommentId = document.getElementById('latestCommentId').value;
	if(code == 13 || code == 3)
	{
		postReply(formName, programId, textBoxId, tempCommentId);
	}
}

function getFriendsLikeProgram(friendsPageNo, scheduleId, stationNumber)
{
   var url = "/programDetail.html?ajaxCall=true&type=friends&friendsPageNo="+friendsPageNo+"&scheduleId="+scheduleId+"&stationNumber="+stationNumber;
   $('#friendsLikeProgram').load(url); 
}

function getOthersLikeProgram(othersPageNo, scheduleId, stationNumber)
{
   var url = "/programDetail.html?ajaxCall=true&type=others&othersPageNo="+othersPageNo+"&scheduleId="+scheduleId+"&stationNumber="+stationNumber;
   $('#othersLikeProgram').load(url); 
}

function charCounter(obj, maxLength, warnDiv)
{  	
	var text; 
	
	if(obj.value)
	{  
		text = obj.value; 
	} 
	else
	{  
		text = obj.innerHTML; 
	} 
	
	var numleft = maxLength - text.length;
	
	if (numleft >= 0)
	{
		var temp = numleft + ' characters remaining';
		document.getElementById(warnDiv).innerHTML = temp; 
	}	
	else if (numleft < 0) 
	{    
		if (obj.value && obj.value.length>maxLength) 
		{   
		 obj.value=obj.value.substring(0,maxLength); 
		}
		return false; 
	}
}

function showOnNow(sliderId)
{
   if (document.getElementById(sliderId).style.visibility == 'visible')
      document.getElementById("onNow").style.display = 'block'; 
}

var updateFromSetInterval = false;

function getUpdatedCommentsTime(commentsTime, objLocation)
{
	if(updateCommentMinutes)
	{
	var commentTimeWithoutBrackets = commentsTime.substring(1,commentsTime.length-1);
	var ctwb = commentTimeWithoutBrackets;
	var updatedCommentsTime = "(";
	
	var hasDays = ctwb.indexOf("day") != -1;
	var hasHours = ctwb.indexOf("hour") != -1;	
	var hasMinutes = ctwb.indexOf("minute") != -1;
	
	if(hasDays)
		cDay = parseInt(ctwb);
	else
		cDay = 0;
	
	if(hasHours)
		cHour = parseInt(ctwb.substring(ctwb.indexOf("hour") - 3, ctwb.indexOf("hour") - 0));
	else
		cHour = 0;
	
	if(hasMinutes)
		cMinute = parseInt(ctwb.substring(ctwb.indexOf("minute") - 3, ctwb.indexOf("minute") - 0));
	else
		cMinute = 0;
		
		cMinute++;
		if(cMinute == 60)
		{
			cMinute = 0;
			cHour++;
		}
		
		if(cHour == 24)
		{
			cHour = 0;
			cDay++;
		}
	
	
	if(cDay != 0)
		if(cDay > 1)
			updatedCommentsTime += cDay + " days ";
		else
			updatedCommentsTime += cDay + " day ";
	
	if(cHour != 0)
		if(cHour > 1)
			updatedCommentsTime += cHour + " hours ";
		else
			updatedCommentsTime += cHour + " hour ";
	
	if(cMinute != 0)
		if(cMinute > 1)
			updatedCommentsTime += cMinute + " minutes ";
		else
			updatedCommentsTime += cMinute + " minute ";
	
	updatedCommentsTime+= " ago)";
	objLocation.lapsedTime = updatedCommentsTime;
	
	return updatedCommentsTime;
	}
	else
		return commentsTime;
}

function returnCommentTime(elapsedTime, commentArray)
{
	if(updateFromSetInterval)
		return getUpdatedCommentsTime(elapsedTime, commentArray);
	else
		return elapsedTime;
}

var hostName = "http://" + document.domain;

function expandCollapseImg(commentId)
{
	if($('#childComments'+commentId).css('display') == 'block')
	{
		document.getElementById('expandCollapse'+commentId).src = '/images/arrowLightGray.png';
		$('#childComments'+commentId).toggle(400);
	}
	else if($('#childComments'+commentId).css('display') == 'none')
	{
		document.getElementById('expandCollapse'+commentId).src = '/images/arrowCollapse.png';
		$('#childComments'+commentId).toggle(400);		
	}
}

var focussedElement;
var focussedCommentId = "";
var focusElementTxt = "";
var parentFocus = true;
function recordfocussedElement(focusId)
{
	parentFocus = false;
	focussedCommentId = focusId;
	focussedElement = 'textBox'+focusId;
	document.getElementById(focussedElement).focus();
}

function recordParentfocussedElement(focusId)
{
	parentFocus = true;
	focussedCommentId = focusId;
	focussedElement = 'textBoxParent'+focusId;
	document.getElementById(focussedElement).focus();
}

function getFocusHTML()
{
	var focussedElementObj = document.getElementById(focussedElement);
	if(focussedElementObj)
	{
		if(parentFocus)
		{
			if(focussedElementObj.type == 'textarea')
			{
				focusElementTxt = focussedElementObj.value;
			}
			else
			{
				focusElementTxt = "";
				focussedElement = null;
			}
		}
		else
		{
			if((document.getElementById('replyDiv'+focussedCommentId).style.display == 'block') && (focussedElementObj.type == 'textarea'))
			{
				focusElementTxt = focussedElementObj.value;
			}
			else
			{
				focusElementTxt = "";
				focussedElement = null;
			}
		}
	}
}

function setFocusTxt()
{
	if(document.getElementById(focussedElement))
	{
		if(parentFocus == false)
			document.getElementById('replyDiv'+focussedCommentId).style.display = 'block';
			
		var myObj = document.getElementById(focussedElement);
		if(myObj)
		{
			if(myObj.type == "textarea")
			{	
			if(myObj.createTextRange) 
			{
				myObj.innerHTML = focusElementTxt;
				var range = myObj.createTextRange();
				range.move('character', (focusElementTxt.length));
				range.select();
			}
			else {
			myObj.innerHTML = focusElementTxt;
					myObj.focus();
					myObj.setSelectionRange(focusElementTxt.length, focusElementTxt.length);
				}
        }
		}
		}
}
// for include / exclude program station.
function jsIncludeProgram(programId)
{
  $.ajax({'type': 'get', 'url': '/addRemoveProgram.html?action=include&programId='+programId, async:false, success:function(data){}});
}
function jsExcludeProgram(programId, page)
{
  $.ajax({'type': 'get', 'url': '/addRemoveProgram.html?programId='+programId+'&page='+page, async:false, success:function(data){}});
}
 
function jsIncludeStation(stationId)
{
  $.ajax({'type': 'get', 'url': '/addRemoveStation.html?action=include&stationId='+stationId, async:false, success:function(data){}});
}  
function jsExcludeStation(stationId, programId, page)
{
  $.ajax({'type': 'get', 'url': '/addRemoveStation.html?action=exclude&stationId='+stationId+"&programId="+programId+'&page='+page, async:false, success:function(data){}});
}

function jsAddReminder(programId, stationId)
{
  $.ajax({'type': 'get', 'url': '/programReminder.html?action=add&programId='+programId+'&stationId='+stationId, async:false, success:function(data){}});
}
function jsDeleteReminder(programId, stationId)
{
  $.ajax({'type': 'get', 'url': '/programReminder.html?programId='+programId+'&stationId='+stationId, async:false, success:function(data){}});
}

function toggleToText(stationId)
{
	document.getElementById('callSignImgBox'+ stationId).innerHTML = "";
}

function removeProgram(programId, page)
{
	if(programId != null && programId > 0)
	{
		jsExcludeProgram(programId, page);
		window.location.reload();
	}	
}

function addProgram(programId, page)
{
	if(programId != null && programId > 0)
	{
		jsIncludeProgram(programId, page);	
		window.location.reload();
	}	
}

function removeStation(stationId, programId, page)
{
	if(programId != null && programId > 0)
	{
		jsExcludeStation(stationId, programId, page);	
		window.location ="/connect.html"	;
	}	
}

function swapBackground(objId, imgName)
{
	objId.style.background='url(/images/' + imgName + ') repeat-y';
}

function toggleIntvSelectDropDown(elementId, propValue, srcElementId, eventFired)
{
	if(propValue == 'none' && elementId != srcElementId)
	{
		document.getElementById(srcElementId).style.background = 'url(/images/filterBoxBg1.png) no-repeat right';
	}
	
	if(eventFired == 'click')
	{
	
		if(document.getElementById(elementId).style.display == 'none')
		{
			MM_changeProp(elementId,'','display','block','DIV');
		}
		else
		{
			MM_changeProp(elementId,'','display','none','DIV');
		}
		return;
		
	}
	
	MM_changeProp(elementId,'','display',propValue,'DIV');
}
$(document).ready(function(){
$('#toggleNavHeaderTop').toggle(
      function () {
	  if($('#navHeaderTopConnect').css('display') == 'block'){
        $('#navHeaderTopConnect').slideUp('slow');
		$(this).attr({src:'/images/navHdrTopConnectCollapsedImg.png'});
		}
		else
		{
			$('#navHeaderTopConnect').slideDown('slow');
			$(this).attr({src:'/images/navHdrTopConnectImg.png'});
		}
      },
	  function () {
	  if($('#navHeaderTopConnect').css('display') == 'none'){
        $('#navHeaderTopConnect').slideDown('slow');
		$(this).attr({src:'/images/navHdrTopConnectImg.png'});
		}
		else
		{
		$('#navHeaderTopConnect').slideUp('slow');
		$(this).attr({src:'/images/navHdrTopConnectCollapsedImg.png'});
		}
      });
	  
	  $('#toggleNavHeaderMiddle').toggle(
      function () {
	  if($('#navHeaderMiddleConnect').css('display') == 'block'){
        $('#navHeaderMiddleConnect').slideUp('slow');
		$(this).attr({src:'/images/navHdrMidConnectCollapsedImg.png'});
		}
		else
		{
			$('#navHeaderMiddleConnect').slideDown('slow');
			$(this).attr({src:'/images/navHdrMidConnectImg.png'});
		}
      },
	  function () {
	  if($('#navHeaderMiddleConnect').css('display') == 'none'){
        $('#navHeaderMiddleConnect').slideDown('slow');
		$(this).attr({src:'/images/navHdrMidConnectImg.png'});
		}
		else
		{
			 $('#navHeaderMiddleConnect').slideUp('slow');
			$(this).attr({src:'/images/navHdrMidConnectCollapsedImg.png'});
		}
      });
	  
	$('#toggleNavHeaderBottom').toggle(
      function () {
	  if($('#navHeaderBottomConnect').css('display') == 'block'){
        $('#navHeaderBottomConnect').slideUp('slow');
		$(this).attr({src:'/images/navHdrBottomConnectImg1.png'});
		}
		else
		{
			$('#navHeaderBottomConnect').slideDown('slow');
			$(this).attr({src:'/images/navHdrBottomConnectImg.png'});
		}
      },
	  function () {
	  if($('#navHeaderBottomConnect').css('display') == 'none'){
        $('#navHeaderBottomConnect').slideDown('slow');
		$(this).attr({src:'/images/navHdrBottomConnectImg.png'});
		}
		else
		{
			$('#navHeaderBottomConnect').slideUp('slow');
			$(this).attr({src:'/images/navHdrBottomConnectImg1.png'});
		}
      });	  
	  
});
function swapImage(objId, imgName)
{
	objId.src = '/images/' + imgName;
}

function showHideTimelineArrow(arrowStatus)
{
	arrowStatus==true ? document.getElementById('timelineArrow').style.display = 'block':document.getElementById('timelineArrow').style.display = 'none';
	arrowStatus==true ? document.getElementById("timeBar").style.display = 'block':document.getElementById("timeBar").style.display = 'none';
}

var mydate = currentTime;
var serverMinutes = mydate.getMinutes();
var serverHour1 = mydate.getHours();

function updateServerHours()
{
	var mydate = currentTime;
	serverMinutes = mydate.getMinutes();
	serverHour1 = mydate.getHours();
	var updateSeconds = mydate.getSeconds();
	updateSeconds = (updateSeconds * 100) / 60 ;
	var serverHour2 = serverHour1 + 1;
	var serverHour3 = serverHour1 + 2;
	var serverHour4 = serverHour1 + 3;
	
	var percentageComplete = ((mydate.getMinutes()+updateSeconds) * 100) / 60 ;
	var redirectLoc1 = document.location+"";

	if(redirectLoc1.indexOf('index.html') != -1)
	{
		if(percentageComplete >= 98)
			document.location = "/index.html";
	}
	
	if(document.getElementById("timeBar1"))
	{
		document.getElementById("timeBar1").style.left = percentageComplete + "%";
		
	}
}

function updateDayNightStatus(hourNum)
{
	if(hourNum == 0)
	{
		return "12 am"; 
	}	
	else if(hourNum == 24)
	{
		hourNum-= 12;
		return  hourNum + " am"; 
	}
	else if(hourNum > 24)
	{
		hourNum-= 24;
		return  hourNum + " am"; 
	}
	else if(hourNum > 12)
	{
		hourNum-= 12;
		return  hourNum + " pm"; 
	}
	else if(hourNum == 12)
	{
		return hourNum + " pm";
	}
	else if(hourNum < 12)
	{
		return  hourNum + " am";
	}
}

function getCurrentTime(hourNum, minNum)
{
	if(minNum < 10)
	{
		minNum = "0" + minNum;
	}
	
	if(hourNum > 12)
	{
		hourNum-= 12;
		return  hourNum + ":" + minNum + " PM"; 
	}
	else if(hourNum == 12)
	{
		return  hourNum + ":" + minNum + " PM"; 
	}
	else if(hourNum < 12)
	{
		return  hourNum + ":" + minNum + " PM"; 
	}
}
 
var dayNightStatus = "am";
if(serverHour1 > 12)
{
	serverHour1-= 12;
	dayNightStatus = "pm";
}
else
{
	dayNightStatus = "am";
}

function showRemoveFavorite(imgObj, removeFromFavId, addCallOut, removeCallOut)
{
   imgObj.style.display = 'none';
   document.getElementById(removeFromFavId).style.display = 'inline';
   document.getElementById(addCallOut).style.display = 'none';
   document.getElementById(removeCallOut).style.display = 'inline';
}

function showAddFavorite(imgObj, addToFavId, removeCallOut, addCallOut)
{
   imgObj.style.display = 'none';
   document.getElementById(addToFavId).style.display = 'inline';
   document.getElementById(removeCallOut).style.display = 'none';
   document.getElementById(addCallOut).style.display = 'inline';
}

function showRemoveReminder(imgObj, removeReminderId, addCallOut)
{	
   imgObj.style.display = 'none';
   document.getElementById(removeReminderId).style.display = 'inline';
   document.getElementById(addCallOut).style.display = 'none';
}

function showAddReminder(imgObj, addReminderId, removeCallOut)
{
   imgObj.style.display = 'none';
   document.getElementById(addReminderId).style.display = 'inline';
   document.getElementById(removeCallOut).style.display = 'none';
}

$(document).ready(function() {
$(".addToFavoritesClass").pngfix();
$(".addToFavoriteBoxClass").hide();
$(".removeFromFavoriteBoxClass").hide();
$(".setReminderBoxClass").hide();
$(".reminderAlreadySetBoxClass").hide();
$(".sendToFriendsBoxClass").hide();
});


var showDetailOverlayButtonsClickStatus = false;
function checkOverlayButtonStatus()
{
	if(showDetailOverlayButtonsClickStatus)
	{
		showDetailOverlayButtonsClickStatus = false;
		window.location.reload();
	}	
}

function renderOverlay(oProgramId, oStationId, oTitle, oTime, oEpisodeTitle, oEpisodeDesc, oMoreLink, oRating, oChannelNo, oHD, oShowRating, oCC, oMPAA, oAddRemoveFavStatus, oAlarmStatus,  oEmailLink, oImgUrl, loopStatus)
{
	
	var myOverlay = '<div class="addToFavoritesClass" style="width:574px; height:329px; background:url(/images/showPopupOverlayBg.png) no-repeat; padding-left:22px; padding-top:17px"><div class="overlayCloseBtn"><a href="#" onclick="Shadowbox.close(); checkOverlayButtonStatus();"><img src="/images/showPopupCloseBtn.png" /></a></div>'+
'<table width="540" border="0" cellspacing="0" cellpadding="0">'+
  '<tr>'+
    '<td colspan="2" class="fB20A whiteText vert-align" height="47" style="padding-left:30px"><div class="left" id="oTitle">Show Title</div>'+
    '<div class="right" id="oTime" style="padding-right:12px">Show: Time pm</div></td>'+
    '</tr>'+
  '<tr>'+
    '<td class="vert-align-top" width="240" height="200" style="border-right:1px solid #44474d;"><img id="oImgUrl" src="/images/showPopupImg.png" /></td>'+
    '<td class="vert-align-top bigFont" style="padding:14px 20px 8px 10px; color:#51555e; line-height:14px; width:270px;"><div style="height:75px; overflow:hidden">'+
    '<p id="oEpisodeTitle" class="bigFontBold">Episode Title</p>'+
    '<span id="oEpisodeDesc"></span></div><div id="oMoreLink" style="height:10px" class="right bigFontBold"></div>'+
    '<div id="oRating" class="clearBoth" style="height:46px"></div>'+
    '<div class="clearBoth">'+
    	'<div id="oChannelNoDiv" class="left bigTitleBold whiteText popupChannelBox"><a id="oChannelNo" class="whiteText" href="/channelDetail.html?stationId='+ oStationId +'">8888</a></div>'+
        '<div class="left">'+
        	'<div class="clearBoth" style="padding-bottom:3px; height:17px; text-align:center">'+
 		       	'<div id="oHD" class="left whiteText fB14A watchProgHDBox">HD</div>'+
                '<div id="oShowRating" class="left whiteText bigFontBold watchProgTvgBox" style="padding-top:1px"></div>'+
            '</div>'+
            '<div class="clearBoth" style="text-align:center">'+
 		       	'<div id="oCC" class="left whiteText fB14A watchProgHDBox">CC</div>'+
                '<div id="oMPAA" class="left whiteText bigFontBold watchProgTvgBox" style="padding-top:1px">MPAA</div>'+
            '</div>'+
        '</div>'+
    '</div>'+
    '</td>'+
  '</tr>'+
  '<tr>'+
    '<td height="45" class="vert-align whiteText bigFontBold" style="line-height:20px; padding-left:10px"><a id="oRemoveShowLink" href="#" class="whiteText oRemoveShowClass TxtPlane" onclick="$(\'#addRemoveBox\').load(\'/addRemoveProgram.html?programId=' + oProgramId +'\',function(){$(this).each(function(i){$(\'.oRemoveShowClass\').html(\'Removed\')});})" onmouseover="swapImage(document.getElementById(\'overlayPopUpClose1\'),\'popupCloseBtnOver.png\');" onmouseout="swapImage(document.getElementById(\'overlayPopUpClose1\'),\'popupCloseBtn.png\');"><img id="overlayPopUpClose1" src="/images/popupCloseBtn.png" align="left" style="padding-right:10px" class="vert-align TxtPlane" />Remove Show</a><br />'+
      '<a id="oRemoveChannel" href="#" onclick="$(\'#addRemoveBox\').load(\'/addRemoveStation.html?action=exclude&stationId='+oStationId+'&programId='+oProgramId+'\',function(){$(\'#oRemoveChannel\').each(function(i){$(\'.oRemoveChannelClass\').html(\'Removed\')});})" class="whiteText oRemoveChannelClass TxtPlane" onmouseover="swapImage(document.getElementById(\'overlayPopUpClose2\'),\'popupCloseBtnOver.png\');" onmouseout="swapImage(document.getElementById(\'overlayPopUpClose2\'),\'popupCloseBtn.png\');"><img id="overlayPopUpClose2" src="/images/popupCloseBtn.png" align="left" style="padding-right:10px" class="vert-align" />Remove Channel</a></td>'+
    '<td style="padding-left:8px" class="vert-align"><div style="position:relative">'+
    
    '<div id="addToFavoritesPopUp" class="addToFavoriteBoxClass" style="position:absolute; margin-top:-50px; left:-15px;"><img src="/images/addToFavoritesPopUp.png" width="131" height="53" class="addToFavoritesClass" /></div>'+
    '<div id="removeFromFavoritesPopUp" class="removeFromFavoriteBoxClass" style="position:absolute; margin-top:-50px; left:-40px;"><img src="/images/removeToFavoritesPopUp.png" class="addToFavoritesClass" /></div>'+
    '<div id="addReminderPopUp" class="setReminderBoxClass" style="position:absolute; margin-top:-50px; left:35px;"><img src="/images/setAReminderPopUp.png" width="129" height="53" class="addToFavoritesClass" /></div>'+
    '<div id="removeReminderPopUp" class="reminderAlreadySetBoxClass" style="position:absolute; margin-top:-50px; left:35px"><img src="/images/reminderPopUpIsSet.png" width="129" height="53" class="addToFavoritesClass" /></div>'+
    '<div id="addEmailPopUp" class="sendToFriendsBoxClass" style="position:absolute; margin-top:-50px; left:90px; z-index:3"><img src="/images/emailAFriendPopUp.png" width="131" height="53" class="addToFavoritesClass" /></div>'+
    '<div id="oAddToFavoriteBox" class="left" style="display:inline"><a id="oAddToFavorite" href="#" onclick="$(\'#addRemoveBox\').load(\'/addProgramInGuide.html?programId=' + oProgramId + '\'); document.getElementById(\'oAddToFavoriteBox\').style.display = \'none\'; document.getElementById(\'oRemoveFromFavoriteBox\').style.display=\'inline\';showDetailOverlayButtonsClickStatus = true"><img src="/images/popupAddToFavorite.png" onmouseover="swapImage(this,\'popupAddToFavoriteOver.png\'); $(\'.addToFavoriteBoxClass\').show();" onmouseout="swapImage(this,\'popupAddToFavorite.png\'); $(\'.addToFavoriteBoxClass\').hide();" /></a></div>'+
    '<div id="oRemoveFromFavoriteBox" class="left" style="display:none"><a id="oRemoveFromFavorite" href="#" onclick="$(\'#addRemoveBox\').load(\'/removeProgramInGuide.html?programId=' + oProgramId + '\'); document.getElementById(\'oRemoveFromFavoriteBox\').style.display = \'none\'; document.getElementById(\'oAddToFavoriteBox\').style.display=\'inline\';showDetailOverlayButtonsClickStatus = true"><img src="/images/popupRemoveFromFavorite.png" onmouseover="swapImage(this,\'popupRemoveFromFavoriteOver.png\'); $(\'.removeFromFavoriteBoxClass\').show();" onmouseout="swapImage(this,\'popupRemoveFromFavorite.png\'); $(\'.removeFromFavoriteBoxClass\').hide();" /></a></div>'+
    '<div id="oSetReminderBox" class="left"><a id="oSetReminderHref" href="#" onclick="if(isRegister == \'true\'){$(\'#addRemoveBox\').load(\'/programReminder.html?action=add&programId=' + oProgramId+'&stationId=' + oStationId + '\'); document.getElementById(\'oSetReminderBox\').style.display=\'none\'; document.getElementById(\'oReminderAlreadySetBox\').style.display=\'inline\'}else{openShadowboxToRegistration();}"><img src="/images/popupSetReminder.png" onmouseover="swapImage(this,\'popupSetReminderOver.png\'); $(\'.setReminderBoxClass\').show();" onmouseout="swapImage(this,\'popupSetReminder.png\'); $(\'.setReminderBoxClass\').hide();" /></a></div>'+
    '<div id="oReminderAlreadySetBox" class="left" style="display:none"><a id="oReminderAlreadySetHref" href="#" onclick="$(\'#addRemoveBox\').load(\'/programReminder.html?programId=' + oProgramId+'&stationId=' + oStationId + '\'); document.getElementById(\'oReminderAlreadySetBox\').style.display=\'none\'; document.getElementById(\'oSetReminderBox\').style.display=\'inline\'"><img src="/images/popupSetReminderOver.png" onmouseover="swapImage(this,\'popupSetReminder.png\'); $(\'.reminderAlreadySetBoxClass\').show();" onmouseout="swapImage(this,\'popupSetReminderOver.png\'); $(\'.reminderAlreadySetBoxClass\').hide();" /></a></div>'+
    '<div id="oReminderBox" class="left" style="display:none"><img src="/images/popupSetReminder.png"></div>'+ 
    '<div class="left"><a  href="#" onclick="openShadowboxForUser('+ oProgramId +')"><img src="/images/popupSentToFriend.png" onmouseover="swapImage(this,\'popupSentToFriendOver.png\'); $(\'.sendToFriendsBoxClass\').show();" onmouseout="swapImage(this,\'popupSentToFriend.png\'); $(\'.sendToFriendsBoxClass\').hide();" /></a></div>'+
    '<div style="right:5px;">&nbsp;<a id="popupInteractBtnHref" href="#"><img src="/images/popupInteractBtn.png" width="111" height="29" onmouseover="swapImage(this,\'popupInteractBtnOver.png\');" onmouseout="swapImage(this,\'popupInteractBtn.png\');" style="padding-top:2px" /></a></div></div></td>'+
  '</tr>'+
'</table>'+
'</div>';

	document.getElementById('allOverlayBox').innerHTML = myOverlay;
	document.getElementById('oTitle').innerHTML = oTitle;
	document.getElementById('oTime').innerHTML = oTime;
	document.getElementById('oEpisodeTitle').innerHTML = oEpisodeTitle;
	document.getElementById('oEpisodeDesc').innerHTML = oEpisodeDesc;
	document.getElementById('oMoreLink').innerHTML = '<a href="'+oMoreLink+'" style="color:#51555e;" class="TxtPlane">More</a> &gt';
	document.getElementById('oRating').innerHTML = "";
	for(var i = 0; i < oRating; i++)
	{
		document.getElementById('oRating').innerHTML += '<img src="/images/popupGrayStar.png" />';
	}
	
	var remaingStars = 5 - oRating;
	
	for(var i = 0; i < remaingStars; i++)
	{
		document.getElementById('oRating').innerHTML += '<img src="/images/popupWhiteStar.png" />';
	}
	
	document.getElementById('oChannelNo').innerHTML = oChannelNo;
	if(oChannelNo == null || oChannelNo == '')
	{    /* Added if no schedule available for fav prog then we do not have channel number and stationid*/
		document.getElementById('oChannelNoDiv').style.display = 'none';
		document.getElementById('oRemoveChannel').style.display = 'none';
		
	}
	if(oHD == 'true')
		document.getElementById('oHD').style.display = 'inline';
	else
		document.getElementById('oHD').style.display = 'none';
		
	if(oCC == 'true')
		document.getElementById('oCC').style.display = 'inline';
	else
		document.getElementById('oCC').style.display = 'none';
		
	if(oShowRating != "")
		document.getElementById('oShowRating').innerHTML = oShowRating;
	else
		document.getElementById('oShowRating').style.display = 'none';
	if(oMPAA != "")
		document.getElementById('oMPAA').innerHTML = oMPAA;
	else
		document.getElementById('oMPAA').style.display = 'none';
		
	document.getElementById('oImgUrl').src = oImgUrl;

	if(loopStatus != null && loopStatus != undefined && loopStatus != "undefined" && loopStatus != "")
	{
		var backgroundImageIsPlus = document.getElementById('sectionPlus' + loopStatus).style.display == 'block' ? true:false;
		if(backgroundImageIsPlus)
		{
			document.getElementById('oRemoveFromFavoriteBox').style.display = 'none';
			document.getElementById('oAddToFavoriteBox').style.display = 'inline';
		}
		else
		{
			document.getElementById('oRemoveFromFavoriteBox').style.display = 'inline';
			document.getElementById('oAddToFavoriteBox').style.display = 'none';
		}
	}
	else
	{
		if(oAddRemoveFavStatus == 'Add to my favorites')
		{
			document.getElementById('oRemoveFromFavoriteBox').style.display = 'none';
			document.getElementById('oAddToFavoriteBox').style.display = 'inline';
		} 
		else if(oAddRemoveFavStatus == 'Remove from my favorites')
		{
			document.getElementById('oRemoveFromFavoriteBox').style.display = 'inline';
			document.getElementById('oAddToFavoriteBox').style.display = 'none';
		}
	}
	if(oTime == null || oTime == '')
	{
		document.getElementById('oReminderBox').style.display = 'inline';
		document.getElementById('oSetReminderBox').style.display = 'none';
		document.getElementById('oReminderAlreadySetBox').style.display = 'none';
	}
	else
	{	
		if(oAlarmStatus == true)
		{
			document.getElementById('oSetReminderBox').style.display = 'none';
			document.getElementById('oReminderAlreadySetBox').style.display = 'inline';
		}
		else if(oAlarmStatus == false)
		{
			document.getElementById('oSetReminderBox').style.display = 'inline';
			document.getElementById('oReminderAlreadySetBox').style.display = 'none';			
		}
	}
	document.getElementById('popupInteractBtnHref').href = oMoreLink;

$(".addToFavoriteBoxClass").hide();
$(".removeFromFavoriteBoxClass").hide();
$(".setReminderBoxClass").hide();
$(".reminderAlreadySetBoxClass").hide();
$(".sendToFriendsBoxClass").hide();

}//End of renderOverlay function

function headLeftOver()
{
	document.getElementById('intvHeaderBox').style.background='url(/images/intvBgLeftSectionOver.png) no-repeat';
	if(jQuery.browser.version==6){
	$('#intvHeaderBox').css('background','url(/images/intvBgLeftSectionOver1.png) no-repeat');
	}
}

function headLeftOut()
{
	document.getElementById('intvHeaderBox').style.background='url(/images/headerBg.png) no-repeat';
	if(jQuery.browser.version==6){
	$('#intvHeaderBox').css('background','url(/images/headerBg1.png) no-repeat');
	}
}

function toggleIntvSelectDropDown1(elementId, propValue, srcElementId, eventFired)
{
	if(propValue == 'none' && elementId != srcElementId)
	{
		document.getElementById(srcElementId).style.background = 'url(/images/filterBoxBg2.png) no-repeat right';
	}
	
	if(eventFired == 'click')
	{
	
		if(document.getElementById(elementId).style.display == 'none')
		{
			MM_changeProp(elementId,'','display','block','DIV');
		}
		else
		{
			MM_changeProp(elementId,'','display','none','DIV');
		}
		return;
		
	}
	
	MM_changeProp(elementId,'','display',propValue,'DIV');
}

function toggleIntvSelectDropDown5(elementId, propValue, srcElementId, eventFired)
{
	if(propValue == 'none' && elementId != srcElementId)
	{
		document.getElementById(srcElementId).style.background = 'url(/images/selectProviderDropDownBg.jpg) no-repeat right';
	}
	
	if(eventFired == 'click')
	{
	
		if(document.getElementById(elementId).style.display == 'none')
		{
			MM_changeProp(elementId,'','display','block','DIV');
		}
		else
		{
			MM_changeProp(elementId,'','display','none','DIV');
		}
		return;
		
	}
	
	MM_changeProp(elementId,'','display',propValue,'DIV');
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function preloadAllImages()
{
	$('#byGenre').click(function(){$.scrollTo(document.getElementById('targetCategory'),2000)});
	$('#futureEpisodeAnchor').click(function(){$.scrollTo(document.getElementById('futureEpisodeBlock'),2000)});
	$('#futureEpisodeAnchorMore').click(function(){$.scrollTo(document.getElementById('futureEpisodeBlock'),2000)});
	$('#loginLinks').hide();
	MM_preloadImages('/images/timelineMidSegmentOver.png','/images/showPopupOverlayBg.png','/images/popupCloseBtnOver.png','/images/popupAddToFavoriteOver.png','/images/popupSetReminderOver.png','/images/popupSentToFriendOver.png','/images/popupInteractBtnOver.png','/images/intvBgLeftSectionOver.png','/images/searchBtnOver.png','/images/searchBtnDown.png','/images/onNowImgOver.png','/images/arrowLeftTimelineOver.jpg','/images/timelineLeftSegmentOver.png','/images/timelineMidSegmentOver.png','/images/timeleftRightSegmentOver.png','/images/arrowRightTimelineOver.jpg','/images/filterBoxBg2Over.png','/images/myShowsLensImgOver.png','/images/searchFriendsBtnOver.png','/images/gmailImgOver.png','/images/windowsImgOver.png','/images/yahooImgOver.png','/images/aolImgOver.png','/images/inviteFriendsBtnOver.png','/images/sectionLensOver.png','/images/sectionPlusOver.png','/images/sectionMinusOver.png','/images/redCloseBtn.png','/images/watchingProgramDetailAddFavoriteBtnOver.png','/images/watchingAddReminderOver.png','/images/watchingEmailOver.png','/images/ebayBtnOver.png','/images/PostCommentDown.png','/images/filterBox1ContentBg.png', '/images/filterBox1ContentBgOver.png','/images/filterBox1Ftr.png','/images/AddonInactiveBut.png','/images/FriendsActiveBut.png','/images/programListGridBtnOver.png');
}