
/*function resizeFrame() 
{
    var h = $(document).height();
    var w = $(document).width();
	//alert('height : ' + h + '\n width : ' + w );
    $("#background").css('height', h);
}*/
$(document).ready(function(){


	$(".appointments").colorbox({
	  width:"370px",
      height:"507px",
      inline:true,
      href:"#appointments",
      onLoad:function(){ $("#cboxClose").hide();}
    });

	$(".feedback").colorbox({width:"303px", height:"353px",inline:true, href:"#feedback", onLoad:function(){ $("#cboxClose").hide();}});

	$(".corporates").colorbox({width:"252px", height:"164px",inline:true, href:"#corporates", onLoad:function(){ $("#cboxClose").hide();}});

	$(".careers").colorbox({width:"303px", height:"355px", iframe:true, href:"careers.php"});

	$(".gifting").colorbox({width:"380px", height:"304px",inline:true, href:"#gifting", onLoad:function(){ $("#cboxClose").hide();}});
	
	$("p.buttons #Ok").click(function(){
		window.open("http://www.cheervoucher.com/PersonalizeVoucher.aspx?BrandID=25&LocationID=", '_blank');
	})

    $(".cancel").click(function(){
        $.colorbox.close()
    });




//jQuery.event.add(window, "load", resizeFrame);
//jQuery.event.add(window, "resize", resizeFrame);

  $("SELECT").selectBox();

  $("#time").mask("99:99");

  $(".contact_number").mask("9999999999");
  
  
  

// ######################  VALIDATE APPOINTMENT FORM  ######################## //

	$("#appointment_form").validate({
		rules: {
			fullname: "required",
			services: "required",
			location: "required",
			time: "required",
			date: "required",
			contact_number: "required"
		},
		messages: {
			time: "Please enter a time.",
			date: "Please enter a date.",
			contact_number: "Please enter a valid Contact Number.",
			services: "Please Select any One"
		},
		submitHandler: submitFrom
	});

// ######################  VALIDATE FEEDBACK FORM  ######################## //

	$("#feedback_form").validate({
		rules: {
			fullname: "required",
			contact_number: "required",
			comments: "required",
			email: {
				required: true,
				email: true
			}
		},
		messages: {
			contact_number: "Please enter a valid Contact Number.",
			email: "Please enter a valid Email."
		},
		submitHandler: submitFrom
	});


/*  $("input[type=file]").filestyle({
      image: "images/bt_browse.gif",
      imageheight : 23,
      imagewidth : 53
  });

*/
// ######################  VALIDATE FEEDBACK FORM  ######################## //

	/*$("#careers_form").validate({
		rules: {
			fullname: "required",
			contact_number: "required",
			comments: "required",
			email: "required",
			position: "required",
			browse: "required",
			browse : {
				url : true
			},	
		},
		messages: {
			contact_number: "Please enter a valid Contact Number.",
			email: "Please enter a valid Email.",
			position: "Please Select a Position",
			browse: "Please Attach a file."
		},
		submitHandler: submitFrom
	});*/
	
	$("#date").datepicker({
		showOn: "button",
		buttonImage: "images/icon_calender.gif",
		buttonImageOnly: true
	});

	$(".scroll-content").jScrollPane({
		showArrows:true,
		arrowScrollOnHover:true,
		verticalDragMinHeight: 0,
		verticalDragMaxHeight: 0,
		clickOnTrack: false,
		arrowButtonSpeed : 5
	});

	$(".scroll-content1").jScrollPane({
		showArrows:true,
		arrowScrollOnHover:true,
		verticalDragMinHeight: 0,
		verticalDragMaxHeight: 0,
		clickOnTrack: false,
		arrowButtonSpeed : 5,
		autoReinitialise: true
	});
	
});


	
function submitFrom(form) {
	var obj = $('form#'+form.id);
	
	var formData = $('form#'+form.id).serialize()+'&command='+form.id;
	
	//console.log(formData);
	
	$.post("form_submit.php",  formData , function(data) {
		if(data.status=='success') {
			obj.hide();
			obj.parent().append(data.message);
		} else {
			obj.hide();
			obj.parent().append(data.message);
		}
	}, "json");
	
	return false;
}


