<!--
function onImageClick(strWindowTitle, strImgName, intImgWidth, intImgHeight){
	var url = "img_zoom.asp?img=" + strImgName + "&title=" + strWindowTitle
	var intWindowWidth = intImgWidth + 25
	var intWindowHeight = intImgHeight + 70
	
	//Make sure the window will fit on an 8x6 screen vertically
	if (intWindowHeight > 525){
	  intWindowHeight -= (intWindowHeight - 525)
	  var scrollBarValue = "yes"
	}else{
	  var scrollBarValue = "no"
	}
	
	var strParams = "resizable=no,menubar=no,scrollbars=" + scrollBarValue + ",status=no,toolbar=no,"
	var strWidth = intWindowWidth.toString()
	var strHeight = intWindowHeight.toString()
	
	strParams += "width=" + strWidth + ",height=" + strHeight
	window.open(url, "", strParams)
}

//Popup window with no features
function openpopWindow(theURL,winName,features) {
  window.open(theURL,"",features);
}

//Returns value of incoming object, or selectedIndex of a drop down    
function GetObjValue(objField){
//alert("Function GetObjValue: field type is: "+objField.type)
  switch (objField.type){
    case "text":
    case "hidden":
      return objField.value
    case "password":
    case "textarea":
      return objField.value
    case "select-one":
      return objField.selectedIndex.toString()
  }
}

//Returns true if incoming string is null, an empty string, or a single space.
function isBlank(theString){
  if ((theString == null) || (theString == "") || (theString == " ")){
    return true;
  }else{
    for(var i = 0; i < theString.length; i++){
          var c = theString.charAt(i);
      if ((c != '\n') && (c != '\t')){
          return false;
      }
    }
    return true;
  }
}

//Function to make sure a string is all numeric digits
function allDigits(str, allowDash){
	var strValidChars = "0123456789"
	if (allowDash) { strValidChars += "-" }
	return inValidCharSet(str, strValidChars)
}

//function to make sure the username and password is alpha-numeric
function isAlphaNum(fieldValue, bAllowSpace){
  var strValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_"
  if (bAllowSpace){
    strValidChars += " "
  }
  return inValidCharSet(fieldValue, strValidChars)
}

//Function to determine whether str contains only characters in charset
function inValidCharSet(str, charset){
	var result = true
	// Note: doesn't use regular expressions to avoid early Mac browser bugs	
	for (var i = 0; i < str.length; i++){
		if (charset.indexOf(str.substr(i,1)) < 0){
			result = false
			break
		}
	}
	return result
}

//Function to make sure a number string is in a specific format
function numFilter(objField, strLabel, strFormat) {
  //Grab the controls name and value, or selectedIndex in the case of a drop down
  var strObjName = objField.name //.toLowerCase()
  var strObjValue = GetObjValue(objField) //selectedIndex for drop downs
	if (!isBlank(strObjValue)) { //Do not perform if empty strObjValue
  	var chr = "";
		var numbers = ""; //Store all the numbers here
		//Process to remove non-numbers and spaces
		for(var i = 0; i < strObjValue.length; i++) {
			chr = strObjValue.charAt(i);
			if(!(isNaN(chr) || chr == " ")) numbers += chr;
		}
		//Remove country code, if any
		//if(numbers.substring(0, 2) == "47") numbers = numbers.substring(2, numbers.length);
		var output = ""; //Assign numbers here
		//assign numbers to chosen strFormat
		var n = 0, i = 0;
		while(i < strFormat.length && n < numbers.length) {
			chr = strFormat.charAt(i);
			if(chr == "#") {
				output += numbers.charAt(n++)
			} else {
				output += chr;
			}
			i++;
		}
		//If it's a phone number field, it must be 10 digits long plus 2 dashes.
		if (numbers.length != 10 && strObjName.toLowerCase().indexOf("phone") > -1) {
			return "--- The "+strLabel+" field must be 10 digits long in the format '###-###-####'\n"
		}else{
		  objField.value = output; //output to objField
		  return ""
		}
	}
}

function chkLength(fieldValue, fieldLabel, minLength, maxLength){
  var msg = ""
  //See if it's too short
  if (fieldValue.length < minLength){
    msg += "--- Length of "+fieldLabel+" is too short.\n"
  }
  //See if it's too long
  if (fieldValue.length > maxLength){
    msg += "--- Length of "+fieldLabel+" is too long.\n"
  }
  return msg
}

function emailFilter(objField){
  //Grab the controls name and value, or selectedIndex in the case of a drop down
  var strObjName = objField.name //.toLowerCase()
  var strObjValue = GetObjValue(objField) //selectedIndex for drop downs
  //See if there's an @ sign in the string
  var index = strObjValue.indexOf("@")
  if (index > 0){
    //Make sure there's a period somewhere after the @ sign
    var pindex = strObjValue.indexOf(".", index)
    if ((pindex > index+1) && (strObjValue.length > pindex+1)){
	    return ""
	  }
  }
  return "-- "+strObjName+" entered is invalid; email address format is: 'user@domain.com'\n"
}

function onShippingChange(objField){
	var theForm = document.frmConfirm
	var strObjText = objField.options[objField.selectedIndex].text
	var textArray = strObjText.split(" - ")
	var subTotal = get2Decimals(theForm.Sub_Total.value)
	var shipping = get2Decimals(textArray[1])
	var tax = get2Decimals(theForm.Sales_Tax.value)
	var total = get2Decimals(subTotal+shipping+tax)
	
	//alert("Subtotal = "+subTotal+"\nShipping = "+shipping+"\nTax = "+tax+"\nTotal = "+total)
	
	theForm.Shipping.value = FormatMoneyString(shipping.toString(), false)
	theForm.Total.value = FormatMoneyString(total.toString(), false)
}

function get2Decimals(vData){
  var vFloat = parseFloat(vData)
  var vTemp = Math.round(vFloat * 100) / 100
  return vTemp
}

function FormatMoneyString(sVal, bAddDollarSign){
  var stmp, intPos
  //If the incoming value is empty or is not a number, return zero
  if (isBlank(sVal) || isNaN(sVal)){ return "0.00" }
  stmp = sVal //.toString()
  intPos = sVal.indexOf(".")
  if (intPos == -1){
    stmp += ".00"
  }else if (intPos == (stmp.length - 2)){
    stmp += "0"
  }
  if (bAddDollarSign && (stmp.indexOf("$") == -1)){
    stmp = "$"+stmp
  }
  return stmp
}

function onAddClick(catNo, itemNo){
  //cart.asp?action=add&c=4&i=TS-A10&iq=1
  var i = 0
  var msg = ""
  var options = ""
  var sq = document.frmDetail.sq.value
  var qty = document.frmDetail.Qty.value
  var optionsDD = document.frmDetail.itemOptions
  var URL = "cart.asp?action=add&c="+catNo+"&i="+itemNo+"&iq="+qty+"&sq="+sq
  
  //Make sure there's an options drop down before we try to check it
  if (hasOptions){
	  //If there's more than 1 options dd
	  if (optionsDD[1].selectedIndex >= 0) {
	    //Make if there are options, something is selected
	    for (i = 0; i < optionsDD.length; i++) {
	      msg += (optionsDD[i].selectedIndex == 0 ? "--- Please make a selection for "+optionsDD[i].id+"\n" : "")
	    }
	    //If not show user a message
	    if (!isBlank(msg)){
	      msg = "Please correct the following items before adding to cart:\n\n" + msg
	      alert(msg)
	      return
	    }else{
	      //Otherwise, add options to querystring
	      for (i = 0; i < optionsDD.length; i++) {
	        if (isBlank(options)) {
	          options += optionsDD[i].id+";"+optionsDD[i].options[optionsDD[i].selectedIndex].value
	        } else {
	          options += "|" + optionsDD[i].id+";"+optionsDD[i].options[optionsDD[i].selectedIndex].value
	        } //isBlank(options)
	      } //for
	    } //!isBlank(msg)
	  }else if (optionsDD.selectedIndex >= 0) {
	    msg += (optionsDD.selectedIndex == 0 ? "--- Please make a selection for "+optionsDD.id+"\n" : "")
	    //If not show user a message
	    if (!isBlank(msg)){
	      msg = "Please correct the following items before adding to cart:\n\n" + msg
	      alert(msg)
	      return
	    }else{
	      //Otherwise, add options to querystring
	      options += optionsDD.id+";"+optionsDD.options[optionsDD.selectedIndex].value
	    } //if (!isBlank(msg))
	  } //if (optionsDD[1].selectedIndex >= 0)
	  URL += "&o="+options
  } //if (optionsDD[1])
  document.location.href = URL
  /*
  if (confirm("URL for Add to Cart is:\n\n"+URL+"\n\nContinue?")) {
    document.location.href = URL
  }
  */
}
var hasOptions = false
//-->

