/*
*
*  KOMILFO CONSEIL
*  © 2010
*
*/

/* Raccourcis vers GetElementById */
function $id(element_id) {return document.getElementById(element_id)};

/* Newsletter */
function nl_checker() {
	if (document.getElementById) {
		init_value = "adresse e-mail";
		$id('nl-input').value = init_value;
		a_null = "javascript:void(0);";
		//$('lien').href = a_null;
		// FOCUS
		$id('nl-input').onfocus = function() {
			this.style.backgroundColor = "";
			if (this.value == init_value || this.value == "") {
				this.value = "";
			}
		};
		// BLUR
		$id('nl-input').onblur = function() {
			// Valeur initiale
			if(this.value == "" || this.value == init_value) {
				this.value = init_value;
				$id('nl-input').style.backgroundColor = "";
			} else {
				// Autre et valide
				if (this.value.indexOf("@") != 0) {
					$id('nl-input').className = "";
				}
				// Autre mais non valide
				else {
					//$('lien').href = a_null;
					$id('nl-input').style.backgroundColor = "#fdd";
				}
			}
		};
	}
};
window.onload = nl_checker;

/* IE6 warn */
if (isIE == 'undefined') var isIE = false;
$(document).ready(function () {
	if (isIE == 6) {
		$('body').append("<div id=\"ie-update-warning\" style=\"display: none;\">Le navigateur que vous utilisez (Internet Explorer 6) est instable et obsolète depuis plusieurs années.<br />Merci de <a href='http://www.microsoft.com/france/windows/internet-explorer/'>mettre à jour votre version d'Internet Explorer</a> ou de <a href='http://www.browserchoice.eu'>choisir un autre navigateur</a>, pour profiter pleinement de notre site (et de l'ensemble du Web).</div>");
		$('#ie-update-warning').slideToggle("blind", null, "slow");
	}
});

/* JQuery stuffs and fires */
$(document).ready(function() {
	switch (pagecurrent) {
		case "index":
			$('#coda-apercu').codaSlider({
				autoSlide: true,
				autoSlideInterval: 6000,
				autoSlideStopWhenClicked: true,
				dynamicArrows: false
			});
			break;
		case "clients":						
			
			$("a.aopenul").click(function() {
					/*if ($(this).next(".projects ul").text != "0")
					{*/
				if($($(this).attr("href")+" > li").attr("title") == 'ok'){
					$($(this).attr("href")).slideToggle("blind", null, "speed");
				}
				
				return false;
					
			});
			
			
				
			
			$("a.afancy").fancybox({
				'transitionIn'	:	'elastic',
				'transitionOut'	:	'elastic',
				'speedIn'		:	300,
				'speedOut'		:	300,
				'titleShow'		:	false
			});
			anchor = self.document.location.hash.substring(1);
			// On a demandé quelque chose ?
			if (anchor != "") {
				// Détermination des blocs à ouvrir
				if (anchor.indexOf("-",0) != -1) {
					$.scrollTo($("#bloc-"+anchor.substring(0, (anchor.indexOf("-",0)))), 500, {offset:-80});
					$("#"+anchor.substring(0, (anchor.indexOf("-",0)))).delay(500).slideToggle("blind", null, "speed");
					window.setTimeout('$("a[href=#"+anchor.substring(anchor.indexOf("-",0)+1)+"]").trigger("click")', 1000);
				} else {
					$.scrollTo($("#bloc-"+anchor), 500, {offset:-80});
					$("#"+anchor).delay(500).slideToggle("blind", null, "speed");
				}
			}
			break;
		case "contact":
			anchor = self.document.location.hash.substring(1);
			if (anchor != "" && anchor.indexOf("recrutement",0) != -1) {
				$("#recrutement").css("display", "block");
				$.scrollTo($("#recrutement"), 500, {offset:-80});
			}
			$("#recrut").click(function() {
				$("#recrutement").css("display", "block");
				$.scrollTo($("#recrutement"), 500, {offset:-80});
			});
			break;
	}
});
