// jQuery ignition

$(document).ready(function() {
	  
$.validator.addMethod("lettersOnly", function(value, element) { 
// Addon method for validating letter-only text boxes.
        return this.optional(element) || /^[a-z]+$/i.test(value); 

}, 'This field accepts letters only.');


$.validator.addMethod("numbersOnly", function(value, element) {
        return this.optional(element) || /^[0-9\-\+]+$/i.test(value);
    }, "Phone must contain only numbers, + and -.");


$.validator.addMethod("postalCode", function(value, element) { 
// Addon method for validating postal codes. Valid formats are (X1X 1X1) or (X1X1X1) or (X1X-1X1).
        return this.optional(element) || /^[a-zA-Z][0-9][a-zA-Z](-| )?[0-9][a-zA-Z][0-9]$/i.test(value);

}, 'Please enter a valid postal code');


//You can then use the rule postalCode:true to validate. 


	  
	  
$("#the_form").validate();


//$('#date').datepicker();

var emailtext = $('#register_form .email').val();
$('register_form .email').css('color','#ccc');
//set this variable to whatever you want in the email box as defualt text

$('#register_form input.email').bind('focus',function(){
	if($(this).val()== emailtext) {
		$(this).val('');
		$(this).css('color','#000');
	}
});
$('#register_form input.email').bind('blur',function(){
	if($(this).val()=='') {
		$(this).val(emailtext);
		$(this).css('color','#ccc');
	}
});
$('#register_form').submit(function(event){
	event.preventDefault();
	if($('#register_form input.email').val() == emailtext)
	{
		return false;
	}
	var id = $(this).attr('id');
	var uri= $(this).attr('action');
	var sendThisData = $(this).serialize();
	$.post(uri, sendThisData,
	   function(data) {
	   $('#register_form .email').val(data);
	});
	return false;
});

});

