﻿var ns6=document.getElementById&&!document.all;
var opera=navigator.userAgent.indexOf("Opera")>=0;
var eventObj = (document.all) ? "window.event.srcElement" : "event.target";

function getKey(evt) {
    /*
	if (evt && ns6)
		typedKey=evt.which;
	else
		typedKey=event.keyCode;    
    */
    
    var typedKey = null;
	if(evt && evt.which)
	{ //if which property of event object is supported (NN4)
		//e = e ?? 
		typedKey = evt.which //character code is contained in NN4's which property
	}
	else
	{		
		typedKey = event.keyCode; //character code is contained in IE's keyCode property
	}
	if (typedKey == 13) {	    
		if(document.all) {
			window.event.cancelBubble='true';
		    window.event.returnValue = false;
		} else {
			evt.stopPropagation();
		    evt.preventDefault();
		    
		}
		document.getElementById("btnLogin").click();		
	 }
}


// tip en ven


function openTipEnVenPopup(pUrl, pTitle)
{
    var winl = (screen.width-400)/2;
    var wint = (screen.height-300)/2;
    var settings = "width=450,height=450" + ",top=" + wint + ",left=" + winl;
    window.open(pUrl, '', settings);

}

// DROPDOWN MENU


$(document).ready(function(){

	$(".postflatviewtable a").attr("target","_blank");





// Remove right column if empty


 
$("#flyOutMenu li").hover(
	function(){ $("ul", this).fadeIn("normal"); }, 
	function() { } 
);
if (document.all) {
		$("#flyOutMenu li").hoverClass ("sfHover");
	}
});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};	



/*
--------------------------------------------------------
Search
--------------------------------------------------------
*/


function trapSearchEnter(e, enterFunction){
     if (!e) e = window.event;
     if (e.keyCode == 13){
          e.cancelBubble = true;
          if (e.returnValue) e.returnValue = false;
          if (e.stopPropagation) e.stopPropagation();
          if (enterFunction) eval(enterFunction);
          document.getElementById("searchButton").click();
          return false;
     } else {
 
          return true;
     }     
}

function trimString (str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}


/* Search - æøå… works from user search text.*/

function postSearch(searchStr){
	var searchStr = encodeURIComponent(searchStr);
	if(searchStr != ""){
		location = "/sog.aspx?search=" + searchStr + "&page=1";
	}
	else{
		return false;
	}
}


function goToPage(pageNum, searchStr){
	var searchStr = encodeURIComponent(searchStr);
	if(searchStr != ""){
		location = "/sog.aspx?search=" + searchStr + "&page="+pageNum;
	}
	else{
		return false;
	}
}

function doPostBack () {
    var answer = confirm("Er du sikker på du vil slette?")
	if (answer){
	    var hide = document.getElementById("hide");
	    if (hide != null)	    
	        hide.value = "postback"
		document.forms[0].submit();

	}	
}

function clickButton(e, buttonid){
     var bt = document.getElementById(buttonid);
     if (typeof bt == 'object'){
           if(navigator.appName.indexOf("Netscape")>(-1)){
                 if (e.keyCode == 13){
                       bt.click();
                       return false;
                 }
           }
           if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){
                 if (event.keyCode == 13){
                       bt.click();
                       return false;
                 }
           }
     }
}

/*
--------------------------------------------------------
openMap
--------------------------------------------------------
*/


function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { 
    if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
    }
    window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
    }
    
 