$(document).ready(function(){
	
	var loader = $('<div class="loaderGlobal" style="text-align: center;"><img src="/skins/soluseo/loaderGlobal.gif" alt="" title=""></div>');

	/**Liens externes**/
	$('a[rel=open]').click(function () {
		window.open($(this).attr('href'));
		return false;
	});
	/****/
		
	/**Gestion des champs recherche**/
	var inputSearchValue;
	
	$('.inputSearch').focus(function() {
		inputSearchValue = $(this).val();
		$(this).val('');
	});

	$('.inputSearch').blur(function() {
		if ($(this).val() == '') $(this).val(inputSearchValue);
	});
	/**Tooltip searchMap**/
	var reg = new RegExp('(.*)([0-9][0-9]|[0-9][a-b]|[0-9][a-b])(.*)','g');
	$('.jsTip').hover(function(e) {
		var dpt     = $(this).attr('href').replace(reg,'$2');
		var toolTip = $('#departement-'+dpt);

		var leftP = e.clientX-(toolTip.width()/2);
		if(isIE){
			var topP  = e.clientY-toolTip.height()-2+document.documentElement.scrollTop;
		}else{
			var topP  = e.clientY-toolTip.height()-2+window.scrollY;
		}
		toolTip.css({
			top: topP,
			left: leftP
		});
		toolTip.show();
	},function() {
		var dpt     = $(this).attr('href').replace(reg,'$2');
		var toolTip = $('#departement-'+dpt);
	
		toolTip.hide();
	});

	/** home slide **/
	if ($('#blockSlide').length) {
		var slideFade = new $.fn.slide({
			container : $('#blockSlide'),
			slider    : $('#blockSlide div:first'),
			slides    : $('#blockSlide div:first div'),
			links     : '',
			effect    : 'fade',
			delay     : 4000,
			noactiv   : true
		});
	}

	$('a[href=#zoommaplist]').click(function () {
		var map      = $('#map');
		var blockMap = $('div.blockMap');
		var shopMap  = $('#shopMap');
		var time     = 500;

		var center   = gShopMap.getCenter();
		var size	 = gShopMap.getSize();
	
		if (map.css('display') == 'none') {
			$(this).html($(this).html().replace('Afficher','Masquer'));
			map.height(0);
			map.stop().animate({
				height: 364
			},time);
			gShopMap.checkResize();
			gShopMap.setCenter(center);
		} else {
			map.stop().animate({
				height: 0
			},time,function () {
				map.css('display','none');
			});
			$(this).html($(this).html().replace('Masquer','Afficher'));
		}
	});
});

