



function validateEmail(fld) {
    if (fld.val() != "")
	{
		var tfld = jQuery.trim(fld.val());
		var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
		
		if (!emailFilter.test(tfld)) {      
			return false;
		} else if (fld.val().match(illegalChars)) {
			return false;
		} else {
			return true;
		}
	}
	return false;
}



function validateDPB() {
	
	// Check for Name
	if ($('#dpb_Name_And_Surname').val() == '') {
		$('#validationMsg').html("Please enter your Name and Surname.");
		scroll(0,465);
		$('#validationMsg').fadeIn("Normal");
		return false;
	}
	if ($('#get_captcha_val').val() == '') {
		$('#validationMsg').html("What does the image show?");
		scroll(0,465);
		$('#validationMsg').fadeIn("Normal");
		return false;
	}
	if ($('#get_captcha_val').val() != $('#captcha_val').val()) {
		$('#validationMsg').html("What does the image show?");
		scroll(0,465);
		$('#validationMsg').fadeIn("Normal");
		return false;
	}
	
	
	/* Check for Telephone
	if ($('#dpb_Phone_Number').val() == '') {
		$('#validationMsg').html("Please enter your Contact Number.");
		scroll(0,465);
		$('#validationMsg').fadeIn("Normal");
		return false;
	}
	*/
	
	
	// check if email is valid
	if (!validateEmail($('#dpb_Email_Address'))) {
		$('#validationMsg').html("Please enter a valid Email Address.");
		scroll(0,465);
		$('#validationMsg').fadeIn("Normal");
		return false;
	}
	// check if email is valid
	if ($('#dpb_Email_Address').val() != $('#dpb_Email_Address2').val()) {
		$('#validationMsg').html("The Email Addresses you supplied does not match.");
		scroll(0,465);
		$('#validationMsg').fadeIn("Normal");
		return false;
	}
	
	/*
	// Check Supplier Name
	if ($('#dpb_Supplier_Name').val() == '') {
		$('#validationMsg').html("Please provide the name of the supplier.");
		scroll(0,465);
		$('#validationMsg').fadeIn("Normal");
		return false;
	}
	
	// Check Supplier Location
	if ($('#dpb_Supplier_Location').val() == '') {
		$('#validationMsg').html("Please provide the location of the supplier.");
		scroll(0,465);
		$('#validationMsg').fadeIn("Normal");
		return false;
	}
	
	// Check Quote Date
	if ($('#dpb_Date_of_quote').val() == '') {
		$('#validationMsg').html("Please provide the date of your quote.");
		scroll(0,465);
		$('#validationMsg').fadeIn("Normal");
		return false;
	}
	
	// Check Carat
	if ($('#dpb_Carat').val() == '') {
		$('#validationMsg').html("Please indicate the Carat size of the stone you were quoted on.");
		scroll(0,465);
		$('#validationMsg').fadeIn("Normal");
		return false;
	}
	
	// Check Colour
	if ($('#dpb_Colour').val() == '') {
		$('#validationMsg').html("Please indicate the Colour grading of the stone you were quoted on.");
		scroll(0,465);
		$('#validationMsg').fadeIn("Normal");
		return false;
	}
	
	// Check Clarity
	if ($('#dpb_Clarity').val() == '') {
		$('#validationMsg').html("Please indicate the Clarity grading of the stone you were quoted on.");
		scroll(0,465);
		$('#validationMsg').fadeIn("Normal");
		return false;
	}
	*/
	
	
	return true;	
};




// DOM loaded
$(document).ready(function() {				   			   	

	// Bind step buttons to actions
	$("#btnValidate").click(validateDPB);
	
	// Handles form field focus highlighting for usability purposes
	$("input.diamondEnqField").focus(function(){
		$(this).removeClass('diamondEnqField');
		$(this).addClass('diamondEnqFieldFocus');
	});
	$("input.diamondEnqField").blur(function(){
		$(this).removeClass('diamondEnqFieldFocus');
		$(this).addClass('diamondEnqField');
	});
	
	$("textarea.diamondEnqTA2").focus(function(){
		$(this).removeClass('diamondEnqTA2');
		$(this).addClass('diamondEnqTA2Focus');
	});
	$("textarea.diamondEnqTA2").blur(function(){
		$(this).removeClass('diamondEnqTA2Focus');
		$(this).addClass('diamondEnqTA2');
	});

});
//-->





