//PRECHARGEMENT DES IMAGES
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//ROLL-OVER DES IMAGES
function rollover(param,fichier) { //v3.0
  var temp = document.getElementById(param).src = "interface/"+fichier;
}

//FONCTION IMPRESSION
function imprimer(){
	window.print();
}

//FONCTION OUVERTURE DE LA GREYBOX POUR FLASH
function ouverture_greybox(titre,largeur,hauteur){
	/*alert(titre+" "+largeur+" "+hauteur);*/
	greybox_anim.show( titre, 'a-propos.php', largeur, hauteur);
}

//GESTION DU FOND DE DROITE AU CHARGEMENT DE LA PAGE D'ACCUEIL
function gestion_fond(){
	var body = document.getElementById('body').clientWidth;
	var calcul = Math.round(body-((body/2)+492))-1;
	//30 est la taille en pixels au dela de laquelle il n'est plus necessaire de redimmensionner le DIV car la coupure n'est plus visible
	if (calcul<30){
		document.getElementById('fond_droite').style.width = calcul+'px';
		}
	else{
		document.getElementById('fond_droite').style.width = '30px';
	}
}

//EFFET SUR LES CHAMPS DE FORMULAIRES
function input_focus(element){
	element.className = "focus";
	element.style.width = "";
}
function input_blur(element){
	element.className = "blur";
}

//REPLIS DU FORMULAIRE
function cache_block(identifiant){
	document.getElementById(identifiant).style.display = "none";
}

//ROLL DES BOUTONS DE FORMULAIRE
function rollover_submit(bouton){
	bouton.style.backgroundPosition = "left -22px";
}
function rollout_submit(bouton){
	bouton.style.backgroundPosition = "left top";
}



// SCRIPTS POUR VLBOX
function ajax(fichier)
	{
	if(window.XMLHttpRequest) // FIREFOX
	xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
	xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
	
	return(false);
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	
	if(xhr_object.readyState == 4) return(xhr_object.responseText);
	else return(false);
	}
	



function cbbox(fichier){
	largeur = 0;
	lalpha = 0;
	document.getElementById("cbbox_content").innerHTML = ajax(fichier);
	document.getElementById("cbbox").style.display = "block";
}

function cbbox_ouverte(fichier){
	document.getElementById("cbbox_content").innerHTML = ajax(fichier);
	document.getElementById("cbbox").style.display = "block";
}

function vlbox_fermer(){
	largeur = 0;
	lalpha = 0;
	document.getElementById("vlbox").style.display = "none";
	fermeture = window.setInterval("moins()", 10);
}

function cbbox_fermer(){
	largeur = 0;
	lalpha = 0;
	document.getElementById("cbbox").style.display = "none";
	fermetureCB = window.setInterval("moinsCB()", 10);
}

function cbbox_ouvrir(origine){
	document.getElementById("chauffeBiberon").style.display = "block";
	var so = new SWFObject("maquette/viralCB/bandeAnnonce4.swf", "Tigex", "984", "785", "8", "", true);
	so.addParam("wmode", "transparent");
	so.addVariable("origine", origine);
	so.write("chauffeBiberon");
}

function fermerTV(){
	document.getElementById("chauffeBiberon").style.display = "none";
}

// ouverture et fermeture de la vlbox

function plus(lavitesse){
	largeur = largeur + (100 - largeur)/lavitesse;
	lalpha = lalpha + ((40 - (lalpha*100))/3)/100;
	// positionnement
	document.getElementById("transp").style.marginLeft = (100 - largeur)/2 + "%";
	document.getElementById("transp").style.marginTop = (100 - largeur)/2 + "%";
	// mise a l'echelle
	document.getElementById("transp").style.width = largeur + "%";
	document.getElementById("transp").style.height = largeur + "%";
	// ajustement de l'alpha
	document.getElementById("transp").style.opacity = lalpha;
	document.getElementById("transp").style.filter = "alpha(opacity=" + (lalpha*100) + ")";
	// augmentation de la vitesse sur la fin pour eviter la nuisance du ralentissement de fin sur les vitesses trop faible
	if (largeur > 94) {
	lavitesse = 2;
	}
	// test de la fin
	if (largeur > 98.9) {
	document.getElementById("transp").style.width = "99.9%";
	document.getElementById("transp").style.height = "99.9%";
	document.getElementById("transp").style.opacity = 0.4;
	document.getElementById("transp").style.filter = "alpha(opacity=40)";
	document.getElementById("vlbox").style.display = "block";
    clearInterval(ouverture);
	}
}

function moins(){
	largeur = largeur + (100 - largeur)/3;
	lalpha = lalpha + ((40 - (lalpha*100))/3)/100;
	// positionnement
	//document.getElementById("transp").style.marginLeft = (100 - largeur)/2 + "%";
	//document.getElementById("transp").style.marginTop = (100 - largeur)/2 + "%";
	// mise a l'echelle
	//document.getElementById("transp").style.width = (100 - largeur) + "%";
	//document.getElementById("transp").style.height = (100 -largeur) + "%";
	// ajustement de l'alpha
	le_alpha = 0.4 - lalpha;
	document.getElementById("transp").style.opacity = le_alpha;
	document.getElementById("transp").style.filter = "alpha(opacity=" + (le_alpha*100) + ")";
	// test de la fin
	if (largeur > 98) {
	//document.getElementById("transp").style.width = "0%";
	//document.getElementById("transp").style.height = "0%";
	document.getElementById("transp").style.opacity = 0;
	document.getElementById("transp").style.filter = "alpha(opacity=0)";
	document.getElementById("transp").style.display = "none";
    clearInterval(fermeture);
	}
}


function plusCB(lavitesse){
	largeur = largeur + (100 - largeur)/lavitesse;
	lalpha = lalpha + ((40 - (lalpha*100))/3)/100;
	// positionnement
	document.getElementById("transp").style.marginLeft = (100 - largeur)/2 + "%";
	document.getElementById("transp").style.marginTop = (100 - largeur)/2 + "%";
	// mise a l'echelle
	document.getElementById("transp").style.width = largeur + "%";
	document.getElementById("transp").style.height = largeur + "%";
	// ajustement de l'alpha
	document.getElementById("transp").style.opacity = lalpha;
	document.getElementById("transp").style.filter = "alpha(opacity=" + (lalpha*100) + ")";
	// augmentation de la vitesse sur la fin pour eviter la nuisance du ralentissement de fin sur les vitesses trop faible
	if (largeur > 94) {
	lavitesse = 2;
	}
	// test de la fin
	if (largeur > 98.9) {
	document.getElementById("transp").style.width = "99.9%";
	document.getElementById("transp").style.height = "99.9%";
	document.getElementById("transp").style.opacity = 0.4;
	document.getElementById("transp").style.filter = "alpha(opacity=40)";
	document.getElementById("cbbox").style.display = "block";
    clearInterval(ouvertureCB);
	}
}

function moinsCB(){
	largeur = largeur + (100 - largeur)/3;
	lalpha = lalpha + ((40 - (lalpha*100))/3)/100;
	// positionnement
	//document.getElementById("transp").style.marginLeft = (100 - largeur)/2 + "%";
	//document.getElementById("transp").style.marginTop = (100 - largeur)/2 + "%";
	// mise a l'echelle
	//document.getElementById("transp").style.width = (100 - largeur) + "%";
	//document.getElementById("transp").style.height = (100 -largeur) + "%";
	// ajustement de l'alpha
	le_alpha = 0.4 - lalpha;
	document.getElementById("transp").style.opacity = le_alpha;
	document.getElementById("transp").style.filter = "alpha(opacity=" + (le_alpha*100) + ")";
	// test de la fin
	if (largeur > 98) {
	//document.getElementById("transp").style.width = "0%";
	//document.getElementById("transp").style.height = "0%";
	document.getElementById("transp").style.opacity = 0;
	document.getElementById("transp").style.filter = "alpha(opacity=0)";
	document.getElementById("transp").style.display = "none";
    clearInterval(fermetureCB);
	}
}

/// COMPLISS : operation virale

function vlbox_compliss(cle,origine){
	document.getElementById("vlbox_compliss").style.display = "block";
	var leflash = new SWFObject("compliss/tigex.swf", "pourCompliss", "100%", "100%", "8", "#FFFFFF");
	leflash.addParam("scale", "noscale");
	leflash.addParam("wmode", "transparent");
	leflash.addParam("allowScriptAccess", "always");
	leflash.addVariable("fv_cle", cle);
	leflash.addVariable("origine", origine);
	leflash.write("compliss");
	
	lenavigateur = navigator.appName;
	laversion = navigator.appVersion;
	if (lenavigateur == "Microsoft Internet Explorer" ){
		document.getElementById("form1_element1").style.display = "none";
		document.getElementById("form1_element2").style.display = "none";
		if(laversion == "4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)"){
		document.getElementById("form1_element1").style.display = "block";
		document.getElementById("form1_element2").style.display = "block";
		}
	}
}

function fermer_compliss(){
	document.getElementById("vlbox_compliss").style.display = "none";
	document.getElementById("form1_element1").style.display = "block";
		document.getElementById("form1_element2").style.display = "block";
}

function affich_participer(origine,cle,biberon,prenom){
	document.getElementById("vlbox_compliss_texte").innerHTML = ajax("compliss/formulaire_inscription.php?origine="+origine+"&cle="+cle+"&biberon="+biberon+"&prenom="+prenom);
	document.getElementById("vlbox_compliss").style.visibility = "hidden";
	document.getElementById("vlbox_compliss_texte").style.display = "block";
	if ( biberon == "1" || biberon == 1 ) {
	document.getElementById("vlbox_compliss_part1").style.visibility = "visible";
	}
	if ( biberon == "2" || biberon == 2 ) {
	document.getElementById("vlbox_compliss_part2").style.visibility = "visible";
	}
}

function affich_ami(origine,cle,biberon,prenom) {
	document.getElementById("vlbox_compliss_texte").innerHTML = ajax("compliss/formulaire_ami.php?origine="+origine+"&cle="+cle+"&biberon="+biberon+"&prenom="+prenom+"&lequel=initial");
	document.getElementById("vlbox_compliss").style.visibility = "hidden";
	document.getElementById("vlbox_compliss_texte").style.display = "block";
	if ( biberon == "1" || biberon == 1 ) {
	document.getElementById("vlbox_compliss_part1").style.visibility = "visible";
	}
	if ( biberon == "2" || biberon == 2 ) {
	document.getElementById("vlbox_compliss_part2").style.visibility = "visible";
	}
}

function affich_ami2(origine,cle,biberon,prenom) {
	document.getElementById("vlbox_compliss_texte").innerHTML = ajax("compliss/formulaire_ami.php?origine="+origine+"&cle="+cle+"&biberon="+biberon+"&prenom="+prenom+"&lequel=secondaire");
	document.getElementById("vlbox_compliss").style.visibility = "hidden";
	document.getElementById("vlbox_compliss_texte").style.display = "block";
	if ( biberon == "1" || biberon == 1 ) {
	document.getElementById("vlbox_compliss_part1").style.visibility = "visible";
	}
	if ( biberon == "2" || biberon == 2 ) {
	document.getElementById("vlbox_compliss_part2").style.visibility = "visible";
	}
}

function affich_participer_sub(origine,cle,prenom){
	document.getElementById("vlbox_compliss_texte").innerHTML = ajax("compliss/formulaire_inscription.php?origine="+origine+"&cle="+cle+"&prenom="+prenom);
}

function affich_ami_sub(origine,cle,prenom){
	document.getElementById("vlbox_compliss_texte").innerHTML = ajax("compliss/formulaire_ami.php?origine="+origine+"&cle="+cle+"&prenom="+prenom);
}

function sub_participer(origine,cle,prenom){
	document.getElementById("vlbox_compliss_texte").innerHTML = ajax("compliss/sub_participer.php?origine="+origine+"&cle="+cle+"&prenom="+prenom)
}

function sub_ami(origine,cle,prenom){
	document.getElementById("vlbox_compliss_texte").innerHTML = ajax("compliss/sub_envoyer_amis.php?origine="+origine+"&cle="+cle+"&prenom="+prenom);
}

function sub_partir(){
	document.getElementById("vlbox_compliss_texte").innerHTML = ajax("compliss/sub_partir.php");
}

function fermer_participer(){
	document.getElementById("vlbox_compliss_merci").style.display = "block";
	var smerci = new SWFObject("compliss/merci.swf", "merci", "420", "110", "8", "#FFFFFF");
	smerci.addParam("wmode", "transparent");
	smerci.write("vlbox_compliss_merci");
	document.getElementById("vlbox_compliss").style.visibility = "visible";
	document.getElementById("vlbox_compliss_texte").style.display = "none";
	document.getElementById("vlbox_compliss_part1").style.visibility = "hidden";
	document.getElementById("vlbox_compliss_part2").style.visibility = "hidden";
}

function fermer_ami(participation){
	if (participation == "a_participe"){
		document.getElementById("vlbox_compliss_merci").style.display = "block";
		var smerci = new SWFObject("compliss/merci.swf", "merci", "420", "110", "8", "#FFFFFF");
		smerci.addParam("wmode", "transparent");
		smerci.write("vlbox_compliss_merci");
	}
	document.getElementById("vlbox_compliss").style.visibility = "visible";
	document.getElementById("vlbox_compliss_texte").style.display = "none";
	document.getElementById("vlbox_compliss_part1").style.visibility = "hidden";
	document.getElementById("vlbox_compliss_part2").style.visibility = "hidden";
}