$(function() {
	
	if(typeof initDatePicker == 'function') {
		initDatePicker();
	} 
	
	$("#header_callcenter a").hover(
			function () {$("#popup-callcenter").show();},
		    function () {$("#popup-callcenter").hide();}
	);
	
	$(".popper").click(function(){
		w = h = 0;
		s = r = "yes";
		switch($(this).attr("id")){
			case "geotrust":
				w = 400;
				h = 450;
				break;
			default :
				w = 400;
				h = 400;
				break;
		}
		geo = window.open($(this).attr("href"),"geo","scrollbars="+s+",width="+w+",height="+h+",resizable="+r);
		geo.focus();
		return false;
	});
	
	
	$(".hotelsearch").click(function(){
		form = $("#hotelsearch");
		$("input[name='hotel_id']",form).attr('value', $(this).attr('alt'));
		form.submit();
		return false;
	});

	$(".holidaysearch").click(function(){
		form = $("#holidaysearch");
		$("input[name='URL']",form).attr('value', $(this).attr('alt'));
		form.submit();
		return false;
	});	
	
	$(".form-link").click(function(){
		$("#form_link").attr("action",$(this).attr('alt'))
					   .attr("target",$(this).attr('target'))
					   .submit();
		return false;
	});
	
	$(".pop-abstracts a").hover(
		function(event){
			$tip = $("#"+$(this).attr("alt"));
			offset = $(this).offset();
			l =  offset.left+$(this).width()+10;
			t = offset.top;
			$tip.css({top: t, left: l}); 
			$tip.show();
		},
		function(event){
			$("#"+$(this).attr("alt")).hide();
		}
	);
});


(function($) {
	var cache = [];
	$.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);


jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
};

