 function hover(id, onoff){

    if(document.forms[0].product.value==id && !onoff){return;}
    
    e = document.getElementById('p_'+id);
    
    e.style.border = onoff ? '2px solid #F00' : '2px solid #000';

 }
 
 function choose(id,nam){
   document.forms[0].product.value = id+','+nam;
   goNext();
 }
 
 function goNext(){
    if(document.URL.indexOf("imprint-upload")!==-1){
      alert("Your artwork has been uploaded successfully.\nYou will now be redirected to the next\n"+
      "step of the shopping system.");
    }

   document.forms[0].submit();

 }
 
 function sync_fields(){
   d = document.forms[0];
   d.sfname.value           = d.fname.value;
   d.slname.value           = d.lname.value;
   d.saddress.value         = d.address.value;
   d.scity.value            = d.city.value;
   d.sstate.value           = d.state.value;
   d.szip.value             = d.zip.value;
   d.scountry.selectedIndex = d.country.selectedIndex;
   d.sphone.value           = d.phone.value;
 }
 
 function do_paytype(){
   v = document.forms[0].paytype[document.forms[0].paytype.selectedIndex].value;
   if(v=='paypal'){
     document.forms[0].ccardnum.className = 'txtd';
     document.forms[0].verif.className = 'txtd';
     document.forms[0].expMONTH.className = 'txtd';
     document.forms[0].expYEAR.className = 'txtd';
     document.forms[0].ccardnum.disabled = true;
     document.forms[0].verif.disabled = true;
     document.forms[0].expMONTH.disabled = true;
     document.forms[0].expYEAR.disabled = true;
   }else{
     document.forms[0].ccardnum.className = 'txt';
     document.forms[0].verif.className = 'txt';
     document.forms[0].expMONTH.className = 'txt';
     document.forms[0].expYEAR.className = 'txt';
     document.forms[0].ccardnum.disabled = false;
     document.forms[0].verif.disabled = false;
     document.forms[0].expMONTH.disabled = false;
     document.forms[0].expYEAR.disabled = false;
   }
     
}

function val_chkout(event){
	
	if(event.ctrlKey){

			__paypal_checkout();
			return;
	
	}
	
    d = new Object();
    d.f = document.forms[0];
    d.e = d.f.elements;
    pp = d.f.paytype[d.f.paytype.selectedIndex].value=='paypal' ? true : false;
    ff = true;
    for(i=0;i<d.e.length;i++){
      if(d.e[i].type=='text'){
        n = d.e[i].name;
        if((n=='ccardnum'||n=='expMONTH'||n=='expYEAR'||n=='verif')&&pp){continue;}
        if(d.e[i].value.length<=0){ ff=ff?false:true; break}
      }else{continue;}
    }
    if(ff){goNext();}else{alert("Error: All fields are mandatory. Please complete the form and try again.");}
}

/********************************* PAYPAL BETA *****************************/

function __paypal_checkout(){
	

	document.forms[0].action = "http://www.beerkoozies.com/cgi-bin/paypal-custom/index.php";
	document.forms[0].submit();	
	
	
	
}


function previewColor(dat){
  arr = dat.split(',');
  if(arr[0] == "Assorted"){
   document.getElementById('assorted_selector').style.visibility = "visible";
   document.getElementById('colorPreviewer').style.backgroundColor = "#000";
   document.getElementById('colorPreviewer').style.backgroundImage = "url()";
  }else{
   document.getElementById('assorted_selector').style.visibility = "hidden";
  }
  if(arr[0].indexOf(".") != -1){
    document.getElementById('colorPreviewer').style.backgroundImage = "url(./bgs/"+arr[0]+")";
  }else{
    document.getElementById('colorPreviewer').style.backgroundImage = "url()";
    document.getElementById('colorPreviewer').style.backgroundColor=arr[1];
  }
}

var forcedShippingValue = -1;
function forceShipping(val){
  list = document.getElementById('color');
  list.selectedIndex = val;
  forcedShippingValue = val;
  //list.disabled = true;
}
function releaseShipping(){
  forcedShippingValue = -1;
  //list.disabled = false;
}
function respectForcedValue(val){
  if(parseInt(val) < forcedShippingValue && forcedShippingValue != -1){
    forceShipping(forcedShippingValue);
    alert("Your shipping service has been automatically chosen based on the turnaround time you have chosen. You can upgrade your shipping service for faster delivery but you cannot downgrade your service.");
  }

}

function toggleColor(buttonId){

  button = document.getElementById(buttonId);
  if(!button) return;
  button.checked = button.checked ? false : true;

}
        

