<!-- // begin
imageFlag = 0

function setFlag()  {
   imageFlag = 1
}

function Go(){return}

function scrapeFields()  {
  tForm = document.dynaform
  sHIDKIT = tForm.HID_KIT.value
  arKitRows = sHIDKIT.split('|')
  var i = 0 
  var tempValue = ''
  // input validation, numbers only, we will handle gift certificate quantity later
  for (i=3;i<tForm.length-1;i++)  {
    strValidChars = "0123456789"            
    tempValue = tForm.elements[i].value	
    for (j=0;j<tempValue.length;j++) {
	     tempCharValue = tempValue.charAt(j)
  	   if (strValidChars.indexOf(tempCharValue,0) == -1 || isNaN(tempValue) || tempValue < 0)  {
	      alert('Please enter a valid quantity.\n\n HINTS:\n- Do not use commas or periods with your numbers.\n- If you wish to delete an entry, change the quantity to zero.\n- You can quickly clear your entire cart by clicking on the "Clear Shopping Cart" link.' + '\nthis is from loop:' + j)
	      tForm.elements[i].focus()
	      return false
	     }
      
	   }
    
	   if (tempValue != "1" && arKitRows[i] == "1") {
	     alert("Due to the nature of this product\nthe quantity must be 1\nPlease re-enter")
	     tForm.elements[i].focus()
	     return false
	   }	
  
  }
  
  return true 
}

function reCalc(action)  {
 // 05/03/00 GTS rewrite
// start by calling scrapeFields() to validate the input data, if it fails return focus to form

  smsForm = document.dynaform
  if (!scrapeFields())  {
    return
  }
  // Check for gift in product code, allow only 1 or 0 as numeric input --only one gift certificate at a time--
  if (smsForm.hidSessionCart.value.substring(0,4) == 'Gift' && smsForm.elements[0].value > 1) {
    alert('You can only order one Gift Certificate at a time. \nIf you wish to delete the Gift Certificate, enter a 0 in the Quantity box.')
    smsForm.elements[0].value = 1
    smsForm.elements[0].focus()
    return
  }
  // now rebuild HID_CART --we will do this everytime
  // subCart.asp will actually handle removing a line item
  newData = ""
  var sRawHIDCART = smsForm.hidSessionCart.value
  if (sRawHIDCART != null)  {
    arSCartRows = sRawHIDCART.split('|')
      for (i=0;i<arSCartRows.length;i++)  {
        if (i == 0)  {
          newData = newData
        }else{
          newData = newData  + "|"
        }
        sSCartCols = arSCartRows[i]
        arSCartCols = sSCartCols.split('~')
        for (j=0;j<arSCartCols.length;j++)  {
          // if the text field entry is not zero, add the line to the newData variable
          if (j < arSCartCols.length - 1)  {
           newData = newData + arSCartCols[j] + "~"
          }else{
           newData = newData + smsForm.elements[i+3].value  // need to add three to the counter due
          }
//          alert("rebuild of cart is: " + newData)
        }  //end of COLS for loop
      }  //end of ROWS for loop
    // update form field with latest sessionCart info
    smsForm.hidSessionCart.value = newData
//    alert(newData)
  }	//end of sRawHIDCART if statement
  // hidSessionCart has the latest values, we will go on to subCart.asp (submit action of form)
  // but set the hidNextLink hidden element based on param passed in from link, then submit form
  if (action == "UPDATE")  {
    smsForm.hidNextLink.value = "sy599frm.asp"
    smsForm.submit()    
  }
  if (action == "MOVEON")  {
    smsForm.hidNextLink.value = "te199frm.asp"
    smsForm.submit()    
  }
  if (action == "MOVEONQUOTE")  {
    smsForm.hidNextLink.value = "te195frm.asp"
    smsForm.submit()
  }
}

function kitCalc(action){
smsForm = document.dynaform
strHidCart = smsForm.hidSessionCart.value
	var i = 0
	for (i=3;i<smsForm.length;i++)
	{
	strURLAppendQTY = smsForm.elements[i].value
	if (i==3){
	arrQTY = strURLAppendQTY
	}else{
	arrQTY = arrQTY + "," + strURLAppendQTY
	}
	}
  if (action == "MOVEON")  {
  location.href= "reCalcCart.asp?NewQTY=" + arrQTY + "&From599=yes&nextLink=te199frm.asp"
  }else if (action == "MOVEONQUOTE")  {
    
    location.href= "reCalcCart.asp?NewQTY=" + arrQTY + "&From599=yes&nextLink=te195frm.asp"

  }else{
	location.href= "reCalcCart.asp?NewQTY=" + arrQTY + "&From599=yes"
  }
}

function formatNum(expr, decplaces) {
   // usually called after a number is entered
   var str = "" + Math.round(eval(expr) * Math.pow(10,decplaces));
   while (str.length <= decplaces) {
     str = "0" + str
   }
   var decpoint = str.length - decplaces
   return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

function clearCart(){
	smsForm = document.dynaform
  	smsForm.hidSessionCart.value = "" 
  	smsForm.hidNextLink.value = "ic294frm.asp"
  	smsForm.submit()
}

browserName = navigator.appName;

function keyDown ( ev ) {
	var key = ev.which;
	if (key == "13") {document.dynaform.submit();}
}

if (browserName == "Netscape" ) {
	document.onkeydown = keyDown;	
	document.captureEvents(Event.KEYDOWN) 
}

// Checks to make sure a number was entered -- jms
function check(contents) {
    if (((contents / contents) != 1) && (contents != 0)) {alert('Please enter only a number into this box');document.dynaform.qty.focus()};
	}
function openPrint(url) {
       winStats='toolbar=no,location=no,directories=no,menubar=no,'
       winStats+='scrollbars=yes,width=640,height=370'
       if (navigator.appName.indexOf("Microsoft")>=0) {
          winStats+=',left=5,top=150'
        }else{
          winStats+=',screenX=5,screenY=150'
        }
       floater=window.open(url,"",winStats)     
    }
// -->