var photoStudioGenre=new Array("Friends","Family","Others","Sharing");var currentPhotoStudioGenre=0;var prevPhotoStudioGenre=0;var photoXpandIndex=0;var curPhotoIndex=new Array();var photoIdCache=new Array();var photoTagCache=new Array();var photoTitleCache=new Array();var curImageIndex=new Array();var photoShareCustomer=new Array();var customerPicId=new Array();var photoStudioPanel=0;var photoRowIndex=0;var photoColumnIndex=0;var photoTitleTotal=0;var photoTitleMax=1;var photoGenreIndex=0;var photoGenreTotal=0;var curPhotoAssestIndex=0;var photoCursorIndex=0;var photoGenreCursor=0;var startPhotoIndex=0;var sharedPhotoIndex=0;var photoShowStatus=false;function resetAllPhotoIndex(){currentPhotoStudioGenre=0;prevPhotoStudioGenre=0;photoXpandIndex=0;curPhotoIndex=new Array();photoIdCache=new Array();photoTagCache=new Array();photoTitleCache=new Array();curImageIndex=new Array();photoShareCustomer=new Array();customerPicId=new Array();photoStudioPanel=0;photoRowIndex=0;photoColumnIndex=0;photoTitleTotal=0;photoTitleMax=1;photoGenreIndex=0;photoGenreTotal=0;curPhotoAssestIndex=0;photoCursorIndex=0;photoGenreCursor=0;startPhotoIndex=0;sharedPhotoIndex=0;photoShowStatus=false}function getPhotoInfo(){var A="method=getPhotoInfo&serial="+serial;createAjaxRequest();if(ajaxRequest==null){return }ajaxRequest.onreadystatechange=function(){if(ajaxRequest.readyState==4){if(ajaxRequest.status==200){if(ajaxRequest.responseText=="recall"){getPhotoInfo()}else{var D=ajaxRequest.responseText;if(D.length>0){try{var F=D.split("-*$-");var G=F[0].split("-?#-");if((G[0]).length>0){photoIdCache=G[0].split("-@#-")}photoTagCache=G[1].split("-@#-");photoTitleCache=G[2].split("-@#-");curImageIndex=returnPhotoTagIndex(0);var C=F[1].split("-?#-");photoShareCustomer=C[1].split("-@#-");var H=C[0].split("-$#-");for(var E=0;E<photoShareCustomer.length;E++){customerPicId[E]=H[E].split("-@#-")}updatePhotoStudioPanel()}catch(B){}}}}else{if(ajaxRequest.status==500){failureInfo()}}}};ajaxRequest.open("POST","/TvHandler",true);ajaxRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");ajaxRequest.send(A);return false}function returnPhotoTagIndex(A){var C=new Array();var D=-1;for(var B=0;B<photoIdCache.length;B++){if(photoTagCache[B]==A){++D;C[D]=B}}return C}function launchPhotoStudioPanel(){getPhotoInfo()}function resetPhotoTitleIndex(){photoRowIndex=0;photoColumnIndex=0;photoTitleTotal=0;photoTitleMax=1;startPhotoIndex=0;photoXpandIndex=0;sharedPhotoIndex=0;photoCursorIndex=0}function resetPhotoGenreIndex(){photoStudioPanel=0;photoGenreIndex=0;photoGenreTotal=0;curPhotoAssestIndex=0;currentPhotoStudioGenre=0;prevPhotoStudioGenre=0;photoXpandIndex=0}function selPhotoGenre(A){photoStudioPanel=0;document.getElementById("photoGenreId"+currentPhotoStudioGenre).style.backgroundImage="none";prevPhotoStudioGenre=currentPhotoStudioGenre;currentPhotoStudioGenre=A;document.getElementById("photoGenreId"+A).style.backgroundImage='url("/view/tv/images/adultSelector.png")';document.getElementById("photoGenreId"+A).style.backgroundRepeat="no-repeat";curImageIndex=new Array();if(currentPhotoStudioGenre==3){redesignPhotoPanel()}else{curImageIndex=returnPhotoTagIndex(currentPhotoStudioGenre);updatePhotoStudioTitlePanel();document.getElementById("picHolderName").innerHTML="";document.getElementById("picCountPanel").innerHTML=""}}function updatePhotoStudioPanel(){resetPhotoGenreIndex();lockedAdultPanelOpen=true;var A="";for(i=0;i<photoStudioGenre.length;++i){A+='<tr><td id="photoGenreId'+i+'" '+(statusInfo==1?' onmouseover="selPhotoGenre('+i+');" ':"")+' style="width:150px;height:35px;text-align:left;font-size:15px;vertical-align:middle;white-space:nowrap;">&nbsp;&nbsp;&nbsp;&nbsp;'+photoStudioGenre[i]+"</td></tr>"}document.getElementById("photoStudioGenrePanel").innerHTML='<table width="150px" align="left" border="0" style="margin-top:10px;margin-left:15px;" cellspacing="0" cellpadding="0">'+(A?A:'<tr><td width="100%" height="35" valign="middle" nowrap>&nbsp;&nbsp;&nbsp;No genre available</td></tr>')+"</table>";updatePhotoStudioSelector();updatePhotoStudioTitlePanel()}function updatePhotoStudioSelector(){if(document.getElementsByTagName){var A=document.getElementById("photoStudioGenrePanel");var B=A.getElementsByTagName("td");B[prevPhotoStudioGenre].style.backgroundImage="none";B[currentPhotoStudioGenre].style.backgroundRepeat="no-repeat";B[currentPhotoStudioGenre].style.backgroundImage='url("/view/tv/images/adultSelector.png")'}document.getElementById("picHolderName").innerHTML="";document.getElementById("picCountPanel").innerHTML=""}function returnPhotoIndex(){var A=new Array();if(curPhotoTitleIndex[photoGenreIndex].length>0){A=(curPhotoTitleIndex[photoGenreIndex])}photoTitleTotal=A.length-1;return A}function updatePhotoStudioTitlePanel(){resetPhotoTitleIndex();document.getElementById("photoStudioTitlePanel").innerHTML="";var B="";var J="";for(var D=0;D<3;D++){curPhotoIndex[D]=new Array(3);for(var C=0;C<3;C++){curPhotoIndex[D][C]=0}}var F=0;var J="<tr>";for(i=0;(curImageIndex.length>=6&&i<6)||(curImageIndex.length<6&&i<curImageIndex.length);++i){++F;var A=curImageIndex[i];var H=parseInt(i/3);var G=parseInt(i%3);curPhotoIndex[H][G]=1;if(i%3==0&&i!=0){J+="</tr><tr>"}J+="<td "+(statusInfo==1?' onmouseover="selPhotoTitle('+H+","+G+", "+i+');" onclick="openPhotoTitle();" ':"")+'  id="photoPanelId'+H+""+G+'" width="120px" height="120px" align="center" valign="middle" nowrap >';J+='<img id="photoTitle'+H+""+G+'" style="width:120px;height:120px;border:1px solid gray;cursor:pointer;" alt="'+photoTitleCache[A]+'" src="/ImageHandler?value='+photoIdCache[A]+'&icon=-1&imageType=7" />';J+="</td>"}if(F>0){for(var E=0;E<(6-F);++E){var H=parseInt((E+F)/3);var G=parseInt((E+F)%3);if((F+E)%3==0){J+="</tr><tr>"}J+="<td "+(statusInfo==1?' onmouseover="selPhotoTitle('+H+","+G+", "+E+');" onclick="openPhotoTitle();" ':"")+'  id="photoPanelId'+H+""+G+'" width="120px" height="120px" align="center" valign="middle" nowrap >';J+="&nbsp;";J+="</td>"}}J+="</tr>";try{document.getElementById("photoStudioTitlePanel").innerHTML='<table width="400px" height="300px" align="center" valign="middle" border="0" cellspacing="0" cellpadding="0">'+(F==0?"<td height='100%' width='100%' align='center' valign='middle'>No photo available</td>":J)+"</table>"}catch(I){}photoTitleTotal=curImageIndex.length-1}function redesignPhotoPanel(){resetPhotoTitleIndex();for(var C=0;C<3;C++){curPhotoIndex[C]=new Array(3);for(var B=0;B<3;B++){curPhotoIndex[C][B]=0}}document.getElementById("photoStudioTitlePanel").innerHTML="";var E="";var A=0;for(var F=0;F<2;F++){E+="<tr>";for(var D=0;D<3;D++){E+="<td "+(statusInfo==1?' onmouseover="selPhotoTitle('+F+","+D+", "+A+');" onclick="openPhotoTitle();" ':"")+'  id="photoPanelId'+F+""+D+'" width="120px" height="120px" align="center" valign="middle" nowrap >';E+="&nbsp;";E+="</td>";++A}E+="</tr>"}document.getElementById("photoStudioTitlePanel").innerHTML='<table width="400px" height="300px" align="center" valign="middle" border="0" cellspacing="0" cellpadding="0">'+E+"</table>";var G=0;for(var F=0;(photoShareCustomer.length>=6&&F<6)||(photoShareCustomer.length<6&&F<photoShareCustomer.length);++F){var I=parseInt(F/3);var H=parseInt(F%3);curPhotoIndex[I][H]=1;var J='<table id="photoTitle'+I+""+H+'" style="background:darkslategray;border:1px solid gray;cursor:pointer;"><tr>';var A=0;for(var D=0;(customerPicId[F].length>=4&&D<4)||(customerPicId[F].length<4&&D<customerPicId[F].length);++D){if(D%2==0&&D!=0){J+="</tr><tr>"}J+='<td width="50px" height="50px" align="center" valign="middle" nowrap >';J+='<img style="width:50px;height:50px;border:1px solid transparent;background:darkolivegreen;" alt="" src="/ImageHandler?value='+customerPicId[F][D]+'&icon=-1&imageType=7" />';J+="</td>";++A}if(A>0){for(var D=0;D<(4-A);++D){if((A+D)%2==0){J+="</tr><tr>"}J+='<td width="50px" height="50px" align="center" valign="middle" nowrap >';J+="&nbsp;";J+="</td>"}}J+="</tr></table>";document.getElementById("photoPanelId"+I+""+H).innerHTML=J;++G}photoTitleTotal=photoShareCustomer.length-1;updatePhotoDesc(0)}function scrollPhotoPanel(C,E){var D=0;document.getElementById("photoStudioTitlePanel").innerHTML="";var K="<tr>";for(var G=C;G<=E;++G){var J=parseInt(G/3);var H=parseInt(G%3);if(G%3==0&&G!=0&&D!=0){K+="</tr><tr>"}curPhotoIndex[parseInt(D/3)][parseInt(D%3)]=1;var I=3*J+H;var A=curImageIndex[I];var B=0;K+="<td "+(statusInfo==1?' onmouseover="selPhotoTitle('+J+","+H+", "+D+');" onclick="openPhotoTitle();" ':"")+'  id="photoPanelId'+J+""+H+'" width="120px" height="120px" align="center" valign="middle" nowrap >';K+='<table id="photoTitle'+J+""+H+'" style="background:darkslategray;border:1px solid gray;cursor:pointer;"><tr>';K+="<tr>";for(var F=0;(customerPicId[G].length>=4&&F<4)||(customerPicId[G].length<4&&F<customerPicId[G].length);++F){if(F%2==0&&F!=0){K+="</tr><tr>"}K+='<td width="50px" height="50px" align="center" valign="middle" nowrap >';K+='<img style="width:50px;height:50px;border:1px solid transparent;background:darkolivegreen;" alt="" src="/ImageHandler?value='+customerPicId[G][F]+'&icon=-1&imageType=7" />';K+="</td>";++B}if(B>0){for(var F=0;F<(4-B);++F){if((B+F)%2==0){K+="</tr><tr>"}K+='<td width="50px" height="50px" align="center" valign="middle" nowrap >';K+="&nbsp;";K+="</td>"}}K+="</tr></table>";K+="</td>";D++}if(D>0){for(var F=0;F<(6-count);++F){var J=parseInt((F+count)/3);var H=parseInt((F+count)%3);if((count+F)%3==0){K+="</tr><tr>"}K+='<td id="photoPanelId'+J+""+H+'" width="120px" height="120px" align="center" valign="middle" nowrap >';K+="&nbsp;";K+="</td>"}}K+="</tr>";document.getElementById("photoStudioTitlePanel").innerHTML='<table width="400px" height="300px" align="center" valign="middle" border="0" cellspacing="0" cellpadding="0">'+K+"</table>";selPhotoTitlePanel(photoRowIndex,photoColumnIndex)}function updatePhotoDesc(A){document.getElementById("picHolderName").innerHTML=photoShareCustomer[A];document.getElementById("picCountPanel").innerHTML=" "+customerPicId[A].length+" photos "+(customerPicId[A].length<2?"is":"are")+" shared by this customer."}function scrollPhotoTitle(B,F){for(var E=0;E<3;E++){curPhotoIndex[E]=new Array(3);for(var C=0;C<3;C++){curPhotoIndex[E][C]=0}}var D=0;document.getElementById("photoStudioTitlePanel").innerHTML="";if(currentPhotoStudioGenre==3){scrollPhotoPanel(B,F);return }var K="<tr>";for(i=B;i<=F;++i){var J=parseInt(i/3);var I=parseInt(i%3);if(i%3==0&&i!=0&&D!=0){K+="</tr><tr>"}curPhotoIndex[parseInt(D/3)][parseInt(D%3)]=1;var H=3*J+I;var A=curImageIndex[H];K+="<td "+(statusInfo==1?' onmouseover="selPhotoTitle('+J+","+I+", "+D+');" onclick="openPhotoTitle();" ':"")+' id="photoPanelId'+J+""+I+'" width="120px" height="120px" align="center" valign="middle" nowrap >';K+='<img id="photoTitle'+J+""+I+'" style="width:120px;height:120px;border:1px solid transparent;cursor:pointer;" alt="'+photoTitleCache[A]+'" src="/ImageHandler?value='+photoIdCache[A]+'&icon=-1&imageType=7" />';K+="</td>";D++}if(D>0){for(var G=0;G<(6-count);++G){var J=parseInt((G+count)/3);var I=parseInt((G+count)%3);if((count+G)%3==0){K+="</tr><tr>"}K+='<td id="photoPanelId'+J+""+I+'" width="120px" height="120px" align="center" valign="middle" nowrap >';K+="&nbsp;";K+="</td>"}}K+="</tr>";document.getElementById("photoStudioTitlePanel").innerHTML='<table width="400px" height="300px" align="center" valign="middle" border="0" cellspacing="0" cellpadding="0">'+K+"</table>";selPhotoTitlePanel(photoRowIndex,photoColumnIndex)}function selPhotoTitlePanel(D,C){photoStudioPanel=1;try{if(currentPhotoStudioGenre==3){var B=3*D+C;updatePhotoDesc(B)}else{document.getElementById("picHolderName").innerHTML="";document.getElementById("picCountPanel").innerHTML=""}}catch(A){}try{document.getElementById("photoTitle"+D+""+C).style.border="1px solid skyblue"}catch(A){photoRowIndex-=1;photoCursorIndex-=1;selPhotoTitlePanel(photoRowIndex,photoColumnIndex)}}function unSelPhotoTitlePanel(C,B){try{document.getElementById("photoTitle"+C+""+B).style.border="1px solid gray"}catch(A){}}function selPhotoTitle(D,B,C){try{if(curPhotoIndex[D][B]==0){return }unSelPhotoTitlePanel(photoRowIndex,photoColumnIndex);photoRowIndex=D;photoColumnIndex=B;photoCursorIndex=parseInt(C/3);selPhotoTitlePanel(D,B)}catch(A){}}function openPhotoTitle(){try{if(curPhotoIndex[rowIndex][columnIndex]==0){return }photoStudioKeyHandler(rcOK)}catch(A){}}function photoStudioKeyHandler(F){switch(F){case rcUP:if(photoShowStatus){return }if(photoStudioPanel==1){if(photoRowIndex==0){return }unSelPhotoTitlePanel(photoRowIndex,photoColumnIndex);photoRowIndex--;if(photoCursorIndex!=0){photoCursorIndex--;selPhotoTitlePanel(photoRowIndex,photoColumnIndex)}else{photoCursorIndex=0;var H=0;H=(startPhotoIndex<3?0:startPhotoIndex-3);startPhotoIndex=H;var B=((photoTitleTotal-H)>5?(H+5):photoTitleTotal);scrollPhotoTitle(H,B)}return }if(currentPhotoStudioGenre>0&&currentPhotoStudioGenre<photoStudioGenre.length){prevPhotoStudioGenre=currentPhotoStudioGenre;currentPhotoStudioGenre--;updatePhotoStudioSelector();curImageIndex=new Array();if(currentPhotoStudioGenre!=3){document.getElementById("picHolderName").innerHTML="";document.getElementById("picCountPanel").innerHTML=""}curImageIndex=returnPhotoTagIndex(currentPhotoStudioGenre);updatePhotoStudioTitlePanel()}else{return }break;case rcDOWN:if(photoShowStatus){return }if(photoStudioPanel==1){var G=photoCursorIndex+1;var D=photoColumnIndex;if(G<2){if(curPhotoIndex[G][D]==0){return }}var A=(photoTitleTotal/3);if(photoRowIndex==parseInt(A)){return }unSelPhotoTitlePanel(photoRowIndex,photoColumnIndex);photoRowIndex++;if(photoCursorIndex<photoTitleMax){photoCursorIndex++;selPhotoTitlePanel(photoRowIndex,photoColumnIndex)}else{var H=0;if(photoRowIndex<2){H=photoRowIndex;startPhotoIndex=H}else{H=startPhotoIndex+3;startPhotoIndex=H}photoCursorIndex=1;var B=((photoTitleTotal-H)>5?(H+5):photoTitleTotal);scrollPhotoTitle(H,B)}return }if(currentPhotoStudioGenre>=0&&currentPhotoStudioGenre<(photoStudioGenre.length-1)){prevPhotoStudioGenre=currentPhotoStudioGenre;currentPhotoStudioGenre++;updatePhotoStudioSelector();if(currentPhotoStudioGenre==3){curImageIndex=new Array();redesignPhotoPanel()}else{curImageIndex=new Array();curImageIndex=returnPhotoTagIndex(currentPhotoStudioGenre);updatePhotoStudioTitlePanel();document.getElementById("picHolderName").innerHTML="";document.getElementById("picCountPanel").innerHTML=""}}else{return }break;case rcLEFT:if(photoShowStatus){if(currentPhotoStudioGenre==3){--sharedPhotoIndex;var C=photoRowIndex*3+photoColumnIndex;sharedPhotoIndex=(sharedPhotoIndex<0?customerPicId[C].length-1:sharedPhotoIndex);showExpandImage(sharedPhotoIndex)}else{--photoXpandIndex;photoXpandIndex=(photoXpandIndex<=0?curImageIndex.length:photoXpandIndex);showExpandImage(photoXpandIndex)}return }if(photoColumnIndex==0){photoStudioPanel=0;unSelPhotoTitlePanel(photoRowIndex,photoColumnIndex);return }if(photoStudioPanel==0){return }if(photoColumnIndex>=0){unSelPhotoTitlePanel(photoRowIndex,photoColumnIndex);--photoColumnIndex;selPhotoTitlePanel(photoRowIndex,photoColumnIndex);return }break;case rcRIGHT:if(photoShowStatus){if(currentPhotoStudioGenre==3){++sharedPhotoIndex;var C=photoRowIndex*3+photoColumnIndex;sharedPhotoIndex=(sharedPhotoIndex>=customerPicId[C].length?0:sharedPhotoIndex);showExpandImage(sharedPhotoIndex)}else{++photoXpandIndex;photoXpandIndex=(photoXpandIndex>curImageIndex.length?1:photoXpandIndex);showExpandImage(photoXpandIndex)}return }if(photoStudioPanel==0){if(currentPhotoStudioGenre!=3){if(curImageIndex.length==0){return }}selPhotoTitlePanel(photoRowIndex,photoColumnIndex);photoStudioPanel=1;return }var C=photoRowIndex*3+photoColumnIndex;if(C==photoTitleTotal||photoColumnIndex==2){return }if(photoColumnIndex>=0){unSelPhotoTitlePanel(photoRowIndex,photoColumnIndex);++photoColumnIndex;selPhotoTitlePanel(photoRowIndex,photoColumnIndex);return }break;case rcMENU:if(photoShowStatus){photoShowStatus=false;if(document.getElementById("movePhotoPanel")!=null){document.getElementById("movePhotoPanel").style.visibility="hidden"}document.getElementById("openChartId").innerHTML=""}else{resetAllPhotoIndex();photoStudioActive=false;showGuidePanel()}break;case rcOK:if(photoStudioPanel==0){return }if(photoShowStatus){}else{photoShowStatus=true;var E=3*photoRowIndex+photoColumnIndex+1;photoXpandIndex=E;if(currentPhotoStudioGenre==3){sharedPhotoIndex=0;showExpandImage(0)}else{showExpandImage(photoXpandIndex)}}break}}function showExpandImage(B){if(document.getElementById("movePhotoPanel")!=null){document.getElementById("movePhotoPanel").style.visibility="visible"}if(currentPhotoStudioGenre==3){var C=3*photoRowIndex+photoColumnIndex;var A='<img style="width:624px;height:422px;" alt="" src="/ImageHandler?value='+customerPicId[C][B]+'&icon=-1&imageType=7" />';document.getElementById("openChartId").innerHTML=A}else{B=(B==0?B:B-1);var C=curImageIndex[B];var A='<img style="width:624px;height:422px;" alt="'+photoTitleCache[C]+'" src="/ImageHandler?value='+photoIdCache[C]+'&icon=-1&imageType=7" />';document.getElementById("openChartId").innerHTML=A}}function showHomePhotoStudio(B){var A="";A=(B==1?"#fcf3b8":"none");document.getElementById("photoStudioHome").style.background=A}function escapePhotoStudio(){keyActionHandler(rcMENU)}function disabledPhotoStudio(){showStatusPanel();document.getElementById("statusMessagePanel").innerHTML="";document.getElementById("statusMessagePanel").innerHTML=records.key374}function changePhoto(A){(A==0?photoStudioKeyHandler(rcLEFT):photoStudioKeyHandler(rcRIGHT))}function selPhotoArrs(A,C){var B=C==0?"Cyan":"white";document.getElementById("photoArr"+A).style.background=B}function highLightPhotoPanel(B){var A="#fcf3b8";document.getElementById("photoPanel"+B).style.background=A}function hidePhotoPanel(B){var A="none";document.getElementById("photoPanel"+B).style.background=A}function photoPanelHome(B){var A="";A=(B==1?"#fcf3b8":"none");document.getElementById("photoPanelHomeBtn").style.background=A}function escapePhotoPanel(){photoStudioKeyHandler(rcMENU)}function movePhotoPanel(A){switch(A){case 1:photoStudioKeyHandler(rcUP);break;case 2:photoStudioKeyHandler(rcDOWN);break}}