// scriipt

function _onError(input_object, object_value, obj_type, error_message) {
	alert(error_message);
	if (obj_type == "TEXT" || obj_type == "PASSWORD") {
		input_object.focus();
		input_object.select();
	}
	return false;	
}

function _validEmail(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(str))
		return true;
	else
		return false;
}

function _hasValue(obj, obj_type) {
	if (obj_type == "TEXT" || obj_type == "PASSWORD") {
  	if (obj.value.length == 0) 
    	return false;
    else 
    	return true;
  }
  else if (obj_type == "SELECT") {
  	for (i=1; i < obj.length; i++) {
			// modified 6/3/05 for RMA form
			 if (obj.options[i].selected)
			//if (obj.selectedIndex == i)
				return true;
			//	break;
		}
   	return false;
	}
  else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX") {
		if (obj.checked)
			return true;
		else
    	return false;	
	}
  else if (obj_type == "RADIO" || obj_type == "CHECKBOX") {
		for (i=0; i < obj.length; i++) {
			if (obj[i].checked)
				return true;
		}
		return false;	
	}
}


/** functions to check form fields
 ***/

function _checkText(obj, msg) {
	if (!_hasValue(obj, "TEXT" )) {
		if  (!_onError(obj, obj.value, "TEXT", msg))	{
	    return false; 
    }
  }
	return true;
}

function _checkEmail(obj, msg) {
	if (!_hasValue(obj, "TEXT" ) || !_validEmail(obj.value)) {
  	if  (!_onError(obj, obj.value, "TEXT", msg)) {
    	return false; 
		}
  }
	return true;
}


/**** PayPal ****/

function  _checkForm_Checkout_PP(_this) {
	if (!_hasValue(_this.AgreeToTerms, "SINGLE_VALUE_CHECKBOX" )) {
  	if (!_onError(_this, _this.AgreeToTerms, _this.AgreeToTerms.value, "SINGLE_VALUE_CHECKBOX", "If you have read and understand AtBatt.com\'s Terms & Conditions,\n please indicate that you have done so by selecting the checkbox.")) {
    	return false; 
    }
  }
  return true;
}

function  _checkForm_Checkout_PP_Intl(_this) {
	if (!_hasValue(_this.AgreeToTerms, "SINGLE_VALUE_CHECKBOX" )) {
  	if (!_onError(_this, _this.AgreeToTerms, _this.AgreeToTerms.value, "SINGLE_VALUE_CHECKBOX", "If you have read and understand AtBatt.com\'s Terms & Conditions,\n please indicate that you have done so by selecting the checkbox.")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.AgreeToTerms_Intl, "SINGLE_VALUE_CHECKBOX" )) {
  	if (!_onError(_this, _this.AgreeToTerms_Intl, _this.AgreeToTerms_Intl.value, "SINGLE_VALUE_CHECKBOX", "If you have read and understand AtBatt.com\'s Terms & Conditions regarding International delivery,\n please indicate that you have done so by selecting the checkbox.")) {
    	return false; 
    }
  }
  return true;
}

function _checkinteger(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is an integer defined as
    //   having an optional leading + or -.
    //   otherwise containing only the characters 0-9.
	var decimal_format = ".";
	var check_char;

    //The first character can be + -  blank or a digit.
	check_char = object_value.indexOf(decimal_format)
    //Was it a decimal?
    if (check_char < 1)
	return _checknumber(object_value);
    else
	return false;
    }


function _numberrange(object_value, min_value, max_value)
    {
    // check minimum
    if (min_value != null)
	{
        if (object_value < min_value)
		return false;
	}

    // check maximum
    if (max_value != null)
	{
	if (object_value > max_value)
		return false;
	}
	
    //All tests passed, so...
    return true;
    }



function _checknumber(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is a number defined as
    //   having an optional leading + or -.
    //   having at most 1 decimal point.
    //   otherwise containing only the characters 0-9.
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;

    //The first character can be + - .  blank or a digit.
	check_char = start_format.indexOf(object_value.charAt(0))
    //Was it a decimal?
	if (check_char == 1)
	    decimal = true;
	else if (check_char < 1)
		return false;
        
	//Remaining characters can be only . or a digit, but only one decimal.
	for (var i = 1; i < object_value.length; i++)
	{
		check_char = number_format.indexOf(object_value.charAt(i))
		if (check_char < 0)
			return false;
		else if (check_char == 1)
		{
			if (decimal)		// Second decimal.
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{
			if (decimal || digits)	
				trailing_blank = true;
        // ignore leading blanks

		}
	        else if (trailing_blank)
			return false;
		else
			digits = true;
	}	
    //All tests passed, so...
    return true
    }



function _checkrange(object_value, min_value, max_value)
    {
    //if value is in range then return true else return false

    if (object_value.length == 0)
        return true;


    if (!_checknumber(object_value))
	{
	return false;
	}
    else
	{
	return (_numberrange((eval(object_value)), min_value, max_value));
	}
	
    //All tests passed, so...
    return true;
    }




function _checkzip(object_value)
    {
    if (object_value.length == 0)
        return true;
		
    if (object_value.length != 5 && object_value.length != 10)
        return false;

	// make sure first 5 digits are a valid integer
	if (object_value.charAt(0) == "-" || object_value.charAt(0) == "+")
        return false;

	if (!_checkinteger(object_value.substring(0,5)))
		return false;

	if (object_value.length == 5)
		return true;
	
	// make sure

	// check if separator is either a'-' or ' '
	if (object_value.charAt(5) != "-" && object_value.charAt(5) != " ")
        return false;

	// check if last 4 digits are a valid integer
	if (object_value.charAt(6) == "-" || object_value.charAt(6) == "+")
        return false;

	return (_checkinteger(object_value.substring(6,10)));
    }



function _checkcreditcard(object_value)
    {
	var white_space = " -";
	var creditcard_string="";
	var check_char;


    if (object_value.length == 0)
        return true;

	// squish out the white space
	for (var i = 0; i < object_value.length; i++)
	{
		check_char = white_space.indexOf(object_value.charAt(i))
		if (check_char < 0)
			creditcard_string += object_value.substring(i, (i + 1));
	}	

	// if all white space return error
    if (creditcard_string.length == 0)
        return false;
	 
	 	
	// make sure number is a valid integer
	if (creditcard_string.charAt(0) == "+")
        return false;

	if (!_checkinteger(creditcard_string))
		return false;

    // now check mod10

	var doubledigit = creditcard_string.length % 2 == 1 ? false : true;
	var checkdigit = 0;
	var tempdigit;

	for (var i = 0; i < creditcard_string.length; i++)
	{
		tempdigit = eval(creditcard_string.charAt(i))

		if (doubledigit)
		{
			tempdigit *= 2;
			checkdigit += (tempdigit % 10);

			if ((tempdigit / 10) >= 1.0)
			{
				checkdigit++;
			}

			doubledigit = false;
		}
		else
		{
			checkdigit += tempdigit;
			doubledigit = true;
		}
	}	
	return (checkdigit % 10) == 0 ? true : false;

    }


function  _checkForm_RMA1(_this) {
	if  (!_hasValue(_this.Ordernumber, "TEXT" )) {
		if  (!_onError(_this, _this.Ordernumber, _this.Ordernumber.value, "TEXT", "Order number is required"))	{
	    return false; 
    }
  }
  return true;
}


function  _checkForm_RMA2(_this) {
	if  (!_hasValue(_this.Sku, "CHECKBOX" )) {
		if  (!_onError(_this, _this.Sku, _this.Sku.value, "CHECKBOX", "Please select the item you would like to return"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.Reason, "SELECT" )) {
		if  (!_onError(_this, _this.Reason, _this.Reason.value, "SELECT", "Please select the reason you\'re requesting an RMA"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.Action, "SELECT" )) {
		if  (!_onError(_this, _this.Action, _this.Action.value, "SELECT", "Please select the action you\'re requesting"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.Explanation, "TEXT" )) {
		if  (!_onError(_this, _this.Explanation, _this.Explanation.value, "TEXT", "Please enter a brief explanation of why you\'re requesting an RMA"))	{
	    return false; 
    }
  }
	if (!_hasValue(_this.AgreeToTerms, "SINGLE_VALUE_CHECKBOX" )) {
  	if (!_onError(_this, _this.AgreeToTerms, _this.AgreeToTerms.value, "SINGLE_VALUE_CHECKBOX", "If you have read and understand AtBatt.com\'s Return Policy,\n please indicate that you have done so by selecting the checkbox.")) {
    	return false; 
    }
  }
  return true;
}

function  _checkForm_RMA3(_this, str, sku) {
	if  (!_hasValue(_this.Sku, "CHECKBOX" )) {
		if  (!_onError(_this, _this.Sku, _this.Sku.value, "CHECKBOX", "Please select the item you would like to return"))	{
	    return false; 
    }
  }
	var arr_str = str.split(",");
	var arr_sku = sku.split(",");
	for (var i = 0; i < arr_str.length; i++) {
	if (document.getElementById('cb_Sku_' + arr_str[i]).checked) {
		if  (!_hasValue(document.getElementById('id_Reason_' + arr_str[i]), "SELECT" )) {
			if  (!_onError(_this, document.getElementById('id_Reason_' + arr_str[i]), document.getElementById('id_Reason_' + arr_str[i]).value, "SELECT", "Please select the reason you\'re requesting an RMA for SKU: " + arr_sku[i]))	{
	  	  return false; 
  	  }
	  }
		if  (!_hasValue(document.getElementById('id_Action_' + arr_str[i]), "SELECT" )) {
			if  (!_onError(_this, document.getElementById('id_Action_' + arr_str[i]), document.getElementById('id_Action_' + arr_str[i]).value, "SELECT", "Please select the action you\'re requesting for SKU: " + arr_sku[i]))	{
	    	return false; 
    	}
	  }
		if  (!_hasValue(document.getElementById('id_Explanation_' + arr_str[i]), "TEXT" )) {
			if  (!_onError(_this, document.getElementById('id_Explanation_' + arr_str[i]), document.getElementById('id_Explanation_' + arr_str[i]).value, "TEXT", "Please enter a brief explanation of why you\'re requesting an RMA for SKU: " + arr_sku[i]))	{
	    return false; 
  	  }
	  }
	}
	} // end for


	if (!_hasValue(_this.AgreeToTerms, "SINGLE_VALUE_CHECKBOX" )) {
  	if (!_onError(_this, _this.AgreeToTerms, _this.AgreeToTerms.value, "SINGLE_VALUE_CHECKBOX", "If you have read and understand AtBatt.com\'s Return Policy,\n please indicate that you have done so by selecting the checkbox.")) {
    	return false; 
    }
  }
  return true;
}


function  _checkForm_Checkout(_this) {
	if  (!_hasValue(_this.Email, "TEXT" )) {
		if  (!_onError(_this, _this.Email, _this.Email.value, "TEXT", "Please enter your e-mail address"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.Password, "PASSWORD" )) {
		if  (!_onError(_this, _this.Password, _this.Password.value, "TEXT", "Please enter your account password"))	{
	    return false; 
    }
  }
 return true;
}


function  _checkForm_Checkout1(_this) {
	if  (!_hasValue(_this.First, "TEXT" )) {
		if  (!_onError(_this, _this.First, _this.First.value, "TEXT", "Billing first name is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.Last, "TEXT" )) {
		if  (!_onError(_this, _this.Last, _this.Last.value, "TEXT", "Billing last name is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.Address, "TEXT" )) {
		if  (!_onError(_this, _this.Address, _this.Address.value, "TEXT", "Billing address is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.City, "TEXT" )) {
		if  (!_onError(_this, _this.City, _this.City.value, "TEXT", "Billing city is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.State, "SELECT" ) && _this.Country.value == 'United States') {
		if  (!_onError(_this, _this.State, _this.State.value, "SELECT", "Billing state is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.Zip, "TEXT" ) && _this.Country.value == 'United States') {
		if  (!_onError(_this, _this.Zip, _this.Zip.value, "TEXT", "Billing zip code is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.Country, "SELECT" )) {
		if  (!_onError(_this, _this.Country, _this.Country.value, "SELECT", "Billing country is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.Phone, "TEXT" )) {
		if  (!_onError(_this, _this.Phone, _this.Phone.value, "TEXT", "Billing phone is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.Email, "TEXT" )) {
		if  (!_onError(_this, _this.Email, _this.Email.value, "TEXT", "E-mail address is required"))	{
	    return false; 
    }
  }
  if  (!_validEmail(_this.Email.value)) {
  	if  (!_onError(_this, _this.Email, _this.Email.value, "TEXT", "Please enter a valid e-mail address")) {
    	return false; 
		}
  }
	if  (!_hasValue(_this.ShipFirst, "TEXT" )) {
		if  (!_onError(_this, _this.ShipFirst, _this.ShipFirst.value, "TEXT", "Ship-to first name is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.ShipLast, "TEXT" )) {
		if  (!_onError(_this, _this.ShipLast, _this.ShipLast.value, "TEXT", "Ship-to last name is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.ShipAddress, "TEXT" )) {
		if  (!_onError(_this, _this.ShipAddress, _this.ShipAddress.value, "TEXT", "Ship-to address is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.ShipCity, "TEXT" )) {
		if  (!_onError(_this, _this.ShipCity, _this.ShipCity.value, "TEXT", "Ship-to city is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.ShipState, "SELECT" ) && _this.ShipCountry.value == 'United States') {
		if  (!_onError(_this, _this.ShipState, _this.ShipState.value, "SELECT", "Ship-to state is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.ShipZip, "TEXT" ) && _this.ShipCountry.value == 'United States') {
		if  (!_onError(_this, _this.ShipZip, _this.ShipZip.value, "TEXT", "Ship-to zip code is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.ShipCountry, "SELECT" )) {
		if  (!_onError(_this, _this.ShipCountry, _this.ShipCountry.value, "SELECT", "Ship-to country is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.ShipPhone, "TEXT" )) {
		if  (!_onError(_this, _this.ShipPhone, _this.ShipPhone.value, "TEXT", "Ship-to phone is required"))	{
	    return false; 
    }
  }
	if (!_hasValue(_this.AddressTypeID, "RADIO" )) {
  	if (!_onError(_this, _this.AddressTypeID, _this.AddressTypeID.value, "RADIO", "Please indicate if shipping address is Residential or Commercial")) {
    	return false; 
    }
  }
  return true;
}

function  _checkForm_Checkout1_Shipping(_this) {
	if  (!_hasValue(_this.ShipFirst, "TEXT" )) {
		if  (!_onError(_this, _this.ShipFirst, _this.ShipFirst.value, "TEXT", "Ship-to first name is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.ShipLast, "TEXT" )) {
		if  (!_onError(_this, _this.ShipLast, _this.ShipLast.value, "TEXT", "Ship-to last name is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.ShipAddress, "TEXT" )) {
		if  (!_onError(_this, _this.ShipAddress, _this.ShipAddress.value, "TEXT", "Ship-to address is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.ShipCity, "TEXT" )) {
		if  (!_onError(_this, _this.ShipCity, _this.ShipCity.value, "TEXT", "Ship-to city is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.ShipState, "SELECT" )) {
		if  (!_onError(_this, _this.ShipState, _this.ShipState.value, "SELECT", "Ship-to state is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.ShipZip, "TEXT" )) {
		if  (!_onError(_this, _this.ShipZip, _this.ShipZip.value, "TEXT", "Ship-to zip code is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.ShipCountry, "SELECT" )) {
		if  (!_onError(_this, _this.ShipCountry, _this.ShipCountry.value, "SELECT", "Ship-to country is required"))	{
	    return false; 
    }
  }
	if  (!_hasValue(_this.ShipPhone, "TEXT" )) {
		if  (!_onError(_this, _this.ShipPhone, _this.ShipPhone.value, "TEXT", "Ship-to phone is required"))	{
	    return false; 
    }
  }
	if (!_hasValue(_this.AddressTypeID, "RADIO" )) {
  	if (!_onError(_this, _this.AddressTypeID, _this.AddressTypeID.value, "RADIO", "Please indicate if shipping address is Residential or Commercial")) {
    	return false; 
    }
  }
  return true;
  return true;
}


function  _checkForm_Checkout2(_this) {
	if (!_hasValue(_this.ShippingTypeID, "RADIO" )) {
  	if (!_onError(_this, _this.ShippingTypeID, _this.ShippingTypeID.value, "RADIO", "Please select shipping method")) {
    	return false; 
    }
  }
  return true;
}


function  _checkForm_Checkout3(_this) {
	if (!_hasValue(_this.Cardnumber, "TEXT" )) {
  	if (!_onError(_this, _this.Cardnumber, _this.Cardnumber.value, "TEXT", "Credit card number is required")) {
    	return false; 
    }
  }
	if  (!_checkcreditcard(_this.Cardnumber.value)) {
		if  (!_onError(_this, _this.Cardnumber, _this.Cardnumber.value, "TEXT", "Please enter a valid Credit card number")) {
			return false; 
		}
	}
	if (!_hasValue(_this.CCID, "TEXT" )) {
  	if (!_onError(_this, _this.CCID, _this.CCID.value, "TEXT", "Credit Card ID is required")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.Cardholder, "TEXT" )) {
  	if (!_onError(_this, _this.Cardholder, _this.Cardholder.value, "TEXT", "Name on credit card is required")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.AgreeToTerms, "SINGLE_VALUE_CHECKBOX" )) {
  	if (!_onError(_this, _this.AgreeToTerms, _this.AgreeToTerms.value, "SINGLE_VALUE_CHECKBOX", "If you have read and understand AtBatt.com\'s Terms & Conditions,\n please indicate that you have done so by selecting the checkbox.")) {
    	return false; 
    }
  }
  return true;
}

function  _checkForm_Checkout3_Intl(_this) {
	if (!_hasValue(_this.Cardnumber, "TEXT" )) {
  	if (!_onError(_this, _this.Cardnumber, _this.Cardnumber.value, "TEXT", "Credit card number is required")) {
    	return false; 
    }
  }
	if  (!_checkcreditcard(_this.Cardnumber.value)) {
		if  (!_onError(_this, _this.Cardnumber, _this.Cardnumber.value, "TEXT", "Please enter a valid Credit card number")) {
			return false; 
		}
	}
	if (!_hasValue(_this.CCID, "TEXT" )) {
  	if (!_onError(_this, _this.CCID, _this.CCID.value, "TEXT", "Credit Card ID is required")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.Cardholder, "TEXT" )) {
  	if (!_onError(_this, _this.Cardholder, _this.Cardholder.value, "TEXT", "Name on credit card is required")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.AgreeToTerms, "SINGLE_VALUE_CHECKBOX" )) {
  	if (!_onError(_this, _this.AgreeToTerms, _this.AgreeToTerms.value, "SINGLE_VALUE_CHECKBOX", "If you have read and understand AtBatt.com\'s Terms & Conditions,\n please indicate that you have done so by selecting the checkbox.")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.AgreeToTerms_Intl, "SINGLE_VALUE_CHECKBOX" )) {
  	if (!_onError(_this, _this.AgreeToTerms_Intl, _this.AgreeToTerms_Intl.value, "SINGLE_VALUE_CHECKBOX", "If you have read and understand AtBatt.com\'s Terms & Conditions regarding International delivery,\n please indicate that you have done so by selecting the checkbox.")) {
    	return false; 
    }
  }
  return true;
}

function  _checkForm_Password(_this) {
	if (!_hasValue(_this.Password, "PASSWORD" )) {
  	if (!_onError(_this, _this.Password, _this.Password.value, "PASSWORD", "Please enter current password")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.Password1, "PASSWORD" )) {
  	if (!_onError(_this, _this.Password1, _this.Password1.value, "PASSWORD", "Please enter your new password")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.Password2, "PASSWORD" )) {
  	if (!_onError(_this, _this.Password2, _this.Password2.value, "PASSWORD", "Please verify your new password")) {
    	return false; 
    }
  }
	if (_this.Password1.value != _this.Password2.value) {
  	if (!_onError(_this, _this.Password2, _this.Password2.value, "PASSWORD", "Passwords don\'t match.  Please verify your new password.")) {
    	return false; 
    }
  }
  return true;
}


function  _checkForm_Contact(_this) {
	if (!_hasValue(_this.txtName, "TEXT" )) {
  	if (!_onError(_this, _this.txtName, _this.txtName.value, "TEXT", "Your name is required")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.txtEmail, "TEXT" )) {
  	if (!_onError(_this, _this.txtEmail, _this.txtEmail.value, "TEXT", "E-mail address is required")) {
    	return false; 
    }
  }
  if  (!_validEmail(_this.txtEmail.value)) {
  	if  (!_onError(_this, _this.txtEmail, _this.txtEmail.value, "TEXT", "Please enter a valid e-mail address")) {
    	return false; 
		}
  }
	if (!_hasValue(_this.txtSubject, "TEXT" )) {
  	if (!_onError(_this, _this.txtSubject, _this.txtSubject.value, "TEXT", "Message subject is required")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.txtAreaComments, "TEXT" )) {
  	if (!_onError(_this, _this.txtAreaComments, _this.txtAreaComments.value, "TEXT", "Please enter your comments / questions")) {
    	return false; 
    }
  }
  return true;
}

function  _checkForm_VolPurchasing(_this) {
	if (!_hasValue(_this.Firstname, "TEXT" )) {
  	if (!_onError(_this, _this.Firstname, _this.Firstname.value, "TEXT", "Your first name is required")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.Lastname, "TEXT" )) {
  	if (!_onError(_this, _this.Lastname, _this.Lastname.value, "TEXT", "Your last name is required")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.Company, "TEXT" )) {
  	if (!_onError(_this, _this.Company, _this.Company.value, "TEXT", "Company is required")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.Phone, "TEXT" )) {
  	if (!_onError(_this, _this.Phone, _this.Phone.value, "TEXT", "Phone number is required")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.Email, "TEXT" )) {
  	if (!_onError(_this, _this.Email, _this.Email.value, "TEXT", "E-mail address is required")) {
    	return false; 
    }
  }
  if  (!_validEmail(_this.Email.value)) {
  	if  (!_onError(_this, _this.Email, _this.Email.value, "TEXT", "Please enter a valid e-mail address")) {
    	return false; 
		}
  }
  return true;
}

function  _checkForm_SaveCart(_this) {
	if (!_hasValue(_this.Email, "TEXT" )) {
  	if (!_onError(_this, _this.Email, _this.Email.value, "TEXT", "E-mail address is required")) {
    	return false; 
    }
  }
  if  (!_validEmail(_this.Email.value)) {
  	if  (!_onError(_this, _this.Email, _this.Email.value, "TEXT", "Please enter a valid e-mail address")) {
    	return false; 
		}
  }
  return true;
}

function  _checkForm_SendCart(_this) {
	if (!_hasValue(_this.Email, "TEXT" )) {
  	if (!_onError(_this, _this.Email, _this.Email.value, "TEXT", "E-mail address is required")) {
    	return false; 
    }
  }
  if  (!_validEmail(_this.Email.value)) {
  	if  (!_onError(_this, _this.Email, _this.Email.value, "TEXT", "Please enter a valid e-mail address")) {
    	return false; 
		}
  }
	if (!_hasValue(_this.Name, "TEXT" )) {
  	if (!_onError(_this, _this.Name, _this.Name.value, "TEXT", "Your name is required")) {
    	return false; 
    }
  }
	if (!_hasValue(_this.Description, "TEXT" )) {
  	if (!_onError(_this, _this.Description, _this.Description.value, "TEXT", "Please enter message for your friend")) {
    	return false; 
    }
  }
  return true;
}