// JavaScript Document


$(function() 
{

function getQuerystring(key, default_)
{
  if (default_==null) default_=""; 
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}

var formsuccess_value = getQuerystring('formsuccess');

if( formsuccess_value == "true") 
{ 
 $("#sign-up-home").show().html("<h1>Thank you!</h1>");
 
}
else{

$("ul.sign-up-home li:first").show();
$('#cons_first_name').show();
$("#sign-up-home-intro").show();
var ck_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i 
var ck_name = /^[A-Za-z0-9_]{3,20}$/;


$('#cons_email').keyup(function()
{
var cons_email=$(this).val();
if (!ck_email.test(cons_email)) 
{
 $(this).next().show().html("Enter valid email");
}
else
{
$(this).next().hide();
$("#sign-up-home-intro").hide({duration: 'slow',easing: 'easeOutElastic'});
$("li").next("li.cons_first_name").slideDown({duration: 'slow',easing: 'easeOutElastic'});
}

});

$('#cons_first_name').keyup(function()
{
var cons_first_name=$(this).val();

if (!ck_name.test(cons_first_name)) 
{
 $(this).next().show().html("Min 3 charecters");
}
else
{
$(this).next().hide();
$("li").next("li.cons_last_name").slideDown({duration: 'slow',easing: 'easeOutElastic'});
}
});

$('#cons_last_name').keyup(function()
{
var cons_first_name=$(this).val();
if (!ck_name.test(cons_first_name)) 
{
 $(this).next().show().html("Min 3 charecters");
}
else
{
$(this).next().hide();
$("li").next("li.submit").slideDown({duration: 'slow',easing: 'easeOutElastic'});
}
});


$('#submit').click(function()
{
var cons_email=$("#cons_email").val();
var cons_first_name=$("#cons_first_name").val();
var cons_last_name=$("#cons_last_name").val();

if(ck_email.test(cons_email) && ck_name.test(cons_first_name) && ck_name.test(cons_last_name) )
{
	
$("#sign-up-home").show().html("<h1>Thank you!</h1>");


}
else
{

}
return false;

});

}
})
