﻿function onres()
{
var hFrame=document.getElementById("Previous");
 if (hFrame)
 {

 }
 
}
function clickLogin() {
    var button = document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_cmdLogin');
    button.focus();
    button.click();
    return false;
}
function LoginFocus() {
    var txt = document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_txtPassword');
    txt.focus();
    return false;
}

function buttonClickSearch(url) {
    
   // var jt = document.getElementById('ajax1_ctl00_txtJtK').value;
    // var str = document.getElementById('ajax1_ctl00_txtFreeText').value;
    var jt = document.getElementById('ajax1_ctl00_topInput1_txtJtK').value;
    var str = document.getElementById('ajax1_ctl00_topInput1_txtFreeText').value;   
    if (jt=='')
    {
        if (str == '')
            { alert('mangler søke streng, enten Jungelkode eller Fritekst søk!') }
        else {
            parent.frames['innhold'].document.location.href = url + '&str=' + str
        }
    }
    else
    {
      parent.frames['innhold'].document.location.href = url + '&JK=' + jt
    }
    return false
}
function buttonClickSearchTop(url) {

    // var jt = document.getElementById('ajax1_ctl00_txtJtK').value;
    // var str = document.getElementById('ajax1_ctl00_txtFreeText').value;
    var jt = document.getElementById('ajax1_ctl00_topInput1_txtJtK').value;
    if (jt == '') {
         alert('mangler søke streng, enten Jungelkode eller Fritekst søk!') 
    }
    else {
        top.document.location.href = url + '&SeachString=' + jt
    }
    return false
}
function textOn(obj) {
    obj.style.textDecoration='underline'
}
function textOff(obj) {
    obj.style.textDecoration = 'none'
}

function writeWindow(url){
var n=new Date();
var x=window.open(url, 'newWin'+n.getTime(), "width=300,height=100");
    x.document.write('<scri'+'pt>setTimeout("self.close()", 2000 )</scr'+'ipt>Annonsen er lagt til din profil<br>');        
    //x.focus();
    //x.Close
}

function setPreloadShow(id)
    {
        document.getElementById(id).className='PreloaderShow'
        setTimeout('setAutoPreloadHide()',3000) 
    }
function setPreloadHide(id)
    {
        document.getElementById(id).className='Preloader'
    }    
function setAutoPreloadHide()
    {        
        setTimeout('setAutoPreloadHide()',3000) 
        //document.getElementById('Preloader').className='Preloader'
    }        
function setDivHeight(id)
    {
        var _objHeight = document.getElementById(id);        
        var _height = getMenuHeight()-120
        _objHeight.style.height=''+_height+''+'px';
    }
    function setDivHeightG(id) {
        var browser = getBrowser();
        var substract = 190;
        var _objHeight = document.getElementById(id);
        var _height = getMenuHeight()
        if (browser == 'Explorer') {
            _height -= 190
        }
        else {
            _height -=170
        }        
        _objHeight.style.height = '' + _height + '' + 'px';
    }
    function setIframeHeight(id) {        
        var _objHeight = document.getElementById(id);
        var _height = getMenuHeight() - 250
        _objHeight.style.height = '' + _height + '' + 'px';
    }        
function setDivHeightCenter(id)
    {
        var _menuHeight=240
        var _objHeight = document.getElementById(id);        
        var _height = getMenuHeight()-_menuHeight
        _objHeight.style.height=''+_height+''+'px';                
    }    
function setDivHeightEqual(id,id2)
    {        
        var _objHeight = document.getElementById(id);        
        var _height = document.getElementById(id2).style.height;          
        _objHeight.style.height=_height;                
    }    
function scrollDivDown(id){ 
    var step=30 ;     
    document.getElementById(id).scrollTop+=step 
} 


function linkForside(iurl)
    {
        window.top.mainFrame.location.href=iurl;  
    }
function GetSize(what) 
{
    var myWidth=0;
    var myHeight=0;
   if( typeof( window.innerWidth ) == 'number' ) 
    {        
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } 
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
    {
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } 
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  {  
     myWidth = document.body.clientWidth;
     myHeight = document.body.clientHeight;
  }
  if (what=='width')
    {return myWidth}
  else if (what=='height')
    {return myHeight}
}


 function HideMainLayer(Layer)
    {
    Obj = document.getElementById(Layer)  
    Obj.style.display = 'block';
    toggleDisabled(Obj)
    } 
function toggleDisabled(el) {
                try {
                    el.disabled = el.disabled ? false : true;
                }
                catch(E){}
                
                if (el.childNodes && el.childNodes.length > 0) {
                    for (var x = 0; x < el.childNodes.length; x++) {
                        toggleDisabled(el.childNodes[x]);
                    }
                }
            }

    function Redirect(url)
        {
            document.location.href=url;   
        }
    function onClick(defaultValue)
        {           
        var obj;
        if (getBrowser()=='Explorer')
            {
                obj = document.getElementById("ctl00_TopMenuSerach_V21_JungelKode");                      
            }
        else
            {
                obj = document.getElementById("ctl00_TopMenuSerach_V21_JungelKode");                      
            
            }            
           if (obj.value==defaultValue)
                {                
                    obj.value='';
                }
        }
    function onLostFocus(defaultValue)
        {           
        var obj;
        if (getBrowser()=='Explorer')
            {
                obj = document.getElementById("ctl00_TopMenuSerach_V21_JungelKode");                      
            }
        else
            {
                obj = document.getElementById("ctl00_TopMenuSerach_V21_JungelKode");                      
            
            }                      
           if (obj.value=='')
                {                
                    obj.value=defaultValue;
                }
        } 
function ScreenWidthHeight(item)
    {
        var winW = 630, winH = 460;

        if (parseInt(navigator.appVersion)>3) {
         if (navigator.appName=="Netscape") {
          winW = window.innerWidth;
          winH = window.innerHeight;
         }
         if (navigator.appName.indexOf("Microsoft")!=-1) {
          winW = document.body.offsetWidth;
          winH = document.body.offsetHeight;
         }
        }

            if (item=='w')
                {return winW;}
            else    
                {return winH;}            
    }
function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  alert( 'Width = ' + myWidth );
  alert( 'Height = ' + myHeight );
}
function mainPage(what) {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    if (what == 'Width') {
        return myWidth + 'px'
    }
    if (what == 'Height') {
        return myHeight + 'px'
    }    
}  
function getMenuHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
    return myHeight;
  }  
function setTopLayerVisible()
    {
        var obj = document.getElementById("TopLayer") ; 
        obj.style.width=ScreenWidthHeight('w')+'px';
        obj.style.height=ScreenWidthHeight('h')+'px';
        obj.style.display = 'block';
        document.getElementById("objBody").style.overflow='hidden'
   }    
function setTopLayerhidden()
    {   var obj = document.getElementById("TopLayer") ; 
        obj.style.display = 'hidden';
        document.getElementById("objBody").style.overflow='auto';
   }   
      function flashcontent(iwith, iheight, filename, id)
    {
	    if (AC_FL_RunContent == 0) {
		    //alert("This page requires AC_RunActiveContent.js.");
	    } else {
		    AC_FL_RunContent(
			    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			    'width', iwith,
			    'height', iheight,
			    'src', filename,
			    'quality', 'high',
			    'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			    'align', 'middle',
			    'play', 'true',
			    'loop', 'true',
			    'scale', 'showall',
			    'wmode', 'window',
			    'devicefont', 'false',
			    'id', id,
			    'bgcolor', '#FFFFFF',
			    'name', id,
			    'menu', 'true',
			    'allowFullScreen', 'false',
			    'allowScriptAccess','sameDomain',
			    'movie', filename,
			    'salign', ''
			    ); //end AC code
	    }
	}
	function openPrint(url) {
	    var Win= window.open(url, 'print', 'status=1');
	}
	function fbs_click(u) 
	    {
	        t = document.title;
	        window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
	        return false;
	    }
	    function tw_click(u) {
	        t = document.title;
	        window.open('http://twitter.com/home?status=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
	        return false;
	    }
	    function validatethisLogin() {
	        var msg = '';	   
	        if (document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_addCustomer1_txtNavn').value == '') {
	            msg = 'mangler Navn';
	            document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_addCustomer1_txtNavn').style.backgroundColor = '#cccc00'
	        }
	        if (document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_addCustomer1_txtAdresse').value == '') {
	            msg = msg + '\nmangler Adresse';
	            document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_addCustomer1_txtAdresse').style.backgroundColor = '#cccc00'
	        }
	        if (document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_addCustomer1_txtPostnr').value == '') {
	            msg = msg + '\nmangler postnr';
	            document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_addCustomer1_txtPostnr').style.backgroundColor = '#cccc00'
	        }
	        if (document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_addCustomer1_txtSted').value == '') {
	            msg = msg + '\nmangler sted';
	            document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_addCustomer1_txtSted').style.backgroundColor = '#cccc00'
	        }
	        if (document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_addCustomer1_txtCellular').value == '') {
	            msg = msg + '\nmangler mobilnr';
	            document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_addCustomer1_txtCellular').style.backgroundColor = '#cccc00'
	        }
	        if (document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_addCustomer1_txtPassword').value == '') {
	            msg = msg + '\nmangler passord';
	            document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_addCustomer1_txtPassword').style.backgroundColor = '#cccc00'
	        }
	        if (document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_addCustomer1_txtEmail').value == '') {
	            msg = msg + '\nmangler epost adresse';
	            document.getElementById('ctl00_cpCenter_ActionHandler1_ctl00_addCustomer1_txtEmail').style.backgroundColor = '#cccc00'
	        }

	        if (msg == '')
	        {return true; }
	        else {
	          alert(msg);
	          return false;   
	         }
	    }
