function valOrderLocal(form){
	var errorMsg = '';
	if (form.ssn){
		if (!isNumeric(form.ssn.value) || trim(form.ssn.value).length != 11 ){
			errorMsg += "\n- Ditt personnumer er ikke skrevet inn korrekt (11 nummer)";
		}		
	}
	if (trim(form.fname.value).length < 2 || trim(form.sname.value).length < 2){
		errorMsg += "\n- Ditt navn mangler";
	}
	if (trim(form.pcode.value).length < 4 || trim(form.city.value).length < 1){
		errorMsg += "\n- Postadressen er ikke fullstendig";
	}
	if (!validEmail(form.email.value)){
		errorMsg += "\n- E-postadressen er ikke korrekt";
	}
	if (trim(form.phone.value).length < 8){
		errorMsg += "\n- Mobilnummer mangler";
	}
	if (form.terms) {
		if (!form.terms.checked) {
			errorMsg += "\n- Vennligst bekreft at du har lest betingelsene";
		}
	}
	if (errorMsg != ""){
		msg = "Bestillingen kan ikke sendes:\n";
		msg += "__________________________________________\n";
		errorMsg += alert(msg + errorMsg + "\n\n");
		return false;
	}
	return true;
}

function emptyCart() {
  return confirm('Er du sikker på at du vil tømme handlekurven?');
}

function setShippingID(form){
	form.hidShippingID.value = form.selshipping.options[form.selshipping.selectedIndex].value;
	return true;
}

function printOrder(orderID,orderKey) {
	var printWin
	var w = 660
	var h = 600
	var winParam = "left=" + (screen.availWidth-10-w)/2 + ",top=" + (screen.availHeight-30-h)/2 + ",width="+w+",height="+h+",scrollbars=1,resizable=1,toolbar=1,location=0,status=0,menubar=0";
	if (!printWin || printWin.closed) {
		printWin = window.open('/common/print_order.asp?orderID='+orderID+'&key='+orderKey,'printWin',winParam)
	}
	printWin.focus()
}

function eshopTerms() {
	var termsWin
	var w = 800
	var h = 500
	var winParam = "left=" + (screen.availWidth-10-w)/2 + ",top=" + (screen.availHeight-30-h)/2 + ",width="+w+",height="+h+",scrollbars=1,resizable=1,toolbar=1,location=0,status=0,menubar=0";
	if (!termsWin || termsWin.closed) {
		termsWin = window.open('/common/terms_netshop.asp','termsWin',winParam)
	}
	termsWin.focus()
}

function getVariant(sel) {
	var form = document.frm_product
	var selVarID = (sel.options[sel.selectedIndex].value)
	if (!selVarID == "") {
		//document.location.href = window.location+'&variantID='+selVarID
	}
}

// DIBSWINDOW 
function dibsWin() {
	var newwin = null;
	var theHeight = 550
	var theWidth = 600
	var theTop = (screen.height/2)-(theHeight/2);
	var theLeft = (screen.width/2)-(theWidth/2);
	newwin = window.open('', 'paywin', 'left='+theLeft+',top='+theTop+',screenX='+theLeft+',screenY='+theTop+',width='+theWidth+',height='+theHeight+',menubar=0,toolbar=0,location=0,scrollbars=1,resizable=0');
	newwin.focus();
	return true;
}

jQuery(document).ready(function(){	
	if($("body").find("a[rel^='prettyPhoto']").length > 0) {
		$("a[rel^='prettyPhoto']").prettyPhoto({
			"default_width": 820,
			"default_height": 500,
			"opacity": 0.80,
			"theme": 'light_square'	
		});
	}

});
