$(document).ready(function(){
	
	/* if on contact page */
	if($("#contact-form").length>0){
		$('p.warning').remove();
		$('.addy').hide();
		$.ajax({
			type: "POST",
			url: app.baseurl+'/scripts/ajax/token.php',
			success: function(txt){
				$('fieldset#ghost').append('<input type="hidden" name="ts" value="'+txt+'" />');
			}
		});
		$("#contact-form").validate({
			rules: {
				name: "required",
				email:  {
					required: true,
					email: true
				},
				comments: "required"
			},
			errorElement : "span",
			errorPlacement : function(error,element){
				error.appendTo(element.prev())
			},
			messages: {
				name: "Required",
				email: "Valid Email Required",
				comments: "Required"
			},
			submitHandler: function(form){
				$('#submit').activity({outside: true, align: 'right', segments: 10, steps: 3, width:2, space: 0, length: 3, color: '#DAD9D0', speed: 1.5});
				$(form).ajaxSubmit({
					success: function(){
						$('#contact-form').slideUp('fast');
						$('#submit').activity(false);
						$('div.thanks').slideDown('fast');
					}
				});
			}
		});
	}
	
});

var app = {
    rate: 200,
    baseurl: 'http://localhost/hbs/wp-content/themes/hbs_site/'
};
