
	function popupWindow(url, title) {
		//window.open (url, title,"status=0,toolbar=0");
		window.open (url, title, 'scrollbars=yes, menubar=no, height=240, width=480, resizable=yes, toolbar=no, location=no, status=no');
	}

	function popupWindowCustom(url, title, width, height) {
		y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;	
        window.open (url, title, 'scrollbars=0, menubar=0, height='+height+', width='+width+', resizable=0, toolbar=0, location=no, status=no ,left = '+x+',top = '+y+'');
	}

	function swapimage(url,height,width){
		var preload = new Image;
		preload.src = url;
		//fulkod f?r att ie inte hanterar laddning r?tt
		pause(500);
		var obj = document.getElementById('galleryimage');
		obj.height = height;
		obj.width = width;
		obj.src = url;
	}
	
    function pause(numberMillis) {
        var now = new Date();
        var exitTime = now.getTime() + numberMillis;
        while (true) {
            now = new Date();
            if (now.getTime() > exitTime)
            return;
        }
	}
	
	function checkVariation(formId) {
		if (document.forms[formId].identifier.value == "null") {
			alert("Dette produktet har flere variasjonsm"+unescape("%E5")+"ter. Velg en variasjon og klikk s"+unescape("%E5")+" p"+unescape("%E5")+" 'Legg i handlekurv'-knappen.");
			return false;
		} else {
			return true;
		}
	}
	
	function searchProduct(searchField) {
		if (searchField.value.length < 3) {
			alert("S"+unescape("%F8")+"keordet m"+unescape("%E5")+" inneholde minst 3 tegn!");
			return false;
		} else {
			return true;
		}
	}	

	function checkCreditCard() {
		alert("checkCreditCard");
		for (i = 0; i < document.forms[0].creditCardType.length; i++) {
			if (document.forms[0].creditCardType[i].checked == true) {
				return true;
			}
		}
		alert("Du m"+unescape("%E5")+" velge et kredittkort f"+unescape("%F8")+"r du g"+unescape("%E5")+"r videre.");
		return false;
	}
	
	function checkPaymentMethod() {

		var shippingRet = false;
		var paymentRet = false;
	
		for (i = 0; i < document.forms[0].shippingMethod.length; i++) {
			if (document.forms[0].shippingMethod[i].checked == true) {
				shippingRet = true;
			}
		}
		
		for (i = 0; i < document.forms[0].paymentMethod.length; i++) {
			if (document.forms[0].paymentMethod[i].checked == true) {
				paymentRet = true;
			}
		}
		
		if (shippingRet && paymentRet) {
			return true;
		} else {
			if (shippingRet == false && paymentRet == false) {
				alert("Du m"+unescape("%E5")+" velge frakt- og betalingsm"+unescape("%E5")+"te f"+unescape("%F8")+"r du g"+unescape("%E5")+"r videre til neste steg.");
			} else if (paymentRet == false) {
				alert("Du m"+unescape("%E5")+" velge en betalingsm"+unescape("%E5")+"te f"+unescape("%F8")+"r du g"+unescape("%E5")+"r videre til neste steg.");
			} else if (shippingRet == false) {
				alert("Du m"+unescape("%E5")+" velge frakt f"+unescape("%F8")+"r du g"+unescape("%E5")+"r videre til neste steg.");
			} else {
				alert("Should not happen...");
			}
			return false;
		}
	}
	
	function setOrderDispatch(action) {
		document.forms[0].dispatch.value=action;
	}
	
	function updateShoppingCart() {
		document.forms[0].dispatch.value="updateShoppingCart";
		return true;
	}

	function removeFromShoppingCart(cartItemId) {
		document.forms[0].dispatch.value="removeFromShoppingCart";
		document.forms[0].shoppingCartItemId.value=cartItemId;
		return true;
	}

	function emptyShoppingCart() {
		document.forms[0].dispatch.value="emptyShoppingCart";
		
		return true;
	}

	function reloadFrames() {
		//window.document.shoppingCart.location.reload();
		//window.document.content.location.reload();
		//parent.shoppingCart.location.reload();
		//parent.content.location.reload();
		//top.frames['shoppingCart'].location.reload();
		//top.frames['shoppingCart'].location.reload();
		//top.frames['content'].location.reload();
		top.frames['shoppingCart'].location.href="/shoppingCart.do"
		//top.frames['content'].location.reload();
	}
	
	function confirmDeleteAccount() {
		if (confirm("Vil du virkelig avslutte din konto? Denne handlingen kan ikke angres.")) {
			return true;
		}
		else {
			return false;
		}						
	}		
		