
$(document).ready(function(){
	hotelCarouselB.init();
	hotelCarouselA.init();
	catA_Gallery.init();
});

function random(min,max){
    var r = min+Math.floor(Math.random()*((max+1)-min));
    return r > max ? max-1 : r; 
}

var hotelCarouselA = {
	points : [],
	init : function(that) {
		var nElems = 0;
		
        if ((nElems = $(".hotel_carousel_ul").find("li").size()) > 0){
	        if ((nElems -= 1) > 0){  // make 0 based for jCarousel
				// Business Rule: start carousel with random frame
				// so not to favor any hotel on page load
	            nElems = random(0, nElems);
			}
			
			// set up the carousel
			$("#hotelACarousel").jCarouselLite({
			    btnNext: ".hotelANext",
			    btnPrev: ".hotelAPrev",
			    visible: 1,
	            start: nElems,
				circular: true
			});
		}
	}
};

var hotelCarouselB = {
	points : [],
	init : function(that) {
		
		if ($(".hotelB_ul").find("li").size() > 0){
			// set up the carousel
			$("#hotelBCarousel").jCarouselLite({
			    btnNext: ".hotelBNext",
			    btnPrev: ".hotelBPrev",
			    visible: 1,
				circular: true
			});
        }			
	}
};

var catA_Gallery = {
	points : [],
	init : function(that) {
				
		var nElems = $("#catA_Gallery").find("li").size();

		if (nElems>3){
			// set up the carousel
			 $("#catA_Gallery").jCarouselLite({
			    btnNext: ".topCarouselNext",
			    btnPrev: ".topCarouselPrev",
			    visible: 3,
				scroll: 3
			});
		}else{
			$("a.topCarouselPrev").hide();
			$("a.topCarouselNext").hide();
			// set up the carousel
			 $("#catA_Gallery").jCarouselLite({
			    visible: 3
			});			
		}
	}
};

