
	function addToFavorites() {
		if (window.external) {
			window.external.AddFavorite("http://www.mountaingirlbotanics.com", "Natural Soap and Body Care - Mountain Girl Botanics") 
		}
	 	else { 
	 		alert("Sorry. Your browser does not support this function."); 
		}
	}
	 
  function submitForm()
  {
    document.form.submit(); 
  }

  function focusIngredients(anchorName)
  {
	open("pages/ingredients.htm#" + anchorName, "ingredients", "width=400, height=500, scrollbars=yes, resizable=yes").focus();
  }

  function openInstructions()
  {
     open("pages/mtn_baby_ecowipes_kit_instructions.htm", "ingredients", "width=400, height=500, scrollbars=yes, resizable=yes").focus();
  }
  
  
  function openPicture(pictureName)
  {
     open(pictureName, "image2",  "width=318, height=248").focus();
  }
  
  function validateUserPassword(text)
  {
     if (text.length < 6)
     {
       alert("Enter valid user/password")
       return false
     }
  } 

  function validateInquiry(code)
  {
    code = code.replace(" ", "");
    
    if (code != "QR7ZKL83")
    {
    	alert("Please enter code to submit Custom Order Inquiry");
        return false;
    }
  }

  function validateQuantity(quantity)
  {

    // strip spaces
    quantity = quantity.replace(" ", "");   
	len=quantity.length

	if ( len == 0 )
    {
    	alert("Please enter quantity");
		return false;
	}
	
	if ( len > 3 )
    {
         alert("Quantity is too large");
         return false;
    }
		
    for ( i = 0; i < len; i++ )
    {
        digits="0123456789"
        
        if ( digits.indexOf(quantity.charAt(i)) < 0 )
        {
        	alert("Quantity should be numeric");
            return false;
        }
    }  

	if ( quantity <= 0 )
	{
		alert("Can not add 0 to cart.  To remove items from cart, go to shopping cart and click delete.");
		return false;
	}
  }
  

  function validateCartQuantity(quantity)
  {

    // strip spaces
    quantity = quantity.replace(" ", "");   
	len=quantity.length

	if ( len == 0 )
    {
    	alert("Please enter quantity");
		return false;
	}
	
	if ( len > 3 )
    {
         alert("Quantity is too large");
         return false;
    }
		
    for ( i = 0; i < len; i++ )
    {
        digits="0123456789"
        
        if ( digits.indexOf(quantity.charAt(i)) < 0 )
        {
        	alert("Quantity should be numeric");
            return false;
        }
    }  

	if ( quantity < 0 )
	{
		alert("Can not add negative values for items in cart.  To remove items from cart click delete.");
		return false;
	}
  }

  function validateCustomQuantity(quantity)
  {
    // strip spaces
    quantity = quantity.replace(" ", "");   
	len=quantity.length

	if ( len == 0 )
    {
    	alert("Please enter quantity");
		return false;
	}
	
	if ( len > 3 )
    {
         alert("Quantity is too large");
         return false;
    }
		
    for ( i = 0; i < len; i++ )
    {
        digits="0123456789"
        
        if ( digits.indexOf(quantity.charAt(i)) < 0 )
        {
        	alert("Quantity should be numeric");
            return false;
        }
    }  

	if ( quantity <= 0 )
	{
		alert("Can not add 0 to cart.  To remove items from cart, go to shopping cart and click delete.");
		return false;
	}

		alert("Please customize your gift box and then add it to your cart");

  }

  
  function parseelement(thisone){
  alert("hi");
    //Remove the $ sign if you wish the parse number to NOT include it
  var prefix=""
  var wd
  if (thisone.value.charAt(0)=="$")
    return
  wd="w"
  var tempnum=thisone.value
  for (i=0;i<tempnum.length;i++){
    if (tempnum.charAt(i)=="."){
      wd="d"
      break 
    }
  }
  if (wd=="w")
    thisone.value=prefix+tempnum+".00"
  else{
    if (tempnum.charAt(tempnum.length-2)=="."){
      thisone.value=prefix+tempnum+"0"
    }
    else{
      tempnum=Math.round(tempnum*100)/100
      thisone.value=prefix+tempnum
    }
  }
}
  
  
  
  function stopRKey(evt) { 
  var evt = (evt) ? evt : ((event) ? event : null); 
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;} 
} 
  function noenter() {
  	return !(window.event && window.event.keyCode == 13);
  }
  
  
  
	
function trim(str)
{
   return str.replace(/^\s+|\s+$/g,'');
}
  
  
  function checkWholesaleForm(businessName,address1, city, state, zipCode, contactPerson,email,taxId) {
	
   if(trim(businessName.value) == '')
   {
      alert('Please enter your Business Name');
      businessName.focus();
      return false;
   }
   else if(trim(address1.value) == '')
   {
      alert('Please enter your Address');
      address1.focus();
      return false;
   }
   else if(trim(city.value) == '')
   {
      alert('Please enter your City');
      city.focus();
      return false;
   }
   else if(trim(state.value) == '')
   {
      alert('Please enter your State');
      state.focus();
      return false;
   }
   else if(trim(zipCode.value) == '')
   {
      alert('Please enter your Zip Code');
      zipCode.focus();
      return false;
   }   
   else if(trim(contactPerson.value) == '')
   {
      alert('Please enter your Contact Person');
      contactPerson.focus();
      return false;
   }
   else if(trim(email.value) == '')
   {
      alert('Please enter your Email');
      email.focus();
      return false;
   }
   else if(trim(taxId.value) == '')
   {
      alert('Please enter your Tax ID');
      taxId.focus();
      return false;
   }
   else
   {
      return true;
   }
  }

