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;
	}
	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 = /^([\x20\0-9-\+\(\)\_.-])+$/;
	if(!filter.test(phone))	
	{
		$("#phone-error").slideDown(500);
		$("#phone").focus();
		return false;
	}
	else
		$("#phone-error").slideUp(500);
		
	// check for seo_plan
	var sel = $("#seo_plan :selected").val();
	if(sel == 0)
	{
		$("#seo_plan-error").slideDown(500);
		$("#seo_plan").focus();
		return false;
	}
	else
		$("#seo_plan-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 = $("#contact_form > form").serialize();

	$.ajax({
		type: "POST",
		url: "/sendContact-pack.php",
		data: data,
		cache: false,
		success: function(msg){
		  captcha_result(msg)
		}
	});
	
	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 captcha_result(msg)
{
  if( msg=="OK" ){
	$("#message_sent").show();
	$("#contact_form").fadeOut(2000, function()  {
//		$("#message_sent").slideDown(500);
		$("#message_sent").show();
		setTimeout('$.fn.colorbox.close()',500)
	});
  }else{
//      $("#captcha-error").slideUp(500);
      $("#captcha-error").show();
  }

}

function generate_captcha(id)
{
	var id = (id) ? id : 'lcaptcha';
	$("#"+id).html(captcha_a + " + " + captcha_b + " = ");
}
