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) 
{
	

	if(getCookie('konsolPC') != "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-160+10)+"px";
			document.getElementById("koebpopup").style.top 				= (windowHeight/2-225)+document.body.scrollTop+"px";
			document.getElementById("koebpopup").style.width 			= "454px";
			document.getElementById("koebpopup").style.height 			= "320px";
			document.getElementById("koebpopup").style.backgroundImage 	= "url(/grafik/varekort/popup-lagt-i-kurv.png)";
			document.getElementById("koebpopup").style.backgroundRepeat	= "no-repeat";
			document.getElementById("koebpopup").style.position		 	= "absolute";
			document.getElementById('koebpopup').style.display 			= "inline";
	
			var innerDIV = "<div><div style=\"height:65px;\"></div><div style=\"margin-right:0px; width:40px; height:40px; float:right; cursor:pointer;\" onclick=\"HideKoebPopup()\"></div></div>"
						+"<div style=\"float:left; margin:190px 0 0 30px;\"><img onclick=\"HideKoebPopup()\" style=\"cursor:pointer\" src=\"/grafik/varekort/knap-koeb-flere.png\" onMouseOver=\"this.src='/grafik/varekort/knap-koeb-flere-hover.png'\" onMouseOut=\"this.src='/grafik/varekort/knap-koeb-flere.png'\"></div>"
						+"<div style=\"float:left; margin:190px 0 0 60px;\"><a href=\"/shop/showbasket.html\"><img style=\"cursor:pointer\" src=\"/grafik/varekort/knap-gaa-til-kassen.png\" onMouseOver=\"this.src='/grafik/varekort/knap-gaa-til-kassen-hover.png'\" onMouseOut=\"this.src='/grafik/varekort/knap-gaa-til-kassen.png'\"></a></div>"
						+ "<br /><br /><div style=\"clear:both\"></div><div style=\"display:none; clear:left; padding-left:300px; margin-top:10px; color:#fff;\"><p style=\"padding-top:0px\"><form><input type=\"checkbox\" name=\"popupCHECK\" id=\"popupCHECK\"onclick=\"CookieSkjulKoebPopup()\"> <label for=\"popupCHECK\">Vis ikke igen</label></form></p>";
			document.getElementById("koebpopup").innerHTML = innerDIV;
			

			setTimeout(HideKoebPopup, 10000);
			
		}
	}
	
}

//bruges til at skjule købspopuppen via coockies
function CookieSkjulKoebPopup()
{
	setCookie('konsolPC','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';
}
