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 (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) 
    {
    }
	
	//vis animation i kurven
	//document.getElementById('kurvhover').style.backgroundImage = "url(/grafik/overall/kurv-bg-animation.gif)";
	
	if(getCookie('lpvPC') != "on")
	{
		if(window.location.href.indexOf("showbasket") < 1)
		{
		
			//Købs popup
			 var myWidth = 0, myHeight = 0;
		  	 if(typeof(window.innerWidth) == 'number') {
		        //Non-IE
		        myWidth = window.innerWidth;
		        myHeight = window.innerHeight;
			}
			else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		        //IE 6+ in 'standards compliant mode'
		        myWidth = document.documentElement.clientWidth;
		        myHeight = document.documentElement.clientHeight;
		    } 
			else if(document.body &&(document.body.clientWidth || document.body.clientHeight)) {
		        //IE 4 compatible
		        myWidth = document.body.clientWidth;
		        myHeight = document.body.clientHeight;
		    } 
			
			document.getElementById("koebpopup").style.left 			= (myWidth/2-155+10)+"px";
			document.getElementById("koebpopup").style.top 				= (myHeight/2-235)+document.body.scrollTop+"px";
			document.getElementById("koebpopup").style.width 			= "469px";
			document.getElementById("koebpopup").style.height 			= "309px";
			document.getElementById("koebpopup").style.backgroundImage 	= "url(/grafik/varekortpopup/bg.png)";
			document.getElementById("koebpopup").style.position		 	= "absolute";
			document.getElementById('koebpopup').style.display 			= "inline";
	
			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=\"float:left; margin:160px 0 0 60px\"><a href=\"/shop/showbasket.html\"><img style=\"cursor:pointer\" src=\"/grafik/varekortpopup/ga-til-kurven.gif\" onMouseOver=\"this.src='/grafik/varekortpopup/ga-til-kurven-hover.gif'\" onMouseOut=\"this.src='/grafik/varekortpopup/ga-til-kurven.gif'\"></a></div>"
						+"<div style=\"float:left; margin:160px 0 0 30px\"><img onclick=\"HideKoebPopup()\" style=\"cursor:pointer\" src=\"/grafik/varekortpopup/kob-flere-varer.gif\" onMouseOver=\"this.src='/grafik/varekortpopup/kob-flere-varer-hover.gif'\" onMouseOut=\"this.src='/grafik/varekortpopup/kob-flere-varer.gif'\"></div>"
						+ "<br /><br /><div style=\"clear:both\"></div><div style=\"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('lpvPC','on',100)
	setTimeout(HideKoebPopup, 1000);
}

function HideKoebPopup() 
{
   document.getElementById('koebpopup').style.display = 'none';
}


function RestoreOriginalSrc() 
{
    ProductImage.src = OriginalSrc;     
}

function RestoreOriginalMedia() 
{
    ProductImageCanvasTD.style.display = '';
    ProductImageDummyImg.style.display = 'none';
}


