function validate(formId)
{
	//var form = document.form;
	var ok = true;
	
	$("form#"+formId).find(".required").not(".email").each(function(){
		if(IsBlank($(this).val()) || $(this).val() == 'name:' || $(this).val() == 'phone:' || $(this).val() == 'email:' || $(this).val() == 'Enter a brief description of your case') 
		{		
			ok = false;
			if($(this).siblings("span.error").length == 0 ){ 
				$(this).siblings("span.error").remove();
				//$(this).css("border","1px solid #f00");
				$(this).after('<span class="error">This is a required field.</span>');
				$(this).siblings("span.error").css("display","block");
			}
		}
		else    
		{
			//$(this).css("border","1px solid #E6E6E6");
			$(this).siblings("span.error").remove();
		}
	});


	$("form#"+formId).find(".email").filter(".required").each(function(){ 
		if(!isValidEmail($(this).val())){ 
			ok = false; 
			if($(this).siblings("span.error").length == 0 ){ 
				$(this).siblings("span.error").remove();
				//$(this).css("border","1px solid #f00");
				$(this).after('<span class="error">Email is invalid.</span>');
				$(this).siblings("span.error").css("display","block");
			}
			
		}else{
		
			//$(this).css("border","1px solid #E6E6E6");
			$(this).siblings("span.error").remove();
			
		}			
	});
	
	if(ok)$("form#"+formId).submit();
	else return false;
}

function IsBlank (strString)
{
	if (strString.length == 0)
		return true;

	for (i = 0; i < strString.length; i++)
	{
		strChar = strString.charAt(i);
		if (strChar != " ")
			return false;
	}
	return true;
}

function isValidEmail(email){

	if (email.length < 5)
		return false;

	subEmail=email.split('@'); //subEmail is a string array (contains strings splitted by '@')
	if (subEmail.length != 2)
		return false;

	dotStr=subEmail[1].split('.'); //dotStr is a string array (contains strings splitted by '.')

	if(dotStr.length<2)
		return false;

	for(i=1;i<dotStr.length;i++){
		if((dotStr[i].length!=2)&&(dotStr[i].length!=3))
			return false;
	}
return true;
}// End isValidEmail
