var newWin = null;
function popUp(strURL, strType, strHeight, strWidth) {
	if (newWin != null && !newWin.closed)
		newWin.close();
		var strOptions="";
	if (strType=="popup")
		strOptions="location=0,menubar=1,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,height="+strHeight+",width="+strWidth;
	newWin = window.open(strURL, 'newWin', strOptions);
	newWin.focus();
}

//Function for expanding or collapsing a chosen tag in the XSL template
 function expand(thistag) {
      if(document.getElementById(thistag)){
      styleObj = document.getElementById(thistag).style;
      if (styleObj.display=='none') {styleObj.display = '';}
      else {styleObj.display = 'none';}
      }
}
function goTarget(url) {
  window.open(url);
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}function isInt(str) {
    return /^ *[1-9]+ *$/.test(str);
}

function externalLinks(){
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for(var i=0;i<anchors.length; i++){
		var anchor = anchors[i];
		if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
			anchor.target = "_blank";
		}
	}
}

$(document).ready( function() { 
    $('a[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
});



 

function checkForm(){
			
		name = document.myForm.navn;
		email = document.myForm.epost;
		phone = document.myForm.telefon;
		
		
		document.myForm.cc.value = document.myForm.epost.value;
		
		if (!document.myForm.navn.value)
		{
			alert('Vennligst fyll inn et navn!');
			document.myForm.navn.focus();
			return false;
		}

		if (!document.myForm.epost.value)
		{
			alert('Vennligst oppgi en epost!');
			document.myForm.epost.focus();
			return false;
		}
		else
		{
			if(checkemail(document.myForm.epost))
			{return true;}
			else return false;
		}
		
		if (!document.myForm.telefon.value)
		{
			alert('Vennligst fyll inn ett telefonnummer!');
			document.myForm.telefon.focus();
			return false;
		}
}

function checkemail(input)
{

	var tekst;
	tekst = input;
		
	if (tekst.value.length > 0) 
	{ 
		if (!new RegExp('^.+@.+..+$').test(tekst.value)) 
		{
			alert('Feil epost format!');
			tekst.style.backgroundColor = '#FFF1F1';
			tekst.focus();
			return false;
		}
		else
		{
			tekst.style.backgroundColor = '';
			return true;
		}	
	}
	else 
	{
		tekst.style.backgroundColor = '';
		return false;
	}
 }

function equalHeight(one,two) {
          var lh;var rh;var nh;
          if (document.getElementById(one)) {
          lh=document.getElementById(one).offsetHeight;
          rh=document.getElementById(two).offsetHeight;
          nh = Math.max(lh, rh);
          document.getElementById(one).style.height=nh+"px";
          document.getElementById(two).style.height=nh+"px";
          }
};
function equalInner(one,two) {
          var lh;var rh;var nh;
          if (document.getElementById(one)) {
          lh=document.getElementById(one).offsetHeight;
          rh=document.getElementById(two).offsetHeight;
          nh = Math.max(lh, rh);
          document.getElementById(one).style.height=nh+"px";
		  nh= nh-20;
          document.getElementById(two).style.height=nh+"px";
          }
};


