function verify_email(id)
{	var pass=-1;
	var npass=-1;
	var pass1=-1;
	
	if(id=="")
	{
		return(false);
	}
	if(id != "") 
	{
		pass = id.indexOf('@',0);
		if((pass<1)) 
		{
			return (false);
		}
		else
		{	
			npass=id.indexOf('@',pass+1);
			if(npass>-1)
			{
				return (false);
			}
		}
		pass1 = id.indexOf('.',pass);
		if((pass1<5)||pass1==id.length-1)
		{
			return(false);
		}
	}
	return (true);
}
function chk_blank(con)
{
	if(con.value=="")
	{
		con.style.borderColor="#FF0000";		
	}
	else
	{
		con.style.borderColor="#000000";	
	}
}

function chk_email(con)
{
	if(!verify_email(con.value))
	{
		con.style.borderColor="#FF0000";		
	}
	else
	{
		con.style.borderColor="#000000";	
	}
}

function validate_quick_contact()
{
	var f=document.forms["form1"];
	if(f.fname.value=="")
	{	
	  f.fname.style.borderColor="#FF0000";
		$(document).ready(function () {
			$("#ce_fname").html("Enter Your First Name <div id='close_frm'><img src='images/close_button.png' id='name_cls'/></div>");
			$("#ce_fname").fadeIn(500);
			$("#name_cls").click(function(){ 
			$("#ce_fname").fadeOut(500); 
			});
		});
		f.fname.focus();
		return false;
	}
	else
	{
		f.fname.style.borderColor="#000000";	
		$(document).ready(function(){
			$("#ce_fname").fadeOut(500); 
		});	
	}
	
	/*if(f.mname.value=="")
		{	
		f.mname.style.borderColor="#FF0000";
			$(document).ready(function () {
				$("#ce_mname").html("Enter Your Middle Name <div id='close_frm'><img src='images/close_button.png' id='mname_cls'/></div>");
				$("#ce_mname").fadeIn(500);
				$("#mname_cls").click(function(){ 
				$("#ce_mname").fadeOut(500); 
				});
		});
		f.mname.focus();
		return false;
	}
	else
	{
		f.mname.style.borderColor="#000000";	
		$(document).ready(function(){
			$("#ce_mname").fadeOut(500); 
		});	
	}	*/
	
	if(f.lname.value=="")
		{	
		f.lname.style.borderColor="#FF0000";
			$(document).ready(function () {
				$("#ce_lname").html("Enter Your Last Name <div id='close_frm'><img src='images/close_button.png' id='lname_cls'/></div>");
				$("#ce_lname").fadeIn(500);
				$("#lname_cls").click(function(){ 
				$("#ce_lname").fadeOut(500); 
				});
		});
		f.lname.focus();
		return false;
	}
	else
	{
		f.lname.style.borderColor="#000000";	
		$(document).ready(function(){
			$("#ce_lname").fadeOut(500); 
		});	
	}

	if(f.saname.value=="")
		{	
		f.saname.style.borderColor="#FF0000";
			$(document).ready(function () {
				$("#ce_saname").html("Enter Your Street Address <div id='close_frm'><img src='images/close_button.png' id='saname_cls'/></div>");
				$("#ce_saname").fadeIn(500);
				$("#saname_cls").click(function(){ 
				$("#ce_saname").fadeOut(500); 
				});
		});
		f.saname.focus();
		return false;
	}
	else
	{
		f.saname.style.borderColor="#000000";	
		$(document).ready(function(){
			$("#ce_saname").fadeOut(500); 
		});	
	}
	
	if(f.cname.value=="")
		{	
		f.cname.style.borderColor="#FF0000";
			$(document).ready(function () {
				$("#ce_cname").html("Enter Your City<div id='close_frm'><img src='images/close_button.png' id='cname_cls'/></div>");
				$("#ce_cname").fadeIn(500);
				$("#cname_cls").click(function(){ 
				$("#ce_cname").fadeOut(500); 
				});
		});
		f.cname.focus();
		return false;
	}
	else
	{
		f.cname.style.borderColor="#000000";	
		$(document).ready(function(){
			$("#ce_cname").fadeOut(500); 
		});	
	}

	if(f.state.value=="")
		{	
		f.state.style.borderColor="#FF0000";
			$(document).ready(function () {
				$("#ce_state").html("Enter Your State <div id='close_frm'><img src='images/close_button.png' id='state_cls'/></div>");
				$("#ce_state").fadeIn(500);
				$("state_cls").click(function(){ 
				$("#ce_state").fadeOut(500); 
				});
		});
		f.state.focus();
		return false;
	}
	else
	{
		f.state.style.borderColor="#000000";	
		$(document).ready(function(){
			$("#ce_state").fadeOut(500); 
		});	
	}

	if(f.zip.value=="")
		{	
		f.zip.style.borderColor="#FF0000";
			$(document).ready(function () {
				$("#ce_zip").html("Enter Your Zip code <div id='close_frm'><img src='images/close_button.png' id='zip_cls'/></div>");
				$("#ce_zip").fadeIn(500);
				$("#zip_cls").click(function(){ 
				$("#ce_zip").fadeOut(500); 
				});
		});
		f.zip.focus();
		return false;
	}
	else
	{
		f.zip.style.borderColor="#000000";	
		$(document).ready(function(){
			$("#ce_zip").fadeOut(500); 
		});	
	}


	if(verify_email(f.email.value)==false)
	{	
		f.email.style.borderColor="#FF0000";
		$(document).ready(function () {
			$("#ce_email").html("Enter valid Email <div id='close_frm'><img src='images/close_button.png' border='0' id='email_cls' /></div>");
			$("#ce_email").fadeIn(500);
			$("#email_cls").click(function(){ 
			$("#ce_email").fadeOut(500);
			});
		});
		f.email.focus();
		return false;
	}
	else
	{
		f.email.style.borderColor="#000000";	
		$(document).ready(function(){
			$("#ce_email").fadeOut(500); 
		});		
	}
	
	if(f.tyinsurance.value=="")
	{
		f.tyinsurance.style.borderColor="#FF0000";
		$(document).ready(function () {
			$("#ce_tyinsurance").html("Enter Type of Insurance <div id='close_frm'><img src='images/close_button.png' border='0' id='tyinsurance_cls' /></div>");
			$("#ce_tyinsurance").fadeIn(500);
			$("#tyinsurance_cls").click(function(){ 
			$("#ce_tyinsurance").fadeOut(500);
			});
		});
		f.tyinsurance.focus();
		return false;
	}
	else
	{
		f.tyinsurance.style.borderColor="#000000";	
		$(document).ready(function(){
			$("#ce_tyinsurance").fadeOut(500); 
		});	
	}
	
	$.ajax({
		   type: "POST",
		   url: "sendmail.php",
		   data: $(f).serialize(),
		   success: function(msg){
			$(':input',f)
			 .not(':button, :submit, :reset, :hidden')
			 .val('');
			
	   		$("form1").html(msg);
			window.location = 'contact_success.php';
			}
	 });

    return false;
}


