/* 2004 - Demetrey Iljin */

var counter39=0;

/* Manages the Navigation (Cursor, Enter, Escape) */
function window.parent.cursorManager(key){
  if (window.parent.contextMenuOpen==true){window.parent.contextMenuCursor(key);return;}
  if (window.parent.quickJumpOpen==true){window.parent.quickJumpCursor(key);return;}
  if (window.parent.mediaWindowOpen==true){window.parent.mediaWindowCursor(key);return;}
  else {window.parent.portalCursor(key);}
					 }

function window.parent.contextMenuCursor(key){
   if (key==40){
    counterContextMenu++
    if (counterContextMenu>window.parent.contextMenuLinks.length-1){counterContextMenu=0;}
    window.parent.contextMenuLinks[counterContextMenu].focus();
               }
   if (key==38){
    counterContextMenu--
    if (counterContextMenu<0){counterContextMenu=window.parent.contextMenuLinks.length-1;}
    window.parent.contextMenuLinks[counterContextMenu].focus();
  	       }
   if (key==36){  
    counterContextMenu=0;
    window.parent.contextMenuLinks[counterContextMenu].focus(); 
	       }
   if (key==35){
    counterContextMenu=window.parent.contextMenuLinks.length-1;
    window.parent.contextMenuLinks[counterContextMenu].focus(); 
	       }
   if ((key==37)||(key==39)){window.parent.menuLaunch();}
   if (key==48){if (window.parent.contextMenuLinks[9]!=null){window.parent.location.href=window.parent.contextMenuLinks[9].href;}}
   if (key==49){if (window.parent.contextMenuLinks[0]!=null){window.parent.location.href=window.parent.contextMenuLinks[0].href;}}
   if (key==50){if (window.parent.contextMenuLinks[1]!=null){window.parent.location.href=window.parent.contextMenuLinks[1].href;}}
   if (key==51){if (window.parent.contextMenuLinks[2]!=null){window.parent.location.href=window.parent.contextMenuLinks[2].href;}}
   if (key==52){if (window.parent.contextMenuLinks[3]!=null){window.parent.location.href=window.parent.contextMenuLinks[3].href;}}
   if (key==53){if (window.parent.contextMenuLinks[4]!=null){window.parent.location.href=window.parent.contextMenuLinks[4].href;}}
   if (key==54){if (window.parent.contextMenuLinks[5]!=null){window.parent.location.href=window.parent.contextMenuLinks[5].href;}}
   if (key==55){if (window.parent.contextMenuLinks[6]!=null){window.parent.location.href=window.parent.contextMenuLinks[6].href;}}
   if (key==56){if (window.parent.contextMenuLinks[7]!=null){window.parent.location.href=window.parent.contextMenuLinks[7].href;}}
   if (key==57){if (window.parent.contextMenuLinks[8]!=null){window.parent.location.href=window.parent.contextMenuLinks[8].href;}}
   if (key==79){window.parent.menuLaunch();}
   if ((event.shiftKey)&&(event.ctrlKey)&&(key==13)){window.parent.location.href=window.parent.contextMenuLinks[counterContextMenu].href;}
					     }

function window.parent.quickJumpCursor(key){
  window.parent.mouseOver=true;
  window.parent.killHighlight();
   if (key==40){
    counterQuickJump++
    if (counterQuickJump>window.parent.tdJumpCollection.length-1){counterQuickJump=0;}
    window.parent.tdJumpCollection[counterQuickJump].focus();
               }
   if (key==38){
    counterQuickJump--
    if (counterQuickJump<0){counterQuickJump=window.parent.tdJumpCollection.length-1}
    window.parent.tdJumpCollection[counterQuickJump].focus();
	       }
   if ((key==37)||(key==39)){window.parent.jumpShowLayer();}
   if (key==36){counterQuickJump=0;window.parent.tdJumpCollection[counterQuickJump].focus();}
   if (key==35){counterQuickJump=window.parent.tdJumpCollection.length-1;window.parent.tdJumpCollection[counterQuickJump].focus();}
   if (key==34){
    counterQuickJump+=10;
    if (counterQuickJump>window.parent.tdJumpCollection.length-1){counterQuickJump=0;}
    window.parent.tdJumpCollection[counterQuickJump].focus();
	       }
   if (key==33){
    counterQuickJump-=10;
    if (counterQuickJump<0){counterQuickJump=window.parent.tdJumpCollection.length-1}
    window.parent.tdJumpCollection[counterQuickJump].focus();
	      }
   if ((event.shiftKey)&&(event.ctrlKey)&&(key==13)){window.parent.location.href=window.parent.linkJumpCollection[counterQuickJump].href;}
   if (key==79){window.parent.jumpShowLayer();}
					   }

function window.parent.portalCursor(key){
  window.parent.mouseOver=true;
  if (window.parent.balkenClean!=true){window.parent.cursorCleaner();}
  if (window.parent.trueLinksCollection==null){return;}
  if (window.parent.trueLinksCollection==""){return;}
  if (key==40){
   counter39++;
   if (counter39>trueLinksCollection.length-1){counter39=0;}
   if (trueLinksCollection[counter39].name=='green'){greenLinksCollection[counter39].focus();}
   if (trueLinksCollection[counter39].name!='green'){
   if (trueLinksCollection[counter39].currentStyle.display=='none'){while(trueLinksCollection[counter39].currentStyle.display=='none'){counter39++;}}
    trueLinksCollection[counter39].focus();
						    }
              }
  if (key==38){
   counter39--;
   if (counter39<0){counter39=trueLinksCollection.length-1;}
   if (trueLinksCollection[counter39].name=='green'){greenLinksCollection[counter39].focus();}
   if (trueLinksCollection[counter39].name!='green'){
   if (trueLinksCollection[counter39].currentStyle.display=='none'){while(trueLinksCollection[counter39].currentStyle.display=='none'){counter39--;}}
    trueLinksCollection[counter39].focus();
						    }
              }
  if ((window.parent.greenCursorExist!=null)&&(greenLinksCollection.length<=10)){
   if (key==49){if(greenLinksCollection[0]==null){return;}greenLinksCollection[0].focus();counter39=0;}
   if (key==50){if(greenLinksCollection[1]==null){return;}greenLinksCollection[1].focus();counter39=1;}
   if (key==51){if(greenLinksCollection[2]==null){return;}greenLinksCollection[2].focus();counter39=2;}
   if (key==52){if(greenLinksCollection[3]==null){return;}greenLinksCollection[3].focus();counter39=3;}
   if (key==53){if(greenLinksCollection[4]==null){return;}greenLinksCollection[4].focus();counter39=4;}
   if (key==54){if(greenLinksCollection[5]==null){return;}greenLinksCollection[5].focus();counter39=5;}
   if (key==55){if(greenLinksCollection[6]==null){return;}greenLinksCollection[6].focus();counter39=6;}
   if (key==56){if(greenLinksCollection[7]==null){return;}greenLinksCollection[7].focus();counter39=7;}
   if (key==57){if(greenLinksCollection[8]==null){return;}greenLinksCollection[8].focus();counter39=8;}
   if (key==48){if(greenLinksCollection[9]==null){return;}greenLinksCollection[9].focus();counter39=9;}
					                                     }
  if ((window.parent.greenCursorExist!=null)&&(greenLinksCollection.length>10)){
   if (key==49){if(greenLinksCollection[0]==null){return;}greenLinksCollection[0].focus();counter39=0;}
   if (key==50){if(greenLinksCollection[2]==null){return;}greenLinksCollection[2].focus();counter39=2;}
   if (key==51){if(greenLinksCollection[4]==null){return;}greenLinksCollection[4].focus();counter39=4;}
   if (key==52){if(greenLinksCollection[6]==null){return;}greenLinksCollection[6].focus();counter39=6;}
   if (key==53){if(greenLinksCollection[8]==null){return;}greenLinksCollection[8].focus();counter39=8;}
   if (key==54){if(greenLinksCollection[10]==null){return;}greenLinksCollection[10].focus();counter39=10;}
   if (key==55){if(greenLinksCollection[12]==null){return;}greenLinksCollection[12].focus();counter39=12;}
   if (key==56){if(greenLinksCollection[14]==null){return;}greenLinksCollection[14].focus();counter39=14;}
   if (key==57){if(greenLinksCollection[16]==null){return;}greenLinksCollection[16].focus();counter39=16;}
   if (key==48){if(greenLinksCollection[18]==null){return;}greenLinksCollection[18].focus();counter39=18;}
					                                     }
  if ((event.shiftKey)&&(event.ctrlKey)&&(key==13)){window.parent.location.href=window.parent.trueLinksCollection[counter39].href;}
  if (key==36){
   if (window.parent.greenCursorExist!=null){counter39=0;greenLinksCollection[counter39].focus();}
   if (window.parent.greenCursorExist==null){counter39=0;trueLinksCollection[counter39].focus();}
              }
  if (key==35){
   if (window.parent.greenCursorExist!=null){
    if (greenLinksCollection.length==trueLinksCollection.length){counter39=greenLinksCollection.length-1;greenLinksCollection[counter39].focus();}
    if (greenLinksCollection.length!=trueLinksCollection.length){counter39=trueLinksCollection.length-1;trueLinksCollection[counter39].focus();}    
					  }
   if (window.parent.greenCursorExist==null){
    counter39=trueLinksCollection.length-1;
    trueLinksCollection[counter39].focus();
					  }
              }
  if (key==79){window.parent.menuLaunch('Power');}
				        }

function window.parent.mediaWindowCursor(key){
  window.parent.manageFocus('mediaWindow');
  if (key==79){window.parent.openWindow();return;}
  window.parent.mediaWindowCursor2(key);
					     }

function window.parent.killHighlight(which,status){
  if (document.getElementById("newMenuCartinca")!=null){
   if ((window.parent.mouseOver!=true)&&(status=='over')){which.className="greenTDcursor2_on"}
   if ((window.parent.mouseOver!=true)&&(status=='out')){which.className="greenTDcursor2_off"}
   if ((window.parent.mouseOver==true)&&(status=='out')){which.className="greenTDcursor2_off"}
						       }
  if (document.getElementById("newMenuCartinca")==null){
   if ((window.parent.mouseOver!=true)&&(status=='over')){which.className="greenTDcursor_on"}
   if ((window.parent.mouseOver!=true)&&(status=='out')){which.className="greenTDcursor_off"}
   if ((window.parent.mouseOver==true)&&(status=='out')){which.className="greenTDcursor_off"}
						       }
				                  }

function window.parent.cursorCleaner(){
  if (window.parent.greenCursorExist==null){return;}
  window.parent.balkenClean=true;
  if (document.getElementById("newMenuCartinca")!=null){for (var a=0; a<greenLinksCollection.length; a++){greenLinksCollection[a].className='greenTDcursor2_off'}}
  if (document.getElementById("newMenuCartinca")==null){for (var a=0; a<greenLinksCollection.length; a++){greenLinksCollection[a].className='greenTDcursor_off'}}
				      }

/* Manages the Keys */
function window.parent.functionsManager(key){
  if (key==65){window.history.go(-1);}
  if (key==68){window.history.go(1);}
  if (key==71){window.parent.menuLaunch('G');return;}
  if (key==83){window.parent.menuLaunch('S');return;}
  if (key==72){window.parent.menuLaunch('H');return;}
  if (key==66){window.parent.menuLaunch('B');return;}
  if (key==77){window.parent.menuLaunch('Sound');return;}
  if (key==87){window.parent.location.href="tvoon://epg/WTable";return;}
  if (key==85){window.parent.location.href="tvoon://tv";return;}   //TV-Button
  if (key==90){window.parent.location.href="tvoon://epg/GeneralMenu";return;} //EPG-Button
  if (window.parent.mediaWindowOpen==true){
   window.parent.manageFocus('mediaWindow');
   if (window.parent.which==1){
    if (key==80){window.parent.webtvPlay('play');}
    if (key==70){window.parent.webtvPlay('stop');}
    if (key==69){window.parent.webtvPlay('pause');} 
			      }
			                  }
					    }

function window.parent.divFunctionsManager(key){}
