$(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;
	
	$('.searchField').focus(function() {
		inputSearchValue = $(this).val();
		$(this).val('');
	});

	$('.searchField').blur(function() {
		if ($(this).val() == '') $(this).val(inputSearchValue);
	});
	/****/
	
	$('.blockMiniBasket').css('cursor','pointer');
	$('.blockMiniBasket, .blockMiniBasket a[rel=#popupSearch]').live('click',function() {
		$('#popupSearch').show();
		smoothScroll($('.blockHeaderMenu').offset().top+80);
		return false;
	});

	/** Caroussel fiche produit **/
	$('.carousselProduct').slideNextPrev({
		blockElList: $('.carousselProduct'),
		width: 151,
		nbElVisible: 4
	});

	/** Caroussel home conseil **/
	$('.carousselAdvice').slideNextPrev({
		blockElList: $('.carousselAdvice'),
		width: 304,
		nbElVisible: 3
	});




	///**ToolTips page des solutions**/
	//if ($('.blockSolutionsLabel').size()) {
		//$('.blockSolutionsLabel a').each(function() {
			//var toolTip    = 'div.'+$(this).attr('id');
			////var link       = $(this);
			////var height     = link.height();
			////var offset     = link.offset();
////
			////$(toolTip).css({
				////position : 'absolute',
				////top : (offset.top+height-16),
				////left : (offset.left-2)
			////})
//
			//$(this).menu({
				//menuHeight : $(toolTip).height(),
				//sLink      : $(this),
				//sMenu      : $(toolTip).height(0),
				//sClass	   : $(this).attr('class'),
				////sClassSel  : '-selected',
				//sCloseTime : 300
			//});
		//});
//
	//}
	///****/
//
	///**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 top  = e.clientY-toolTip.height()-2+window.scrollY;
		//var left = e.clientX-(toolTip.width()/2);
//
		//toolTip.css({
			//top: top,
			//left: left
		//});
		//toolTip.show();
	//},function() {
		//var dpt     = $(this).attr('href').replace(reg,'$2');
		//var toolTip = $('#departement-'+dpt);
	//
		//toolTip.hide();
	//});
//
	////Menu solutions
	//var menuSolution;
	//$('ul.mainMenu li.item-1 a').attr('id','itemMenuSolutions');
	//$('ul.mainMenu li.item-1 a').each(function(){
		//menuSolutions = $(this).menu({
			//menuHeight : $('div.underMenuSolutions').height(),
			//sLink      : $(this),
			//sMenu      : $('div.underMenuSolutions').height(0),
			//input      : $('input.inputSearch'),
			//lagLeft    : 8,
			//lagTop     : 0
		//});
	//});
	//
	////$('ul.mainMenu li').each(function(){
		////var liEl = $(this);
		////var aEl = liEl.find('a');
		////var ulEl = liEl.find('ul');
		////ulEl.css('display','none');
		////liEl.hover(function(){
			////ulEl.css('display','block');
			////liEl.addClass('hover');
		////},function(){
			////ulEl.css('display','none');
			////liEl.removeClass('hover');
		////});
	////});
	////$('.inputSearch').each(function(){
		////$(this).hover(function(){
			////$('#mainMenu li').each(function(){
				////$(this).find('ul').css('display','none');
				////$(this).removeClass('hover');
			////});
		////});
	////});
//
	////Menu sideBar solutions
	//$('ul.menuSolutions li a').click(function () {
		//var underMenu = $('ul.menuSolutions li ul');
		//var parentUl  = $(this).closest('ul');
//
		//if (parentUl.hasClass('menuSolutions') && !$(this).hasClass('activ')) {
			//underMenu.each(function () {
				//var link = $(this).closest('li').children('a');
	//
				//var reg   = new RegExp('\/(.*)\.html','gi');
				//var href  = link.attr('href').replace(reg,'$1');
				//var match = window.location.href.match(href);
		//
			//});
//
		//}
	//});
//
	//$('ul.menuSolutions li a').each(function(){
		//var parentLi        = $(this).closest('li');
		//var parentUl        = $(this).closest('ul');
		//var underMenu       = parentLi.children('ul');
//
		//var reg   = new RegExp('\/(.*)\.html','gi');
		//var href  = $(this).attr('href').replace(reg,'$1');
		//var match = window.location.href.match(href);
//
		//if (parentUl.hasClass('menuSolutions') && !match) {
			//underMenu.hide();
		//} else if (parentUl.hasClass('menuSolutions') && match) {
			//$(this).addClass('activ');
		//}
	//});
//
	///**Construction de la popup**/
	//constructPopupSearch();
//
	$('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'));
		}
	});

	//if ($('#blockGlobal #blockCenter .blockSlides').length) {
		//var slideSlide = new $.fn.slide({
			//container : $('.blockSlides .blockSolution-1 .blockContent'),
			//slider    : $('div.blockSlides .blockSolution-1 .blockContent div:first'),
			//slides    : $('div.blockSlides .blockSolution-1 .blockContent div.slide'),
			//links     : $('div.blockSlides .blockNav,div.blockMenuNav ul.menuSolutions li'),
			//effect    : 'slide',
			//delay     : 5000
		//});
	//
		//var slideFade = new $.fn.slide({
			//container : $('.blockSlides .blockSolution-1 #slideImg'),
			//slider    : $('div.blockSlides .blockSolution-1 #slideImg div:first'),
			//slides    : $('div.blockSlides .blockSolution-1 #slideImg div:first div'),
			//links     : $('div.blockSlides .blockNav,div.blockMenuNav ul.menuSolutions li'),
			//effect    : 'fade',
			//delay     : 5000,
			//noactiv   : true
		//});
	//}
//
	//var slidePartner = new $.fn.slide({
		//slides : $('div.blockPartners div div.logoPartners'),
		//effect : 'fade',
		//delay  : '5000'
	//});
//
	//$('.btnVideo').fancybox({
		//'padding' : 10, 
		//'width' : 560,
		//'height' : 340,
		//'centerOnScroll' : true,
		//'transitionIn' : 'none',
		//'transitionOut' : 'none',
		//'type' : 'swf',
		//'overlayOpacity' : 0.6,
		//'overlayColor' : '#000000'
	//});
//
	///**
	 //*  Popup Splash
	 //*/
	//window.setTimeout(function() {$('#popupSplash[class=showPopup]').show()},1000);
	//$('#popupSplash a.btnClose,#popupSplash a[rel=btnClose],#popupSplash #popupOverlay').click(function () {
		//$('#popupSplash').hide();
//
		//return false;
	//});

});

