
function check_amount(amount,curr) {


var decimalcount;
var afterdecimalcount;
var j;
decimalcount = 0;
afterdecimalcount = 0;

    if ((amount == null) || (amount == "") || (amount == 0) || (amount == '0.00')) {
		alert("Amount must not be Zero or Null !");
        return false;
    }


if (curr == "422")
{
	for (j=0; j <= amount.length - 1 ; j++)
	{
		if (isNaN(amount.charAt(j)))
		{
			alert("Amount in LBP should not contain decimals or characters (LBP Amount Format: 16520)");
			return false;
		}
	}

	if (amount.charAt(0) == '0')
	{
		alert("Amount should not contain zeros at the left side (LBP Amount Format: 16520)");
		return false;
	}
}


if (curr == "840")
{
	for (j=0; j <= amount.length - 1 ; j++)
	{
		if (decimalcount > 0)
		{
			afterdecimalcount = afterdecimalcount + 1;
		}
		if (amount.charAt(j) == ".")
		{
			decimalcount = decimalcount + 1;
		}
		if (amount.charAt(j) != ".")
		{
		    if (isNaN(amount.charAt(j)))
		    {
				alert("No Characters or spaces are allowed in amount form");
				return false;
		    }
	    }
	}
}



	if (amount.charAt(0) == '0' && decimalcount == '0')
	{
		alert("Amount should not contain zeros at the left side (LBP Amount Format: 16520)");
		return false;
	}
	if (amount.charAt(0) == '0' && decimalcount == '1' && afterdecimalcount != '0' && amount.charAt(1) != '.')
	{
		alert("Invalid Amount format (at left of decimal point)");
		return false;
	}
	if ((decimalcount != '0') && (decimalcount > '1')){
		alert("Invalid Amount format");
		return false;
		}
	if ((decimalcount != '0') && (afterdecimalcount > '2')){
		alert("Amount require 2 digits at most after decimal point");
		return false;
		}
	if ((decimalcount != '0') && (afterdecimalcount == '0')){
		alert("Amount require value after decimal point");
		return false;
		}


return true
}


function validate_recurrent_donation(form) {

	if (form.full_name.value.length == 0){
	    alert("Please enter your Full Name");
	    form.full_name.focus();
	    return false;
	}
	if (form.email.value.length == 0){
	    alert("Please enter your Email");
	    form.email.focus();
	    return false;
	}		
	if (form.city.value.length == 0){
	    alert("Please enter your City");
	    form.city.focus();
	    return false;
	}
	if (form.country.value.length == 0){
	    alert("Please enter your Country");
	    form.country.focus();
	    return false;
	}
	if (form.phone.value.length == 0){
	    alert("Please enter your Phone");
	    form.phone.focus();
	    return false;
	}
	if (form.full_address.value.length == 0){
	    alert("Please enter your Full Address");
	    form.full_address.focus();
	    return false;
	}
	
	if (form.amount.value.length == 0){
	    alert("Please enter an Amount");
	    form.amount.focus();
	    return false;
	}

    if (!check_amount(form.amount.value,form.txtCurrency.value)){
	    form.amount.focus();
	    return false;
    }

    if (form.frequency[form.frequency.selectedIndex].value.length == 0){
	    alert("Please enter the recurring Frequency");
	    form.frequency.focus();
	    return false;
	}
    if (form.card_number.value.length == 0){
	    alert("Please enter your Credit Card Number");
	    form.card_number.focus();
	    return false;
	}
	
    if (form.expiry_month[form.expiry_month.selectedIndex].value.length == 0){
	    alert("Please enter your card's Expiry Month");
	    form.expiry_month.focus();
	    return false;
	}
    if (form.expiry_year[form.expiry_year.selectedIndex].value.length == 0){
	    alert("Please enter your card's Expiry Year");
	    form.expiry_year.focus();
	    return false;
	}
    if (form.cvv_code.value.length == 0){
	    alert("Please enter your 3-digit Crypto Code found on the back of your credit card");
	    form.cvv_code.focus();
	    return false;
	}


return true;
}


function validate_become_member(form) {

	if (form.first_name.value.length == 0){
	    alert("Please enter your First Name");
	    form.first_name.focus();
	    return false;
	}
	if (form.last_name.value.length == 0){
	    alert("Please enter your Last Name");
	    form.last_name.focus();
	    return false;
	}
	if (form.city.value.length == 0){
	    alert("Please enter your City");
	    form.city.focus();
	    return false;
	}
	if (form.country.value.length == 0){
	    alert("Please enter your Country");
	    form.country.focus();
	    return false;
	}
	if (form.phone.value.length == 0){
	    alert("Please enter your Phone");
	    form.phone.focus();
	    return false;
	}
    if (form.birth_month[form.birth_month.selectedIndex].value.length == 0){
	    alert("Please enter the Birth Month");
	    form.birth_month.focus();
	    return false;
	}
    if (form.birth_year[form.birth_year.selectedIndex].value.length == 0){
	    alert("Please enter the Birth Year");
	    form.birth_year.focus();
	    return false;
	}
	if (form.zip_code.value.length == 0){
	    alert("Please enter your Mailing Address/P.O.box");
	    form.zip_code.focus();
	    return false;
	}
	if (form.full_address.value.length == 0){
	    alert("Please enter your Home Address");
	    form.full_address.focus();
	    return false;
	}
	if (form.email.value.length == 0){
	    alert("Please enter your Email");
	    form.email.focus();
	    return false;
	}
	/*
	if (form.amount.value.length == 0){
	    alert("Amount value not available, please contact the site administrator");
	    return false;
	}

    if (!check_amount(form.amount.value,form.txtCurrency.value)){
        alert("Amount value not correct, please contact the site administrator");
	    return false;
    }

    if (form.frequency[form.frequency.selectedIndex].value.length == 0){
	    alert("Frequency value not available, please contact the site administrator");
	    return false;
	}
	*/
    if (form.card_number.value.length == 0){
	    alert("Please enter your Credit Card Number");
	    form.card_number.focus();
	    return false;
	}
	
    if (form.expiry_month[form.expiry_month.selectedIndex].value.length == 0){
	    alert("Please enter your card's Expiry Month");
	    form.expiry_month.focus();
	    return false;
	}
    if (form.expiry_year[form.expiry_year.selectedIndex].value.length == 0){
	    alert("Please enter your card's Expiry Year");
	    form.expiry_year.focus();
	    return false;
	}
    if (form.cvv_code.value.length == 0){
	    alert("Please enter your 3-digit Crypto Code found on the back of your credit card");
	    form.cvv_code.focus();
	    return false;
	}


return true;
}


function validate_donation(form) {

	if (form.full_name.value.length == 0){
	    alert("Please enter your Full Name");
	    form.full_name.focus();
	    return false;
	}
	if (form.email.value.length == 0){
	    alert("Please enter your Email");
	    form.email.focus();
	    return false;
	}

	if (form.city.value.length == 0){
	    alert("Please enter your City");
	    form.city.focus();
	    return false;
	}
	if (form.country.value.length == 0){
	    alert("Please enter your Country");
	    form.country.focus();
	    return false;
	}
	if (form.phone.value.length == 0){
	    alert("Please enter your Phone");
	    form.phone.focus();
	    return false;
	}
	if (form.full_address.value.length == 0){
	    alert("Please enter your Full Address");
	    form.full_address.focus();
	    return false;
	}
	if (form.amount.value.length == 0){
	    alert("Please enter an Amount");
	    form.amount.focus();
	    return false;
	}

    if (!check_amount(form.amount.value,form.txtCurrency.value)){
	    form.amount.focus();
	    return false;
    }

return true;
}



function confirm_msgbox(temp) {
	if (confirm (temp))
		return true;
	return false;
}


function validate_membership_form(form) {


	if (form.first_name.value.length == 0){
	    alert("Please enter First Name");
	    form.first_name.focus();
	    return false;
	}
	if (form.last_name.value.length == 0){
	    alert("Please enter Last Name");
	    form.last_name.focus();
	    return false;
	}

	if (form.date_of_birth_day[form.date_of_birth_day.selectedIndex].value.length == 0){
	    alert("Please select date of birth - day");
	    form.date_of_birth_day.focus();
	    return false;
	}
	if (form.date_of_birth_month[form.date_of_birth_month.selectedIndex].value.length == 0){
	    alert("Please select date of birth - month");
	    form.date_of_birth_month.focus();
	    return false;
	}
	if (form.date_of_birth_year[form.date_of_birth_year.selectedIndex].value.length == 0){
	    alert("Please select date of birth - year");
	    form.date_of_birth_year.focus();
	    return false;
	}
	
	if (form.place_of_birth.value.length == 0){
	    alert("Please enter your place of birth");
	    form.place_of_birth.focus();
	    return false;
	}
		
	if (form.address1.value.length == 0){
	    alert("Please enter your principal address");
	    form.address1.focus();
	    return false;
	}

	if (form.city.value.length == 0){
	    alert("Please enter city");
	    form.city.focus();
	    return false;
	}

	if (form.country.value.length == 0){
	    alert("Please enter your country");
	    form.country.focus();
	    return false;
	}
	if (form.phone.value.length == 0){
	    alert("Please enter your phone");
	    form.phone.focus();
	    return false;
	}

return true;

}


function validate_adoption_form(form) {

	if (form.name.value.length == 0){
	    alert("Please enter Your Name");
	    form.name.focus();
	    return false;
	}
	if (form.email.value.length == 0){
	    alert("Please enter Your Email");
	    form.email.focus();
	    return false;
	}
	if (form.home_phone.value.length == 0){
	    alert("Please enter Your Home Phone");
	    form.home_phone.focus();
	    return false;
	}
	if (form.home_phone.value.length == 0){
	    alert("Please enter Your Home Phone");
	    form.home_phone.focus();
	    return false;
	}
	if (form.address.value.length == 0){
	    alert("Please enter Your Address");
	    form.address.focus();
	    return false;
	}
	if (form.birth_month[form.birth_month.selectedIndex].value.length == 0){
	    alert("Please select date of birth - month");
	    form.birth_month.focus();
	    return false;
	}
	if (form.birth_year[form.birth_year.selectedIndex].value.length == 0){
	    alert("Please select date of birth - year");
	    form.birth_year.focus();
	    return false;
	}
	if (form.nationality.value.length == 0){
	    alert("Please enter Your Country of Residence");
	    form.nationality.focus();
	    return false;
	}
	if ( (form.q2_radio1[0].checked == false) && (form.q2_radio1[1].checked == false) && (form.q2_radio1[2].checked == false) ){
	    alert("Please select where [Your newly adopted pet will live with you]");
	    form.q2_radio1[0].focus();
	    return false;
	}
	if (form.q2_radio1[2].checked == true){
	    if (form.q2_radio1_textbox1.value.length == 0){
	        alert("Please specify where [Your newly adopted pet will live with you]");
	        form.q2_radio1_textbox1.focus();
	        return false;
	    }
	    
	}
	if (form.q2_select1[form.q2_select1.selectedIndex].value.length == 0){
	    alert("Please select [Is your residence owned, or do you rent]");
	    form.q2_select1.focus();
	    return false;
	}
	if (form.q2_select2[form.q2_select2.selectedIndex].value.length == 0){
	    alert("Please select [Does your residence owner allow animals]");
	    form.q2_select2.focus();
	    return false;
	}
	if (form.q2_select3[form.q2_select3.selectedIndex].value.length == 0){
	    alert("Please select [If you moved from your current residence will you take your pet with you]");
	    form.q2_select3.focus();
	    return false;
	}
	if (form.q2_select4[form.q2_select4.selectedIndex].value.length == 0){
	    alert("Please select [How many people will live in the same residence as the pet]");
	    form.q2_select4.focus();
	    return false;
	}
	if (form.q2_select5[form.q2_select5.selectedIndex].value.length == 0){
	    alert("Please select [Will there be children living in the same residence as the pet]");
	    form.q2_select5.focus();
	    return false;
	}
	if (form.q2_select5[form.q2_select5.selectedIndex].value == "Yes"){
	    if (form.q2_select5_textarea1.value.length == 0){
	        alert("Please specify number of children living in the same residence as the pet, and their ages");
	        form.q2_select5_textarea1.focus();
	        return false;
	    }
	}
	if (form.q2_select6[form.q2_select6.selectedIndex].value.length == 0){
	    alert("Please select [Do you or anyone else who will live with the pet have allergies to hair and dust]");
	    form.q2_select6.focus();
	    return false;
	}
	if (form.q2_select7[form.q2_select7.selectedIndex].value.length == 0){
	    alert("Please select [Are you willing to allow a BETA member to visit your home before an adoption is complete]");
	    form.q2_select7.focus();
	    return false;
	}

	if (form.q3_select1[form.q3_select1.selectedIndex].value.length == 0){
	    alert("Please select [Do you want a dog or cat]");
	    form.q3_select1.focus();
	    return false;
	}
	if (form.q3_select2[form.q3_select2.selectedIndex].value.length == 0){
	    alert("Please select [Do you want a male or female]");
	    form.q3_select2.focus();
	    return false;
	}
	if (form.q3_select3[form.q3_select3.selectedIndex].value.length == 0){
	    alert("Please select [What age pet]");
	    form.q3_select3.focus();
	    return false;
	}
	if ( (form.q3_radio1[0].checked == false) && (form.q3_radio1[1].checked == false) ){
	    alert("Please select [Do you want a specific breed]");
	    form.q3_radio1[0].focus();
	    return false;
	}
	if (form.q3_radio1[0].checked == true){
	    if (form.q3_radio1_textbox1.value.length == 0){
	        alert("Please specify [What specific breed do you want]");
	        form.q3_radio1_textbox1.focus();
	        return false;
	    }
	    
	}
	if ( (form.q3_radio2[0].checked == false) && (form.q3_radio2[1].checked == false) && (form.q3_radio2[2].checked == false) ){
	    alert("Please select [Would you adopt a pet that has some kind of health problems or need special care]");
	    form.q3_radio2[0].focus();
	    return false;
	}
	if (form.q3_radio2[2].checked == true){
	    if (form.q3_radio2_textbox1.value.length == 0){
	        alert("Please specify [Maybe you would adopt a pet that has some kind of health problems or need special care]");
	        form.q3_radio2_textbox1.focus();
	        return false;
	    }
	    
	}
	if (form.q3_select4[form.q3_select4.selectedIndex].value.length == 0){
	    alert("Please select [Do you want the pet to be for...]");
	    form.q3_select4.focus();
	    return false;
	}


	if (form.q4_select1[form.q4_select1.selectedIndex].value.length == 0){
	    alert("Please select [Cats and Dogs can live for more than ten years, are you ready for this long of a commitment]");
	    form.q4_select1.focus();
	    return false;
	}
	if (form.q4_select2[form.q4_select2.selectedIndex].value.length == 0){
	    alert("Please select [Are you willing to spay and neuter you new pet or adopt a pet which is already spayed or neutered]");
	    form.q4_select2.focus();
	    return false;
	}
	if (form.q4_select3[form.q4_select3.selectedIndex].value.length == 0){
	    alert("Please select [How many hours a day will your pet be left alone]");
	    form.q4_select3.focus();
	    return false;
	}
	if (form.q4_select3_textarea1.value.length == 0){
	    alert("Please specify [How many hours a day will your pet be left alone]");
	    form.q4_select3_textarea1.focus();
	    return false;
	}
	if (form.q4_select4[form.q4_select4.selectedIndex].value.length == 0){
	    alert("Please select where [Your new pet will stay]");
	    form.q4_select4.focus();
	    return false;
	}
	if (form.q4_select5[form.q4_select5.selectedIndex].value.length == 0){
	    alert("Please select where [If you are adopting a dog, is there anytime that you would chain the dog up]");
	    form.q4_select5.focus();
	    return false;
	}
	if (form.q4_select5[form.q4_select5.selectedIndex].value == "Yes"){
	    if (form.q4_select5_textarea1.value.length == 0){
	        alert("Please explain [If you are adopting a dog, is there anytime that you would chain the dog up]");
	        form.q4_select5_textarea1.focus();
	        return false;
	    }
	}
	

	if (form.q5_textarea1.value.length > 0){
	    if (form.q5_select1[form.q5_select1.selectedIndex].value.length == 0){
	        alert("Please select [Are these pets spayed or neutered]");
	        form.q5_select1.focus();
	        return false;
	    }
	    if (form.q5_select1[form.q5_select1.selectedIndex].value == "Other"){
	        if (form.q5_select1_textarea1.value.length == 0){
	            alert("Please explain [Are these pets spayed or neutered]");
	            form.q5_select1_textarea1.focus();
	            return false;
	        }
	    }
	}
    if (form.q5_textarea2.value.length > 0){
    
        if ((form.q5_checkbox1.checked == false) && 
            (form.q5_checkbox2.checked == false) && 
            (form.q5_checkbox3.checked == false) &&
            (form.q5_checkbox4.checked == false) &&
            (form.q5_checkbox5.checked == false)){
            
            alert("Please select [What happened to your pets]");
            form.q5_checkbox1.focus();
            return false;
        }
    }
	
	
	
return true;

}




