//request querystring
setTimeout("location.href=location.href",3000000);
function getURLParam(strParamName){
  var strReturn = "";
  var strHref = location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( 
		aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
}
function getURLParamVareliste(strParamName){
  var strReturn = "";
  var strHref = location.href.replace("&", "?");
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( 
		aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
}
//productlist
function search()
{
	var keyword = unescape(getURLParam("keyword"));
	
	if(keyword !="")
	{
		document.getElementById('VarelistSearchh1').innerHTML = '<br />Søgning på &quot;' + keyword.replace('+',' ') + '&quot;';
	}
	else
	{
		var keywordnew = unescape(getURLParamVareliste("keyword"));
		if(keywordnew !="")
		{
		document.getElementById('VarelistSearchh1').innerHTML = '<br />Søgning på &quot;' + keywordnew.replace('+',' ') + '&quot;';
		}
	}
}
//cookie functions
function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name){
if (document.cookie.length>0){
	c_start=document.cookie.indexOf(c_name + "=");
	if (c_start!=-1){ 
	    c_start=c_start + c_name.length+1; 
    	c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));} 
  }
return "";
}

//popup
function ProductAdded(prodnumber, caller, postorigin) 
{
	if(getCookie('popup') != "on")
	{
		if(window.location.href.indexOf("showbasket") < 1)
		{
		
			var strarrayPageSize = getPageSize().toString();
			var pageWidth = strarrayPageSize.split(',')[0];
			var pageHeight = strarrayPageSize.split(',')[1];
			var windowWidth = strarrayPageSize.split(',')[2];
			var windowHeight = strarrayPageSize.split(',')[3];
	
	
			document.getElementById("overlay").style.display = "block";
			document.getElementById("overlay").style.width = pageWidth+'px';
			document.getElementById("overlay").style.height = pageHeight+'px';
			
			//*fjern vertical scroll fra NON ID
			if(typeof(window.innerWidth) == 'number') 
				document.getElementById("overlay").style.width = '100%';
			
			document.getElementById("koebpopup").style.left 			= (windowWidth/2-255+10)+"px";
			document.getElementById("koebpopup").style.top 				= (windowHeight/2-235)+document.body.scrollTop+"px";
			document.getElementById("koebpopup").style.width 			= "419px";
			document.getElementById("koebpopup").style.height 			= "350px";
			document.getElementById("koebpopup").style.backgroundImage 	= "url(/images/dd/popup/popup-bg.png)";
			document.getElementById("koebpopup").style.position		 	= "absolute";
			document.getElementById('koebpopup').style.display 			= "inline";
				
			var Box1ShippingTxt = document.getElementById('Box1ShippingTxt').innerHTML;

			var innerDIV = "<div><div style=\"height:30px\"></div><div style=\"margin-right:30px; width:30px; height:30px; float:right; cursor:pointer\" onclick=\"HideKoebPopup()\"></div></div>"
+ "<div style=\"clear:both\"></div><center><div class=\"kob-popup-div\" id=\"kpopup\">"+Box1ShippingTxt+"</div></center>"
						+"<div style=\"float:left; margin:30px 0 0 55px\"><img onclick=\"HideKoebPopup()\" style=\"cursor:pointer\" src=\"/images/dd/popup/kobmere.png\" onMouseOver=\"this.src='/images/dd/popup/kobmere-hover.png'\" onMouseOut=\"this.src='/images/dd/popup/kobmere.png'\"></div>"
						+"<div style=\"float:left; margin:30px 0 0 30px\"><a href=\"/shop/showbasket.html\"><img border=\"0\" style=\"cursor:pointer\" src=\"/images/dd/popup/gatilkurven.png\" onMouseOver=\"this.src='/images/dd/popup/gatilkurven-hover.png'\" onMouseOut=\"this.src='/images/dd/popup/gatilkurven.png'\"></a></div>"
						+ "<br /><br /><div style=\"clear:both\"></div><div style=\"clear:left; padding-left:270px; margin-top:10px; color:#111\"><p style=\"padding-top:0px\"><form><input type=\"checkbox\" name=\"popupCHECK\" id=\"popupCHECK\"onclick=\"CookieSkjulKoebPopup()\"> <label for=\"popupCHECK\">Vis ikke igen</label></form></p></div>";
			document.getElementById("koebpopup").innerHTML = innerDIV;

			setTimeout(HideKoebPopup, 10000);
		}
	}
	
}

//bruges til at skjule købspopuppen via coockies
function CookieSkjulKoebPopup()
{
	setCookie('popup','on',100)
	setTimeout(HideKoebPopup, 1000);
}

function HideKoebPopup()
{
   document.getElementById('koebpopup').style.display = 'none';
   document.getElementById("overlay").style.display = "none";   
}
//popup
function popup(width, height, url, name){
	window.open(url,name,"width="+width+",height="+height);
}
//match prisen fra varekort
function OpenPriceWindow(URL)
{
	var shortURL = URL.split("shop/")[1];
	popup(450,570,'/tilbudsmodul/matchprisen.asp?url='+shortURL,'mp')
}
//Skjul kurv
function DisableBasket()
{

	if(document.getElementById('basketCount').innerHTML == '0')
		document.getElementById('viewbasket').innerHTML = '<div><img src="/images/dd/grafik/step0tom.jpg" alt="" /></div><div><img src="/images/dd/grafik/indkobskurv-tom.gif"></div>';
}

function getPageSize()
{
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
	//return pageHeight+'px';
}
