   
   
   function icbpopup(url, windowoptions) {
	   if (windowoptions==null)
	   { windowoptions="width=600,height=500,toolbar=no,status=yes,scrollbars=yes,resizable=yes,menubar=no";
	   }
	    remote = window.open("","icbpopup",windowoptions); 
  	    remote.location.href=url;	
        remote.focus();
	}


   function icbbasketupdate(productid) {
       var q1 = 1;
	   if (document.basketform.qty.length>0)
	   {
         for (i=0;i<document.basketform.qty.length;i++) {
           if (document.basketform.product_id[i].value==productid) {
             q1 = document.basketform.qty[i].value;
           }
         }
	   } else {
		   q1 = document.basketform.qty.value;
	   }       
       var url = "control.php?_command=/BASKETUPDATE/" + productid + '/' + q1 +"/350";   	 
       document.location.href=url;	       
	}

   function icbbasketcheckout() {
       var vat='1';
	   var promocode='';
       if (document.basketform.outsideeu.checked)
       { vat='0';
       } 
       if (document.basketform.promotioncode.value!='')
       { promocode='/' + document.basketform.promotioncode.value;
       } 	   
       var url = "control.php?_command=/BASKETCHECKOUT/" + vat + "/351" + promocode;   
       document.location.href=url;
	       
	}

	function checkemail(myEmail) {
      if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myEmail)){
        return (true);
      }
      return (false);
    }
   

   function icbcallworldpay() {
       var email = document.checkoutform.email.value;
	   if (checkemail(email))
	   {  
         var vat='1';
	     var promocode='';
         if (document.checkoutform.vat.value!='')
         { vat=document.checkoutform.vat.value;
         } 
         if (document.checkoutform.promotioncode.value!='')
         { promocode='/' + document.checkoutform.promotioncode.value;
         } 
         var url = "control.php?_command=/BASKETCALLWORLDPAY/" + email + '/' + vat + promocode;   
         document.location.href=url;  
		 // alert(url);
	   }
	   else {
         alert("The email address given is not valid.\nPlease re-enter a valid email address.");
       }    	   
	}


	function checkproductcode(theProductCode) {
      if ((theProductCode > 10000000) && (theProductCode < 999999999)) 
	  {
        return (true);
      }
      return (false);
	}


    function icbgetregistrationcode(windowoptions) {
	   if (windowoptions==null)
	   { windowoptions="width=600,height=500,toolbar=no,status=yes,scrollbars=yes,resizable=yes,menubar=no";
	   }
	   if (checkproductcode(document.regcodeform.productcode.value))
	   {  
	    var url="/public/registrationcode.php?"+
		        "productid="+document.regcodeform.productid.value+
			    "&purchasetoken="+document.regcodeform.purchasetoken.value+
				"&email="+document.regcodeform.email.value+
				"&productcode="+document.regcodeform.productcode.value;
	    remote = window.open("","icbpopup",windowoptions); 
  	    remote.location.href=url;	
        remote.focus();
	   }
	   else {
         alert("The software product code that you entered is invalid.\n\nIt should be an 8 or 9 digit number that is shown when you run the program.\n\nIf in doubt, run the program and see Help->Registration Status");
       }  
	}

