/* -------------------------------------
/////////////////////////////////////////
// Simple Form Validation with JQuery. //
/////////////////////////////////////////
// C.Burnett :: 09.05.06 ////////////////
/////////////////////////////////////////
---------------------------------------*/
//var str = 'marcus@airtightdesign.com';str.isEmail();
/* -------------------------------------
/////////////////////////////////////////
// Simple Form Validation with JQuery. //
/////////////////////////////////////////
// C.Burnett :: 09.05.06 ////////////////
/////////////////////////////////////////
---------------------------------------*/
$.fn.validate = function() {
	var er = 0;
    var defaultMsg = 'This field is required';
	$('.form-error',this).remove();
    // Not empty validation
	$(".required input[type='text'], .required select",this).each(function (i) {
		var v = this.value;
		if(v === ''){
			var msg  = ($(this).attr('title') !== undefined) ? $(this).attr('title') : defaultMsg;
			var html = '<span class="form-error">'+msg+'</span>';
			$('#'+this.id).after(html);
			console.log('#'+this.id);
			er++; 
		} else {
			$('#'+this.id).removeClass('form-error');
		}
	});
	// Catch Submit Event on Error
	if (er) {
		return false;
	}else{
		return true;
	}
}