jQuery(function(){
		jQuery('.pleaseValidate').submit(function(){
				jQuery('.errors').hide();
				var defaults=Array('Name','Email','Company','Telephone');
				var process=true;
				var red='#BD161D';
				var text_color='#898989';
				var border_color='#cccccc';
				jQuery(this).find('.required').each(function(){
					$this=jQuery(this);
					$this.css({
							'border-color':border_color,
							'color':text_color
					});
					jQuery('label[for='+$this.attr('id')+']').css({
							'color':text_color
					});
					
					if($this.attr('value').length<=0 || defaults.in_array($this.attr('value'))){
						$this.css({
							'border-color':red,
							'color':red
						});
						jQuery('label[for='+$this.attr('id')+']').css({
							'color':red
						});
						process=false;
					}
					
				});
				jQuery(this).find('.email').each(function(){
						$this=jQuery(this);
						if($this.attr('value').length>0 && !defaults.in_array($this.attr('value')) &&  !$this.attr('value').match(/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/)){
							$this.css({
									'border-color':red,
									'color':red
							});
							jQuery('label[for='+$this.attr('id')+']').css({
									'color':red
							});
							process=false;
						}
				});
				
				if(!process){
					jQuery('.errors').css({'background-color':'#FFF799','padding':'10px'}).slideDown();
				}
				
				return process;
		});
});

Array.prototype.in_array = function(p_val) {
	for(var i = 0, l = this.length; i < l; i++) {
		if(this[i] == p_val) {
			return true;
		}
	}
	return false;
}

