$(document).ready(function() {

	$("a#logo").click(function(e) {
		e.preventDefault();
		window.location="/";
	});


	/**
	 * ------------------------------------
	 * Carousel fiche d'un bien
	 * ------------------------------------
	 */
	$('#carousel').jcarousel();
	$('#carousel li a').hover(function (e) {
		e.preventDefault();
		$('#main-image img').attr('src', $(this).children('img').attr('src'));
	}, function(e) {})
	.click(function(e) {

	});

	/**
	 * ------------------------------------
	 * Calendrier fiche d'un bien
	 * ------------------------------------
	 */

	$(".calendar-prev, .calendar-next").live('click', function(e) {
		e.preventDefault();

		var loader = $('<div style="position: absolute; left: 270px; top : 180px;"><img src="/design/varatuwa/images/ajax-loader.gif" /></div>');
		$("#accomodation-calendar").append(loader);
		$("#accomodation-calendar").load('/accomodation/calendar' +  $(this).attr('href').split('#')[1], 'uuid=' + $.uuid(), function() {
			loader.hide();
		});

	});

	/**
	 * ------------------------------------
	 * Liens externes
	 * ------------------------------------
	 */
	$("a.external").click(function(e) {
		e.preventDefault();
		window.open($(this).attr('href'));
	});

	/**
	 * ------------------------------------
	 * Bloc de recherche accueil
	 * ------------------------------------
	 */
	$("#map-search-tab, #ref-search-tab").click(function(e) {
		e.preventDefault();
		$("#right-panel").children('div').hide();
		$("#tabs > a").removeClass('active');

		$(this).addClass('active');
		$("#" + $(this).attr('href').split('#')[1]).show();

		switch ($(this).attr('id'))
		{
			case 'ref-search-tab':
				$('#se_ref').focus();
				break;
		}

	});

	/*
	$("div.picture-frame").click(function(e)
    {
		e.preventDefault();
		window.location=$(this).children('a').attr('href');
	});
	*/

	if (typeof(gmapInitialize) == 'function')
	{
		gmapInitialize();
	}


});