// JavaScript Document
function validate_renew(renew){
	
		var email = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; 
	var msg = "";
	if(isEmpty(renew.name.value)){
		alert("Please enter your name.");
		renew.name.focus();
		return false;
	}
	
	else if(isEmpty(renew.company.value)){
		alert("Please enter your company name.");
		renew.company.focus();
		return false;
	}
	else if(isEmpty(renew.email.value) || !email.test(renew.email.value)  ){
		alert("Please enter valid email address.");
			renew.email.focus();
		return false;
	}
	else if(isEmpty(renew.state.value)){
		alert("Please enter your state.");
		renew.state.focus();
		return false;
	}
	else if(isEmpty(renew.zipcode.value)){
		alert("Please enter your Zipcode.");
		renew.zipcode.focus();
		return false;
	}
	else if(isEmpty(renew.phone.value) || !IsInteger(renew.phone.value) ){
		alert("Please enter a valid phone number.");
		renew.phone.focus();
		return false;
	}
	
		else if(isEmpty(renew.no_of_licenses.value) || !IsInteger(renew.no_of_licenses.value)){
		alert("Please enter How many licenses do you currently own?.Should be a Number");
		renew.no_of_licenses.focus();
		return false;
	}
			
		else if(isEmpty(renew.no_of_licenses_add.value) || !IsInteger(renew.no_of_licenses_add.value)){
		alert("Please enter How many licenses would you like to add or subtract?.Should be a Number");
		renew.no_of_licenses_add.focus();
		return false;
	}	
	else if(isEmpty(renew.exp_date.value)){
		alert("Please enter Expiration Date");
		renew.exp_date.focus();
		return false;
	}
		else if(isEmpty(renew.key.value) ){
		alert("Please enter Grant / Serial / Key or License ");
			renew.key.focus();
		return false;
	}	
	else if(isEmpty(renew.years.value) || !IsInteger(renew.years.value)){
		alert("Please enter 'For how many years are you wanting to renew?'.Should be a Number ");
		renew.years.focus();
		return false;
	}

	
	else
		return true;

}

function validate_eval_form(thefrm){
	var email = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; 
	if(isEmpty(thefrm.contactname.value)){
		alert("Please enter Primary Contact name.");
		thefrm.contactname.focus();
		return false;
	}
	else if(isEmpty(thefrm.contactnum.value) || !IsInteger(thefrm.contactnum.value) ){
		alert("Please enter a valid Primary Contact number.");
		thefrm.contactnum.focus();
		return false;
	}
	else if(isEmpty(thefrm.itcontact.value)){
		alert("Please enter Your IT Contact.");
		thefrm.itcontact.focus();
		return false;
	}
	else if(isEmpty(thefrm.itnumber.value) || !IsInteger(thefrm.itnumber.value) ){
		alert("Please enter a valid  IT Contact number.");
		thefrm.itnumber.focus();
		return false;
	}
	else if(isEmpty(thefrm.ship_eval_unit.value)){
		alert("Please enter address to ship Evaluation box.");
		thefrm.ship_eval_unit.focus();
		return false;
	}
	else if(isEmpty(thefrm.address2.value)){
		alert("Please enter address 2.");
		thefrm.address2.focus();
		return false;
	}
	else if(isEmpty(thefrm.state.value)){
		alert("Please enter State.");
		thefrm.state.focus();
		return false;
	}
	else if(isEmpty(thefrm.zipcode.value) || !IsInteger(thefrm.zipcode.value) ){
		alert("Please enter a valid Zipcode.");
		thefrm.zipcode.focus();
		return false;
	}
	else
		return true;
	
	
}
	

function validate_quote(thefrm){
	//alert('test..');
	var email = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; 
	var msg = "";
	if(isEmpty(thefrm.name.value)){
		alert("Please enter your name.");
	thefrm.name.focus();
		return false;
	}
	else if(isEmpty(thefrm.phone.value) || !IsInteger(thefrm.phone.value) ){
		alert("Please enter a valid phone number.");
		thefrm.phone.focus();
		return false;
	}
	else if(isEmpty(thefrm.company.value)){
		alert("Please enter your company name.");
		thefrm.company.focus();
		return false;
	}
	else if(isEmpty(thefrm.email.value) || !email.test(thefrm.email.value)  ){
		alert("Please enter valid email address.");
		thefrm.email.focus();
		return false;
	}
	else
		return true;
}


///////////////////////////
function IsInteger(snum)
{
	var reInteger = /^\d+$/
    return reInteger.test(snum)
}

// Check whether string s is empty.
function isEmpty(s)
{   
	return ((s == null) || (s.length == 0) || (s.substr(0,1) == " "))
}