// -----------------------------------------------------------
// Browser detection
// -----------------------------------------------------------
InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

  isNS6 = false;
  if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 5) {
    isNS6 = true;
  }

  isMacIE = false;
  if ((navigator.appVersion.indexOf("Mac") != -1) && (navigator.userAgent.indexOf("MSIE") != -1)) {
    isMacIE = true;
  }

function DisableScroll()
{
 	//document.body.scroll="no";
 	if(InternetExplorer)
	 	noScrollIE()
	//else
		//noScrollNS()

} 
function noScrollIE()
{
 	document.body.scroll="no";
}
function scrollIE()
{
 	document.body.scroll="yes";
}
function noScrollNS()
{
 	alert("NS")
 	document.width= window.innerWidth;
	document.height=window.innerHeight;
}
function scrollNS()
{
 	document.width=1000;
	document.height=1000;
}
  
function numeric_onkeypress(event) 
{
	var c;

	if ( document.all ) 
		c = event.keyCode;
	else
		c = event.charCode;

	keyvalid = ( ((c>47) && (c<58)) || (c==0) );
	
	if ( !keyvalid )
	{
		event.returnValue = false;

		if ( document.all )
			return false;

		event.preventDefault ();
		return false;
	}

	return true;
}

function textCounter(field,maxlimit) 
{
	if (field.value.length > maxlimit) 
		field.value = field.value.substring(0, maxlimit);
}

// -----------------------------------------------------
//                   CMS funktioner
// -----------------------------------------------------
function ShowCMSBoks(H,B,Link)
{

 	  ScrollerTop = document.body.scrollTop
	  	  
	  // Show bokse
	  ShowBlock('CMSBOX')
	  ShowBlock('CMSBG')

	  // Sæt højde brede
      document.getElementById('CMSBOX').style.width=B
      document.getElementById('CMSBOX').style.height=H
      document.getElementById('CMSFRAME').style.width=B
      document.getElementById('CMSFRAME').style.height=H
	  
	  // Set url i cms frame
	  var F = parent.parent.document.getElementById('CMSFRAME');
  	  if(F != null)
  	  {	
  			F.src = Link
  	  }
	  
      var IpopTop = (screen.Height - document.getElementById('CMSBOX').offsetHeight)/2;
      var IpopLeft = (screen.Width - document.getElementById('CMSBOX').offsetWidth)/2;
      
      document.getElementById('CMSBOX').style.left=IpopLeft + document.body.scrollLeft;
      //document.getElementById('CMSBOX').style.top=IpopTop + document.body.scrollTop;
      
	  document.getElementById('CMSBOX').style.top=ScrollerTop + 50;
  	  document.getElementById('CMSBG').style.top = ScrollerTop
 
   	  document.body.scroll="no";
}

function ShowCMSBoks2(top,H,B,Link)
{

 	  ScrollerTop = document.body.scrollTop
	  	  
	  // Show bokse
	  ShowBlock('CMSBOX')
	  ShowBlock('CMSBG')

	  // Sæt højde brede
      document.getElementById('CMSBOX').style.width=B
      document.getElementById('CMSBOX').style.height=H
      document.getElementById('CMSFRAME').style.width=B
      document.getElementById('CMSFRAME').style.height=H
	  
	  // Set url i cms frame
	  var F = parent.parent.document.getElementById('CMSFRAME');
  	  if(F != null)
  	  {	
  			F.src = Link
  	  }
	  
      var IpopTop = (screen.Height - document.getElementById('CMSBOX').offsetHeight)/2;
      var IpopLeft = (screen.Width - document.getElementById('CMSBOX').offsetWidth)/2;
      
      document.getElementById('CMSBOX').style.left=IpopLeft + document.body.scrollLeft;
      //document.getElementById('CMSBOX').style.top=IpopTop + document.body.scrollTop;
      
	  document.getElementById('CMSBOX').style.top=ScrollerTop + top;
  	  document.getElementById('CMSBG').style.top = ScrollerTop
 
   	  document.body.scroll="no";
}


function HideCMSBoks(Link)
{
	  HideBlock('CMSBOX')
	  HideBlock('CMSBG')
	  document.body.scroll="yes";
 	if(Link!='')
	{
	 	document.location  = Link
	}
}

// -----------------------------------------------------
//                   Layer funktioner
// -----------------------------------------------------

function ShowBlock(LAG)
{
		

	if(InternetExplorer == true)
	{
		document.all[""+LAG].style.display = "BLOCK"
	}	
	else
	{
		document.getElementById(""+LAG).style.visibility = 'visible'
		document.getElementById(""+LAG).style.display = 'Block'	
	}

}

function HideBlock(LAG)
{

	if(InternetExplorer == true)
	{
		document.all[""+LAG].style.display = "NONE"
	}

	else
	{
		document.getElementById(""+LAG).style.visibility = 'hidden'
		document.getElementById(""+LAG).style.display = 'none'		
	}


}

function FindDivStyle(LAG)
{
	if(InternetExplorer == true)
	{		
		return document.all[""+LAG]
	}

	else
	{
		return document.getElementById(""+LAG)
	}
}

function SetDivBgColor(Lag, color)
{
	if(InternetExplorer == true)
	{
		l = FindDivStyle(Lag)
		l.style.background = color
	}
	else

	{
		l = FindDivStyle(Lag)	
		l.style.background = "#" + color	
	}

}

function SetDivBgColor(Lag, color)
{
	if(InternetExplorer == true)
	{
		l = FindDivStyle(Lag)
		l.style.background = color
	}
	else

	{
		l = FindDivStyle(Lag)	
		l.style.background = "#" + color	
	}

}

//Advanced Email Check credit-
//By JavaScript Kit (http://www.javascriptkit.com)
//Over 200+ free scripts here!

var testresults

function CheckEmail(email)
{
   var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
   if (filter.test(email))
   {
   	  testresults=true
   }
   else
   {
	   testresults=false
   }
   return (testresults)
}

function numeric_onkeypress(event) 
{
	var c;

	if ( document.all ) 
		c = event.keyCode;
	else
		c = event.charCode;

	keyvalid = ( ((c>47) && (c<58)) || (c==0) );
	
	if ( !keyvalid )
	{
		event.returnValue = false;

		if ( document.all )
			return false;

		event.preventDefault ();
		return false;
	}

	return true;
}

function launchWin(url, name, width, height,x_pos,y_pos, otherfeatures)
{
  var str = "" 
  
  str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;

  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + x_pos + ",screenX=" + x_pos;
    str += ",top=" + y_pos + ",screenY=" + y_pos;

  }
  newwin = window.open(url, name, str + ',' + otherfeatures);


}


function PrintWindow(url)
{
 	tmpy = ((screen.availWidth) / 2) - 300
	tmpx = ((screen.availHeight) / 2) - 75
 	
	launchWin(url,'_blank',600,150,0,0,'scrollbars=no,resizable=no,top='+ tmpx + ',left=' + tmpy);
}