function  checkForm(this_form){
    if  (!hasValue(this_form.shipping_first_name, "TEXT" )) {
                if  (!putMessage("Please enter your first name")){
                        return false; 
                }
        }
    if  (!hasValue(this_form.shipping_last_name, "TEXT" )) {
                if  (!putMessage("Please enter your last name")){
                        return false; 
                }
        }	
	if  (!hasValue(this_form.shipping_address_1, "TEXT" )) {
                if  (!putMessage("Please enter your address")){
                        return false; 
                }
        }
    if  (!hasValue(this_form.shipping_city, "TEXT" )) {
                if  (!putMessage("Please enter your city")){
                        return false; 
                }
        }	
    if  (!hasValue(this_form.shipping_state, "TEXT" )) {
			if  (!hasValue(this_form.shipping_province, "TEXT" )) {
                if  (!putMessage("Please enter the US State or International Province for the shipping address")){
                        return false; 
                }
       	 	}	
        }
    if  (!hasValue(this_form.shipping_zip, "TEXT" )) {
                if  (!putMessage("Please enter your zip")){
                        return false; 
                }
        }
		
    if  (!hasValue(this_form.shipping_phone, "TEXT" )) {
                if  (!putMessage("Please enter your phone number")){
                        return false; 
                }
        } 
		
	if  (!hasValue(this_form.same_as, "SINGLE_VALUE_CHECKBOX" )) {
		if  (!hasValue(this_form.billing_first_name, "TEXT" )) {
                if  (!putMessage("Please enter your billing first name")){
                        return false; 
                }
        }
		if  (!hasValue(this_form.billing_last_name, "TEXT" )) {
                if  (!putMessage("Please enter your billing last name")){
                        return false; 
                }
        }	
		if  (!hasValue(this_form.billing_address_1, "TEXT" )) {
                if  (!putMessage("Please enter your billing address")){
                        return false; 
                }
        }
    	if  (!hasValue(this_form.billing_city, "TEXT" )) {
                if  (!putMessage("Please enter your billing city")){
                        return false; 
                }
        }	
    	if  (!hasValue(this_form.billing_state, "TEXT" )) {
        	if  (!hasValue(this_form.billing_province, "TEXT" )) {
                if  (!putMessage("Please enter the US State or International Province for the billing address")){
                        return false; 
                }
        	}
        }
    	if  (!hasValue(this_form.billing_zip, "TEXT" )) {
                if  (!putMessage("Please enter your billing zip")){
                        return false; 
                }
        }
		
   	 	if  (!hasValue(this_form.billing_phone, "TEXT" )) {
                if  (!putMessage("Please enter your billing phone number")){
                        return false; 
                }
        } 
    } 
			
	
	
        
        return true;    
}

function  checkForm2(this_form){
    if  (!hasValue(this_form.shipping_first_name, "TEXT" )) {
                if  (!putMessage("Please enter your first name")){
                        return false; 
                }
        }
    if  (!hasValue(this_form.shipping_last_name, "TEXT" )) {
                if  (!putMessage("Please enter your last name")){
                        return false; 
                }
        }	
	if  (!hasValue(this_form.shipping_address_1, "TEXT" )) {
                if  (!putMessage("Please enter your address")){
                        return false; 
                }
        }
    if  (!hasValue(this_form.shipping_city, "TEXT" )) {
                if  (!putMessage("Please enter your city")){
                        return false; 
                }
        }	
    if  (!hasValue(this_form.shipping_state, "TEXT" )) {
			if  (!hasValue(this_form.shipping_province, "TEXT" )) {
                if  (!putMessage("Please enter your shipping state or province")){
                        return false; 
                }
       	 	}	
        }
    if  (!hasValue(this_form.shipping_zip, "TEXT" )) {
                if  (!putMessage("Please enter your zip")){
                        return false; 
                }
        }
		
    if  (!hasValue(this_form.shipping_phone, "TEXT" )) {
                if  (!putMessage("Please enter your phone number")){
                        return false; 
                }
        } 
		

		if  (!hasValue(this_form.billing_first_name, "TEXT" )) {
                if  (!putMessage("Please enter your billing first name")){
                        return false; 
                }
        }
		if  (!hasValue(this_form.billing_last_name, "TEXT" )) {
                if  (!putMessage("Please enter your billing last name")){
                        return false; 
                }
        }	
		if  (!hasValue(this_form.billing_address_1, "TEXT" )) {
                if  (!putMessage("Please enter your billing address")){
                        return false; 
                }
        }
    	if  (!hasValue(this_form.billing_city, "TEXT" )) {
                if  (!putMessage("Please enter your billing city")){
                        return false; 
                }
        }	
    	if  (!hasValue(this_form.billing_state, "TEXT" )) {
        	if  (!hasValue(this_form.billing_province, "TEXT" )) {
                if  (!putMessage("Please enter your billing state or province")){
                        return false; 
                }
        	}
        }
    	if  (!hasValue(this_form.billing_zip, "TEXT" )) {
                if  (!putMessage("Please enter your billing zip")){
                        return false; 
                }
        }
		
   	 	if  (!hasValue(this_form.billing_phone, "TEXT" )) {
                if  (!putMessage("Please enter your billing phone number")){
                        return false; 
                }
        } 
     
			
	
	
        
        return true;    
}


function  checkForm3(this_form){
	if  (!hasValue(this_form.billing_first_name, "TEXT" )) {
                if  (!putMessage("Please enter your first name as it appears on your credit card")){
                        return false; 
                }
        }
	if  (!hasValue(this_form.billing_last_name, "TEXT" )) {
                if  (!putMessage("Please enter your last name as it appears on your credit card")){
                        return false; 
                }
        }	
	if  (!hasValue(this_form.card_number, "TEXT" )) {
                if  (!putMessage("Please enter your credit card number")){
                        return false; 
                }
        }	
	if  (!hasValue(this_form.cvs, "TEXT" )) {
                if  (!putMessage("Please enter the cvs code on the back of your credit card")){
                        return false; 
                }
        }	
	if  (!hasValue(this_form.email, "TEXT" )) {
                if  (!putMessage("Please enter your email address")){
                        return false; 
                }
        } else {
                if (!checkEmail(this_form.email)){
                        if  (!putMessage("Please enter valid email address")){
                                return false; 
                        }
                }
        }

}

function  checkEmail2(this_form){

	if  (!hasValue(this_form.email, "TEXT" )) {
                if  (!putMessage("Please enter your email address")){
                        return false; 
                }
        } else {
                if (!checkEmail(this_form.email)){
                        if  (!putMessage("Please enter valid email address")){
                                return false; 
                        }
                }
        }

}


function putMessage(error_message){
        alert(error_message);
        return false;   
}

function checkEmail(email){
        var email_string = email.value; 
        var at_position = email_string.indexOf('@'); 
        var dot_position = email_string.indexOf('.', at_position); 
        var extension = email_string.substring(dot_position+1,email_string.length); 
        
        if(at_position<0){
                return false; 
        } else if (dot_position<0){
                return false; 
        } else if (extension.length<=0){
                return false; 
        } 
        return true; 
}

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 == "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;   
        } else  if (obj_type == "SELECT") {
                if (obj.selectedIndex == 0)
                        return false;
                else
                        return true;
        }
}

function hasValue2(obj1, obj2, obj3, obj4, obj5, obj6){
        var flag = 0;
        for (i=1; i < 7; i++){
                if (obj[i].checked)
                        flag = i;
                }
        if (flag == 0)
                return false;
        else
                return true;
}


function clearinputText() {
  document.frm.email.value= "";
}


