function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


//this point onwards is for ORDERFORM only
function orderTotal(oform, prefix)
{

// set references to fields
var qty = oform[prefix + "_qty"];
var stHold = oform[prefix + "_stHold"];
var price = oform[prefix + "_price"];
var stVis = oform[prefix + "_stVis"];


// only bother if the field has contents
if (qty == "")return;

// if the with is not a number (NaN)
// or is zero or less
// everything goes blank
if(isNaN(qty.value) || (qty.value <= 0))
{
 qty.value = "";
 stHold.value = "";
}

// else the field is a valid number, so calculate the 
// total order cost and put that value in the 
// hidden subtotal field
else

 stHold.value = (Math.round(qty.value * price.value * 100))/100;

// call the routine which checks if the 
// visible subtotal is correct
visTotal(oform, prefix);

}


// checks if the visible subtotal is correct
// ie, if it equals the hidden subtotal field
function visTotal(oform, prefix)
{
var stHold = oform[prefix + "_stHold"];
var stVis = oform[prefix + "_stVis"];

if (stVis.value != stHold.value)
 stVis.value = stHold.value;
}


function joeTotal(oform)
{

  var subtot1 = oform["vn_stVis"];
  var subtot2 = oform["ja_stVis"];
   var v_vn_qty = oform["vn_qty"];
   var v_ja_qty = oform["ja_qty"];
     var v_radiobutton_no = oform["radiobutton_no"];
  var v_radiobutton_yes = oform["radiobutton_yes"];
  
  if (v_vn_qty.value > 0)
    subtot1.value = v_vn_qty.value * 24;
  if (v_ja_qty.value > 0)
    subtot2.value = v_ja_qty.value * 34;
	
	
	   v_radiobutton_no.checked = false;
	   
  // ** calls isRequiredNotEmpty function
 isRequiredNotEmpty(oform);
 
  
  if ( (subtot1.value > 0) && (subtot2.value > 0) )
    return(eval(subtot1.value)+eval(subtot2.value));
  else if (subtot2.value == "")
    return(eval(subtot1.value));
  else if (subtot1.value == "")
    return(eval(subtot2.value))
  ;
}



function setExpMM(oform)
{
  var v_exp_mm           = oform["exp_mm"];
  var v_hidden_exp_mm    = oform["hidden_exp_mm"];

  if (v_exp_mm.value != v_hidden_exp_mm.value)
    v_hidden_exp_mm.value = v_exp_mm.value;
}


function setExpYY(oform)
{
  var v_exp_yy           = oform["exp_yy"];
  var v_hidden_exp_yy    = oform["hidden_exp_yy"];

  if (v_exp_yy.value != v_hidden_exp_yy.value)
    v_hidden_exp_yy.value = v_exp_yy.value;
}


function sethiddenExpYY(oform)
{
  var v_exp_yy = oform["exp_yy"];
  var v_hidden_exp_yy = oform["hidden_exp_yy"];

  if (v_exp_yy.value != v_hidden_exp_yy.value)
  {
  v_hidden_exp_yy = v_exp_yy.value;
  return(v_hidden_exp_yy.value);
}
  //hidden_exp_yy.value = v_hidden_exp_yy.value;
}


/*******************************************************************
Name: checkEmail 
      make sure there is not spaces and contains '@' & '.'
      this is being called from onChange from email_id
********************************************************************/
function checkEmail(oform)
{
  var blnReturnValue = true;

  var v_email_id   = oform["email_id"];

  // the next three lines is used to
  //   make sure one DOT exists after the @ sign
  apos=v_email_id.value.indexOf("@");
  dotpos=v_email_id.value.lastIndexOf(".");
  lastpos=v_email_id.value.length-1;


  // * it can not have spaces
  if (v_email_id.value.indexOf(' ') >= 0) 
       alert('Email address cannot have spaces');
  //  * there must be an @ sign
  else if (v_email_id.value.indexOf('@') == -1)
       alert('A valid email address must have an @ in it');
  //  * there must be at least one DOT in the email address
  else if (v_email_id.value.indexOf('.') == -1)
       alert('A valid email address must have at least one DOT in it');
  //  * there must be one DOT after the @ sign
  else if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
     alert('A valid email address must have one DOT after the @ sign');

}
/*****************************************************************
  END checkEmail function
*****************************************************************/



/*******************************************************************
Name: isRequiredNotEmpty 
********************************************************************/
function isRequiredNotEmpty(oform)
{
  var v_full_name = oform["full_name"];
  var v_email_id  = oform["email_id"];
  var v_address1  = oform["address1"];
  var v_city      = oform["city"];
  var v_state     = oform["state"];
  var v_zip       = oform["zip"];
  var v_country   = oform["country"];
  var v_phone_num = oform["phone_num"];
  var v_cardtype  = oform["cardtype"];
  var v_card_no   = oform["card_no"];
  var v_exp_mm    = oform["exp_mm"];
  var v_exp_yy    = oform["exp_yy"];
  var v_hidden_exp_mm    = oform["hidden_exp_mm"];
  var v_hidden_exp_yy    = oform["hidden_exp_yy"];
  var v_ja_qty    = oform["ja_qty"];
  var v_vn_qty    = oform["vn_qty"];
  var v_amount    = oform["amount"];
  var v_radiobutton_no = oform["radiobutton_no"];
  var v_radiobutton_yes = oform["radiobutton_yes"];

  if (v_full_name.value == "") {
	alert('Please enter your full name');
	v_radiobutton_no.checked = true;
	v_radiobutton_yes.checked = false;
        return false;
  }
  else if(v_email_id.value == "") {
	alert('Please enter your email address');
	v_radiobutton_no.checked = true;
	v_radiobutton_yes.checked = false;
        return false;
  }
  else if(v_address1.value == "") {
	alert('Please enter your address');
	v_radiobutton_no.checked = true;
	v_radiobutton_yes.checked = false;
        return false;
  }
  else if(v_city.value == "") {
	alert('Please enter your city');
	v_radiobutton_no.checked = true;
	v_radiobutton_yes.checked = false;
        return false;
  }
  else if(v_state.value == "" || v_state.value == "Choose a state") {
	alert('Please enter your state');
	v_radiobutton_no.checked = true;
	v_radiobutton_yes.checked = false;
        return false;
  }
  else if(v_country.value == "") {
	alert('Please enter your country');
	v_radiobutton_no.checked = true;
	v_radiobutton_yes.checked = false;
        return false;
  }
  else if(v_cardtype.value == "" || v_cardtype.value == "Choose a Credit Card") {
	alert('Please select credit card type');
	v_radiobutton_no.checked = true;
	v_radiobutton_yes.checked = false;
        return false;
  }
  else if(v_card_no.value == "") {
	alert('Please enter your credit card number');
	v_radiobutton_no.checked = true;
	v_radiobutton_yes.checked = false;
        return false;
  }
  else if(v_exp_mm.value == "") {
	alert('Please enter your credit card expiration month');
	v_radiobutton_no.checked = true;
	v_radiobutton_yes.checked = false;
        return false;
  }
  else if(v_exp_yy.value == "") {
	alert('Please enter your credit card expiration year');
	v_radiobutton_no.checked = true;
	v_radiobutton_yes.checked = false;
        return false;
  }
  else if(v_vn_qty.value == "" && v_ja_qty.value == "") {
	alert('Please enter quantity');
	v_radiobutton_no.checked = true;
	v_radiobutton_yes.checked = false;
        return false;
  }
  



  // ** calls isValidNumber function
  isValidNumber(oform);
}
/*****************************************************************
  END isRequiredNotEmpty function
*****************************************************************/




/*******************************************************************
Name: isValidNumber (checks for starting number & correct digits)
returns true if it's a valid credit card number.
    VISA - starts with '4',       13 or digits
    MC   - starts between 52-55,  16 digits
    AmEx - starts with 34 or 37,  15 digits
********************************************************************/
function isValidNumber(oform)
{
  var blnReturnValue = true;

  var v_cardtype   = oform["cardtype"];
  var v_card_no   = oform["card_no"];

  if (v_cardtype.value == 'Visa') {
    if (v_card_no.value.substring(0,1) != 4 || v_card_no.value.length != 13 &&
        v_card_no.value.length != 16){
       alert('The Card Number you have entered is not a valid Visa Number');
       blnReturnValue = false;
    }
  }
  else if (v_cardtype.value == 'MasterCard') {
     if (v_card_no.value.substring(0,2) < 51 || v_card_no.value.substring(0,2) > 55 ||      
         v_card_no.value.length != 16) {
       alert('The Card Number you have entered is not a valid MasterCard Number');
       blnReturnValue = false;
    }
  }
  else if (v_cardtype.value == 'American Express'){
    if (v_card_no.value.substring(0,2) != 34 && v_card_no.value.substring(0,2) != 37 ||   
        v_card_no.value.length != 15) {
      alert('The Card Number you have entered is not a valid American Express Number');
      blnReturnValue = false;
    }
  }
}
/*****************************************************************
  END isValidNumber function
*****************************************************************/


