// -----------------------------------------------------------
// 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 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);
}


// -----------------------------------------------------
//                   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);
}
