var huluRowIndex=0;var huluColumnIndex=0;var huluCursorIndex=0;var huluTotalTitle=0;var startHuluIndex=0;var curHuluIndexArr=new Array();var huluUrlCache=new Array();var huluPlayStatus=false;function launchHuluPanel(A){resetHulupanel();getHuluDetails(A)}function resetHulupanel(){huluRowIndex=0;huluColumnIndex=0;huluCursorIndex=0;huluTotalTitle=0;startHuluIndex=0;curHuluIndexArr=new Array();huluUrlCache=new Array();huluPlayStatus=false}function getHuluDetails(A){var B="method=getHuluDetails&serial="+serial+"&widgetId="+A;createAjaxRequest();if(ajaxRequest==null){return }ajaxRequest.onreadystatechange=function(){if(ajaxRequest.readyState==4){if(ajaxRequest.status==200){if(ajaxRequest.responseText=="recall"){getHuluDetails(A)}else{var C=ajaxRequest.responseText;var D=C.split("-?#-");huluUrlCache=D[0].split("-@#-");huluTotalTitle=huluUrlCache.length-1;updateHuluPanel();showHuluPanel()}}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 huluImageCache(A){var B=A.substring(A.lastIndexOf("/")+1,A.length);return B}function updateHuluPanel(){var A="";var F;var B=0;var A='<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++){curHuluIndexArr[D]=new Array(3);for(var C=0;C<3;C++){curHuluIndexArr[D][C]=0}}for(F=0;(huluUrlCache.length>=9&&F<9)||(huluUrlCache.length<9&&F<huluUrlCache.length);++F){B++;var I=parseInt(F/3);var G=parseInt(F%3);if(F%3==0&&F!=0){A+='</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=huluUrlCache[H];curHuluIndexArr[I][G]=1;A+='<td id="huluTitleId'+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='onHuluTitle("+I+", "+G+");' onclick='huluKeyHandler("+rcOK+");' ":"")+" >"+getHuluImage(image)+'</td><td width="15px" height="80px" >&nbsp;</td>'}if(B>0){for(var E=0;E<(9-B);++E){if((B+E)%3==0){A+='</tr><tr><td colspan="7" width="400px" height="10px">&nbsp;</td></tr><tr><td width="15px" height="80px">&nbsp;</td>'}A+='<td align="center" valign="middle" nowrap style="width:75px;height:80px;">&nbsp;</td><td width="15px" height="80px" >&nbsp;</td>'}}A+='</tr><tr><td colspan="7" width="400px" height="10px">&nbsp;</td></tr>';document.getElementById("huluContentPanel").innerHTML='<table height="300px;" width="100%" align="left" valign="top" cellspacing="0" cellpadding="0" >'+(A?A:'<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>";selHuluTitle(0,0)}function showHomeHuluPanel(B){var A="";A=(B==1?"#fcf3b8":"none");document.getElementById("huluHome").style.background=A}function escapeHuluPanel(){huluKeyHandler(rcMENU)}function huluKeyHandler(I){switch(I){case rcRIGHT:var B=huluRowIndex*3+huluColumnIndex;if(B==huluTotalTitle||huluColumnIndex==2){return }if(huluColumnIndex>=0){unSelHuluTitle(huluRowIndex,huluColumnIndex);++huluColumnIndex;selHuluTitle(huluRowIndex,huluColumnIndex);return }break;case rcLEFT:if(huluColumnIndex==0){return }if(huluColumnIndex>=0){unSelHuluTitle(huluRowIndex,huluColumnIndex);--huluColumnIndex;selHuluTitle(huluRowIndex,huluColumnIndex);return }break;case rcUP:if(huluRowIndex==0){return }unSelHuluTitle(huluRowIndex,huluColumnIndex);huluRowIndex--;if(huluCursorIndex!=0){huluCursorIndex--;selHuluTitle(huluRowIndex,huluColumnIndex)}else{huluCursorIndex=0;var C=0;C=(startHuluIndex<3?0:startHuluIndex-3);startHuluIndex=C;var D=((huluTotalTitle-C)>8?(C+8):huluTotalTitle);scrollHuluPanel(C,D)}break;case rcDOWN:var G=huluCursorIndex+1;var E=huluColumnIndex;if(G<3){if(curHuluIndexArr[G][E]==0){return }}var H=(huluTotalTitle/3);if(huluRowIndex==parseInt(H)){return }unSelHuluTitle(huluRowIndex,huluColumnIndex);huluRowIndex++;if(huluCursorIndex<2){huluCursorIndex++;selHuluTitle(huluRowIndex,huluColumnIndex)}else{var C=0;if(huluRowIndex<3){C=huluRowIndex;startHuluIndex=C}else{C=startHuluIndex+3;startHuluIndex=C}huluCursorIndex=2;var D=((huluTotalTitle-C)>8?(C+8):huluTotalTitle);scrollHuluPanel(C,D)}break;case rcOK:var F=huluRowIndex*3+huluColumnIndex;var A=huluUrlCache[F];playHuluVid(A);document.getElementById("layer61").style.display="none";break;case rcMENU:if(huluPlayStatus){huluPlayStatus=false;hideStatusPanel();document.getElementById("statusMessagePanel").innerHTML="";document.getElementById("layer61").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{resetHulupanel();feedType="igmp";document.getElementById("epgPlayer").innerHTML="";startStream();huluPlayStatus=false;huluActive=false;showGoPanel();showGuidePanel()}break}}function selHuluTitle(E,B){var C="huluTitleId"+E+""+B;try{document.getElementById(C).style.border="1px solid white"}catch(A){try{huluRowIndex-=1;huluCursorIndex-=1;selHuluTitle(huluRowIndex,huluColumnIndex)}catch(D){}}}function unSelHuluTitle(C,A){var B="huluTitleId"+C+""+A;if(document.getElementById(B)!=null){document.getElementById(B).style.border="1px solid gray"}}function onHuluTitle(A){unSelHuluTitle(huluRowIndex,huluColumnIndex);var C=parseInt(A/3);var B=A%3;huluRowIndex=C;huluColumnIndex=B;selHuluTitle(huluRowIndex,huluColumnIndex)}function scrollHuluPanel(A,F){var B="";var H;var C=0;document.getElementById("huluContentPanel").innerHTML="";var B='<tr><td colspan="7" width="400px" height="10px">&nbsp;</td></tr><tr><td width="15px" height="80px">&nbsp;</td>';for(var E=0;E<3;E++){curHuluIndexArr[E]=new Array(3);for(var D=0;D<3;D++){curHuluIndexArr[E][D]=0}}for(H=A;H<=F;H++){var K=parseInt(H/3);var J=parseInt(H%3);if(H%3==0&&H!=0&&C!=0){B+='</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=huluUrlCache[I];curHuluIndexArr[parseInt(C/3)][parseInt(C%3)]=1;B+='<td id="huluTitleId'+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='onHuluTitle("+K+", "+J+");' onclick='huluKeyHandler("+rcOK+");' ":"")+" >"+getHuluImage(image)+'</td><td width="15px" height="80px" >&nbsp;</td>';C++}if(C>0){for(var G=0;G<(9-C);++G){if((C+G)%3==0){B+='</tr><tr><td colspan="7" width="400px" height="10px">&nbsp;</td></tr><tr><td width="15px" height="80px">&nbsp;</td>'}B+='<td align="center" valign="middle" nowrap style="width:75px;height:80px;">&nbsp;</td><td width="15px" height="80px" >&nbsp;</td>'}}B+='</tr><tr><td colspan="7" width="400px" height="10px">&nbsp;</td></tr>';document.getElementById("huluContentPanel").innerHTML='<table height="300px;" width="100%" align="left" valign="top" cellspacing="0" cellpadding="0" >'+(B?B:'<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>";selHuluTitle(huluRowIndex,huluColumnIndex)}function playHuluVid(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 }huluPlayStatus=true;document.getElementById("epgPlayer").innerHTML="";var C='<object width="624" height="422"><param name="movie" value="'+B+'"></param><param name="wmode" value="opaque"></param><param name="allowFullScreen" value="true"></param><param name="bgcolor" value="#000000"></param><embed src="'+B+'&autoplay=1" type="application/x-shockwave-flash" allowFullScreen="true" bgcolor="#000000" width="624" height="422" allowfullscreen="true" wmode="opaque"></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 showHuluArraow(A){document.getElementById("moveHulu"+A).style.background="#fcf3b8"}function hideHuluArrow(A){document.getElementById("moveHulu"+A).style.background="none"}function moveYtPage(A){if(A==1){huluKeyHandler(rcUP)}else{huluKeyHandler(rcDOWN)}}function getHuluImage(A){var B="<span class='huluThumbnail' onClick=\"playHuluVid("+A+")\"></span><object width='75' height='75'><param name='movie' value="+A+"&autoplay=0></param><param name='wmode' value='opaque'></param><param name='allowFullScreen' value='false'></param><param name='bgcolor' value='#000000'></param><embed src="+A+"&autoplay=0 type='application/x-shockwave-flash' allowFullScreen='false' bgcolor='#000000' width='75' height='75' allowfullscreen='false' wmode='opaque'></embed></object>";return B}