
	jQuery(document).ready(function($){
		$("#feedbackForm").validate();
		$("#subscribeForm").validate();
		$("#appointmentForm").validate();
				
		$(".ajaxFormSwitch").click(function(e){
			var formName = e.currentTarget.id + 'Form';
			var $form = $("#"+formName);
			$boxyform = new Boxy('#'+formName, {title: e.currentTarget.rel, modal: true});
			$form.find(".response").text('').hide();
			$form.find(":text, textarea").val('');
			$form.find(".form-elements").show();
			$form.find('input[type="text"],textarea').first().focus();
			return false;
		});

		$(".staticDisplaySwitch").click(function(e){
			var formName = e.currentTarget.id + 'Form';
			$boxyform = new Boxy('#'+formName, {title: e.currentTarget.rel});
			return false;
		});

		$("#mapdirections").click(function(e){
			new Boxy('#locationmap', {title: '<span style="font-size:1.2em; font-family: Arial, sans-serif, Tahoma, Helvetica;">BEES beauty</span><br/>17/6, Jawaharlal Nehru Road, Ambal Nagar<br/>Ekkatuthangal, Chennai, TamilNadu, INDIA - 600032'});
			return false;
		});
		
		$(".cancel-form").click(function(e){
			var $form = $(this).parents('form');
			$form.validate().resetForm();
			$form.hide();
			return false;
		});
		
		$('.ajaxform').submit(function(e) {
			$thisForm = $('#'+e.currentTarget.id);
			if($thisForm.validate().numberOfInvalids() > 0) {
				return false;
			}
			$.post(e.currentTarget.action, $thisForm.serialize(), function(data) {
			$thisForm.find(".response").html(data).show();
			$thisForm.find(".form-elements").hide();
			});
			return false;
		});
		$.get('feedbacks.php', function(data) {
			$('#feedbacks').html(data);		
		});
		$.get('offers.php', function(data) {
			$('#offers').html(data);		
		});
	 });

