//match prisen fra varekort
function OpenPriceWindow(URL)
{
	var shortURL = URL.split("shop/")[1];
	popup(450,570,'/frontpage/matchprisen.asp?url='+shortURL,'kviksvar')
}
//Indberet fejl fra varekort
function OpenErrorWindow(URL)
{
	var shortURL = URL.split("shop/")[1];
	popup(450,570,'/frontpage/indberetfejl.asp?url='+shortURL,'kviksvar')
}

//varekort chat
function getVareKortChat()
{
	document.getElementById('VarekortCHAT').innerHTML = "<a href=\"https://server.iad.liveperson.net/hc/6855645/?cmd=file&file=visitorWantsToChat&site=6855645&byhref=1&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/\" target=\"chat6855645\" style=\"font-weight:normal; font-size:11px; color:#959698; text-decoration:none\" onclick=\"javascript:window.open('https://server.iad.liveperson.net/hc/6855645/?cmd=file&file=visitorWantsToChat&site=6855645&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/&referrer='+escape(document.location),'chat6855645','width=475,height=400,resizable=yes');return false;\" ><img src=\"/grafik/varekort/chat-varekort.png\"></a>";
}
//vareliste & kundeservice chat
function getVareListeChat()
{
	document.getElementById('VarelisteCHAT').innerHTML = "<a href=\"https://server.iad.liveperson.net/hc/6855645/?cmd=file&file=visitorWantsToChat&site=6855645&byhref=1&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/\" target=\"chat6855645\" style=\"font-weight:normal; font-size:11px; color:#959698; text-decoration:none\" onclick=\"javascript:window.open('https://server.iad.liveperson.net/hc/6855645/?cmd=file&file=visitorWantsToChat&site=6855645&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/&referrer='+escape(document.location),'chat6855645','width=475,height=400,resizable=yes');return false;\" ><img src=\"/grafik/vareliste/chat-vareliste.png\"></a>";
}

//disable mouseover på securetunnel
function DisableMouseover()
{
	if(getURLParam('merchantnumber') != '')
	{
	document.getElementById('JSgemte').onmouseover = '';document.getElementById('JSgemte').onmouseout = '';
	document.getElementById('JStopsearch').onmouseover = '';document.getElementById('JStopsearch').onmouseout = '';
	document.getElementById('JSfacebook').onmouseover = '';document.getElementById('JSfacebook').onmouseout = '';
	document.getElementById('JStwitter').onmouseover = '';document.getElementById('JStwitter').onmouseout = '';
	document.getElementById('JSYoutube').onmouseover = '';document.getElementById('JSYoutube').onmouseout = '';	
	document.getElementById('JSafmeld').onmouseover = '';document.getElementById('JSafmeld').onmouseout = '';
	document.getElementById('JStilmeld').onmouseover = '';document.getElementById('JStilmeld').onmouseout = '';
	document.getElementById('JSTrustpilpt').onmouseover = '';document.getElementById('JSTrustpilpt').onmouseout = '';
	
	document.getElementById('logolink').onclick = ''; document.getElementById('logolink').style.cursor = 'default'
	document.getElementById('kontaktlink1').href = 'http://www.lavprisvvs.dk/shop/external/kontakt/'; document.getElementById('kontaktlink2').href = 'http://www.lavprisvvs.dk/shop/external/kontakt/'; document.getElementById('kontaktlink3').href = 'http://www.lavprisvvs.dk/shop/external/kontakt/'; document.getElementById('kontaktlink4').href = 'http://www.lavprisvvs.dk/shop/external/kontakt/';
	document.getElementById('support').innerHTML = '';
	document.getElementById('JSlysoff').style.display = 'none';
	document.getElementById('JSlyson').style.display = 'none';
	}
}


//preload
LoadImg_104_30		= new Image();
LoadImg_104_30.src	= "/grafik/loader/loader-104-30.gif"
LoadImg_110_67		= new Image();
LoadImg_110_67.src	= "/grafik/loader/loader-110-67.gif"
LoadImg_90_70		= new Image();
LoadImg_90_70.src	= "/grafik/loader/loader-90-70.gif"
LoadImg_200_140		= new Image();
LoadImg_200_140.src	= "/grafik/loader/loader-200-140.gif"
LoadImg_310_160		= new Image();
LoadImg_310_160.src	= "/grafik/loader/loader-310-160.gif"
LoadImg_280_140		= new Image();
LoadImg_280_140.src	= "/grafik/loader/loader-280-140.gif"
LoadImg_150_170		= new Image();
LoadImg_150_170.src	= "/grafik/loader/loader-150-170.gif"
LoadImg_140_66 		= new Image();
LoadImg_140_66.src	= "/grafik/loader/loader-140-66.gif"
LoadImg_240_140 	= new Image();
LoadImg_240_140.src	= "/grafik/loader/loader-240-140.gif"
LoadImg_130_80	 	= new Image();
LoadImg_130_80.src	= "/grafik/loader/loader-130-80.gif"
LoadImg_129_67	 	= new Image();
LoadImg_129_67.src	= "/grafik/loader/loader-129-67.gif"

//Swap image
function swap(img,size)
{
	img.setAttribute("src", '/grafik/loader/loader-'+size+'.gif');
	img.style.border = "3px solid #fff";
}


// select all in textbox
function select_all()
{
	var text_val=eval("document.lpvform.Forespoergsel");
	text_val.focus();
	text_val.select();
}

//mail support
Date.prototype.add = function(iNum){
	var dTemp = this;
    dTemp.setMinutes(dTemp.getMinutes() + iNum);
	return dTemp;
}
function CheckSettings()
{	
	//FRAGTPRIS I KURV
	if(document.getElementById('kurvtekst').innerHTML == '0&nbsp;varer i kurven')
	{
		document.getElementById('FragtPris').innerHTML = 'Fragt: 0,00 DKK';
	}
	else
	{
		var TotalAmountKURV = parseFloat(document.getElementById('kurvpris').innerHTML.replace('DKK','').replace('.',''));
		var FragtKURV = parseFloat(document.getElementsByClassName('MethodFees_Basket_ShippingMethodFee_TD')[0].innerHTML.replace('DKK','').replace('.',''));
		document.getElementById('kurvpris').innerHTML = add_dot(TotalAmountKURV-FragtKURV) + ',00 DKK';
	}
	
	//SKJUL GEMTE VARER
	if(getCookie('DanDomainWebShop5Favorites')=='')
	{
		document.getElementById('midt').style.display = 'none';
	}

	//MAIL / CHAT / VIDSTE DU SIDEBAR
	var MailSvarRemaining = MailSvar;
	var d = new Date();
		var d2 = d.add(MailSvar);
		MailHours 	= d2.getHours()
		MailMinutes = d2.getMinutes()
		if(MailMinutes < 10)
		{
			MailMinutes = '0'+MailMinutes;
		}
	var vidsteduDIV = "";
	//var vidsteduDIV = "<div id=\"vidstedu\" onclick=\"location.href=('/shop/external/kundeservice/vidstedu.html');\"><div>"
	//					+"<p>&middot; <a href=\"#\">21 dages returret</a></p>"
	//					+"<p>&middot; <a href=\"#\">Tilfredshedsgaranti</a></p>"
	//					+"<p>&middot; <a href=\"#\">Hurtig levering</a></p>"
	//					+"<p>&middot; <a href=\"#\">Sikker betaling</a></p>	"				
	//					+"</div></div>";
	if(MailSvarFastTidspunkt != '')
	{
		var mailDIV = "<div id=\"mail\" onclick=\"popup(450,570,'/frontpage/kviksvarmail.asp','kviksvar');\"><div id=\"svar\">Vi besvarer dit spørgsmål inden </div>"
					+"<div id=\"MailSvar\">Kl. "+MailSvarFastTidspunkt+"</div>"
					+"<div id=\"starther\"><a href=\"#\" style=\"font-size:12px; font-weight:bold; color:#7493A7; text-decoration:underline\" onclick=\"popup(450,570,'/frontpage/kviksvarmail.asp','kviksvar');\" >Skriv til os</a></div>"
					+"</div>";
	}
	else if(MailSvar == "1440")
	{
		var mailDIV = "<div id=\"mail\" onclick=\"popup(450,570,'/frontpage/kviksvarmail.asp','kviksvar');\"><div id=\"svar\">Vi besvarer dit spørgsmål inden </div>"
					+"<div id=\"MailSvar\">24 timer</div>"
					+"<div id=\"starther\"><a href=\"#\" style=\"font-size:12px; font-weight:bold; color:#7493A7; text-decoration:underline\" onclick=\"popup(450,570,'/frontpage/kviksvarmail.asp','kviksvar');\" >Skriv til os</a></div>"
					+"</div>";
	}
	else if(MailSvar == "2880")
	{
		var mailDIV = "<div id=\"mail\" onclick=\"popup(450,570,'/frontpage/kviksvarmail.asp','kviksvar');\"><div id=\"svar\">Vi besvarer dit spørgsmål inden </div>"
					+"<div id=\"MailSvar\">48 timer</div>"
					+"<div id=\"starther\"><a href=\"#\" style=\"font-size:12px; font-weight:bold; color:#7493A7; text-decoration:underline\" onclick=\"popup(450,570,'/frontpage/kviksvarmail.asp','kviksvar');\" >Skriv til os</a></div>"
					+"</div>";
	}
	else
	{
		var mailDIV = "<div id=\"mail\" onclick=\"popup(450,570,'/frontpage/kviksvarmail.asp','kviksvar');\"><div id=\"svar\">Vi besvarer dit spørgsmål inden </div>"
					+"<div id=\"MailSvar\">Kl. "+MailHours+':'+MailMinutes+"</div>"
					+"<div id=\"starther\"><a href=\"#\" style=\"font-size:12px; font-weight:bold; color:#7493A7; text-decoration:underline\" onclick=\"popup(450,570,'/frontpage/kviksvarmail.asp','kviksvar');\" >Skriv til os</a></div>"
					+"</div>";
	}
	
	var chatDIV	= "<div id=\"chat\" onclick=\"javascript:window.open('https://server.iad.liveperson.net/hc/6855645/?cmd=file&file=visitorWantsToChat&site=6855645&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/&referrer='+escape(document.location),'chat6855645','width=475,height=400,resizable=yes');return false;\"><div id=\"svar\">Spørg os direkte!<br />Vi er <b>ONLINE</b><br /></div>"
					+"<div id=\"starther\"><a href=\"https://server.iad.liveperson.net/hc/6855645/?cmd=file&file=visitorWantsToChat&site=6855645&byhref=1&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/\" target=\"chat6855645\" style=\"font-size:12px; font-weight:bold; color:#73A72F; text-decoration:underline\" onclick=\"javascript:window.open('https://server.iad.liveperson.net/hc/6855645/?cmd=file&file=visitorWantsToChat&site=6855645&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/&referrer='+escape(document.location),'chat6855645','width=475,height=400,resizable=yes');return false;\" >Chat med os</a></div>"
					+"</div>";
	
	var spmDIV = "<div id=\"mail\" onclick=\"location.href ='/shop/external/kontakt/stilspm.asp'\"><div id=\"svar\" style=\"font-size:11px\">Har du et spørgsmål?</div>"
					+"<div id=\"starther\" style=\"padding-top:20px\"><a href=\"/shop/external/kontakt/stilspm.asp\" style=\"font-size:12px; font-weight:bold; color:#7493A7; text-decoration:underline\">Skriv til os</a></div>"
					+"</div>";
	
	if(MailOnline == 'True' && ChatOnline == 'False')
	{
		var innerDIV = mailDIV + vidsteduDIV;
	}
	else if(MailOnline == 'True' && ChatOnline == 'True')
	{
		var innerDIV = mailDIV + chatDIV;
	}
	else if(MailOnline == 'False' && ChatOnline == 'True')
	{
		var innerDIV = spmDIV + chatDIV;
	}
	else
	{
		var innerDIV = spmDIV + vidsteduDIV;
	}
	
	document.getElementById("support").innerHTML = innerDIV;
	
	//Vis chat i bund hvis chat online
	if(ChatOnline == 'True')
	{
		document.getElementById('chatbut').innerHTML = "<a href=\"https://server.iad.liveperson.net/hc/6855645/?cmd=file&file=visitorWantsToChat&site=6855645&byhref=1&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/\" target=\"chat6855645\" style=\"font-weight:normal; font-size:11px; color:#959698; text-decoration:none\" onclick=\"javascript:window.open('https://server.iad.liveperson.net/hc/6855645/?cmd=file&file=visitorWantsToChat&site=6855645&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/&referrer='+escape(document.location),'chat6855645','width=475,height=400,resizable=yes');return false;\" >Chat <span style=\"color:#48FF00\">(Online)</span></a>";
	}
	
}

//tjek om overvågning skal aktiveres
function TjekOvervaagning()
{
	
}


//vis gemte varer grafik i højre side
function VisGemteNy()
{
document.getElementById('midt').style.display = 'inline';
document.getElementById("midt").innerHTML = '<a href=\"/shop/favorites.html&Cookiesync=1\"><img src=\"/forsidegrafik/overall/se-gemte-varer-blink.gif\" /></a>';
}

//deaktiver købsfunktion ved top kurv
function DeaktiverKoeb()
{
if(document.getElementById('kurvtekst').innerHTML == '0&nbsp;varer i kurven')
	{	
	document.getElementById('kurvorder').innerHTML = '<div><img src="/forsidegrafik/koeb/top_step0.gif" alt="" /></div><div><img src="/forsidegrafik/koeb/indkobskurv-tom.gif"></div><div class="stepbottom"></div>';
	}
	else
	//SKIFT PRISER
	{
		var TotalAmount = parseFloat(document.getElementById('kurvpris').innerHTML.replace('DKK','').replace('.',''));
		var Fragt = parseFloat(document.getElementsByClassName('MethodFees_Basket_ShippingMethodFee_TD')[0].innerHTML.replace('DKK','').replace('.',''));
		document.getElementById('TotalAmount').innerHTML = add_dot(TotalAmount-Fragt) + ',00 DKK';
	}
}


//lukkede varer
function lukket(){
window.location = "/shop/"
}

//forside dias
function DiasNext(){
		if(ImageNumber ==  DiasCount-1){
			ImageNumber = 0
		}
		else{
			ImageNumber += 1
		}
		ShowDias(ImageNumber)
	}

	function DiasPrev(){
		if(ImageNumber ==  0){
			ImageNumber = DiasCount-1
		}
		else{
			ImageNumber -= 1
		}
		ShowDias(ImageNumber)
	}
	
	function ShowDias(ImageNumber){
		document.getElementById("DiasImg").src 			= DiasArray[ImageNumber][0];
		document.getElementById("DiasLnk1").href 		= DiasArray[ImageNumber][1];
		document.getElementById("DiasLnk2").href 		= DiasArray[ImageNumber][1];
		document.getElementById("DiasLnk2").innerHTML 	= DiasArray[ImageNumber][2];
		document.getElementById("Dias KUN").innerHTML 	= DiasArray[ImageNumber][3];
		document.getElementById("Dias SPAR").innerHTML 	= DiasArray[ImageNumber][4];
		document.getElementById("DiasLnk1").onclick = function() {TrackClick(DiasArray[ImageNumber][5]);return(false);}
		document.getElementById("DiasLnk2").onclick = function() {TrackClick(DiasArray[ImageNumber][5]);return(false);}
	}


//cookies
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 "";
}


//bruges til bgskift
function checkCookie()
{
	
	
	
	//BG
	bgcoockie=getCookie('lpvbg');
	if (bgcoockie=="on"){
		document.body.style.backgroundImage = "url(/grafik/bg_imgLight.gif)";
		document.body.style.backgroundColor = "#9EA8B1";}
}

function ChangeBG(action){
	if(action=='on'){
		document.body.style.backgroundImage = "url(/grafik/bg_imgLight.gif)";
		document.body.style.backgroundColor = "#9EA8B1";
		setCookie('lpvbg','on',100)}
	if(action=='off'){
		document.body.style.backgroundImage = "";
		document.body.style.backgroundColor = "";
		setCookie('lpvbg','off',1)}
}

//popup funktioner
function aabntilbud(){
	window.open('/kontakt/skaffeagent1.asp','mk2','height=680,width=500,location=no');
}

function popup(width, height, url, name){
	window.open(url,name,"width="+width+",height="+height);

}
function Presse(fil)  {
			window.open(fil,'popupomlpv','height=670,width=400,location=no');
			}	
function openwindow() {
	window.open("http://www.genmedia.dk/inc/visvideo.php?id=88","Genstream","toolbar=0,left=200,top=150,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=440,height=282");
	}
function Popup1(fil)  {
window.open(fil,'popup','height=680,width=680,location=no, scrollbars=yes');
}
function Gemte(fil)  {
window.open(fil,'popup1','height=520,width=425,location=no');
}
function PopupOnlineChat()  {
	window.open('http://www.lpv.dk/frontpage/chatpopupONLINE.asp','popup','height=350,width=300');
}
function PopupOfflineChat()  {
	window.open('http://www.lpv.dk/frontpage/chatpopupOFFLINE.asp','popup','height=500,width=400');
}

//fade på billeder
function fade(fadeout,fadeinn){
	if (fadeinn == 'in'){
	fadeout.style.MozOpacity = '0.5';
	fadeout.style.filter = 'alpha(Opacity=50)';
	}
	if (fadeinn == 'out'){
	fadeout.style.MozOpacity = '1';
	fadeout.style.filter = 'alpha(Opacity=100)';
	}
}

//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;
}

//højre ramme
 function TjekMail(whattodo){
	var whattodo;
	var pattern = /[0-9]/;
	var pattern_nr = /^[0-9]+$/;

	if (document.list.email.value=='Indtast e-mail'){
		alert("E-mail skal udfyldes");
		return;
		}
	var tekst=(document.list.email.value).toLowerCase();
		if(! tekst.match(/^\w(\.?\w)+@\w(\.?[-\w])+\.[a-z]{3}(?:\.[a-z,0-9]{1})?|[a-z,0-9]{1}\.[a-z]{2}/) ){
		alert ("Den indtastede email-adresse er ugyldig");
		return;
		}
		document.list.operator.name=whattodo;
		if(whattodo == "add")
		{
			var ajax = new sack();
			ajax.requestFile = '/nyhedsmail.asp?addMail='+document.list.email.value;
			ajax.runAJAX();
			document.getElementById('nyhedadd').innerHTML = "<img style=\"margin:30px 0px 0px 30px\" src=\"/grafik/overall/mailok.png\" />";
			
		}
		else
		{
			var ajax = new sack();
			ajax.requestFile = '/nyhedsmail.asp?Remove=TRUE&addMail='+document.list.email.value;
			ajax.runAJAX();
			document.getElementById('nyhedadd').innerHTML = "<img style=\"margin:30px 0px 0px 30px\" src=\"/grafik/overall/mailremove.png\" />";
		}
 }


//info beskeder
function visright(countright){
	var itmright = document.getElementById("overskrifterright");
	if (itmright){
		itmright.innerHTML = arrright[countright];
			if (countright < (arrright.length-1)){
			setTimeout("visright(" + (countright+1) + ");",tidright);
			} else {
			setTimeout("visright(0);",tidright);
		}
	}
}

//getURLParam til søgning
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;
}

//funktion getElementByClassname
document.getElementsByClassName = function(clsName)
{
    var retVal = new Array();
    var elements = document.getElementsByTagName("*");
    for(var i = 0;i < elements.length;i++){
        if(elements[i].className.indexOf(" ") >= 0){
            var classes = elements[i].className.split(" ");
            for(var j = 0;j < classes.length;j++){
                if(classes[j] == clsName)
                    retVal.push(elements[i]);
            }
        }
        else if(elements[i].className == clsName)
            retVal.push(elements[i]);
    }
    return retVal;
}


//funktion til at skifte købsknappen
function ChangeBuy(clsName,image)
{
    var retVal = new Array();
    var elements = document.getElementsByTagName("*");
    for(var i = 0;i < elements.length;i++){
        if(elements[i].className.indexOf(" ") >= 0){
            var classes = elements[i].className.split(" ");
            for(var j = 0;j < classes.length;j++){
                if(classes[j] == clsName)
                    retVal.push(elements[i]);
            }
        }
        else if(elements[i].className == clsName)
		elements[i].src = image;
            retVal.push(elements[i]);
    }
    return retVal;
}


	
//IBF mail
function SendIBF()
{
	var strErrorMsg='';
	var str 	= document.myform.str; str.style.background='';
	var postnr 	= document.myform.postnr; postnr.style.background='';
	var mail 	= document.myform.mail; mail.style.background='';
	var vn		= document.getElementsByClassName('Description_Productinfo')[1].innerHTML
	
	if(str.value == "") {str.style.background='#f7c1d4'; str.focus(); strErrorMsg+= '      * Antal m2 \n';}
	if(postnr.value == "") {postnr.style.background='#f7c1d4'; postnr.focus(); strErrorMsg+= '      * Postnr. \n';}
	if(mail.value == "") {mail.style.background='#f7c1d4'; mail.focus(); strErrorMsg+= '      * E-mail \n';}

	if (strErrorMsg != '') 
	{
		alert('Følgende felter er ikke udfyldt korrekt: \n\n'+strErrorMsg);
		return false;
	} 
	else
	{
		var ajax = new sack();
		ajax.requestFile = '/formular/operators/ibf.asp?str='+str.value+'&postnr='+postnr.value+'&mail='+mail.value+'&vn='+vn;
		ajax.runAJAX();
		window.location = "/shop/external/formular/tak.asp";
	}
	
}
	
//Formater pris
function add_dot(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1))
	{
		x1 = x1.replace(rgx, '$1' + '.' + '$2');
	}
    return x1 + x2;
}

