
window.name="main"; 

//----validate shipping destination------

function validate()
  { 
    var errors = '';
    
    // do each for element
    errors += check("Shipping",document.options.Shipping)
    
    // do alert message
    if (errors) alert(errors);
  
    // prevent from submitting if errors
    document.rv = (errors == '')
  }


function check(name,ref)
  {
    var errors='', value

    // see description of function
    value = getSelectedValue(ref)

    // do error message
    if (value == "nonjava") {
      errors = "Please choose a Shipping Destination."
    }
   
    return errors
  }


function getSelectedValue(selectList)
  {
    // read the currently selected item
    return selectList[selectList.selectedIndex].value
  }


//-----windows-------

	var first_00 = null;
    var second_00 = null;
	var third_00 = null;
	var fourth_00 = null;

	function close_child() { 
                              if ((first_00 != null) && (!first_00.closed)) {first_00.close();} 
                              if ((second_00 != null) && (!second_00.closed)) {second_00.close();} 
                              if ((third_00 != null) && (!third_00.closed)) {third_00.close();} 
                              if ((fourth_00 != null) && (!fourth_00.closed)) {fourth_00.close();} 
	}

	function shippingWindow() {close_child(); first_00=window.open('/info/shipping.html#here','shipping', 'width=680,height=300,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');first_00.focus();}

	function privacyWindow() {close_child(); second_00=window.open('/info/privacy.html#here','privacy', 'width=680,height=630,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');second_00.focus();}

	function testWindow() {close_child(); third_00=window.open('/info/testimonials.html#here','testimonials', 'width=730,height=700,scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');third_00.focus();}

	function aboutWindow() {close_child(); fourth_00=window.open('/info/about.html#here','aboutus', 'width=680,height=700,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');fourth_00.focus();}

//------wholesale key----

function keyword()
{ 
    var password = ''
    password = prompt('Please enter your keyword:','');
        if (password == "orderwholesale") {
            location.href= "/cgi/shop.cgi?CART=Order&TEMPLATE=templates/display_cart_orderwhsle.htm";
        }else if (password == "order5") {
            location.href= "/cgi/shop.cgi?CART=Order&TEMPLATE=templates/display_cart_order5.htm";
        }else if (password == "") {location.href= "/cgi/shop.cgi?CART=Order&TEMPLATE=templates/display_cart_order.htm";
        }
}

//-----validate process form-----

function MM_validateForm() { //v2.0
  var i,objStr,field,theCheck,atPos,theNum,colonPos,min,max,errors='';
  for (i=0; i<(MM_validateForm.arguments.length-2); i+=3) {
    objStr = MM_validateForm.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.substring(0,objStr.lastIndexOf('.')).
                 lastIndexOf('.'),objStr.length);  //fix layer ref if not supp
    field = eval(objStr);
    field.title = (field.title)?field.title:objStr;
    theCheck = MM_validateForm.arguments[i+2];
    if (field.value) { //IF NOT EMPTY FIELD
      if (theCheck.indexOf('isEmail') != -1) { //CHECK EMAIL
        atPos = field.value.indexOf('@');
        if (atPos < 1 || atPos == (field.value.length - 1))
          errors += ' '+field.title+' must contain an e-mail address.\n';
      } else if (theCheck != 'R') { //START NUM CHECKS
        theNum = parseFloat(field.value);
        if (field.value != ''+theNum) errors += ' '+field.title+' must contain a number.\n';
        if (theCheck.indexOf('inRange') != -1) { //CHECK RANGE
          colonPos = theCheck.indexOf(':');
          min = theCheck.substring(8,colonPos);
          max = theCheck.substring(colonPos+1,theCheck.length);
          if (theNum < min || max < theNum) //bad range
            errors += ' '+field.title+' must contain a number between '+min+' and '+max+'.\n';
    } } }
    else if (theCheck.charAt(0) == 'R') errors += ' '+field.title+' is missing.\n';
  }
  if (errors) alert('You missed filling in the following field(s):\n'+
                    errors);
  document.MM_returnValue = (errors == '')
}

