<!--

////////////////////////////////////////////////////////////
// trim
////////////////////////////////////////////////////////////
function trim(str) {
    str.replace(/^\s*/, '').replace(/\s*$/, '');
    return str;
}

////////////////////////////////////////////////////////////
// validate multi-select
////////////////////////////////////////////////////////////
function valselect(choice) {	
	//alert("choice var:" + choice);
	choiceVal = "";
	for (var i=0; i < choice.length; i++) {
	   if (choice[i].checked) {
	      choiceVal = choiceVal + choice[i].value + "; ";
	      }
	   	}
	//alert("choiceVal: " + choiceVal);
	if ("" == choiceVal) {
       return false;
	} else {
       return true;
	}
}

////////////////////////////////////////////////////////////
// validate
////////////////////////////////////////////////////////////
var i18n_message1   		= "The following fields are required:\n";
var i18n_message2   		= "Please correct the errors and try again.\n\n";
var i18n_first_name			= "First name\n";
var i18n_last_name  		= "Last name\n";
var i18n_company			= "Practice Name\n";
var i18n_street				= "Address\n";
var i18n_city       		= "City\n";
var i18n_state      		= "State/Province\n";
var i18n_zip				= "Postal Code\n";
var i18n_email				= "Email Address\n";
var i18n_phone				= "Phone number\n";
var i18n_phone				= "Phone number\n";
var i18n_product			= "Product(s) Interested in\n";

function validate(ob) {	
    //alert("Object:" + ob);
	var errorMsg = "";
    var isValid = true;
    // validate first name
    if(ob.elements['first_name'].value == "") {
        isValid = false;
        errorMsg += i18n_first_name;
		//alert("first name is blank");
    }

    // validate last name
    if(trim(ob.elements['last_name'].value) == "") {
        isValid = false;
        errorMsg += i18n_last_name;
    }

    if(trim(ob.elements['company'].value) == "") {
        isValid = false;
        errorMsg += i18n_company;
    }

	// validate street
    if(trim(ob.elements['street'].value) == "") {
        isValid = false;
        errorMsg += i18n_street;
    }
	
    // validate city
    if(trim(ob.elements['city'].value) == "") {
        isValid = false;
        errorMsg += i18n_city;
    }
	
	// validate state
    if(trim(ob.elements['state'].value) == "") {
        isValid = false;
        errorMsg += i18n_state;
    }

    // validate zip
    if(trim(ob.elements['zip'].value) == "") {
        isValid = false;
        errorMsg += i18n_zip;
    }
	
   // validate email
    if(trim(ob.elements['email'].value) == "") {
        isValid = false;
        errorMsg += i18n_email;
    }

	// validate phone
    if(trim(ob.elements['phone'].value) == "") {
        isValid = false;
        errorMsg += i18n_phone;
    }

/*	// validate product
	$value_vs2 = document.vet_order_form.interested_in_vs2.checked;
	$value_hm5 = document.vet_order_form.interested_in_hm5.checked;
	$value_vspro = document.vet_order_form.interested_in_vspro.checked;
	$value_profiles = document.vet_order_form.interested_in_profiles.checked;
	
	if (!$value_vs2 && !$value_hm5 && !$value_vspro && !$value_profiles) {
        isValid = false;
        errorMsg += i18n_product;
	}
*/
	// validate vet_type
	if(valselect(ob.elements['productsinterestedintxt'])) {	
		ob.elements['abaxis_productsinterestedintxt'].value = choiceVal;
		//alert(ob.elements['abaxis_productsinterestedintxt'].value);
	} else {	
	    isValid = false;
	    errorMsg += i18n_product;	
	}

	// display error message
    if(isValid == false) {
        errorMsg = i18n_message1 + i18n_message2 + errorMsg;
		//alert("is valid is false");
        alert(errorMsg);
    }
	
	return isValid;
}

//-->

