function country_popup(code)
{
	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-470)+"px";
	document.getElementById("koebpopup").style.top 				= "30px";
	document.getElementById("koebpopup").style.width 			= "470px";
	document.getElementById("koebpopup").style.height 			= "268px";
	document.getElementById("koebpopup").style.backgroundImage 	= "url(/grafik/overall/"+code+"-overlay.png)";
	document.getElementById("koebpopup").style.position		 	= "absolute";
	document.getElementById('koebpopup').style.display 			= "inline";

	var innerDIV = "<div><div style=\"height:200px\"></div><div style=\"padding-left:30px;\" onclick=\"HideKoebPopup()\"><img style=\"cursor:pointer\" src=\"/grafik/overall/luk.png\" onMouseOver=\"this.src='/grafik/overall/luk-hover.png'\" onMouseOut=\"this.src='/grafik/overall/luk.png'\" /></div></div>";

	document.getElementById("koebpopup").innerHTML = innerDIV;
}

var OriginalSrc = "";
var OriginalHtml = "";
var ProductImage;
var ProductImageCanvasTD;
var ProductImageDummyImg;

function SetBasketLocation(source)
{
	if(source.attachEvent)
	{
		source.onclick = function(){location.href='/shop/showbasket.html'};
	}
	else
	{
		source.setAttribute('onclick', 'location.href="/shop/showbasket.html"'); 
	}
}

function ProductAdded(prodnumber, caller, postorigin) 
{
    try
    {
        if(getCookie('lpvPC') == "on")
		{
			if (caller.indexOf('p.html') > -1) 
	        {
	            // Product Info
	            if (postorigin == "productinfo") 
	            {
	                ProductImage = document.getElementById('ProdInfoImage_' + prodnumber);
	
	                if (ProductImage != null) 
	                {	
	                    // Single image
						
	                    OriginalSrc = ProductImage.src;
	                    ProductImage.src = "/images/lagtikurv.gif";
	                    setTimeout(RestoreOriginalSrc, 10000);
	                }
	                else 
	                {
	                    // More media
						ProductImageDummyImg = document.getElementById('ProductInfo_Addedtobasket');
						ProductImageCanvasTD = document.getElementById('ProductImage_Canvas');
	                    ProductImageCanvasTD.style.display = 'none';
	                    ProductImageDummyImg.style.display = '';
						ProductImageDummyImg.style.cursor = 'pointer';
						SetBasketLocation(ProductImageDummyImg);
	                    setTimeout(RestoreOriginalMedia, 10000);
	                }
	                  
	            }
	            
	            // Related
				
	            else 
	            {
	                ProductImage = document.getElementById('ProdRelatedImage_' + prodnumber.replace("+", "%2B"));
	                OriginalSrc = ProductImage.src;
	                ProductImage.src = "/images/lagtikurvlille.gif";
	                setTimeout(RestoreOriginalSrc, 10000);
					document.getElementById('kunder').style.display = 'inline';
	            }
	        }
	        
	        // Productlist
	        else 
	        {
	            ProductImage = document.getElementById('ProdListImage_' + prodnumber.replace("+", "%2B"));
	            OriginalSrc = ProductImage.src;
	            ProductImage.src = "/images/lagtikurvlille.gif";
	            setTimeout(RestoreOriginalSrc, 10000);
	        }
		}
    }
    catch (ex) 
    {
    }
	
	if(getCookie('lpvPC') != "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-155+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 			= "297px";
			document.getElementById("koebpopup").style.backgroundImage 	= "url(/grafik/varekortpopup/bgny.png)";
			document.getElementById("koebpopup").style.position		 	= "absolute";
			document.getElementById('koebpopup').style.display 			= "inline";
	
			var innerDIV = "<div><div style=\"height:45px\"></div><div style=\"margin-right:20px; width:30px; height:35px; float:right; cursor:pointer\" onclick=\"_gaq.push('Popup', 'Luk');HideKoebPopup()\"></div></div>"
						+"<div style=\"float:left; margin:150px 0 0 50px\"><img onclick=\"_gaq.push('Popup', 'Køb mere');HideKoebPopup()\" style=\"cursor:pointer\" src=\"/grafik/varekortpopup/kob-mere.png\" onMouseOver=\"this.src='/grafik/varekortpopup/kob-mere-hover.png'\" onMouseOut=\"this.src='/grafik/varekortpopup/kob-mere.png'\"></div>"
						+"<div style=\"float:left; margin:150px 0 0 20px\"><a onclick=\"_gaq.push('Popup', 'Gå til kurven')\" href=\"/shop/showbasket.html\"><img style=\"cursor:pointer\" src=\"/grafik/varekortpopup/ga-til-kurven.png\" onMouseOver=\"this.src='/grafik/varekortpopup/ga-til-kurven-hover.png'\" onMouseOut=\"this.src='/grafik/varekortpopup/ga-til-kurven.png'\"></a></div>"
						+ "<br /><br /><div style=\"clear:both\"></div><div style=\"clear:left; padding-left:250px; margin-top:20px; color:#111\"><p style=\"padding-top:0px\"><form><input type=\"checkbox\" name=\"popupCHECK\" id=\"popupCHECK\"onclick=\"_gaq.push('Popup', 'Vis ikke igen');CookieSkjulKoebPopup()\"> <label for=\"popupCHECK\">Vis ikke igen</label></form></p>";
			document.getElementById("koebpopup").innerHTML = innerDIV;
			
			setTimeout(HideKoebPopup, 60000);

		}
	}
	
}

//bruges til at skjule købspopuppen via coockies
function CookieSkjulKoebPopup()
{
	setCookie('lpvPC','on',100)
	setTimeout(HideKoebPopup, 1000);
	document.getElementById("overlay").style.display = "none";

}

function HideKoebPopup() 
{
   document.getElementById('koebpopup').style.display = 'none';
   document.getElementById("overlay").style.display = "none";

}


function RestoreOriginalSrc() 
{
    ProductImage.src = OriginalSrc;     
}

function RestoreOriginalMedia() 
{
    ProductImageCanvasTD.style.display = '';
    ProductImageDummyImg.style.display = 'none';
}


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';
}
