function setCookie(name, value, expires, path, domain, secure) {  var curCookie = name + "=" + escape(value) +      ((expires) ? "; expires=" + expires.toGMTString() : "") +      ((path) ? "; path=" + path : "") +      ((domain) ? "; domain=" + domain : "") +      ((secure) ? "; secure" : "");  document.cookie = curCookie;}function getCookie(name) {  var dc = document.cookie;  var prefix = name + "=";  var begin = dc.indexOf("; " + prefix);  if (begin == -1) {    begin = dc.indexOf(prefix);    if (begin != 0) return null;  } else    begin += 2;  var end = document.cookie.indexOf(";", begin);  if (end == -1)    end = dc.length;  return unescape(dc.substring(begin + prefix.length, end));} function deleteCookie( name, path, domain ) {	if ( getCookie( name ) ) document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + 	( ( domain ) ? ";domain=" + domain : "" ) +";expires=Thu, 01-Jan-1970 00:00:01 GMT";}function saveBasket() {	var ref=parent.toppmeny	var shopping ="";	var tolong= false	if(ref.count>-1) {		for (var n =0; n <= ref.count; n++) {				if (shopping.length<2500){		    			shopping = shopping + ref.product[n].link + '\u00A3' + ref.product[n].name + '\u00A3' + ref.product[n].num + '\u00A3' + ref.product[n].img + '\u00A3' + ref.product[n].id + '\u00A3' + ref.product[n].type + '\u00A3' + ref.product[n].p1 + '\u00A3' + ref.product[n].p2 + '\u00A3' + ref.product[n].pcode     				    			shopping = shopping + '$'		    		}	 	}	 	shopping = shopping.substring(0, shopping.length-1); 		setCookie('Shop',shopping);	}	else { 		setCookie('Shop','');	}}function openBasket() {   var shop =getCookie("Shop");	if (shop!=null) {		if(shop.length>2500) {			alert("Ved relasting alle websidene, kan nettleseren din ha slettet noen av de siste varene i handlekurven. Vennligst sjekk etter!");		}		allproducts = shop.split('$');		for (var n=0;n<allproducts.length; n++) {			allitems = allproducts[n].split('\u00A3');			if(allitems[0]!="") {				importToBasket(allitems[0],allitems[1], allitems[2], allitems[3], allitems[4], allitems[5], allitems[6], allitems[7], allitems[8]);			}		}	displayShortBasket();//	parent.main.location.reload(true); JFL M\u00E5 den ha reload???  Firefox takler ikke denne?		}}function displayShortBasket(){	basket = window.open('','handlekurv');	 if(parent.location.host=="localhost") {     	path2 = "/supershop.nsf/";	     path3 ="/weblogin.nsf/";     }     else {     	path2 = "/supershop.nsf/";	     path3 ="/weblogin.nsf/";       }		var doc = basket.document;	doc.close();	var shopInput = sumBasket();	doc.open('text/html');	doc.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">');	doc.write('<html><head><title>Handlekurv</title><link rel="stylesheet" href="' + path2 + 'dgrstyle.css">');	doc.write('<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">');	doc.write('<meta http-equiv="expires" content="-1"><meta http-equiv="pragma" content="no-cache">');	doc.write('<meta http-equiv="Cache-Control" CONTENT="no-cache">');	doc.write('<script>history.forward();</script>');	doc.write('</head><body><div style="z-index:-10">');	doc.write('<img src="' + path2 +'handlekurv.gif" width="179" heigth="99"></div>');	doc.write('<div class="fontshop" style="margin-top:-78;margin-left:8"><div style="color:#46B9DE;"><b>HANDLEKURV</b></div><br>');	doc.write(sumBasket());	doc.write('</div>');	doc.write('<div style="margin-top:-55;margin-left:137" id="heart"><img src="' + path2 +'heart.gif" width="25" heigth="34"></div>');	doc.write('<script> var timerID = setTimeout("hideheart(\'heart\')",3000); function hideheart(id) { if(!document.getElementById)return;');	doc.write('var box=document.getElementById(id);box.className="box2_hidden";}</script>');	doc.write('</body></html>');	doc.close();}function setCustomer(name, member, unid) {	var name = name;	var member = member;	var unid = unid;	// set the new cookie	setCookie("dgr_customer", name + "$" + member + "$" + unid,0,'/', '.www.super-nature.no');}function deleteCustomer() {	deleteCookie('dgr_customer','/', '.www.super-nature.no') 	setPageStatus(0);}function getCustomer(num, msg) {	var customer= getCookie("dgr_customer");	if (customer != null  ) {		var index = customer.indexOf("$");		var name = customer.substring(0, index);			customer = customer.substring(index+1, customer.length);		index = customer.indexOf("$");		var member = customer.substring(0, index);		var unid = customer.substring(index+1, customer.length);		if (num=="1") {			return unid;		}		else if(num=="2") {			alert(member);		}		else if(num=="3") {			  window.open(unid, 'main');		}		else if(num="4") {			document.write('<div class="contentsubheader">Du er allerede p\u00E5logget</div>');			document.write('<div class="contentleftbox">Du har allerede logget deg inn. <a class="red" href="' + unid + '" target="main">Klikk her</a> for \u00E5 g\u00E5 til din side </div>')		}	}	else if( num=="3"){		if(msg=="1") {			alert("Logg inn for \u00E5 f\u00E5 tilgang til din side!");		}		if (location.host=="localhost") {			var link ="http://localhost/Weblogin.nsf/frmLogin?OpenForm";			 window.open(link, 'main');		}		else {			var link = "http://" + location.hostname + "/weblogin.nsf/frmLogin?OpenForm";			 window.open(link, 'main');		}	}}function Product(link, name, id, type, num, p1, p2, pcode, img){	this.link =link;	this.name=name;	this.id = id;	this.type=type;	this.num=num;		this.p1=p1;	this.p2=p2;	this.pcode = pcode;	this.img = img;}function emptyBasket(total) {	var ref= parent.toppmeny;	ref.count =-1;	ref.dgrdis =0;	ref.dgrspdis=0;	if(total==true) {		setCookie('Shop','');		displayShortBasket();	}}function importToBasket(link, name, num, img, id, type, p1, p2, pcode){	var ref= parent.toppmeny	ref.product[++ref.count] = new Product(link, name, id, type, num, p1, p2, pcode, img);}function addToBasket(link, name, num, img, id, type, p1, p2, pcode){   	if( type==null) {		var res = id;		var index = res.indexOf("$");		var id = res.substring(0, index);			res = res.substring(index+1, res.length);		index = res.indexOf("$");		var type = res.substring(0, index);		res = res.substring(index+1, res.length);		index = res.indexOf("$");		var p1 = res.substring(0, index);		res = res.substring(index+1, res.length);		index = res.indexOf("$");		var p2 = res.substring(0, index);		var pcode = res.substring(index+1, res.length);	}	ref= parent.toppmeny	var found = false;		for (var n =0; n <= ref.count; n++) {	 if(id+type==ref.product[n].id+ref.product[n].type) {		ref.product[n].num = eval(ref.product[n].num) + eval(num);		found = true; 		 }	}	if(found==false) {		ref.product[++ref.count] = new Product(link, name, id, type, num, p1, p2, pcode, img);	}	displayShortBasket();	if (ref.backstatus==true) {		displayBasketWindow();	}}function displayBasketWindow(){	if (location.host=="www.super-nature.no") {			var link = "http://" + location.hostname + "/weblogin.nsf/frmShoppingBasket?OpenForm";			 window.open(link, 'main');	}	else {		var link ="http://localhost/weblogin.nsf/frmShoppingBasket?OpenForm";		 window.open(link, 'main');	}}function alternate(row) {	 if(row % 2 == 0){ 	 	return "#F5F9F1";     }else{        	return "#FFFFFF";     }       }function isNumeric(sText){   var ValidChars = "0123456789.";   var IsNumber=true;   var Char;   for (i = 0; i < sText.length && IsNumber == true; i++) {       Char = sText.charAt(i);       if (ValidChars.indexOf(Char) == -1)  {         IsNumber = false;         }      }   return IsNumber;   }function sumBasket(){	var ref= parent.toppmeny	var sumtotal =0;	var sumnum=0;	for (var n =0; n <= ref.count; n++) {	     var price = (ref.product[n].p2 != "") ? ref.product[n].p2 : ref.product[n].p1;	     var sumtotal =  sumtotal + parseFloat(price * ref.product[n].num) ;		var sumnum =  sumnum + parseFloat(ref.product[n].num) 	 }	return "Antall varer: " + sumnum + "<br><br>Totalt kr: " + sumtotal;}function openWindow(page) {	var path = (this.location.host =="localhost")?"":""	var url = "http://" + this.location.host + path +"/supershop.nsf/docs/";	window.open(url +page,"main");}function updateBasket(form) {	var ref = parent.toppmeny	//update number	for (var i=0; i<form.length; i++) {		var item = form.elements[i]		var index = item.name.indexOf("_");		var id = item.name.substring(index+1, item.name.length);		if(item.name.substring(0, index)=="num") {			if(isNumeric(item.value)==true) {				if(item.value != ref.product[eval(id)].num) {					ref.product[eval(id)].num =item.value;				}			}			else {					alert("Du kan kun oppgi tall i feltene for antall!");			}		}	}		//remove items	for (var i=form.length-1; i>=0; i--) {		var item = form.elements[i]		var index = item.name.indexOf("_");		var id = item.name.substring(index+1, item.name.length);		if(item.name.substring(0, index)=="rem") {			if(item.checked==true) {				removeItem(eval(id));			}		}	}	displayShortBasket();	if(ref.count==-1) {		displayBasketWindow(); //rettet		setPageStatus(0);	}	else {		this.location.reload(true);		setPageStatus(1);	}}function removeItem(id) {	var ref = parent.toppmeny	for (var n =id; n < ref.count; n++) {		ref.product[n].link = ref.product[n+1].link;		ref.product[n].name = ref.product[n+1].name;		ref.product[n].id = ref.product[n+1].id;		ref.product[n].type = ref.product[n+1].type;	   ref.product[n].num =ref.product[n+1].num;		ref.product[n].p1=ref.product[n+1].p1;		ref.product[n].p2=ref.product[n+1].p2;		ref.product[n].pcode = ref.product[n+1].pcode;		ref.product[n].img = ref.product[n+1].img;	  }	   ref.product[ref.count].link ="";	   ref.product[ref.count].name ="";	   ref.product[ref.count].id ="";	   ref.product[ref.count].type ="";	   ref.product[ref.count].num ="";	   ref.product[ref.count].p1 ="";	   ref.product[ref.count].p2 ="";	   ref.product[ref.count].pcode ="";	   ref.product[ref.count].img ="";		ref.count = ref.count - 1;}function setPageStatus(status) { parent.toppmeny.pagestatus = status;}function getPageStatus() {	return parent.toppmeny.pagestatus;}function displayHeader(active, docflag) {	if(parent.toppmeny.count !=-1 || active=="6") {		var display ='<br><div style="color:#46B9DE;">';		var img1 = (docflag==true)? '<img src="../' :  '<img src="';		var img2 = ' width="27" heigth="44" align="middle" style="margin-top:-10;margin-left:10"> ';		var img3 = ' width="27" heigth="44" align="middle" style="margin-top:-10;"> ';		for (var i=1; i<=6;i++) {			display = (eval(active==i))? display + img1 + 'b' + i + 'n.gif"': display + img1 + 'b' + i + 'w.gif"';		 	display = (i==1)? display + img3: display +img2;			 	display = (eval(active)==i)? display + "<b>": display ;	 		display = (i==1)? display + "Handlekurv": (i==2)? display + "Innlogging" : (i==3)? display + "Levering": (i==4)? display + "Godkjenning" : (i==5)? display + "Betaling" : display + "Kvittering"		 	display = (eval(active)==i)? display + "</b>": display;		}		display = display + '</div>'		document.write(display);		}}function displayBasket(option) {	//displayShortBasket();	var ref= parent.toppmeny	var path = (this.location.host =="localhost")?"":""	var url = "http://" + this.location.host + path +"/supershop.nsf/docs/";	var sumtotal =0;	var payment =0;	var discount =0;	var discount2=0;	var dgrdis =0;	var dgrdis2 =0;	var dgrspdis=0;	var dgrspdis2=0;	var shopping="";	if (option=="1"){ //shopping basket			document.write('<div style="width:550;float:left;;background-color:#E2F2D8;heigth:10px;padding:2 0 2 0">');			document.write('<b style="padding-left:10">Din handlekurv har f\u00F8lgende innhold: </b></div>');			document.write('<div style="width:548;float:left;border:1px solid #E2F2D8;">');	}	else if(option=="6") { //payment window			document.write('<div style="width:550;float:left;;background-color:#E2F2D8;heigth:10px;">');			document.write('<b style="padding-left:10">Sum ordre til betaling</b></div>');			document.write('<div style="width:548;float:left;;border:1px solid #E2F2D8;">');	}	else {			document.write('<div style="width:550;float:left;;background-color:#E2F2D8;heigth:10px;">');			document.write('<b style="padding-left:10">Din ordre har f\u00F8lgende innhold: </b></div>');			document.write('<div style="width:548;float:left;;border:1px solid #E2F2D8;">');	}	  if (ref.count>-1 ) { 			if(option=="4" || option=="5") { //display order window for members and non members			document.write('<div style="width:548;float:left;"><div style="width:230; float:left;"><b style="padding-left:10">Beskrivelse</b></div>');			document.write('<div style="width:138;float:left"><b>Type</b></div>');				document.write('<div style="width:40;float:left"><b>Antall</b></div><div style="width:65;float:left;text-align:right"><b>Pris</b></div>');			document.write('<div style="width:75;float:left;text-align:right;"><b style="padding-right:10">Sum</b></div></div>')	 	 	  	}	  	else if(option=="6") { //display payment window - nothing here. No spesifications	  	}	  	else { //display spesification headings	  		document.write('<div style="width:548;float:left;"><div style="width:60;float:left;">&nbsp;</div><div style="width:260;float:left"><b>Beskrivelse</b></div>');				document.write('<div style="width:40;float:left"><b>Antall</b></div><div style="width:65;float:left;text-align:right"><b>Pris</b></div>');			document.write('<div style="width:65;float:left;text-align:right"><b>Sum</b></div><div style="width:58;float:left;text-align:center"><b>Fjern</b></div></div>');			}		for (var n =0; n <= ref.count; n++) {			shopping = shopping +  ref.product[n].link + '\u00A3' + ref.product[n].name + '\u00A3' + ref.product[n].num + '\u00A3' + ref.product[n].img + '\u00A3' + ref.product[n].id + '\u00A3' + ref.product[n].type + '\u00A3' + ref.product[n].p1 + '\u00A3' + ref.product[n].p2 + '\u00A3' + ref.product[n].pcode +'$'		     var price = (ref.product[n].p2 != "") ? ref.product[n].p2 : ref.product[n].p1;			var sum = parseFloat(price * ref.product[n].num) ;			sumtotal = sumtotal + sum;			discount2=0;			dgrdis2=0;			dgrspdis2=0;			if(ref.product[n].pcode =="10") { //Internettmedlemsrabatt				dgrdis2 = ((eval(ref.product[n].p1)*10/100) * eval(ref.product[n].num));			}			else if(ref.product[n].pcode!="") { //DGR spesialprisrabatt				dgrspdis2 = ((eval(ref.product[n].p1)* eval(ref.product[n].pcode)/100) * eval(ref.product[n].num));			}						if(ref.product[n].p2!="") { //DGR tilbudsrabatt - til alle				discount2 = ((eval(ref.product[n].p1)- eval(ref.product[n].p2)) * eval(ref.product[n].num));				discount = discount + discount2;  //akkumuler								if(dgrspdis2>discount2) {  //Medlemsrabatt er st\u00F8rre enn tilbud					dgrspdis = dgrspdis + (dgrspdis2 - discount2);				}				else if(dgrdis2>discount2) {   //Medlemsrabatt er st\u00F8rre enn tilbud					dgrdis = dgrdis + (dgrdis2 - discount2);				}							}			else {				if(dgrdis2>0) {					dgrdis = dgrdis + dgrdis2;				}				else if(dgrspdis2>0) {					dgrspdis = dgrspdis + dgrspdis2;				}			}								 	if(option=="4" || option=="5") { //4 is display for members and 5 is for non members		 		document.write('<div style="width:548px;float:left; background-color:' + alternate(n) + ';">');		 		document.write( '<div style="width:230px;float:left;heigth:35px;"><div style="padding-left:10">'+ref.product[n].name + '<br><div class="fontgreen">' +ref.product[n].id + '</div></div></div>');				document.write('<div style="width:138px;float:left;heigth:35px">' + ref.product[n].type + '</div>');							document.write('<div style="width:40px;float:left;heigth:35px">' + ref.product[n].num + '</div>');				document.write('<div style="width:65px;float:left;heigth:35px;text-align:right;">' +((ref.product[n].p2 != "") ? '<b class="priceredbg">' + ref.product[n].p2 +'</b><br>' + ref.product[n].p1: ref.product[n].p1) +'</div>');					document.write('<div style="width:75px;float:left;heigth:35px;text-align:right;"><div style="padding-right:10">'  + sum + '</div></div>');				document.write('</div>');			 	}		 	else if(option=="6") { //do not show items in payment window. 			}		 	else {		 		document.write('<div style="width:548px;float:left; background-color:' + alternate(n) + ';">');				if (ref.product[n].img !="") {					document.write('<div style="width:60px;float:left"><img src="' +url +ref.product[n].link +'/$file/' + ref.product[n].img+ '" height=50 width=50></div>' );					}				else {					document.write('<div style="width:60px;float:left;">&nbsp;</div>' );					}		 		document.write( '<div style="width:260px;float:left;heigth:50px;"><a href="' + url + ref.product[n].link + '">'+ref.product[n].name + "</a><br>"); 				document.write( '<div class="fontgreen">' +ref.product[n].id + "<br>" + ref.product[n].type + '</div></div>');							document.write('<div style="width:40px;float:left;heigth:50px"><input type="text" class="fontsize" name="num_' + n + '" size="2" value="' + ref.product[n].num + '"></div>');				document.write('<div style="width:65px;float:left;heigth:50px;text-align:right;">' +((ref.product[n].p2 != "") ? '<b class="priceredbg">' + ref.product[n].p2 +'</b><br>' + ref.product[n].p1: ref.product[n].p1) +'</div>');					document.write('<div style="width:65px;float:left;heigth:50px;text-align:right;">'  + sum + '</div>');				document.write('<div style="width:58px;float:left;heigth:50px;text-align:center;"><input type="checkbox" name="rem_' + n + '">' + '</div>');				document.write('</div>');				}		}		//export string	 	shopping = shopping.substring(0, shopping.length-1);		ref.dgrexport = shopping;					//part 4		if(option=="4" || option=="5" || option=="6") {			if (option=="4") {				ref.ismember=true;			}			else if(option=="5") {				ref.ismember=false;			}			document.write('<div style="width:548;float:left;text-align:right;background-color:#ffffff;padding:1 0;margin-bottom:1"><div style="width:463;float:left">');			document.write('<b>Totalt:</b></div><div style="width:85;float:right;"><b style="padding-right:10;color: #46B9DE;">' + sumtotal + '</b></div></div>');			payment = sumtotal;							if (option=="4" || ref.ismember==true) {				if (ref.post>0) {					if (payment>=2500) {						document.write('<div style="width:548;float:left;text-align:right;padding: 2 0"><div style="width:463;float:left">');						document.write('Forsendelse gratis superkundehandel over 2500 kr:</div><div style="width:85;float:right"><div style="padding-right:10">0</div></div></div>');					}					else {						document.write('<div style="width:548;float:left;text-align:right;padding: 2 0"><div style="width:463;float:left">');						document.write('Forsendelse:</div><div style="width:85;float:right"><div style="padding-right:10">' + ref.post + '</div></div></div>');						payment = payment + ref.post;					}				}						if(dgrdis>0) {					document.write('<div style="width:548;float:left;text-align:right;padding: 2 0"><div style="width:463;float:left">');					document.write('Sum medlemsrabatt:</div><div style="width:85;float:right;color:#FF0D00"><div style="padding-right:10">- ' + Math.round(dgrdis) + '</div></div></div>');					payment = payment - Math.round(dgrdis);					ref.dgrdis = Math.round(dgrdis);				}				if (dgrspdis>0) {					document.write('<div style="width:548;float:left;text-align:right;padding: 2 0"><div style="width:463;float:left">');					document.write('Sum spesial medlemsrabatt:</div><div style="width:85;float:right;color:#FF0D00"><div style="padding-right:10">- ' + Math.round(dgrspdis) + '</div></div></div>');					payment = payment - Math.round(dgrspdis);					ref.dgrspdis=Math.round(dgrspdis);				}				}			else {				if (ref.post>0) {					document.write('<div style="width:548;float:left;text-align:right;padding: 2 0"><div style="width:463;float:left">');					document.write('Forsendelse:</div><div style="width:85;float:right"><div style="padding-right:10">' + ref.post + '</div></div></div>');					payment = payment + ref.post;				}					}			document.write('<div style="width:548;float:left;text-align:right;background-color:#E2F2D8;padding: 1 0"><div style="width:463;float:left">');			document.write('<b>\u00C5 betale:</b></div><div style="width:85;float:right"><b style="padding-right:10;color: #46B9DE;"><div style="padding-right:10">' + payment+ '</div></b></div></div>');			document.write('</div>');				if(option=="4" || option=="5") {				ref.sumtotal=Math.round(payment);			}		}				else {				document.write('<div style="width:548; float:left;background-color:#E2F2D8;">');			document.write('<div style="width:364;float:left;text-align:right"><input type="button" name="oppdater" value="oppdater" onclick="updateBasket(this.form)" class="btnred"></div>');			document.write('<div style="width:184;float:left;text-align:right;padding-top:3"><b style="font: 1.0em;color: #46B9DE;padding:0 45 0 13;font-weight: bold;">Totalt: ' + sumtotal + ' kr</b></div></div>');					document.write('<div style="width:548; float:left;text-align:right;padding:10 0 0 0"><div style="padding-right:48">');			if (option=="3") {				if(dgrdis>0) {					document.write('Sum internettrabatt (kun for medlemmer): - ' + Math.round(dgrdis)+' kr<br>');				}				if (dgrspdis>0) {					document.write('Sum spesialrabatt utvalgte varer (kun for medlemmer): - ' + Math.round(dgrspdis)+' kr<br>');				}			}			if (discount>0) {				document.write('<div class="fontgreen">Sum tilbudsrabatter (er fratrukket): ' + discount + ' kr</div>');			}			document.write('<br></div></div></div>');			  					if (option=="1") {			document.write('<div style="width:548; float:left;text-align:right;padding:15 0 0 0">');			document.write('<div style="float:left" onclick="this.style.visibility=\'hidden\';">');				if (ref.backstatus==true) {					document.write('(<a href="#" onclick="parent.toppmeny.backstatus=false;">Sl\u00E5 av automatisk visning av handlekurv</a>)');				}				else {				document.write('(<a href="#" onclick="parent.toppmeny.backstatus=true;" >Sl\u00E5 p\u00E5 automatisk visning av handlekurv</a>)');				}			document.write('</div>');			document.write('<input type="button" name="handle" value="Fortsett \u00E5 handle" onclick="openWindow(\'055101\')" class="btnred"> ');			  					document.write('<input type="button" name="kasse" value="Fortsett til kasse" onclick="getNextLevel(2)" class="btnred">');					document.write('</div>');			  								}		}		}	else { 				document.write('<div style="width:548; float:left;"><div style="padding-left:10"><br>Din handlekurv er tom<br><br></div></div></div> ');				if(option=="1") {				document.write('<div style="width:548; float:left;text-align:right;padding:15 0 5 0"><input type="button" name="handle" value="Fortsett \u00E5 handle" onclick=openWindow("055101") class="btnred"></div>');			  						}	}}function MakeArray(n) {	this.length = n;	for (var i =1; i<=n;i++) {		this[i]=0;	}	return this;}