$(document).ready(function()
{
	tooltip_init();
	
	var temp = $('#menu_langue li');
	temp.slice(1,temp.length).hide();
	
	$('#menu_langue li').slice(1,temp.length).hover(
		function()
		{
			$(this).addClass("hover");
		},
		function()
		{
			$(this).removeClass("hover");
		})
	;
	$('#menu_langue').hover(
		function()
		{
			var temp = $('#menu_langue li');
			temp.slice(1,temp.length).show();
		},
		function()
		{
			var temp = $('#menu_langue li');
			temp.slice(1,temp.length).hide();
		}
	);
	
	/* Effet Roll sur le type submit (saleté de IE et de gestion css : hover) */
	// désactivé car les changemnt de fond css cré des bug sous IE
	// $('.submit').hover(function(){$(this).css('background','#71438e'); }, function(){$(this).css('background','#513a57'); } );
	
	/* Customisation CSS de la zone CENTER */
	$('#center .hidden').hide();
	$('#center hr').wrap('<div class="hr"></div>');
	$('#center a[target=_blank]').not('.no-linkout').each(function(){
		if($('img',this).length==0)
			$(this).addClass('linkout');
	});
	
	
	if($('#center.speHotel .bloc-info').height()<300)
		$('#center.speHotel .bloc-info').height(300);
		
	$('.datefield').each(function(){
		if($(this).attr('rel')!=undefined)
		{
			var format = $(this).attr('rel').replace(/yyyy/,'yy');
			$(this).calendar({'dateFormat':format});
		}
		else
			$(this).datepicker();
	});
	
	/* Soumission de formulaire dans une IFrame (effet Thickbox) */
	$('body').append('<div id="iForm_container"><div id="iForm_overlay">&nbsp;</div><div id="iForm_content"><img src="/_img/public/iform-close.png" id="iForm_close" align="right"/><h2>HOTELS & PREFERENCE</h2><iframe border="0" name="iForm_iFrame" width="600" height="600"></iframe></div></div>');
	$('#iForm_container').hide();
	$('#iForm_overlay, #iForm_close').bind('click',function()
	{
		$('#iForm_content iframe').attr('src','about:blank');
		$('#iForm_container').hide();	
	});
	
	pageSize = tb_getPageSize(); // use of a thickbox internal function
	pageSize[1] = Math.max(pageSize[1],600);
	
	$('#iForm_container').width(pageSize[0]-20);
	$('#iForm_container').height(pageSize[1]);
	$('#iForm_overlay').width(pageSize[0]-20);
	$('#iForm_overlay').height(pageSize[1]);
	
	$('#iForm_content').width(700);
	$('#iForm_content').height(pageSize[1]-100);
	$('#iForm_content').css('top',50);
	$('#iForm_content').css('left',(pageSize[0]-700)/2);

	$('#iForm_content iframe').height(pageSize[1]-150);
	
	$('form.iForm').each(function()
	{
		$(this).attr('target','iForm_iFrame');
		$(this).bind('submit',function()
		{
			document.location.href='#';
			$('#iForm_container').show();
			$('#iForm_container h2').html($(this).attr('title'));
		});
	});
	$('a.iForm').each(function()
	{
		$(this).attr('target','iForm_iFrame');
		$(this).bind('click',function()
		{
			document.location.href='#';
			$('#iForm_container').show();
			$('#iForm_container h2').html($(this).attr('title'));
		});
	});
});

var tooltipID = 'F2P3CH8e25qgX5d6'; // à changer si conflit avec un autre objet
var tooltipStatut = false;
function tooltip_init()
{
	$('body').append('<div id="'+tooltipID+'" class="tooltip"> <div class="top"><div>Tooltip content</div></div> <div class="bottom"><div>&nbsp;</div></div> </div>');

	tooltip_hide();
	
	$('img[alt]').bind('mouseover',tooltip_show);
	$('img[alt]').bind('mouseout',tooltip_hide);
	$('.tooltiped').bind('mouseover',tooltip_show);
	$('.tooltiped').bind('mouseout',tooltip_hide);
	
	$().mousemove(function(e)
	{
		if(tooltipStatut)
			$('#'+tooltipID).css({'top':(e.pageY-$('#'+tooltipID).height()-10)+'px','left':(e.pageX-12)+'px'});
	}); 
}
function tooltip_show(e)
{
	//console.debug('hover:'+tooltipID+' :: '+$(this).attr('alt'));
	if($!=undefined && $(this).attr('alt')!=undefined)
	{
		//alert(tooltipID);
		$('#'+tooltipID+' div.top div').html($(this).attr('alt'));
		$('#'+tooltipID).css('opacity',1);
		$('#'+tooltipID+' div.bottom').width(0);
		$('#'+tooltipID+' div.bottom').width($('#'+tooltipID+' div.top').width());
		
		tooltipStatut = true;
	}
}
function tooltip_hide(e)
{
	//console.debug('out:'+tooltipID);
	if($!=undefined)
	{
		$('#'+tooltipID).css('opacity',0);
		tooltipStatut = false;
	}
}