<!--
imageFlag = 0

function setFlag()  {
   imageFlag = 1
}

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 
}

// 031008 dcw - begin...
function CheckKey(e, element) {
	var key = (window.event)?event.keyCode : e.which;
	if(key == 13){
		if (element.type == "text"){
			element.blur();
		}
		
		return false;
   	}else{
       	return true;
	}
	
}



// 031008 dcw - end...

function reCalc(action, blnKitCalc){
	// start by calling scrapeFields() to validate the input data, if it fails return focus to form
  	smsForm = document.dynaform
	
	// 031008 dcw - begin...
	// added as part of afw's new cart logic. This snipplet prevents the cart from being submitted when enter is pressed
	// to allow our AJAX page to finish processing first...

	// 031008 dcw - end...
	
	
  	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
	if (blnKitCalc != "True"){
  		newData = ""
  		var sRawHIDCART = smsForm.hidSessionCart.value
	  	if (sRawHIDCART != null)  {
	    	arSCartRows = sRawHIDCART.split('|')
			//alert(sRawHIDCART)
	      	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
						newData = newData + arSCartCols[j]
						//alert(newData)
	          		}
	        	} 
	      	}
			// update form field with latest sessionCart info
	    	smsForm.hidSessionCart.value = 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
	smsForm.action = "subCart.asp"
  	if (action == "UPDATE")  {
    	smsForm.hidNextLink.value = "sy599frm.asp"
    	smsForm.submit()    
  	}
	if (action == "MOVEON")  {
		smsForm.hidNextLink.value = "te199terms.asp"
		// smsForm.hidNextLink.value = "te199frm.asp"
		smsForm.submit()    
  	}
 	if (action == "MOVEONQUOTE")  {
    	smsForm.hidNextLink.value = "te195frm.asp"
		smsForm.submit()
  	}	
}
 
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(objForm) {
  smsForm = objForm
  smsForm.hidSessionCart.value = "" 
  smsForm.hidNextLink.value = "sy599frm.asp"
  smsForm.action = "subCart.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) 
}


function removeFromCart(prodNumber, UniqueID, KitValue){
	if(KitValue!="0"){
		var r=confirm('This item is part of a group of products. By moving this one item, the other items in the group will also be moved to your wish list.');
		if (r==true){
			location.href = ("processReformatWishList.asp?prodno=" + prodNumber + "&kitid=" + UniqueID + "&action=RemoveFromCart")
		}else{
			void(0);
		}
		
	}else{
		location.href = ("processReformatWishList.asp?prodno=" + prodNumber + "&kitid=" + UniqueID + "&action=RemoveFromCart")
	}
}

function addToWishList(prodNumber, UniqueID, KitValue){
	if(KitValue!="0"){
		var r=confirm('This item is part of a group of products. By moving this one item, the other items in the group will also be moved to your wish list.');
		if (r==true){
			location.href = ("processReformatWishList.asp?prodno=" + prodNumber + "&kitid=" + UniqueID + "&action=MoveToWL")
		}else{
			void(0);
		}
		
	}else{
		location.href = ("processReformatWishList.asp?prodno=" + prodNumber + "&kitid=" + UniqueID + "&action=MoveToWL")
	}
}


function addToCart(prodNumber, UniqueID, KitValue){
	if(KitValue!="0"){
		var r=confirm('This item is part of a group of products. By moving this one item, the other items in the group will also be moved to your cart.');
		if (r==true){
			location.href = ("processReformatWishList.asp?prodno=" + prodNumber + "&kitid=" + UniqueID + "&action=MoveToCart")
		}else{
			void(0);
		}
		
	}else{
		location.href = ("processReformatWishList.asp?prodno=" + prodNumber + "&kitid=" + UniqueID + "&action=MoveToCart")
	}
}

function RemoveFromWL(prodNumber, UniqueID, KitValue){
	if(KitValue!="0"){
		var r=confirm('This item is part of a group of products. By removing this one item, the other items in the group will also be removed from your wish list.');
		if (r==true){
			location.href = ("processReformatWishList.asp?prodno=" + prodNumber + "&kitid=" + UniqueID + "&action=WLRemove")
		}else{
			void(0);
		}
		
	}else{
		location.href = ("processReformatWishList.asp?prodno=" + prodNumber + "&kitid=" + UniqueID + "&action=WLRemove")
	}
}
// -->