// JavaScript Document

// Tirette pour changer de langue dans header
function changeLang() {
	var out = 0;
	$("#change-lang").click(function(){
		if(!out){					  
			$("#header-lang").animate( { top:"0"  }, 500, function(){$(this).css( {'backgroundPosition' : '-36px bottom'}); out = 1; } );
		}else {
			$("#header-lang").animate( { top:"-20"  }, 500, function(){$(this).css( {'backgroundPosition' : '0 bottom'}); out = 0; } );
		}
			return false;
	});
}

// Valeur indicative dans les input + password
function inputIndice() {
	$('.inputIndice').each(function() {
		var default_value = this.value;
		$(this).focus(function() {
			if(this.value == default_value) {
				this.value = '';
			}
		});
		$(this).blur(function() {
			if(this.value == '') {
				this.value = default_value;
			}
		});
	});
	$('#password-clear').show();
	$('#password-password').hide();
	$('#password-clear').focus(function() {					
		$('#password-clear').hide();
		$('#password-password').show();
		$('#password-password').focus();
	});
	$('#password-password').blur(function() {
		if($('#password-password').val() == '') {
			$('#password-clear').show();
			$('#password-password').hide();
		}
	});

}
// Changement style des input type file
function chgInputFile() {
	$("input[type=file]").filestyle({ 
		image: "/templates/1/images/button-carre-fleche-noir.png",
		imageheight : 16,
		imagewidth : 16,
		width : 140
	});
}

// Diaporama visuels sur homepage
function slideHome() {
	 	$("#home-promo").slideshow({
		pauseSeconds: 3,
		height: 386,
		width: 674,
		caption: false
		}); 
}

// Ecriture du flash Labels sur homepage
function flashLabels(langue,link1,link2,link3,link4,link5,link6,link7) {
	$('#home-labels').flash({ 
		src: '/templates/1/images/flash/home-labels.swf',
		width: '972',
		height: '131',
		wmode: 'transparent',
		scale: 'noscale',
		salign: 'tl',
		flashvars: {
			lang: langue,
		  	lien1: link1,
		  	lien2: link2,
		  	lien3: link3,
		  	lien4: link4,
		  	lien5: link5,
		  	lien6: link6,
		  	lien7: link7		
		}
	},
	{ version: 8 }
	);
}

// Ecriture du flash Map dans Magasins
function flashMap(params) {
	if(typeof params == "object" || typeof params == "array"){
		mes_params = params;
	}else{
		mes_params = [];
	}
	
	var flashvars = {
		lang: "fr",
		xml: "/cron/magasins_map.xml",
		/*googleKey: "ABQIAAAAFp1yeG0z_MnnlpVj0AD_lRTL0a1Bj7TOX-YWcFsTfgwK_bMHyRT0_xskW01iuVezThv2LdO99RdUdw", cle preprod*/
		/*googleKey: "ABQIAAAAIvCYgwVkdbB_8OKESagtBxSpr2CEMs-MMSb5Xslz0ITc6EUNwxSkmBPygeVm51QvNhhWr6fzJ2SYFw", cle mezcalito /dev*/
		googleKey: "ABQIAAAAIvCYgwVkdbB_8OKESagtBxSQqzmQ-O2cMlBwR_1gjOuUDopjTRT1SRM5_vnx63ZIcsi2sDxrjOgZkg",


		recherche: mes_params
	};
	var params = {
		menu: 'true',
		wmode: 'transparent',
		scale: 'noscale',
		allowscriptaccess: 'always'
	};
	var attributes = {
		id: "googlemap"
	};

	swfobject.embedSWF("/templates/1/images/flash/magasins-map.swf", "googlemap", "680", "386", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
	
	/*
	$('#page-header-visuels').flash({
		id: 'googlemap',
		src: '/templates/1/images/flash/magasins-map.swf',
		width: "680",
		height: "386",
		wmode: 'transparent',
		allowscriptaccess: 'always',
		scale: 'noscale',
		salign: 'tl',
		flashvars: {
			lang: "fr",
			xml: "/cron/magasins_map.xml",
			googleKey: "ABQIAAAAFp1yeG0z_MnnlpVj0AD_lRTL0a1Bj7TOX-YWcFsTfgwK_bMHyRT0_xskW01iuVezThv2LdO99RdUdw",
			recherche: mes_params
		}
	},
	{ version: 9 }
	);
	*/
	
}
// Affichage des critres de recherche magasins
function criteresSearch() {
	 $("#criteres-plus").click(function(){
		$("#magasins-search-simple").animate(
			{ opacity: 0.4  }, 500, function(){$("#input-search").attr({'disabled': true}).val('').next().attr({'disabled': true}).css( {'cursor' : 'default'}) ; } 
		);								
		$("#criteres-close").hide();
		 $("#criteres-open").show();
		});
	 $("#criteres-moins").click(function(){
		$("#criteres-open").hide();
		 $("#criteres-close").show();
		$("#magasins-search-simple").animate( { opacity: 0.99  }, 500, function(){$("#input-search").removeAttr("disabled").next().removeAttr("disabled").css( {'cursor' : 'pointer'}) ; } );	
		});
}
// Mise en vidence magasin localis dans liste
function localMap() {
	 $(".mag-off").click(function() {
			var recherche;
			recherche = $(this).children(".mag-coordonnees").text(); //on transmet les coordonnes GPS au flash
			$(".mag-off").removeClass("mag-on");
			$(this).toggleClass("mag-on");
		});
}

//Affichage slideshow flux Sportweek
function slideFlux() {
	$("#flux-content").easySlider({
		auto: true,
		continuous: true,
		pause: 4000
	});
}


// Envoi click magasin du flash au html
function onClickMagFlash(_id) {
	//alert("magasin séléctionné : "+_id);
}

// Envoi click magasin du html au flash
function onClickMagHtml(_id) {
	document.getElementById("googlemap").sendClickMagHtml(_id);
}

$(document).ready(function(){						   
	changeLang();
	//slideHome();
 	//flashLabels();
	//flashMap();
	//inputIndice();
	//criteresSearch();
	//slideFlux();
	//localMap();
 });


