/* Validate Order and Order form */

function validateContactForm()
{

	var isError = false;
	var errStr = 'Could not proceed further, there is/are some error(s) in your form submission. Have a look on the error(s) below:\n\n';
	
	if ($.trim($("input[@name=customerName]").val()) == '') {
		errStr += '* Please enter you Name.\n';	
		isError = true;
	}
	
	if ($.trim($("input[@name=customerEmailID]").val()) == '') {
		errStr += '* Please enter your Email ID.\n';	
		isError = true;
		
	} else {
		if (!isValidEmail($.trim($("input[@name=customerEmailID]").val()))) {
			errStr += '* Incorrect Email ID format.\n';	
			isError = true;																 
		}
	}	
	
	if ($.trim($("textarea[@name=comments]").val()) == '') {
		errStr += '* Please enter your Message.\n';	
		isError = true;
	}
	
	if ($.trim($("input[@name=verificationCode]").val()) == '') {
		errStr += '* Please enter the Verification code.\n';	
		isError = true;
	}
	
	if (isError) {
		alert(errStr);
		return false;
	}	
}


/* ADD-ONS functions */

function isValidEmail(email)
{
	return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email);
}


function isValidUrl(s) 
{
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	return regexp.test(s);
}


function isNumberKey(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
		if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;
	
	return true;
}
