/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


$(window).load(function(){
	$('.gallery').lightBox({fixedNavigation:true});
});

$(function() {

	$('.date').datepicker({
        showOn: 'both',
        buttonImage: 'images/calendar.png',
        buttonImageOnly: false,
		dateFormat:'dd-mm-yy'
	});

	$('.remove').live('click',function(){
		$(this).parent('fieldset').parent('div').html('');

	});


	$('.rating_item').live('change',function(){
		var _this = null;
		 _this = $(this);
		var room_type = _this.find('.room_type').val();
		var from_date = _this.find('.arrive').val();
		var to_date = _this.find('.depart').val();
		var room_size = _this.find('.room_size').val();
		var boarding_type = _this.find('.boarding_type').val();


		var post = {
			room_type:room_type,
			from_date:from_date,
			to_date:to_date,
			room_size:room_size,
			boarding_type:boarding_type
		};

		var var_room = {room_type:room_type, selected: room_size};
		$.post('get_total.php', post, function(data){
//			data = eval("(" + data + ')');

			data = jQuery.parseJSON(data)
			var tt = data['total'];
			_this.find('.total').val(tt);
			var grand_total = 0;
			$('.total').each(function(){
				if($(this).val() != undefined && $(this).val().length > 0){
					grand_total = grand_total + parseInt($(this).val());

				}
			});

			$('#grand_total').val(grand_total);
		});

		$.post('get_sizes.php', var_room, function(reply){
			_this.find('.room_size').html(reply);
		})

	});

	$('.rating_item').each(function(){

		$(this).trigger('change');

	});
//$('.date').datepicker( "option", "buttonImage", '../images/calender.png' );

});

