var ytRowIndex=0;var ytColumnIndex=0;var ytCursorIndex=0;var ytTotalTitle=0;var startYouTubeIndex=0;var curYpIndexArr=new Array();var youTubeUrlCache=new Array();var youTubePlayStatus=false;function launchYouTubePanel(A){resetYouTubepanel();getYouTubeDetails(A)}function resetYouTubepanel(){ytRowIndex=0;ytColumnIndex=0;ytCursorIndex=0;ytTotalTitle=0;startYouTubeIndex=0;curYpIndexArr=new Array();youTubeUrlCache=new Array();youTubePlayStatus=false}function getYouTubeDetails(A){var B="method=getYouTubeDetails&serial="+serial+"&widgetId="+A;createAjaxRequest();if(ajaxRequest==null){return }ajaxRequest.onreadystatechange=function(){if(ajaxRequest.readyState==4){if(ajaxRequest.status==200){if(ajaxRequest.responseText=="recall"){getYouTubeDetails(A)}else{var C=ajaxRequest.responseText;var D=C.split("-?#-");youTubeUrlCache=D[0].split("-@#-");ytTotalTitle=youTubeUrlCache.length-1;updateYouTubePanel();showYouTubePanel()}}else{if(ajaxRequest.status==500){failureInfo()}}}};ajaxRequest.open("POST","/TvHandler",true);ajaxRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");ajaxRequest.send(B);return false}function youtubeImageCache(A){var B=A.substring(A.lastIndexOf("/")+1,A.length);return B}function updateYouTubePanel(){var E="";var F;var A=0;var E='<tr><td colspan="7" width="400px" height="10px">&nbsp;</td></tr><tr><td width="15px" height="80px">&nbsp;</td>';for(var C=0;C<3;C++){curYpIndexArr[C]=new Array(3);for(var B=0;B<3;B++){curYpIndexArr[C][B]=0}}for(F=0;(youTubeUrlCache.length>=9&&F<9)||(youTubeUrlCache.length<9&&F<youTubeUrlCache.length);++F){A++;var I=parseInt(F/3);var G=parseInt(F%3);if(F%3==0&&F!=0){E+='</tr><tr><td colspan="7" width="400px" height="10px">&nbsp;</td></tr><tr><td width="15px" height="80px">&nbsp;</td>'}var H=3*I+G;image=youTubeUrlCache[H];curYpIndexArr[I][G]=1;E+='<td id="youtubeTitleId'+I+""+G+'" align="center" valign="middle" nowrap style="width:75px;height:75px;background:black;border:1px solid gray;'+(statusInfo==1?"cursor:pointer;":"")+'" '+(statusInfo==1?" onmouseover='onYouTubeTitle("+I+", "+G+");' onclick='youtubeKeyHandler("+rcOK+");' ":"")+' ><img style="width:75px;height:75px;"src="http://img.youtube.com/vi/'+youtubeImageCache(image)+'/default.jpg" /></td><td width="15px" height="80px" >&nbsp;</td>'}if(A>0){for(var D=0;D<(9-A);++D){if((A+D)%3==0){E+='</tr><tr><td colspan="7" width="400px" height="10px">&nbsp;</td></tr><tr><td width="15px" height="80px">&nbsp;</td>'}E+='<td align="center" valign="middle" nowrap style="width:75px;height:80px;">&nbsp;</td><td width="15px" height="80px" >&nbsp;</td>'}}E+='</tr><tr><td colspan="7" width="400px" height="10px">&nbsp;</td></tr>';document.getElementById("ytContentPanel").innerHTML='<table height="300px;" width="100%" align="left" valign="top" cellspacing="0" cellpadding="0" >'+(E?E:'<tr><td height="28" width="100%" align="center" valign="middle"><span style="width:100%;text-align:center;vertical-align:middle;background-repeat:no-repeat;">No options avaliable</span></td></tr>')+"</table>";selYoutubeTitle(0,0)}function showHomeYouTubePanel(B){var A="";A=(B==1?"#fcf3b8":"none");document.getElementById("youTubeHome").style.background=A}function escapeYouTubePanel(){youtubeKeyHandler(rcMENU)}function youtubeKeyHandler(I){switch(I){case rcRIGHT:var B=ytRowIndex*3+ytColumnIndex;if(B==ytTotalTitle||ytColumnIndex==2){return }if(ytColumnIndex>=0){unSelYoutubeTitle(ytRowIndex,ytColumnIndex);++ytColumnIndex;selYoutubeTitle(ytRowIndex,ytColumnIndex);return }break;case rcLEFT:if(ytColumnIndex==0){return }if(ytColumnIndex>=0){unSelYoutubeTitle(ytRowIndex,ytColumnIndex);--ytColumnIndex;selYoutubeTitle(ytRowIndex,ytColumnIndex);return }break;case rcUP:if(ytRowIndex==0){return }unSelYoutubeTitle(ytRowIndex,ytColumnIndex);ytRowIndex--;if(ytCursorIndex!=0){ytCursorIndex--;selYoutubeTitle(ytRowIndex,ytColumnIndex)}else{ytCursorIndex=0;var C=0;C=(startYouTubeIndex<3?0:startYouTubeIndex-3);startYouTubeIndex=C;var D=((ytTotalTitle-C)>8?(C+8):ytTotalTitle);scrollYouTubePanel(C,D)}break;case rcDOWN:var H=ytCursorIndex+1;var F=ytColumnIndex;if(H<3){if(curYpIndexArr[H][F]==0){return }}var E=(ytTotalTitle/3);if(ytRowIndex==parseInt(E)){return }unSelYoutubeTitle(ytRowIndex,ytColumnIndex);ytRowIndex++;if(ytCursorIndex<2){ytCursorIndex++;selYoutubeTitle(ytRowIndex,ytColumnIndex)}else{var C=0;if(ytRowIndex<3){C=ytRowIndex;startYouTubeIndex=C}else{C=startYouTubeIndex+3;startYouTubeIndex=C}ytCursorIndex=2;var D=((ytTotalTitle-C)>8?(C+8):ytTotalTitle);scrollYouTubePanel(C,D)}break;case rcOK:var G=ytRowIndex*3+ytColumnIndex;var A=youTubeUrlCache[G];playYouTubeVid(A);document.getElementById("layer37").style.display="none";break;case rcMENU:if(youTubePlayStatus){youTubePlayStatus=false;hideStatusPanel();document.getElementById("statusMessagePanel").innerHTML="";document.getElementById("layer37").style.display="block";if(document.getElementById("keyDigitPanel")!=null){document.getElementById("keyDigitPanel").style.visibility="hidden"}document.getElementById("waitPanel").style.backgroundImage="url('./view/tv/images/banner.png')";if(stbTypeId==7){if(document.getElementById("epgPlayer")!=null){document.getElementById("epgPlayer").className="epgPlayerOld"}}if(stbTypeId==7){document.getElementById("homePanelImage").style.visibility="hidden"}}else{resetYouTubepanel();feedType="igmp";document.getElementById("epgPlayer").innerHTML="";startStream();youTubePlayStatus=false;youTubeActive=false;showGoPanel();showGuidePanel()}break}}function selYoutubeTitle(E,B){var C="youtubeTitleId"+E+""+B;try{document.getElementById(C).style.border="1px solid white"}catch(A){try{ytRowIndex-=1;ytCursorIndex-=1;selYoutubeTitle(ytRowIndex,ytColumnIndex)}catch(D){}}}function unSelYoutubeTitle(C,A){var B="youtubeTitleId"+C+""+A;if(document.getElementById(B)!=null){document.getElementById(B).style.border="1px solid gray"}}function onYouTubeTitle(A){unSelYoutubeTitle(ytRowIndex,ytColumnIndex);var C=parseInt(A/3);var B=A%3;ytRowIndex=C;ytColumnIndex=B;selYoutubeTitle(ytRowIndex,ytColumnIndex)}function scrollYouTubePanel(A,E){var G="";var H;var B=0;document.getElementById("ytContentPanel").innerHTML="";var G='<tr><td colspan="7" width="400px" height="10px">&nbsp;</td></tr><tr><td width="15px" height="80px">&nbsp;</td>';for(var D=0;D<3;D++){curYpIndexArr[D]=new Array(3);for(var C=0;C<3;C++){curYpIndexArr[D][C]=0}}for(H=A;H<=E;H++){var K=parseInt(H/3);var J=parseInt(H%3);if(H%3==0&&H!=0&&B!=0){G+='</tr><tr><td colspan="7" width="400px" height="10px">&nbsp;</td></tr><tr><td width="15px" height="80px">&nbsp;</td>'}var I=3*K+J;image=youTubeUrlCache[I];curYpIndexArr[parseInt(B/3)][parseInt(B%3)]=1;G+='<td id="youtubeTitleId'+K+""+J+'" align="center" valign="middle" nowrap style="width:75px;height:75px;background:black;border:1px solid gray;'+(statusInfo==1?"cursor:pointer;":"")+'" '+(statusInfo==1?" onmouseover='onYouTubeTitle("+K+", "+J+");' onclick='youtubeKeyHandler("+rcOK+");' ":"")+' ><img style="width:75px;height:75px;"  src="http://img.youtube.com/vi/'+youtubeImageCache(image)+'/default.jpg" /></td><td width="15px" height="80px" >&nbsp;</td>';B++}if(B>0){for(var F=0;F<(9-B);++F){if((B+F)%3==0){G+='</tr><tr><td colspan="7" width="400px" height="10px">&nbsp;</td></tr><tr><td width="15px" height="80px">&nbsp;</td>'}G+='<td align="center" valign="middle" nowrap style="width:75px;height:80px;">&nbsp;</td><td width="15px" height="80px" >&nbsp;</td>'}}G+='</tr><tr><td colspan="7" width="400px" height="10px">&nbsp;</td></tr>';document.getElementById("ytContentPanel").innerHTML='<table height="300px;" width="100%" align="left" valign="top" cellspacing="0" cellpadding="0" >'+(G?G:'<tr><td height="28" width="100%" align="center" valign="middle"><span style="width:100%;text-align:center;vertical-align:middle;background-repeat:no-repeat;">No options avaliable</span></td></tr>')+"</table>";selYoutubeTitle(ytRowIndex,ytColumnIndex)}function playYouTubeVid(B){if(!B){return }var A=DetectFlashVer(10,0,0);if(!A){document.getElementById("statusMessagePanel").innerHTML="get the flash player now on http://www.adobe.com/go/getflashplayer/";return }youTubePlayStatus=true;document.getElementById("epgPlayer").innerHTML="";var C='<object width="624" height="422"><param name="movie" value="'+B+'&hl=en&fs=1&rel=0&loop=1&autoplay=1"></param><param name="wmode" value="opaque"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="bgcolor" value="#000000"></param><embed src="'+B+'&hl=en&fs=1&rel=0&loop=1&autoplay=1" type="application/x-shockwave-flash" bgcolor="#000000" allowscriptaccess="always" allowfullscreen="true" wmode="opaque" width="624" height="422"></embed></object>';document.getElementById("epgPlayer").innerHTML=C;if(document.getElementById("epgPlayer")!=null){document.getElementById("epgPlayer").className="epgPlayer"}if(stbTypeId==7){document.getElementById("homePanelImage").style.visibility="visible"}document.getElementById("waitPanel").style.backgroundImage="none"}function showYouTubeArraow(A){document.getElementById("moveYouTube"+A).style.background="#fcf3b8"}function hideYouTubeArrow(A){document.getElementById("moveYouTube"+A).style.background="none"}function moveYouTubePage(A){if(A==1){youtubeKeyHandler(rcUP)}else{youtubeKeyHandler(rcDOWN)}}