
function reLoadPage(){
  var MBmanufacturer = document.forms.orderform.MotherboardManufacturer.value;
	  self.location.href='index.cfm?brcid=onlineorder&mbid='+MBmanufacturer;
     }
  
function createFields(){
  var paymentType = document.forms[0].PaymentType.value;
	  self.location.href='index.cfm?brcid=checkout&paymenttype='+paymentType;
     }

 
 function setSelecttoValue(){
   var s = window.location.search;
   var MBmanufacturer = document.forms.orderform.MotherboardManufacturer;
   var idx = s.indexOf("mbid");
 	  if(idx > -1) {
   var idx2 = s.indexOf("&",idx);
 	  if(idx2 == -1) idx2 = s.length;
   var blahval = s.substring(idx,idx2);
   var blahval = blahval.slice(5);
   var sel = MBmanufacturer;
  	 for(var i = 0 ; i < sel.options.length ; ++i) {
 	  if(sel.options[i].value == blahval) {
         sel.options[i].selected = true;
   break;
     }
    }
   }
   
   if (document.forms.orderform.ModelNum2){
   var ModelNumber = document.forms.orderform.ModelNum2;
   }
   else{
   var ModelNumber = document.forms.orderform.ModelNum;
   }
   var idx1 = s.indexOf("modelNum");
          if(idx1 > -1) {
   var idx3 = s.indexOf("&",idx1);
    	  if(idx3 == -1) idx3 = s.length;
   var val = s.substring(idx1,idx3);
   var val = val.slice(9);
   var sel2 = ModelNumber;
     	for(var i = 0 ; i < sel2.options.length ; ++i) {
    	 if(sel2.options[i].value == val) {
            sel2.options[i].selected = true;
   break;
    }
   }
  } 
 }
  
 function getMBInfo(){
     var t = window.location.search;
     var ModelNumber = document.forms.orderform.ModelNum.value;
     var idx = t.indexOf("mbid");
          if(idx > -1) {
	 var idx2 = t.indexOf("&",idx);
	      if(idx2 == -1) idx2 = t.length;
 	 var blahval = t.substring(idx,idx2);
 	//alert(blahval);
          self.location.href='index.cfm?brcid=onlineorder&'+blahval+'&modelNum='+ModelNumber;
        }
       }
       
        
  function increaseQty(Qty){
	  if (document.forms.orderform.qnty.value != 0){
		  document.forms.orderform.qnty.value++;
	 }
	  else{
	   document.forms.orderform.qnty.value = Qty
	}
	}
	
	function decreaseQty(Qty){
	  if (document.forms.orderform.qnty.value > 0){
		  document.forms.orderform.qnty.value--;
	 }
	}
	
	function populateShipTo(){
	 if (document.forms[0].same.checked){
	  document.forms[0].ShipName.value = document.forms[0].BillName.value;
	  document.forms[0].ShipCompany.value = document.forms[0].BillCompany.value;
	  document.forms[0].ShipAddress1.value = document.forms[0].BillAddress1.value;
	  document.forms[0].ShipAddress2.value = document.forms[0].BillAddress2.value;  
	  document.forms[0].ShipAddress3.value = document.forms[0].BillAddress3.value; 
	  document.forms[0].ShipCity.value = document.forms[0].BillCity.value;  
	  document.forms[0].ShipState.value = document.forms[0].BillState.value;  
	  document.forms[0].ShipZip.value = document.forms[0].BillZip.value;  
	  document.forms[0].ShipPhone.value = document.forms[0].BillPhone.value;
	  }
	 }
	 
function moveToCCNum2(){
  var len = document.forms[0].CCNum1.value.length +1;
            if (len <= 4){
	        document.forms[0].CCNum1.focus();
		  }
	        else {
	        document.forms[0].CCNum2.focus();
	      }  
	    }
	 
function moveToCCNum3(){
  var len = document.forms[0].CCNum2.value.length +1;
            if (len <= 4){
	        document.forms[0].CCNum2.focus();
	      }
	        else {
	        document.forms[0].CCNum3.focus();
	     }
	   }
	 
function moveToCCNum4(){
  var len = document.forms[0].CCNum3.value.length +1;
    if (len <= 4){
	  document.forms[0].CCNum3.focus();
	  }
	else {
	  document.forms[0].CCNum4.focus();
	  }
	 }
	 
 function orderformCheck(form){
		   if (document.forms.orderform.qnty.value == 0){
	       alert("Please enter a Quantity");
	       document.forms.orderform.qnty.focus();
		  return false;
		 }
		
		   if (document.forms.orderform.MotherboardManufacturer2){
		      if (document.forms.orderform.MotherboardManufacturer2 == ""){
			      alert("Please Enter a Manufacturer");
		           document.forms[0].MotherboardManufacturer2.focus();
		  return false;
		  }
		 }
		 if (document.forms.orderform.ModelNum.value == ""){
	       alert("Please enter a Model Number");
	       document.forms.orderform.ModelNum.focus();
		  return false;
		 }
		}
	   
 function custinfoformCheck(form){   
	       if (document.forms[0].PaymentType.value == ""){
	       alert("Please select a Payment Type");
	       document.forms[0].PaymentType.focus();
		  return false;
		 }
		 if (document.forms[0].CCType){
		   if (document.forms[0].CCType.value == ""){
	       alert("Please select your Credit Card Type");
	       document.forms[0].CCType.focus();
		  return false;
		 }
		 if (document.forms[0].CCNum1.value == ""){
	       alert("You did not enter the first 4 digits of your Credit Card Number");
	       document.forms[0].CCNum1.focus();
		  return false;
		 }
		 else if (document.forms[0].CCNum2.value == ""){
	       alert("You did not enter the second 4 digits of your Credit Card Number");
	       document.forms[0].CCNum2.focus();
		  return false;
		 }
		 else if (document.forms[0].CCNum3.value == ""){
	       alert("You did not enter the third 4 digits of your Credit Card Number");
	       document.forms[0].CCNum3.focus();
		  return false;
		 }
		 else if (document.forms[0].CCNum4.value == ""){
	       alert("You did not enter the last 4 digits of your Credit Card Number");
	       document.forms[0].CCNum4.focus();
		  return false;
		 }
		 if (document.forms[0].ExpireDate1.value == ""){
	       alert("Please select the month your Credit Card expires");
	       document.forms[0].ExpireDate1.focus();
		  return false;
		 }
		 else if (document.forms[0].ExpireDate2.value == ""){
	       alert("Please select the year your Credit Card expires");
	       document.forms[0].ExpireDate1.focus();
		  return false;
		 }
	   }
	     if (document.forms[0].PONum){
		   if (document.forms[0].PONum.value == ""){
	       alert("Please Enter a PO Number in the space provided");
	       document.forms[0].PONum.focus();
		  return false;
		 }
	  }
	      
		   if (document.forms[0].ShipMethod.value == ""){
	       alert("Please select a Shipping Method");
	       document.forms[0].ShipMethod.focus();
		  return false;
		 }
	      if (document.forms[0].BillName.value == ""){
	       alert("Please enter your first and last name");
	       document.forms[0].BillName.focus();
		  return false;
		 }
		 if (document.forms[0].BillAddress1.value == ""){
	       alert("Please enter your Address");
	       document.forms[0].BillAddress1.focus();
		  return false;
		 }
		 if (document.forms[0].BillCity.value == ""){
	       alert("Please enter your City");
	       document.forms[0].BillCity.focus();
		  return false;
		 }
		 if (document.forms[0].BillState.value == ""){
	       alert("Please enter your State");
	       document.forms[0].BillState.focus();
		  return false;
		 }
		 if (document.forms[0].BillZip.value == ""){
	       alert("Please enter your Zip or Postal Code");
	       document.forms[0].BillZip.focus();
		  return false;
		 }
		 if (document.forms[0].BillPhone.value == ""){
	       alert("Please enter your Phone Number");
	       document.forms[0].BillPhone.focus();
		  return false;
		 }
		 if (document.forms[0].Email.value == ""){
	       alert("Please enter your Email Address");
	       document.forms[0].Email.focus();
		  return false;
		 }
		 if (document.forms[0].ShipName.value == ""){
	       alert("Please enter the Name to be Shipped to");
	       document.forms[0].ShipName.focus();
		  return false;
		 }
		 if (document.forms[0].ShipAddress1.value == ""){
	       alert("Please enter the Address to be Shipped to");
	       document.forms[0].ShipAddress1.focus();
		  return false;
		 }
		 if (document.forms[0].ShipCity.value == ""){
	       alert("Please enter the City to be Shipped to");
	       document.forms[0].ShipCity.focus();
		  return false;
		 }
		 if (document.forms[0].ShipState.value == ""){
	       alert("Please enter the State to be Shipped to");
	       document.forms[0].ShipState.focus();
		  return false;
		 }
		 if (document.forms[0].ShipZip.value == ""){
	       alert("Please enter the Zip or Postal Code to be Shipped to");
	       document.forms[0].ShipZip.focus();
		  return false;
		 }
	}
	 
 function useFullName(){
    if (document.forms[0].CCType){
	   alert("Please type your name Exactly as it appears on your Credit Card");
	  }
	 }
	 