<!--

////////////////////////////////////////////////////////////
// trim
////////////////////////////////////////////////////////////
function trim(str) {
    str.replace(/^\s*/, '').replace(/\s*$/, '');
    return str;
}

////////////////////////////////////////////////////////////
// validate multi-select
////////////////////////////////////////////////////////////
function valselect(choice) {
choiceVal = "";
for (var i=0; i < choice.length; i++)
   {
   if (choice[i].selected)
      {
      choiceVal = choiceVal + choice[i].value + ", ";
      }
   }
	if ("" == choiceVal) {
        return false;
		} else {
		return true;	
		}
	//alert (choiceVal);
}

////////////////////////////////////////////////////////////
// validate radio buttons
////////////////////////////////////////////////////////////
function valbutton(buttons) {
	//alert (buttons);
	var check = -1;
	buttonVal = "";
	for (i=(buttons.length)-1; i > -1; i--) {
		if (buttons[i].checked) {
		check = i;
		break;
		}
	}
	if (-1 == check) {
        return false;
		} else {
		buttonVal = (buttons[i].value);
	 	//alert (buttonVal);
		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_vet_type			= "Vet Specialty Type\n";
var i18n_phone				= "Phone number\n";
var i18n_fax				= "Fax number\n";
var i18n_email				= "Email Address\n";
var i18n_samplepack			= "Choose a Sample Pack\n";

function validate(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 vet_type
    if(!valselect(ob.elements['_00N70000001tBZ7'])) {
        isValid = false;
        errorMsg += i18n_vet_type;
	} else {	
	ob.elements['00N70000001tBZ7'].value = choiceVal;
	//alert (ob.elements['00N70000001tBZ7'].value);
		}

	
	// validate phone
    if(trim(ob.elements['phone'].value) == "") {
        isValid = false;
        errorMsg += i18n_phone;
    }

   // validate email
    if(trim(ob.elements['email'].value) == "") {
        isValid = false;
        errorMsg += i18n_email;
    }

// display error message
    if(isValid == false) {
        errorMsg = i18n_message1 + i18n_message2 + errorMsg;
		//alert("is valid is false");
        alert(errorMsg);
    }
	
	return isValid;
}

//-->
