function input_focus(id)
{
	$("#l"+id).addClass('lcurrent');
}

function input_blur(id)
{
	$("#l"+id).removeClass('lcurrent');
}

function sendContact()
{

	// check for name
	var msg = $("#name").val();
	if(msg.length == 0)
	{
		$("#name-error").slideDown(500);
		$("#name").focus();
		return false;
	}
		if(msg == "name")
	{
		$("#name-error").slideDown(500);
		$("#name").focus();
		return false;
	}
	else
		$("#name-error").slideUp(500);
		
	// check for email
	var email = $("#email").val();
	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if(!filter.test(email))	
	{
		$("#email-error").slideDown(500);
		$("#email").focus();
		return false;
	}
	else
		$("#email-error").slideUp(500);
		
	// check for phone
	var phone = $("#phone").val();
	var filter = /^([0-9)(_.-])+$/;
	if(!filter.test(phone))	
	{
		$("#phone-error").slideDown(500);
		$("#phone").focus();
		return false;
	}
	else
		$("#phone-error").slideUp(500);
	
	// check for how_did_you_hear_about_us
	var sel = $("#how_did_you_hear_about_us :selected").val();
	if(sel == 0)
	{
		$("#how_did_you_hear_about_us-error").slideDown(500);
		$("#how_did_you_hear_about_us").focus();
		return false;
	}
	else
		$("#how_did_you_hear_about_us-error").slideUp(500);



	// check for captcha
	var captcha = $("#captcha").val();
	if(captcha != captcha_c)
	{
		$("#captcha-error").slideDown(500);
		$("#captcha").focus();
		return false;
	}
	else
		$("#captcha-error").slideUp(500);	
	
	var data = $("#qwform > form").serialize();

	$.ajax({
		type: "POST",
		url: "/qContact.php",
		data: data,
		cache: false,
		success: function(msg){
		}
	});
	
	$("#qwform").fadeOut(1000, function() {
		$("#message_sent").slideDown(500);
		if (window.chrome) 
		{
			setTimeout("window.location.href='http://www.nsbcharters.com/thank-you.html'", 100 );
		}
		else
			document.getElementById('myLinkId').click();
	});
	return false;
}
var captcha_a = Math.ceil(Math.random() * 10);
var captcha_b = Math.ceil(Math.random() * 10);       
var captcha_c = captcha_a + captcha_b;
function generate_captcha(id)
{
	var id = (id) ? id : 'lcaptcha';
	$("#"+id).html(captcha_a + " + " + captcha_b + " = ");
}
