$(document).ready(function() {
	$('.slideshow').cycle({
		fx: 'fade' 
	});
	if($( "#datepicker1" )){
	 	$( "#datepicker1" ).datepicker({dateFormat: 'mm/dd/yy',minDate: 0});
	}
	if($( "#datepicker2" )){
		$( "#datepicker2" ).datepicker({dateFormat: 'mm/dd/yy',minDate: 1});
		$( "#datepicker2" ).click(function() {
			if($("#datepicker1").val()){
				var dp1arr = $("#datepicker1").val().split('/');
			 	var dp0 = new Date();
			 	var dp1 = new Date(parseInt(dp1arr[2]),dp1arr[0]-1,dp1arr[1]);
			 	var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
				var dp = Math.floor(Math.abs((dp1.getTime() - dp0.getTime())/(oneDay)));
				if(dp0.getDate()==dp1.getDate()){
		          	dp = 1;
		        }else{
		          	dp += 2;
		        }
			}
		 	if(!dp){
				var dp = 1;
			}
			$("#datepicker2").datepicker("option","minDate",dp);
		});
	}
	$('#gallery a').lightBox({fixedNavigation:true});
	$('#list-item-image a').lightBox({fixedNavigation:true});
	
	$('.bodyList tr.list-item').click(function() {
		/*$('.bodyList tr.list-item').each(function() {
	    	$(this).removeClass("active");
	    	$(this).next().find('.list-body').slideUp();
    	});
    	$(this).addClass("active");
    	$(this).next().find('.list-body').slideDown();*/
    	
    		if($(this).next().find('.list-body').is(':visible')){
    			$(this).removeClass("active");
				$(this).next().find('.list-body').slideUp();
				$(this).next().find('.list-body-close').hide();
			}else{
				$(this).addClass("active");
				$(this).next().find('.list-body').slideDown();
				$(this).next().find('.list-body-close').show();
			}
  	});
  	$('.LinkBody').hide();
  	if($('.LinkText')){
		$('.LinkText').click(function() {
			var index = $(".LinkText").index(this)+1;
			var i = 1;
			$('.bodyCenterText p.LinkBody').each(function() {
				if(i==index){
					if($(this).is(":visible")){
						$(this).slideUp();
						//$(this).nextAll('.LinkBody').slideUp();
					}else{
						$(this).slideDown();
						//$(this).nextAll('.LinkBody').slideDown();
					}
				}
				i++;
			});
		});
  	}
  	$('.leftSubscribe input').focus(function() {
  		$('.leftSubscribe input').val('');
  	});
});

function sendBooking(){
  	$('#bookingForm').submit();  
}
function closeList(t){
	$(t).parent().find('.list-body').slideUp();
	$(t).hide();
}

function addToCart(h,i){
		$.ajax({
			type: "POST",
			url: "http://"+h+"/cart_ajax.php",
			data: "do=add&i="+i,
			success: function(html){
				$('#grozs').html(html);
				$('#grozs').effect("highlight", {color:'#7ec926'}, 1000);
			}
		});
}
function removeFromCart(h,i){
		$.ajax({
			type: "POST",
			url: "http://"+h+"/cart_ajax.php",
			data: "do=remove&i="+i,
			success: function(html){
				$('#grozs').html(html);
				$('#grozs').effect("highlight", {color:'#7ec926'}, 1000);
			}
		});
}
