(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

$(document).ready(function() {
	$.preLoadImages("http://www.continentalhotels.eu/site/assets/images/brands/beyondcoffee_hover.png", 
					"http://www.continentalhotels.eu/site/assets/images/brands/beyondshop_hover.png", 
					"http://www.continentalhotels.eu/site/assets/images/brands/choice_hover.png", 
					"http://www.continentalhotels.eu/site/assets/images/brands/florida_hover.png", 
					"http://www.continentalhotels.eu/site/assets/images/brands/greatamericandisaster_hover.png", 
					"http://www.continentalhotels.eu/site/assets/images/brands/holidayexpress_hover.png", 
					"http://www.continentalhotels.eu/site/assets/images/brands/holidayinn_hover.png", 
					"http://www.continentalhotels.eu/site/assets/images/brands/leziriaparque_hover.png", 
					"http://www.continentalhotels.eu/site/assets/images/brands/radisson_hover.png", 
					"http://www.continentalhotels.eu/site/assets/images/brands/sterling_hover.png");
	
    // IE FIXES
	if( $.browser.msie ) {
		if( $.browser.version.substr(0,1) == '7' ) {
			$('#menucountry').css("margin-top","25px");
		}else{
			$('#menucountry').css("margin-top","15px");
		}
		$('#menutop').css("margin-top","-7px");
		$('#brands').css("margin-top","10px");
		$('#welcomeuser').css("padding-top","10px");
		$('#white').append("<br />");
	}
	
	if( $("#hotelselections").length ) {
		$("#hotelslistselect").css("top", $("#hotelselections a").position().top+18);
		$("#hotelslistselect").css("width", $("#hotelselections a").width()-2);
		$(".scroll-pane").css("width", $("#hotelselections a").width()-2);
		$("#hotelslistselect").css("left", $("#hotelselections a").position().left);
		$('#hotelselections a').hover(
			function() {
				$('#hotelslistselect').jScrollPane({showArrows: true});	
				$("#hotelslistselect").css("width", $("#hotelselections a").width()-2);
				$(".jspContainer").css("width", $("#hotelslistselect").width());
				$(".jspPane").css("width", $("#hotelslistselect").width());
				$(".scroll-pane").css("width", $("#hotelslistselect").width());
				$(".jspScrollable").css("width", $("#hotelslistselect").width());
				$("#hotelslistselect").slideDown();
			}
		);
		$('body').click(function(event) {
			if (!$(event.target).closest('#hotelslistselect').length) {
				$('#hotelslistselect').hide();
			};
		});
	}
	
	/*$("#soonmsg").css("left", $("#menukids").position().left);
	$("#soonmsg").css("top", $("#menukids").position().top+55);
		
	$('#menukids a').hover(
		function() {
			$("#soonmsg").show();
		},function() {
			$("#soonmsg").hide();
	});*/
	if(typeof yourFunctionName == 'ShowBannerLabel') {
		ShowBannerLabel();
	}
});

$(window).resize(function() {
	if(typeof yourFunctionName == 'ShowBannerLabel') {
		ShowBannerLabel();
	}
	if( $("#hotelselections").length ) {
		$("#hotelslistselect").css("top", $("#hotelselections a").position().top+18);
		$("#hotelslistselect").css("width", $("#hotelselections a").width()-2);
		$(".scroll-pane").css("width", $("#hotelselections a").width()-2);
		$("#hotelslistselect").css("left", $("#hotelselections a").position().left);
		$('#hotelselections a').hover(
			function() {
				$('#hotelslistselect').jScrollPane({showArrows: true});	
				$("#hotelslistselect").css("width", $("#hotelselections a").width()-2);
				$(".jspContainer").css("width", $("#hotelslistselect").width());
				$(".jspPane").css("width", $("#hotelslistselect").width());
				$(".scroll-pane").css("width", $("#hotelslistselect").width());
				$(".jspScrollable").css("width", $("#hotelslistselect").width());
				$("#hotelslistselect").slideDown();
			}
		);
		$('body').click(function(event) {
			if (!$(event.target).closest('#hotelslistselect').length) {
				$('#hotelslistselect').hide();
			};
		});
	}
});
