﻿/*
function SignOut(){
	if (confirm("Vilt þú örugglega afskrá þessa tölvu?")==true)
	{location.href='/vefbaekur/g.aspx?dbid=22';	
}}*/

$(document).ready(function(){   
   /*$("#st").change(function(){__doPostBack('btn','');});   
   $("#hideBase").click(    
        function () {            
            $("#theBase").hide();
            createCookie('hideBase', 1, 30);            
            document.forms['form1'].sw.select(); 
            createCookie('headInfoCount', 0, 30);            
    }
   ) */
    
   /*$("#showBase").click(function (){        
        if(readCookie('hideBase')==1) {                        
            $("#theBase").show();createCookie('hideBase', 0, 30);
        }
        else {                     
            $("#theBase").hide();createCookie('hideBase', 1, 30);
        }            
        document.forms['form1'].sw.select();
   });   */
   /*$("#headInfo1").click(function (){$("#theBase").show();createCookie('hideBase', 0, 30);document.forms['form1'].sw.select();$("#headInfo").hide();});*/
      
   /*if (readCookie('hideBase')==1){
        $("#theBase").hide();}
   else{
        $("#theBase").show();
   };*/
   
   /*var headInfoCount = readCookie('headInfoCount');      
   if (headInfoCount>=1){
        //alert(headInfoCount);        
        if (readCookie('hideBase')==1){
            $("#headInfo1").show();
            createCookie('headInfoCount', headInfoCount-1, 30);        
        }else {
            $("#headInfo2").show();
            createCookie('headInfoCount', headInfoCount-1, 30);        
        }
   }else{
        $("#headInfo1").hide();
        $("#headInfo2").hide();
        createCookie('headInfoCount', 0, 30);
   };          */
   if (readCookie('dbchecked')==null){checkEn();}
   var thedb = readCookie('thedb'); 
   //alert(thedb);
   if (thedb==null){
        createCookie('thedb', 'en', 30);
   }
   bold(0);    
   function bold(doinfo){
        var thedb = readCookie('thedb'); 
        $('.btns').css('font-weight', 'normal');
        $('.info').hide();
        $('#logo').show()
        if (thedb){
            $('.db'+thedb).css('font-weight', 'bold');
            if (doinfo){$('.i'+thedb).show();};
        }        
        document.getElementById("sw").focus();        
   }           

   function doAll(){createCookie('headInfoCount', 1, 30);createCookie('thedb', 'all', 30);checkall();bold(1);};                   
   function doIs(){ createCookie('headInfoCount', 1, 30);createCookie('thedb', 'is', 30);checkIs();bold(1);}
   function doEn(){ createCookie('headInfoCount', 1, 30);createCookie('thedb', 'en', 30);checkEn();bold(1);}
   function doDa(){ createCookie('headInfoCount', 1, 30);createCookie('thedb', 'da', 30);checkDa();bold(1);}
   function doDe(){ createCookie('headInfoCount', 1, 30);createCookie('thedb', 'de', 30);checkDe();bold(1);}
   function doSp(){ createCookie('headInfoCount', 1, 30);createCookie('thedb', 'sp', 30);checkSp();bold(1);}
   function doFr(){ createCookie('headInfoCount', 1, 30);createCookie('thedb', 'fr', 30);checkFr();bold(1);}
   function doIt(){ createCookie('headInfoCount', 1, 30);createCookie('thedb', 'it', 30);checkIt();bold(1);}
   function doMa(){ createCookie('headInfoCount', 1, 30);createCookie('thedb', 'ma', 30);checkMa();bold(1);}
   //$(".dball").click(function(){createCookie('hideBase', 0, 30);checkall();__doPostBack('btn','');})
   $(".dball").click(function(){doAll();});
   $(".dbis").click( function(){doIs();});
   $(".dben").click( function(){doEn();});   
   $(".dbda").click( function(){doDa();});
   $(".dbde").click( function(){doDe();});
   $(".dbsp").click( function(){doSp();});
   $(".dbfr").click( function(){doFr();});
   $(".dbit").click( function(){doIt();});
   $(".dbma").click( function(){doMa();});
   
   function doTheL(className){$('.info').hide();$('#logo').show();$(className).show();document.getElementById("sw").focus();}   
   $(".lkaupa").click(    function(){doTheL('.ikaupa')});
   $(".lad").click(    function(){doTheL('.iad')});
   $(".lupp").click(   function(){doTheL('.iupp')});
   $(".lhjalp").click( function(){doTheL('.ihjalp')});
   $(".lblogg").click( function(){doTheL('.iblogg')});
   $(".lannad").click( function(){doTheL('.iannad')});
   
   function doTheBL(className){$('#logo').hide();$('.BLinfo').hide();$(className).show();document.getElementById("sw").focus();}
   function doTheLogo(){$('.BLinfo').hide();$('#logo').show();document.getElementById("sw").focus();}
   //setTimeout(window.location='#bottom', 20000);           
   $(".bl_is").hover(    function(){doTheBL('.l_is');},   function(){});
   $(".bl_alfrord").hover(function(){doTheBL('.l_alfrord');}, function(){});
   $(".bl_stor").hover(  function(){doTheBL('.l_stor');}, function(){});
   $(".bl_staf").hover(  function(){doTheBL('.l_staf');}, function(){});
   $(".bl_bin").hover(   function(){doTheBL('.l_bin');}, function(){});
   $(".bl_kort").hover(  function(){doTheLogo();}, function(){});
   $(".bl_sam").hover(   function(){doTheBL('.l_sam');}, function(){});
   $(".bl_dais").hover(  function(){doTheBL('.l_dais');}, function(){});
   $(".bl_isda").hover(  function(){doTheBL('.l_isda');}, function(){});
   $(".bl_fris").hover(  function(){doTheBL('.l_fris');}, function(){});
   $(".bl_nofn").hover(  function(){doTheBL('.l_nofn');}, function(){});
   $(".bl_isen").hover(  function(){doTheBL('.l_isen');}, function(){});
   $(".bl_isen_s").hover(  function(){doTheLogo();}, function(){});
   $(".bl_enisal").hover(  function(){doTheBL('.l_enisal');}, function(){});
   $(".bl_enisjpv").hover( function(){doTheBL('.l_enisjpv');}, function(){});   
   $(".bl_enlyk").hover(   function(){doTheBL('.l_enlyk');}, function(){});
   $(".bl_atlas").hover(   function(){doTheBL('.l_atlas');}, function(){});
   $(".bl_mast").hover(    function(){doTheBL('.l_mast');}, function(){});   
   $(".bl_spis").hover(    function(){doTheBL('.l_spis');}, function(){});
   $(".bl_deis").hover(    function(){doTheBL('.l_deis');}, function(){});
   $(".bl_enen").hover(    function(){doTheLogo();}, function(){});
   $(".bl_nanna").hover(   function(){doTheLogo();}, function(){});
   $(".bl_daislog").hover( function(){doTheLogo();}, function(){});
   $(".bl_isit").hover(    function(){doTheBL('.l_isit');}, function(){});
   $(".info").hover(function(){}, function(){doTheLogo();});
    
    $(".help8").hover( 
        function () {      
            var p = $(this).position()        
            //alert("#"+$(this).attr("id")+"box");
            $("#"+$(this).attr("id")+"box").css('left', p.left + $(this).width() + 20);
            $("#"+$(this).attr("id")+"box").css('top', p.top);
            $("#"+$(this).attr("id")+"box").fadeIn(5);        
        }, 
        function () {
            $("#"+$(this).attr("id")+"box").fadeOut(1000);
        }
    ); 
    
    
    function fixsw(swlength){ //fyrir 11 22 33 virknina
        var str = "" + document.getElementById('sw').value;
        str=str.substring(0,swlength);
        document.getElementById('sw').value=str;
        document.getElementById('sw').focus();
    }               
    
    var start = new Date().getTime();var laste = 'x'; //fyrir 11 22 33 virknina
    $(document).keydown(function(e){            
        document.getElementById('sw').focus();
        var elapsed = Number(new Date().getTime() - start);        
        var r=true;
        var swlength=document.getElementById('sw').value.length-1;
        //alert(swlength);
        if (elapsed<500){                                    
            if (e.which==laste&&e.which==49){fixsw(swlength);doAll();r=false;}
            if (e.which==laste&&e.which==50){fixsw(swlength);doIs();r=false;}
            if (e.which==laste&&e.which==51){fixsw(swlength);doEn();r=false;}
            if (e.which==laste&&e.which==52){fixsw(swlength);doDa();r=false;}
            if (e.which==laste&&e.which==53){fixsw(swlength);doDe();r=false;}
            if (e.which==laste&&e.which==54){fixsw(swlength);doSp();r=false;}
            if (e.which==laste&&e.which==55){fixsw(swlength);doFr();r=false;}
            if (e.which==laste&&e.which==56){fixsw(swlength);doIt();r=false;}
            if (e.which==laste&&e.which==57){fixsw(swlength);doMa();r=false;}            
        };
        start = new Date().getTime();
        laste = e.which;
        if (r){return true;}
        else {return false;}        
    });      
 });
