﻿// Fonction de stockage des scripts à charger
FunctionsOnLoad = new Array();
function AddFunctionOnLoad(Obj) {
	FunctionsOnLoad[FunctionsOnLoad.length] = Obj;
}

// Execution des scripts au chargement de la page
window.onload = function() {
	for(i=0; i<FunctionsOnLoad.length; i++)
		{FunctionsOnLoad[i]();}
		if (document.getElementById("div_Centrale_video")) {
		init_video_behaviour.init();
		}
}

function ClearTextbox(id)
{
    document.getElementById(id).value = "";
}

function ResetElement(id, text)
{
    if(document.getElementById(id).value == "")
    {
        document.getElementById(id).value = text;
    }
}

/* Ajout aux favoris */
function favoris()
{
	if (navigator.appName != 'Microsoft Internet Explorer')
	{ 
		window.sidebar.addPanel("La Foir'Fouille","http://www.lafoirfouille.fr",""); 
	}
	else 
	{ 
		window.external.AddFavorite("http://www.lafoirfouille.fr","La Foir'Fouille"); 
	}
}

var formRecommanderSite = new Array("monNom","monEmail","nomAmi","emailAmi");
var prefixeMasterPage = "ctl00_ContentPlaceHolderCenter_";

function validateForm(form)
{
	var returnValue = true;
	for(i=0; i < form.length; i++)
	{
		var input = document.getElementById(prefixeMasterPage+form[i]);
		var isValid = checkInput(input);
		if(!isValid) returnValue = false;
	}
	if(returnValue)
		setFormTrue();
	else setFormFalse();
	return returnValue;
}

function checkInput(input)
{
	if(input.value == "")
	{
		setInputFalse(input);
		return false;
	}
	setInputTrue(input);
	return true;
}

function setInputFalse(input)
{
	input.style.backgroundColor = "#ff6600";
}

function setInputTrue(input)
{
	input.style.backgroundColor = "#ffffff";
}

function setFormFalse()
{
	var lbl = document.getElementById(prefixeMasterPage + "lblOnError");
	lbl.innerHTML = "Formulaire non valide";
}

function setFormTrue()
{
	var lbl = document.getElementById(prefixeMasterPage + "lblOnError");
	lbl.innerHTML = "";
}

/* Cache le message d'erreur */
function HidePanel(currentDiv)
{
    currentDiv.style.display="none";
}
function HidePanelRedirect(currentDiv)
{
    currentDiv.style.display="none";
    document.location.href="default.aspx";
}

/* Vide et remplit les champs texte pour y afficher un message par défaut */
function manageTextbox(currentControl, text) 
{
    if(currentControl.value == text)
    {
        currentControl.value = "";
        currentControl.onblur = function(){
			if(this.value == "") 
				this.value = text;
        }
    }
}

/*Cache le message au chargement de la page */
function hideMessage()
{
    if (document.getElementById('ctl00_pMessage') != null)
    {
        document.getElementById('ctl00_pMessage').style.display="none";
    }
}

var TextBoxRecherche;

function InitTextBoxRecherche(value) 
{
    TextBoxRecherche = value;
}

function ClickOnTextBoxRecherche(button) 
{
    document.getElementById(TextBoxRecherche).click();
}

// Contournement d'un bug d'Internet Explorer 6
// Au redimensionnement de la page, on rafraichit la page
//window.onresize = function()
//{
//	if (navigator.appName == 'Microsoft Internet Explorer')
//	{ 
//		window.location.reload();
//	}
//}


// page Video
var init_video_behaviour = 
{
    
	init:function()
	{
	    var videoContainer = document.getElementById('div_Centrale_video');
	    
	    var arrReturnElements_link = document.getElementById('div_Centrale_video').getElementsByTagName('ul')[0].getElementsByTagName('a');
	    var intReturnElements_link = arrReturnElements_link.length;
	    
	    
	    var elEmbed = document.getElementById('div_Centrale_video').getElementsByTagName('embed')[0];
	   
	   
	    var arrSrc_video = new Array ("http://www.dailymotion.com/swf/x9nm4k_4produitsfoirfouille040609finalbis_lifestyle&related=1" , "http://www.dailymotion.com/swf/x9nm4k_4produitsfoirfouille040609finalbis_lifestyle&related=1", "http://www.dailymotion.com/swf/x9nm4k_4produitsfoirfouille040609finalbis_lifestyle&related=1", "http://www.dailymotion.com/swf/x9nm4k_4produitsfoirfouille040609finalbis_lifestyle&related=1");
	    var intReturnElements_video = arrSrc_video.length;
	    var videoToDisplay;
	    
	    for (var i=0; i<intReturnElements_link; i++) {
		    arrReturnElements_link[i].id = i;
		    arrReturnElements_link[i].onclick = function() {
		        // style du lien
                init_video_behaviour.displayLinkClassName(arrReturnElements_link);
                this.className = "current";
                // gestion vidéo
                videoContainer.removeChild(document.getElementById('div_Centrale_video').getElementsByTagName('embed')[0]);
                
                var nouveauEMBED = document.createElement("embed");
                nouveauEMBED.type = "application/x-shockwave-flash";
                nouveauEMBED.src = arrSrc_video[this.id];

		        videoContainer.appendChild(nouveauEMBED);
                
	           return false;
		    }
	    }	
	   elEmbed.src = arrSrc_video[0];
	   arrReturnElements_link[0].className = "current";
	},
	displayLinkClassName:function(arr)
	{
	    
	    var intReturnElements_link = arr.length;
	    for (var i=0; i<intReturnElements_link; i++) {
	        arr[i].className = "";
	    }
	}

}


// Creation de la pluie d'étoiles
var FlashOverlay = 
{
	init: function()
	{
		var c = FlashOverlay.readCookie();
		if(c == null)
		{
			FlashOverlay.createCookie();
			var node = document.createElement("div");
			node.setAttribute("id","flashOverlay");
			document.getElementById("container").insertBefore(node,document.getElementById("header"));
			var flash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="880" height="550" id="oFlashOverlay" align="middle">';
			flash += '<param name="allowScriptAccess" value="always" />';
			flash += '<param name="movie" value="http://images.eto.fr/lafoirfouille/flash/papillon.swf" />';
			flash += '<param name="quality" value="high" />';
			flash += '<param name="bgcolor" value="#ffffff" />';
			flash += '<param name="wmode" value="transparent" />';
			flash += '<embed src="http://images.eto.fr/lafoirfouille/flash/papillon.swf" quality="high" bgcolor="#ffffff" wmode="transparent" width="880" height="550" name="eFlashOverlay" align="middle" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
			flash += '</object>';
			document.getElementById("flashOverlay").innerHTML = flash;
			//setTimeout(FlashOverlay.hide,3000);
		}
	},
	hide:function(){
		document.getElementById("flashOverlay").style.display = 'none';
	},
	createCookie:function(){
		var date = new Date();
		date.setTime(date.getTime()+(60*60*1000));
		var expires = "; expires="+date.toGMTString();
		document.cookie = "FFFlashOverlay=false"+expires+"; path=/";
	},
	readCookie:function(){
		var nameEQ = "FFFlashOverlay=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
}
//AddFunctionOnLoad(FlashOverlay.init);

function CloseSpringFlash()
{
	FlashOverlay.hide();
}

/*
var timeFade = $.browser.msie ? 0 : 200;

$(document).ready(function()
{
    if(ReadCookie("message-read") == null)
    {
        jQuery.get('/message-important.html', function(data) 
        {
         
			jQuery(data).modal(
			{
			    autoPosition : true,
			    overlayClose : true,
			    closeClass :"close",
				onOpen: function(dialog)
				{
				    jQuery("#simplemodal-overlay").css("background-color", "#FFF").css("z-index", "9999998");
				    jQuery("#simplemodal-container").css("z-index", "9999999");
				    dialog.overlay.fadeIn(timeFade,function()
					{
						dialog.container.fadeIn(timeFade, function()
						{
							dialog.data.fadeIn(timeFade, function()
							{
							    CreateCookie("message-read","isread",1);
							    jQuery("#simplemodal-container").css("z-index", "9999999");
							    dialog.data.find(".close").css("cursor","pointer");
							});
						});
					});
				},
				
			    onClose : function(dialog)
			    {
				    dialog.container.fadeOut(timeFade, function()
				    {
					    dialog.overlay.fadeOut(timeFade, function()
					    {
						    $.modal.close();
					    });
				    });
			    }
			});
        });
    }
});
*/
/*
var PluieEtoiles =
{
	creation: function ()
	{
		var c = PluieEtoiles.readCookie();
		if(c == null)
		{
			PluieEtoiles.createCookie();
			var pluieetoiles = document.createElement("div");
			pluieetoiles.setAttribute("id","pluieetoiles");
			document.getElementById("container").insertBefore(pluieetoiles,document.getElementById("header"));
			var flash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="880" height="549" id="voeux" align="middle">';
			flash += '<param name="allowScriptAccess" value="always" />';
			flash += '<param name="movie" value="../flash/pluie-etoiles.swf" />';
			flash += '<param name="quality" value="high" />';
			flash += '<param name="bgcolor" value="#ffffff" />';
			flash += '<param name="wmode" value="transparent" />';
			flash += '<embed src="../Flash/pluie-etoiles.swf" quality="high" bgcolor="#ffffff" wmode="transparent" width="880" height="549" name="voeux" align="middle" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
			flash += '</object>';
			document.getElementById("pluieetoiles").innerHTML = flash;
			setTimeout(enleverPluieEtoiles,3000);
		}
	},
	createCookie:function(){
		var date = new Date();
		date.setTime(date.getTime()+(60*60*1000));
		var expires = "; expires="+date.toGMTString();
		document.cookie = "pluieetoiles=false"+expires+"; path=/";
	},
	readCookie:function(){
		var nameEQ = "pluieetoiles=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
}

function enleverPluieEtoiles()
{
	document.getElementById("pluieetoiles").style.display = 'none';
}

AddFunctionOnLoad(PluieEtoiles.creation);
*/

