function logout(strPageId) {
	var strUrl = window.location;
	if(strUrl.search.length==0) {
		strUrl += "?";
	} else {
		strUrl += "&";
	}
	strUrl += "logintype=logout";
	window.location = strUrl;
}

function fixLoginForm() {
	document.getElementById("user").className = "logininput";
	if (document.getElementById("user").value == "") {
		document.getElementById("user").value="Brugernavn";
	}
	
	objPasswordOld = document.getElementById("pass");
	var objPassword = document.createElement('input');
	objPassword.setAttribute('type','text');
	objPassword.setAttribute('class','logininput');
	objPassword.setAttribute('id','pass');
	objPassword.setAttribute('name','pass');
	
	if (objPasswordOld.value == "") {
		objPassword.setAttribute('value','Password');
	} else {
		objPassword.setAttribute('value',objPasswordOld.value);
	}
	objPasswordOld.parentNode.appendChild(objPassword);
	objPasswordOld.parentNode.removeChild(objPasswordOld);
	document.getElementById("pass").className = "logininput";
	
	var objSubmitContentOld = document.getElementById("logincontent").getElementsByTagName("input")[2];
	var objSubmit = document.createElement('input');
	objSubmit.setAttribute('name','submit');
	objSubmit.setAttribute('value','submit');
	objSubmit.setAttribute('type','image');
	objSubmit.setAttribute('src','fileadmin/system/login-button-top.png');
	objSubmit.setAttribute('width','20');
	objSubmit.setAttribute('height','14');
	objSubmit.setAttribute('alt','Login');
	objSubmitContentOld.parentNode.appendChild(objSubmit);
	objSubmitContentOld.className = "hiddenbutton";
	document.getElementById("logincontent").getElementsByTagName("input")[3].className = "loginbutton";
}
function changeOrderformAction(strId,strUrl) {
	// Ændrer formaction på listevisning, så læg i kurv redirecter til kurv efter varen er lagt i kurv.
	document.getElementById('orderform' + strId).action = strUrl;
}

function checkEmail(strEmail){	
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(strEmail)){         
		return true;   
    } else {   
		return false; 
    }
}
function validateCartCustomer() {
	var intErrorCount = 0;
	var strErrorMessage = "Udfyld venligst alle felter markeret med *";
	document.getElementById("billing_name").className = "";
	document.getElementById("billing_address").className = "";
	document.getElementById("billing_zip").className = "";
	document.getElementById("billing_city").className = "";
	document.getElementById("billing_country").className = "";
	document.getElementById("billing_email").className = "";
	document.getElementById("delivery_agb").parentNode.className = document.getElementById("delivery_agb").parentNode.className.replace(/ inputerror/,"");
	
	if (document.blnValidate == true) {
		if(document.getElementById("billing_name").value.length == 0) {
			document.getElementById("billing_name").className = "inputerror";
			intErrorCount ++;
		}
		if(document.getElementById("billing_address").value.length == 0) {
			document.getElementById("billing_address").className = "inputerror";
			intErrorCount ++;
		}
		if(document.getElementById("billing_zip").value.length == 0) {
			document.getElementById("billing_zip").className = "inputerror";
			intErrorCount ++;
		}
		if(document.getElementById("billing_city").value.length == 0) {
			document.getElementById("billing_city").className = "inputerror";
			intErrorCount ++;
		}
		if(document.getElementById("billing_country").value.length == 0) {
			document.getElementById("billing_country").className = "inputerror";
			intErrorCount ++;
		}
		if(document.getElementById("billing_email").value.length == 0) {
			document.getElementById("billing_email").className = "inputerror";
			intErrorCount ++;
		} else {
			if (checkEmail(document.getElementById("billing_email").value) == false) {
				if (intErrorCount == 0) strErrorMessage = "";
				intErrorCount ++;
				strErrorMessage += "\nIndtast venligst en gyldig e-mail";
				document.getElementById("billing_email").className = "inputerror";
			}
		}
		if(document.getElementById("delivery_agb").checked == false) {
			document.getElementById("delivery_agb").parentNode.className = document.getElementById("delivery_agb").parentNode.className + " inputerror";
			if (intErrorCount == 0) strErrorMessage = "";
			strErrorMessage += "\nDu mangler at acceptere vores salgsbetingelser.";
			intErrorCount ++;
		}
		if (intErrorCount != 0) {
			alert(strErrorMessage);
			return false;
		}
	}
}
function formatPriceForStats(strPrice) {
	strPrice = strPrice.replace(/\./,"");
	strPrice = strPrice.replace(/,/,".");
	return strPrice;
}
function formatTextForStats(strText) {
	strText = strText.replace(/&aelig;/, "æ");
	strText = strText.replace(/&oslash;/, "ø");
	strText = strText.replace(/&aring;/, "å");
	strText = strText.replace(/&AElig;/, "Æ");
	strText = strText.replace(/&Oslash;/, "Ø");
	strText = strText.replace(/&Aring;/, "Å");
	return strText;
}
