var an="";an=navigator.appName;
var av=0;av=parseInt(navigator.appVersion);

function OpenFinansiering(strURL)
{
	newWindow=window.open(strURL,"newwindow","width=550,height=500,resizable=1,status=1,left=30,top=30,menubar=0,scrollbars=1,toolbar=0,location=0,directories=0");
}

function OpenVideo(nVideoID)
{
	newWindow=window.open('/videoplayer.asp?nVideoID='+nVideoID,"newwindow","width=763,height=440,resizable=0,status=0,menubar=0,scrollbars=0,toolbar=0,location=0,directories=0");
}

function OpenShop()
{
	var strURL = "/shop/index.html" // http://www.zillionshop.dk/mall/shop.asp?shop_id=5127&skin_test=1";

	if ( an.indexOf( "Netscape" ) != -1 && av > 2 )
	{
		newWindow=window.open(strURL,"newwindow","width=770,height=450,resizable=1,status=1,left=30,top=30,menubar=0,scrollbars=0,toolbar=0,location=0,directories=0");
		newWindow.focus();
	} 
	else 
	{
		newWindow=window.open(strURL,"newwindow","width=770,height=450,resizable=1,status=1,left=30,top=30,menubar=1,scrollbars=0,toolbar=1,location=1,directories=0");
	}
}

function openProduktPrisliste(url){
		if (an.indexOf("Netscape")!=-1&&av > 2){
			newWindow=window.open(url,"_blank","width=615,height=300,resizable=0,status=1,left=30,top=30,menubar=0,scrollbars=1,toolbar=0,location=0,directories=0");
			newWindow.focus();
		} else {
			newWindow=window.open(url,"_blank","width=615,height=300,resizable=0,status=1,left=30,top=30,menubar=0,scrollbars=1,toolbar=0,location=0,directories=0");
		}
	}

function stoffarvervindue(url){
		if (an.indexOf("Netscape")!=-1&&av > 2){
			newWindow=window.open(url,"newwindow","width=782,height=620,resizable=0,status=1,left=30,top=30,menubar=0,scrollbars=0,toolbar=0,location=0,directories=0");
			newWindow.focus();
		} else {
			newWindow=window.open(url,"newwindow","width=782,height=620,resizable=0,status=1,left=30,top=30,menubar=0,scrollbars=0,toolbar=0,location=0,directories=0");
		}
	}
function gallerivindue(url){
		if (an.indexOf("Netscape")!=-1&&av > 2){
			newWindow=window.open(url,"newwindow","width=794,height=610,resizable=0,status=1,left=30,top=30,menubar=0,scrollbars=0,toolbar=0,location=0,directories=0");
			newWindow.focus();
		} else {
			newWindow=window.open(url,"newwindow","width=794,height=610,resizable=0,status=1,left=30,top=30,menubar=0,scrollbars=0,toolbar=0,location=0,directories=0");
		}
	}

function openLink2( url )
{
  var window_width = screen.availWidth;
  window_width = window_width - 10;
  var window_height = screen.availHeight;
  window_height = window_height - 20;

  if ( an.indexOf( "Netscape" ) != -1 && av > 2 )
  {
    newWindow=window.open(url,"newwindow","width=" + window_width + ",height=" + window_height + ",resizable=0,status=1,left=0,top=0,menubar=0,scrollbars=0,toolbar=0,location=0,directories=0");
    newWindow.focus();
  } 
  else 
  {
    newWindow=window.open(url,"newwindow","width=" + window_width + ",height=" + window_height + ",resizable=0,status=1,left=0,top=0,menubar=0,scrollbars=0,toolbar=0,location=0,directories=0");
  }
}

function openLinkSmall( url )
{
  var faktor = 2;

  var window_width = screen.availWidth;
  window_width = window_width/faktor;
  var window_left = (screen.availWidth - window_width)/2;
  
  var window_height = screen.availHeight;
  window_height = window_height/faktor;
  var window_top = (screen.availHeight-window_height)/2;

  if ( an.indexOf( "Netscape" ) != -1 && av > 2 )
  {
    newWindow=window.open(url,"newwindow","width=" + window_width + ",height=" + window_height + ",resizable=0,status=1,left=" + window_left + ",top=" + window_top + ",menubar=0,scrollbars=0,toolbar=0,location=0,directories=0");
    newWindow.focus();
  } 
  else 
  {
    newWindow=window.open(url,"newwindow","width=" + window_width + ",height=" + window_height + ",resizable=0,status=1,left=" + window_left + ",top=" + window_top + ",menubar=0,scrollbars=0,toolbar=0,location=0,directories=0");
  }
}

function openLinkVarians( url )
{
  var window_width = screen.availWidth;
  window_width = window_width - 10;
  var window_height = screen.availHeight;
  window_height = window_height - 20;
  
  url += '&width=' + window_width;

  if ( an.indexOf( "Netscape" ) != -1 && av > 2 )
  {
    newWindow=window.open(url,"newwindow","width=" + window_width + ",height=" + window_height + ",resizable=0,status=1,left=0,top=0,menubar=0,scrollbars=0,toolbar=0,location=0,directories=0");
    newWindow.focus();
  } 
  else 
  {
    newWindow=window.open(url,"newwindow","width=" + window_width + ",height=" + window_height + ",resizable=0,status=1,left=0,top=0,menubar=0,scrollbars=0,toolbar=0,location=0,directories=0");
  }
}

function ValidateForm( objForm )
{
	if ( objForm.elements( "address1" ).value.length == 0 )
	{
		alert( "Du skal udfylde adresse" )
		objForm.elements( "address1" ).focus()
		return false;
	}
	else if ( objForm.elements( "zip" ).value.length == 0 )
	{
		alert( "Du skal udfylde postnummer" )
		objForm.elements( "zip" ).focus()
		return false;
	}
	else if ( objForm.elements( "zip" ).value.length != 4 ||
			objForm.elements( "zip" ).value != parseInt( objForm.elements( "zip" ).value ) )
	{
		alert( "Det er ikke et gyldigt postnummer" )
		objForm.elements( "zip" ).focus()
		return false;
	}
	else if ( objForm.elements( "city" ).value.length == 0 )
	{
		alert( "Du skal udfylde by" )
		objForm.elements( "city" ).focus()
		return false;
	}
	else if ( objForm.elements( "att" ).value.length == 0 )
	{
		alert( "Du skal udfylde att" )
		objForm.elements( "att" ).focus()
		return false;
	}
	else if ( objForm.elements( "email" ).value.length == 0 )
	{
		alert( "Du skal udfylde email" )
		objForm.elements( "email" ).focus()
		return false;
	}
	else if ( objForm.elements( "email" ).value.length < 5 ||
			objForm.elements( "email" ).value.indexOf( "." ) == -1 ||
			objForm.elements( "email" ).value.indexOf( "@" ) == -1 )
	{
		alert( "Det er ikke en gyldig email" )
		objForm.elements( "email" ).focus()
		return false;
	}
	else if ( objForm.elements( "tlf" ).value.length == 0 )
	{
		alert( "Du skal udfylde tlf" )
		objForm.elements( "tlf" ).focus()
		return false;
	}
	else if ( objForm.elements( "tlf" ).value.replace( /\s/, "" ).length != 8 ||
			objForm.elements( "tlf" ).value.replace( /\s/, "" ) != parseInt( objForm.elements( "tlf" ).value.replace( /\s/, "" ) ) )
	{
		alert( "Det er ikke et gyldig telefonnummer" )
		objForm.elements( "tlf" ).focus()
		return false;
	}
	return true;
}
function ShowCommercial( strName )
{
	var strURL = "/commercial/" + strName + "/index.html"
	
	var strPos = "";
	
	if ( window.screen )
	{
		var nPosLeft = parseInt( window.screen.availWidth, 10 ) - 450;
		var nPosTop = 50;
		strPos = ", left=" + nPosLeft + ", top="+ nPosTop;
	}
	

	newWindow=window.open(strURL,"commercial","width=300,height=400,resizable=0,status=1,menubar=0,scrollbars=0,toolbar=0,location=0,directories=0" + strPos );
	if ( an.indexOf( "Netscape" ) != -1 && av > 2 )
	{
		newWindow.focus();
	} 
}

function CloseWindow()
{
	window.close();
}

function NavigateToWebshop()
{
	window.opener.location.href = "/webshop.asp";
	window.close()
}

function visSkjulVariant(obj,id) {

  if (document.getElementById(id).style.visibility == "hidden") {
    x = y = 0;
    temp = obj;
    while (temp.offsetParent) {
      x += temp.offsetLeft;
      y += temp.offsetTop;
      temp = temp.offsetParent;
    }
  document.getElementById(id).style.left = x;
  document.getElementById(id).style.top = y + obj.offsetHeight-4;  
  }
  document.getElementById(id).style.visibility = (document.getElementById(id).style.visibility == "hidden") ? "visible" : "hidden";
  
}


function GetWindowDimension()
{
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	return (new CSize(y,x));
}
function GetBodyDimension()
{
	var x,y;
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	if (test1 < test2) // all but Explorer Mac
	{
		x = document.body.scrollWidth;
		y = document.body.scrollHeight;
	}
	else // Explorer Mac;
	     //would also work in Explorer 6 Strict, Mozilla and Safari
	{
		x = document.body.offsetWidth;
		y = document.body.offsetHeight;
	}
	return (new CSize(y,x));
}

function getLoadObj(reqHndl) {

	var oLoad;
	try {
	oLoad = new ActiveXObject("Msxml2.XMLHTTP");

	} catch (e) {
		
		try {
			oLoad = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) { oLoad = false; }
	}
	if (!oLoad && typeof XMLHttpRequest!='undefined')
		oLoad = new XMLHttpRequest();
			
	return (oLoad)?new clLoadXmlObj(oLoad,reqHndl):null;
}



function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else {
    if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
      //DOM compliant
      scrOfY = document.body.scrollTop;
      scrOfX = document.body.scrollLeft;
    } else {
      if( document.documentElement &&
          ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
      	//IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
      }
    }
  }
	return (new CSize(scrOfY,scrOfX));
}

function GetBannerPlacing(temp)
{
	var y=0;
	while (temp.offsetParent) {
      y += temp.offsetTop;
      temp = temp.offsetParent;
    }

	return y + temp.offsetHeight - 13;
}

function CSize(nHeight,nWidth)
{
	this.nHeight	= nHeight;
	this.nWidth		= nWidth;
}

function tjekTal(str)
{
  var str_tilladte = '0123456789';
  
  if (str.length < 1)
    return false;
  else
    for (var i = 0; i < str.length; i++)
    {  
      var boo_fundet = false;
      for (var j = 0; j < str_tilladte.length; j++)
        if (str.charAt(i) == str_tilladte.charAt(j))
          boo_fundet = true
      if (!boo_fundet)
        return false;
    }
  
  return true;
}

function tjekTalTlf(str)
{
  var str_tilladte_maerke = '+0123456789';
  var str_tilladte = '0123456789';
  
  if (str.length < 1)
    return false;
  else
    for (var i = 0; i < str.length; i++)
    {  
      var boo_fundet = false;
      var str_tilladte_intern = (i == 0 ? str_tilladte_maerke : str_tilladte);
      for (var j = 0; j < str_tilladte_intern.length; j++)
        if (str.charAt(i) == str_tilladte_intern.charAt(j))
          boo_fundet = true
      if (!boo_fundet)
        return false;
    }
  
  return true;
}

function tjekEmail(str_email)
{
  var kontrol = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
  return kontrol.test(str_email);
}

function trim(str)
{
  while (str.length > 0 && str.charAt(str.length - 1) == " ")
    str = str.substring(0, str.length - 1);
  while (str.length > 0 && str.charAt(0) == " ")
    str = str.substring(1, str.length);
  return(str);
}

function trimInt(str)
{
  while (str.length > 1 && str.charAt(0) == "0")
    str = str.substring(1, str.length);
  return(str);
}

function cifDec(str_streng, int_dec_antal, boo_punktum)
{
  str_streng = str_streng.replace(new RegExp(/\./g), ',');

  if(str_streng.indexOf(',') == -1)
    str_streng += ',';
    
  while((str_streng.length - str_streng.indexOf(',')) <= int_dec_antal)
    str_streng += '0';
    
  if(boo_punktum)
    str_streng = str_streng.replace(new RegExp(/\./g), ',');
  
  return str_streng;
}

function clLoadXmlObj(loadObj,reqHndl) {
	this.loadObj=loadObj;
	this.request = reqHndl;
	this.load = function(url) {
		this.loadObj.open("GET", url ,true);
		this.loadObj.onreadystatechange=function() { if (loadObj.readyState==4) { var oX=document.createElement("div"); oX.innerHTML = loadObj.responseText; reqHndl( oX ); }	}
		this.loadObj.send(null);
	}
	this.directLoad= function(url) {
		this.loadObj.open("GET", url ,false);
		this.loadObj.onreadystatechange=function() { };
		this.loadObj.send(null);
		return loadObj.responseText;
	}
}

function prisGodkendt(str_pris)
{
  var pris = str_pris.replace(new RegExp(/\./g), "a");
  pris = pris.replace(new RegExp(/\,/g), ".");
  
  if (isNaN(pris))
    return false;
  else if (pris <= 0)
    return false;
  else if (pris >= 10000000000)
    return false;
  else if ((Math.round(pris * 100)) / 100 != pris)
    return false;
  
  return true;
}

function dageIMaaned(maaned, aar)
{
  var maanedsDage = new Array(31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
  return maaned == 2 ? skudAar(aar) ? 29 : 28 : maanedsDage[maaned - 1];
}

function skudAar(aar)
{
  return (aar % 400 == 0 || aar % 4 == 0 && aar % 100 != 0);
}

function datokontrol(int_dag, int_maaned, int_aar)
{
  return int_dag <= dageIMaaned(int_maaned, int_aar);
}

function datoAngivet(obj_dagfelt, obj_maanedfelt, obj_aarfelt, boo_etfelt)
{
  return (boo_etfelt ? (trim(obj_dagfelt.value).length > 0 || trim(obj_maanedfelt.value).length > 0 || trim(obj_aarfelt.value).length > 0) : (trim(obj_dagfelt.value).length > 0 && trim(obj_maanedfelt.value).length > 0 && trim(obj_aarfelt.value).length > 0));
}

function datoGodkendt(obj_dagfelt, obj_maanedfelt, obj_aarfelt)
{
  if (isNaN(trimInt(trim(obj_dagfelt.value))) || isNaN(trimInt(trim(obj_maanedfelt.value))) || isNaN(trim(obj_aarfelt.value)))
    return false;
  else if (!( parseInt(trimInt(trim(obj_dagfelt.value))) >= 1 && parseInt(trimInt(trim(obj_dagfelt.value))) <= 31 && parseInt(trimInt(trim(obj_maanedfelt.value))) >= 1 && parseInt(trimInt(trim(obj_maanedfelt.value))) <= 12 && parseInt(trim(obj_aarfelt.value)) >= 1970 && parseInt(trim(obj_aarfelt.value)) <= 2100 ))
    return false;
  else if (!(datokontrol(parseInt(trimInt(trim(obj_dagfelt.value))), parseInt(trimInt(trim(obj_maanedfelt.value))), parseInt(trim(obj_aarfelt.value)))))
    return false;
  
  return true;
}

function betingelser_se_vindue(url){
		
		if (an.indexOf("Netscape")!=-1&&av > 2){
			newWindow=window.open(url,"newwindow","width=530,height=630,resizable=0,status=1,left=30,top=30,menubar=0,scrollbars=0,toolbar=0,location=0,directories=0");
			newWindow.focus();
		} else {
			newWindow=window.open(url,"newwindow","width=530,height=630,resizable=0,status=1,left=30,top=30,menubar=0,scrollbars=0,toolbar=0,location=0,directories=0");
		}
	}
	
	// -------------------- Common

function gE( id ) {
	return document.getElementById( id );
}
function getFirstIdeChild( parentObj, id, searchChildren ) {
	if ( ! parentObj.childNodes ) return;
	var t;
	for(var a=0; a<parentObj.childNodes.length; a++) {
		if ((t=parentObj.childNodes[a])&&(t.id==id)) return t;
	}
	if (searchChildren)
		for(var a=0; a<parentObj.childNodes.length; a++) if ( t=getFirstIdeChild( parentObj.childNodes[a], id, searchChildren ) ) return t;
}

function getFromNameUp( obj, name ) {
	var t = obj.parentNode;
	if (( (typeof t)=='undefined' )||( t==document.body)) return null;
	
	if (((typeof t.attributes)!='undefined')&&((typeof t.attributes['name'])!='undefined')&&((""+t.attributes['name'].value)==name)) { return t; }
	else if ( t=getFromNameUp( t, name ) ) return t;
	
}


function getFirstNamedChild( parentObj, name, searchChildren ) {
	if ( ! parentObj.childNodes ) return;
	name = (""+name).toLowerCase();
	var t;
	
	for(var a=0; a<parentObj.childNodes.length; a++)
		if ((t=parentObj.childNodes[a])&&(t.attributes)&&(t.attributes['name'])&&((""+t.attributes['name'].value).toLowerCase()==name)) return t;

	if (searchChildren)
		for(var a=0; a<parentObj.childNodes.length; a++) if ( t=getFirstNamedChild( parentObj.childNodes[a], name, true ) ) return t;
}