$(document).ready(function(){
	
	hs.graphicsDir = '/highslide/graphics/';
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.fadeInOut = true;
	hs.dimmingOpacity = 0.8;
	hs.outlineType = 'rounded-white';
	hs.captionEval = 'this.thumb.alt';
	hs.marginBottom = 105 // make room for the thumbstrip and the controls
	hs.numberPosition = 'caption';

	// Add the slideshow providing the controlbar and the thumbstrip
	hs.addSlideshow({
		//slideshowGroup: 'group1',
		interval: 5000,
		repeat: false,
		useControls: true,
		overlayOptions: {
			className: 'text-controls',
			position: 'bottom center',
			relativeTo: 'viewport',
			offsetY: -60
		},
		thumbstrip: {
			position: 'bottom center',
			mode: 'horizontal',
			relativeTo: 'viewport'
		}
	});
	
	$(".facilityPic").bind("mouseenter", function(){
		$("#facilityDisplay").empty();
		$("#facilityDisplay").append($(this).attr("alt"));
		$("#facilityDisplay").fadeIn("fast");
	});
	
	$(".facilityPic").bind("mouseleave", function(){
		$("#facilityDisplay").fadeOut("fast");
	});
	
	$("#showImages").bind("click", function(){
		$(this).hide('slow');
		$("#picturesRest>div").show();
		$("#picturesRest").show('slow');
		$("#hideImages").show('slow');
	});
	$("#hideImages").bind("click", function(){
		$(this).hide('slow');
		$("#picturesRest>div").hide('slow');
		$("#picturesRest").hide('slow');
		$("#showImages").show('slow');
	});
	
	$("#showFloorPlans").bind("click", function(){
		$(this).hide('slow');
		$("#floorPlansRest>div").show();
		$("#floorPlansRest").show('slow');
		$("#hideFloorPlans").show('slow');
	});
	$("#hideFloorPlans").bind("click", function(){
		$(this).hide('slow');
		$("#floorPlansRest>div").hide('slow');
		$("#floorPlansRest").hide('slow');
		$("#showFloorPlans").show('slow');
	});
	
	/**************Pegination - index page***************/
	$.get("hot_offers.php?pegination=1", { page: 1},function(data){
		$("#contentHotOffers").html(data);
	});
	$.get("top_offers.php?pegination=1", { page: 1},function(data){
		$("#contentTotOffers").html(data);
	});
	/**************END Pegination***************/
	
	$("#getItems").bind("change", function(){
		obj = this;
		$.ajax({
			type: "GET",
			url: "getItems.php?field=" + $(obj).attr("name") + "&value=" + $(obj).val(),
			dataType: "json",
			success: function(data){
				jsonData = data;
				options = "<option value=\"\">---------------</opiton>";
				$.each(jsonData, function(i){
					options += "<option value=\"" + jsonData[i].id + "\">" + jsonData[i].name + "</option>";
				});
				$("#setItems").html(options);
			}
		});
	});

});

function checkEmailAddress(email){
	var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])*([a-zA-Z])/;
	 if(pattern.test(email)){         
		return true;
    }else{   
		return false;
    }
}
function pagination(page, pageName,divName) {
	$.get(pageName+"?pegination=1", { page: page},
	function(data){
		$("#"+divName).animate({opacity: .5}, 300, "linear",  function() {
			$(this).html(data);
			$(this).animate({opacity: 1.0}, 300, "linear",  function() {});
		});
	});
} 


