
	// callbackfunction 	
	function do_updatecart_cb(z) {
		document.getElementById("shoppingcart").innerHTML = z;
	}
	
	// add productid to cart.  modus is add or replace
	function addtocart(productid, modus){
	 var amount, productid;
	 amount = document.getElementById("productamount" + productid).value;
 	 amount = parseInt(amount);
	 var altn, altselected="";
	 try{		
	   altn = document.getElementById("alternatives" + productid);
           altselected = altn.options[altn.selectedIndex].value;
           if(altselected == "undefined"){altselected ="";}
	 }	
	 catch(e){ }
	 x_addtocart(amount, productid, altselected, modus, do_updatecart_cb);
	}



	function printcart(){
	 x_printcart(do_updatecart_cb);
	}

	function deletefromcart(id, alternative){
	   x_deletefromcart(id, alternative, do_updatecart_cb);
         }	

	// start up by printing out the contents of the cart
	// this makes the user see what he has put in his cart thus far.




function submitform(version){
 if(validateform(version)){
//    document.checkoutform["do"].value="confirmorder";
    document.checkoutform.submit();
	return true;
	 }
	else return false;
}

function validateform(version){
 var errs=0;
 if(!validateEmail(document.forms.checkoutform.email, 'emailvalid', true))errs +=1;
 if(!validatePresent(document.forms.checkoutform.firstname, 'firstnamevalid')) errs +=1;	
 if(!validatePresent(document.forms.checkoutform.lastname, 'lastnamevalid')) errs +=1;	
 if(!validatePresent(document.forms.checkoutform.phone, 'phonevalid')) errs +=1;	
 if(!validatePresent(document.forms.checkoutform.address, 'addressvalid')) errs +=1;	
 if(!validatePresent(document.forms.checkoutform.zipcode, 'zipcodevalid')) errs +=1;		
 if(!validatePresent(document.forms.checkoutform.city, 'cityvalid')) errs +=1;	

 if (version != 110 && version != 112) {
 if(!validatePresent(document.forms.checkoutform.pass1, 'pass1valid')) errs +=1;		
 if(!validatePresent(document.forms.checkoutform.pass2, 'pass2valid')) errs +=1;	
 }
 return ( errs == 0 );
}


function openKontakt(msg, gebyr) {


 var betalingmate = document.getElementById('betalingmate');
 document.getElementById('gebyr').value = gebyr;
 switch (msg) {
  case 'postoppkrav':

   betalingmate.value = "Postoppkrav";  
   break;
  case 'faktura':

   betalingmate.value = "Faktura";
   break;
  case 'forhand':

   betalingmate.value = "Forhandsbetaling";
   break;
  default:
   betalingmate.value = msg;
  break;
 }

document.checkoutform["do"].value="confirmorder";
document.checkoutform.submit();
}


function updatecart(){

/* 
 productarray = getorder();
 alert('update');
 x_update_cart(productarray, do_confirmation_cb); 
*/

   document.checkoutform.submit();
}

function deletefromcart(id){
  document.getElementById(id).value= 0;
  document.checkoutform.submit();

}

