var fish_position = 0 ;
var width=0;
var fish_opacity=0;
function windowHeight() {
    var myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
      //Non-IE
      myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
      //IE 4 compatible
      myHeight = document.body.clientHeight;
    }
  
  return myHeight;

}
            
            
function windowwidth() {
    var myWidth = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
      //Non-IE
      myWidth = window.innerWidth;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
      //IE 4 compatible
      myWidth = document.body.clientWidth;
    }
  
  return myWidth;


}

function setmaincenter(){
    container = document.getElementById('main_div');
    container.style.margin='0px '+(windowwidth()-1000)/2+'px';
}

function setcenter(w_name,w_with,w_height){
            container = document.getElementById(w_name);
    container.style.margin=(windowHeight()-w_height)/2+'px '+(windowwidth()-w_with)/2+'px';
    
}

function browsertest(){
    <!--
    if (navigator.appName == "Microsoft Internet Explorer") {
           window.location = "http://www.mozilla.com/en-US/firefox/upgrade.html?from=getfirefox" ;
    } 
    // -->
}

function displayunicode(e){

    var unicode=e.keyCode? e.keyCode : e.charCode
    if(unicode==76){
        container = document.getElementById('run');
        if(container.style.display=="none"){
        closerun();
        }
    }else if(unicode==13){
        
        runclicked();
        
    }
}

function closerun(){
    container = document.getElementById('run');
    if(container.style.display=="none"){
        container.style.display="";
        document.getElementById('run_textbox').focus();
    }
    else{
        container.style.display="none"
    }
}


function runclicked(){
    
    container = document.getElementById('run_textbox').value;
    document.getElementById('run_textbox').value="";
    switch (container) {
    case "free the fish": fish();closerun(); break;
    case "music": closeopen('music');closerun(); break;
    case "video": closeopen('video');closerun(); break;
    case "terminal": window.location = "jsuix/index.html";closerun(); break;
    case "zanjanlug": closeopen('zanjanlug');zanjanlug();closerun(); break;
    default: result = 'unknown';
    }

}

function fish(){
    container = document.getElementById('fish');
    
    if(fish_position==0){
        width=windowwidth();
    }
    
    if(fish_position< width-110){
        fish_position=fish_position+2;
       container.style.margin='310px '+(fish_position)+'px';
       if(fish_opacity<1){
            fish_opacity+=0.01;
            container.style.opacity= fish_opacity;
       }
       if(fish_position>(width-310)){
                fish_opacity=fish_opacity-0.02;
               container.style.opacity= fish_opacity;       
       }
        setTimeout("fish()",40);
        
    }else{
        container.style.margin='310px '+'0px';
        fish_position = 0 ;
        width=0;
        fish_opacity=0;
    }


   
}





function closeopen(w_name){
    container = document.getElementById(w_name);
    if(container.style.display=="none"){
        container.style.display="";
    }
    else{
        container.style.display="none"
    }
}

function zanjanlug(){
    container = document.getElementById('zanjanlug_img');
    
    if(container.src!="images/zanjanlug.jpg")
        container.src="images/zanjanlug.jpg";
}