var gridPage=0;var gridTotalCat=0;var gridTotalCh=0;var currentGridIndex=0;var prevGridIndex=0;var gridCursorIndex=0;var currentChannelIndex=0;var prevChannelIndex=0;var channelCursorIndex=0;var ggCol=0;var currentProgramIndex=0;var selGuidePageSetNext=new Array();var gridSelGuidePageSet=new Array();var gridTotalGuide=new Array();var navArr=new Array();var gPrgIndex=new Array();var prgIntervalArr=new Array();function launchGridFullGuidePanel(){gridView=true;gridPage=0;resetStatus=false;loadGuidePage(0);updateDescPanel2();updateChannelLogo()}function updateGridChannelPanel(){selChannelIdCache=channelIdCache;selChannelNameCache=channelNameCache;selChannelOrderCache=channelOrderCache;selFavoriteCache=favoriteCache;selLockedCache=lockedCache;selUseGraphicCache=useGraphicCache;gridArr=new Array();var H=0;var E="";for(var D=0;(selChannelNameCache.length>=5&&D<5)||(selChannelNameCache.length<5&&D<selChannelNameCache.length);++D){E+='<tr><td id="gridChannel'+D+'" style="width:100%;height:42px;text-align:left;white-space:nowrap;vertical-align:middle;"'+(statusInfo==1?"":"")+'><table width="100%" align="center" valign="top" cellspacing="0" cellpadding="0"><tr><td id="selGridChannelsOrder'+D+'" style="width:60px;text-align:left">&nbsp;&nbsp;'+selChannelOrderCache[D]+'</td><td id="selGridChannelNames'+D+'" style="width:100px;text-align:left">'+selChannelNameCache[D]+"</td></tr></table></td></tr>";H++;origCacheIndex=D;var G=getGuideIndexStart(origCacheIndex);var A=guideCache[origCacheIndex].split("-$#-");var F=0;var C=new Array();for(var B=G;B<A.length;++B){C[F]=A[B];F++}gridArr[D]=C.join("-$#-")}for(var D=0;D<(5-H);++D){if(H==0){break}E+='<tr><td style="width:100%;height:40px;text-align:left;white-space:nowrap;vertical-align:middle;"><table width="100%" align="center" valign="top" cellspacing="0" cellpadding="0"><tr><td style="width:40px;text-align:left">&nbsp;&nbsp;</td></tr></table></td></tr>'}document.getElementById("channelGuidePanel2").innerHTML='<table width="100%" align="center" valign="top" cellspacing="0" cellpadding="0" class="chGuidePanelWide2">'+(E?E:'<tr><td height="28" width="100%" nowrap align="center" valign="middle"><span style="width:100%;text-align:center;vertical-align:middle;background-repeat:no-repeat;">&nbsp;No Channels Available</span></td></tr>')+"</table>";highlightGridChannel();updateGridGuidePanel();gridPage=0;gridTotalCh=(selChannelNameCache.length==0?0:selChannelNameCache.length-1);updateGridDescPanel()}function updateGridGuidePanel(){var N="";for(var H=0;H<gridArr.length;++H){navArr[H]="";gPrgIndex[H]="";prgIntervalArr[H]="";var Q=gridArr[H];var I=Q.split("-$#-");N+='<tr><td id="gridGuideRow'+H+'" ><table width="100%" class="gridGuideTable"><tr>';var K=0;var C=0;var F=0;var O=new Array();var M=new Array();for(var E=0;E<I.length;++E){var G=I[E].split("|");var B=new Date();var A=new Date(G[1]);A=new Date(A.getTime()-((B.getTimezoneOffset())*60*1000));var D=new Date(G[2]);D=new Date(D.getTime()-((B.getTimezoneOffset())*60*1000));if(D>startTime&&A<endTime){O[K]=E;M[K]=A+"$"+D;K++;var P=((D>endTime?endTime:D)-(K==1?startTime:A))/(endTime-startTime);C=Math.floor(400*P);var L=G[6];if(C<120){L="..."}else{if(C>=200&&L.length>30){L=L.substring(0,27)+"..."}else{if(C>250&&L.length>40){L=L.substring(0,30)+"..."}else{if(L.length>25){L=L.substring(0,25)+"..."}}}}navArr[H]+=(navArr[H]&&navArr[H].length>0?"|":"")+H+""+E;var J=(H+""+E);N+='<td class="gridGuideCell" id="gg'+H+""+E+'" width="'+C+'px" >'+L+"</td>";++F}}if(K==0){var J=(H+""+0);navArr[H]+=(navArr[H]&&navArr[H].length>0?"|":"")+H+""+0;N+='<td class="gridGuideCell" id="gg'+H+""+0+'" width="'+250+'px" '+(statusInfo==1?"":"")+">"+records.key414+"</td>"}prgIntervalArr[H]=M.join("|");gPrgIndex[H]=O.join("|");N+="</tr></table></td></tr>"}for(var H=0;H<5-(gridArr.length);H++){N+='<tr><td  width="'+250+'px" height="46px">&nbsp;</td></tr>'}document.getElementById("proGuidePanel2").innerHTML='<table width="100%" height="100%" align="center" valign="top" cellspacing="0" cellpadding="0" class="proGuidePanel2">'+(N?N:'<tr><td height="28" width="100%" nowrap align="center" valign="middle"><span style="width:100%;text-align:center;vertical-align:middle;background-repeat:no-repeat;">'+records.key413+"</span></td></tr>")+"</table>"}function updateGridDescPanel(){var J=gridArr[channelCursorIndex];var G=J.split("-$#-");var B=new Array();if(gPrgIndex[channelCursorIndex]!=""){B=(gPrgIndex[channelCursorIndex]).split("|")}if(gridCursorIndex>=B.length&&B.length!=0){--gridCursorIndex}if(B.length==0){gridCursorIndex=0}var H=(B.length==0?0:(B[gridCursorIndex]=="undefined"?0:B[gridCursorIndex]));var F=G[H].split("|");var D=F[6];if(D.length>20){D=D.substring(0,17)+"..."}var I=F[10];if(I&&I.length>115){I=I.substring(0,112)+"..."}var E=new Date(F[1]);E=new Date(E.getTime()+curOffSetValue());var C=E.getMonth();var A=E.getDate();C=C<10?"0"+C:C;A=A<10?"0"+A:A;if(document.getElementById("programGuidePanel")){document.getElementById("programGuidePanel").innerHTML=(D?D:"");document.getElementById("fromToGuidePanel").innerHTML=(F[1]&&F[2]?getMonthText(C)+"&nbsp;"+A+"&nbsp;&nbsp;&nbsp;"+formatTime(F[1])+" - "+formatTime(F[2]):"");document.getElementById("titleGuidePanel").innerHTML=(I?I:"")}}function scrollGridChannelPage(A,C){var I=0;gridArr=new Array();for(var E=A;E<=C;++E){var H="selGridChannelsOrder"+I;var J="selGridChannelNames"+I;document.getElementById(H).innerHTML="&nbsp;&nbsp;"+selChannelOrderCache[E];document.getElementById(J).innerHTML=selChannelNameCache[E];origCacheIndex=E;var B=getGuideIndexStart(origCacheIndex);var G=guideCache[origCacheIndex].split("-$#-");var F=0;selGuidePageSet=new Array();for(var D=B;D<G.length;++D){selGuidePageSet[F]=G[D];F++}gridArr[I]=selGuidePageSet.join("-$#-");++I}updateGridGuidePanel();changeGridChannelCursor()}function highlightGridChannel(){try{var C="gridChannel"+prevChannelIndex;document.getElementById(C).className="gridUnSelPanel";var B="gridChannel"+channelCursorIndex;document.getElementById(B).className="gridSelPanel"}catch(A){}}function changeGridChannelCursor(){try{var C="gridChannel"+prevChannelIndex;document.getElementById(C).className="gridUnSelPanel";var B="gridChannel"+channelCursorIndex;document.getElementById(B).className="gridSelPanel"}catch(A){}}function updateChannelLogo(){if(selUseGraphicCache[currentChannelIndex]==1){document.getElementById("chLogoPanel").innerHTML='<img alt="" width="60px" height="40px" src="/ImageHandler?value='+selChannelIdCache[currentChannelIndex]+'&icon=-1&imageType=0" style="padding:1px;" border="0" align="middle">'}else{document.getElementById("chLogoPanel").innerHTML='<img alt="" width="60px" height="40px" src="/view/tv/images/logo_none.png" style="padding:1px;" border="0" align="middle">'}}function toggleGridImage(){if(gridGuidePage==0){highlightGridCategory()}else{if(gridGuidePage==1){changeGridChannelCursor()}else{if(gridGuidePage==2){highlightGridGuide()}else{if(gridGuidePage==3){highlightGridGuide1()}}}}}function resetGridChannelPanel(){gridSelectedChannel=0;gridCurrentChannel=0;gridChannelCursor=0;gridPrevChannelCursor=0}function updateGridSelChannelPanel(){if(gridSelUseGraphicCache[gridSelectedChannel]==1){document.getElementById("chLogoPanel1").innerHTML='<img alt="" height="60px" width="65px" src="/images/channels/logo_'+gridSelChannelIdCache[gridSelectedChannel]+'.gif" style="padding:1px;" border="0" align="middle">'}else{document.getElementById("chLogoPanel1").innerHTML=""}}function selGridProgram(B){try{document.getElementById(B).className="gridContentSelPanel"}catch(A){}}function unselGridProgram(B){try{document.getElementById(B).className="gridContentUnSelPanel"}catch(A){}}function returnElementId(D,C){var B=navArr[D].split("|");var A="gg"+B[C];return A}function resetGridPanel(){gridPage=0;gridTotalCat=0;gridTotalCh=0;currentGridIndex=0;prevGridIndex=0;gridCursorIndex=0;currentChannelIndex=0;prevChannelIndex=0;channelCursorIndex=0;ggCol=0;currentProgramIndex=0;selGuidePageSetNext=new Array();gridSelGuidePageSet=new Array();gridTotalGuide=new Array();navArr=new Array()}function gridViewKeyHandler(F){switch(F){case rcBLUE:resetGridPanel();isGridViewOpened=false;gridView=false;menuActive=true;resetStatus=false;document.getElementById("guideGrid2").style.visibility="hidden";document.getElementById("clockieFG3").style.visibility="hidden";document.getElementById("clockieFG4").style.visibility="hidden";document.getElementById("clockieFG7").style.visibility="hidden";launchGuide();showGuidePanel();break;case rcLEFT:if(gridPage==1){if(currentGridIndex==0){if(gridCursorIndex==0){gridPage=0;var C=returnElementId(channelCursorIndex,gridCursorIndex);unselGridProgram(C)}else{prevGridIndex=gridCursorIndex;var C=returnElementId(channelCursorIndex,gridCursorIndex);unselGridProgram(C);--gridCursorIndex;C=returnElementId(channelCursorIndex,gridCursorIndex);selGridProgram(C);updateGridDescPanel()}}else{showPDStatus=false;gridCursorIndex=0;gridPage=0;--currentGridIndex;--currentProgramIndex;resetStatus=false;loadGuidePage(currentGridIndex);updateGridGuidePanel();gridViewKeyHandler(rcRIGHT)}}break;case rcRIGHT:if(gridPage==0){gridPage=1;var C=returnElementId(channelCursorIndex,gridCursorIndex);selGridProgram(C)}else{var D=navArr[channelCursorIndex].split("|");var B=D.length-1;++currentProgramIndex;if(gridCursorIndex==B){gridStartIndex=true;gridCursorIndex=0;resetStatus=false;loadGuidePage(++currentGridIndex);updateGridGuidePanel();gridPage=1;var C=returnElementId(channelCursorIndex,gridCursorIndex);selGridProgram(C);updateGridDescPanel();gridPrgIndex=currentGridIndex;return }prevGridIndex=gridCursorIndex;var C=returnElementId(channelCursorIndex,gridCursorIndex);unselGridProgram(C);++gridCursorIndex;C=returnElementId(channelCursorIndex,gridCursorIndex);selGridProgram(C);updateGridDescPanel()}break;case rcUP:if(gridPage==0){if(currentChannelIndex==0){return }currentChannelIndex--;if(channelCursorIndex!=0){prevChannelIndex=channelCursorIndex;channelCursorIndex--;changeGridChannelCursor()}else{var G=currentChannelIndex;var A=currentChannelIndex+4;scrollGridChannelPage(G,A)}updateChannelLogo()}else{var C=returnElementId(channelCursorIndex,gridCursorIndex);unselGridProgram(C);var E=channelCursorIndex;gridPage=0;E=(channelCursorIndex==0?++E:E);gridViewKeyHandler(rcUP);gridCursorIndex=getCurPrevPrgIndex(E,channelCursorIndex,gridCursorIndex);gridViewKeyHandler(rcRIGHT)}updateGridDescPanel();break;case rcDOWN:if(gridPage==0){if(currentChannelIndex==gridTotalCh){break}currentChannelIndex++;if(channelCursorIndex<4){prevChannelIndex=channelCursorIndex;channelCursorIndex++;changeGridChannelCursor()}else{var G=currentChannelIndex-4;var A=currentChannelIndex;scrollGridChannelPage(G,A)}updateChannelLogo()}else{var C=returnElementId(channelCursorIndex,gridCursorIndex);unselGridProgram(C);var E=channelCursorIndex;gridPage=0;E=(channelCursorIndex==4?--E:E);gridViewKeyHandler(rcDOWN);gridCursorIndex=getCurPrevPrgIndex(E,channelCursorIndex,gridCursorIndex);gridViewKeyHandler(rcRIGHT)}updateGridDescPanel();break}}function returnPrgArray(B,E){var D=gridArr[B];var A=D.split("-$#-");var C=new Array();if(gPrgIndex[B]!=""){C=(gPrgIndex[B]).split("|")}return C}function getCurPrevPrgIndex(H,D,K){if(prgIntervalArr.length==0){return 0}var L=prgIntervalArr[D];if(L.length==0){return 0}var J=getCurPrgIndex(H,K);var M=getCurEndPrgIndex(H,K);if(J.length==0){return 0}if(M.length==0){return 0}var E=new Date(J);var B=new Date(M);var I=E.getTime();var A=B.getTime();var N=(L).split("|");var G=0;for(G=0;G<N.length;G++){var O=(N[G]).split("$");var C=new Date(O[0]);var F=new Date(O[1]);if((I>=C.getTime()&&I<F.getTime())||(A>=C.getTime()&&I<F.getTime())){return G}}return G}function getCurPrgIndex(A,B){var D=(prgIntervalArr[A]).split("|");B=(B==D.length?--B:B);var C=(D[B]).split("$");return C[0]}function getCurEndPrgIndex(A,B){var D=(prgIntervalArr[A]).split("|");B=(B==D.length?--B:B);var C=(D[B]).split("$");return C[1]}function getHomeInfo(){var A=0;if(document.getElementById("controlPanel"+A)!=null){document.getElementById("controlPanel"+A).style.visibility="visible"}}function showGridGuide(A){hideAll();keyActionHandler(rcBLUE)}function unSelGridGuide(A){if(document.getElementById("gridGuide")!=null){document.getElementById("gridGuide").style.background="none"}}function selGridGuide(A){if(document.getElementById("gridGuide")!=null){document.getElementById("gridGuide").style.background="#fcf3b8"}}function scrollGridGuide(A){if(A==1){keyActionHandler(rcLEFT)}else{if(A==2){keyActionHandler(rcRIGHT)}}}function updateDescPanel2(){updateGridDescPanel()}function updateChannelPanel2(){updateGridChannelPanel()}function updateGuidePanel2(){updateGridGuidePanel()}