var popmessage=false;
var courmenu=false;
var courpage=false;
var doresize=true;
var lien_photo_up=false;
var intro=true;
var popin_courante_block='';
var FB='';

function restore_popin_courante() {
	if (popin_courante_block.id=='' || popin_courante_block=='') {
	} else {
		if (popin_courante_block) popin_courante_block.style.display='block';
	}
}

var ie6=false;

var defil_data = new Array(5);

defil_data[0] = new Array(4);
defil_data[1] = new Array(4);
defil_data[2] = new Array(4);
defil_data[3] = new Array(4);
defil_data[4] = new Array(4);
defil_data[5] = new Array(4);
defil_data[6] = new Array(4);
defil_data[7] = new Array(4);
defil_data[8] = new Array(4);

defil_data[0]['nom']='contacts';	defil_data[0]['nbr_group']=0; 	defil_data[0]['cour_group']=1; 	defil_data[0]['elem_width']=153; 	defil_data[0]['groups_per_screen']=2; 	defil_data[0]['liens']=false;
defil_data[1]['nom']='projets';		defil_data[1]['nbr_group']=0;	defil_data[1]['cour_group']=1; 	defil_data[1]['elem_width']=83; 	defil_data[1]['groups_per_screen']=4; 	defil_data[1]['liens']=false;
defil_data[2]['nom']='liste_un';	defil_data[2]['nbr_group']=0; 	defil_data[2]['cour_group']=1; 	defil_data[2]['elem_width']=72; 	defil_data[2]['groups_per_screen']=6; 	defil_data[2]['liens']=true;
defil_data[3]['nom']='liste_deux';	defil_data[3]['nbr_group']=0; 	defil_data[3]['cour_group']=1; 	defil_data[3]['elem_width']=72; 	defil_data[3]['groups_per_screen']=6; 	defil_data[3]['liens']=true;
defil_data[4]['nom']='liste_ajout';	defil_data[4]['nbr_group']=0; 	defil_data[4]['cour_group']=1; 	defil_data[4]['elem_width']=110; 	defil_data[4]['groups_per_screen']=5; 	defil_data[4]['liens']=false;
defil_data[5]['nom']='liste_ajout_invitation';	defil_data[5]['nbr_group']=0; 	defil_data[5]['cour_group']=1; 	defil_data[5]['elem_width']=110; 	defil_data[5]['groups_per_screen']=4; 	defil_data[5]['liens']=false;
defil_data[6]['nom']='liste_ajout_invitation2';	defil_data[6]['nbr_group']=0; 	defil_data[6]['cour_group']=1; 	defil_data[6]['elem_width']=110; 	defil_data[6]['groups_per_screen']=4; 	defil_data[6]['liens']=false;
defil_data[7]['nom']='liste_fiche_profil_un';	defil_data[7]['nbr_group']=0; 	defil_data[7]['cour_group']=1; 	defil_data[7]['elem_width']=71; 	defil_data[7]['groups_per_screen']=5; 	defil_data[7]['liens']=false;
defil_data[8]['nom']='liste_fiche_profil_deux';	defil_data[8]['nbr_group']=0; 	defil_data[8]['cour_group']=1; 	defil_data[8]['elem_width']=71; 	defil_data[8]['groups_per_screen']=5; 	defil_data[8]['liens']=false;


/* Fonctions standards */
function _(o) {
	if (!o) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById(o)) return false;
	return document.getElementById(o);
}

var api_key = ''; 
var channel_path = '/acseo/xd_receiver.htm'; 
function applique_fb() {
	if (FB) {
		FB.init(api_key, channel_path); 
		FB_RequireFeatures(["Api", "XFBML", "Connect"]);
	}
}

function xhrRequest(type) {
	var xhrSend;
	if (!type) {
		type = 'text';
	}
	if (window.ActiveXObject) {
		try {
			xhrSend = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xhrSend = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	} else if (window.XMLHttpRequest) {
		xhrSend = new XMLHttpRequest();
		if (xhrSend.overrideMimeType) {
			xhrSend.overrideMimeType('text/' + type);
		}
	}
	return (xhrSend);
}
function getnextnode(source,o) {
	if (!o) return false;
	oo=false;
	if (o.firstChild) return o.firstChild;
	if (o.nextSibling) return o.nextSibling;
	o=o.parentNode;
	while (!oo && o && (o!=source)) {
		oo=o.nextSibling;
		o=o.parentNode;
	}
	return oo;
}
function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity; 
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")"; 
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100; 
	// Vieux Mozilla & Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, Firefox and Mozilla recents, CSS3
	obj.style.opacity = opacity/100;
}
function getWidth() {
  myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
	myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	myWidth = document.body.clientWidth;
  }
  return myWidth;
}	
function getHeight() {
  myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
	myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	myHeight = document.body.clientHeight;
  }
  return myHeight;
}
function getElementHeight(Elem) {
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all){
		var elem = document.all[Elem];
	}
	if (elem.style.pixelHeight>0) { 
		xPos = elem.style.pixelHeight;
	} else {
		xPos = elem.offsetHeight;
	}
	return xPos;
}
function getElementWidth(Elem) {
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all){
		var elem = document.all[Elem];
	}
	if (elem.style.pixelWidth>0) {
		xPos = elem.style.pixelWidth;
	} else {
		xPos = elem.offsetWidth;
	}
	return xPos;
}
function getScrollPosition() {
	return Array((document.documentElement && document.documentElement.scrollLeft) || window.pageXOffset || self.pageXOffset || document.body.scrollLeft,(document.documentElement && document.documentElement.scrollTop) || window.pageYOffset || self.pageYOffset || document.body.scrollTop);
}
function getElementsByClassName(needle) {
	var my_array = document.getElementsByTagName("*");
	var retvalue = new Array();
	var i;
	var j;
	for (i=0,j=0;i<my_array.length;i++) {
		var c = " " + my_array[i].className + " ";
		if (c.indexOf(" " + needle + " ") != -1) retvalue[j++] = my_array[i];
	}
	return retvalue;
}
function classRepl(whatReplace,style,type) {
	for(var i=0;i<whatReplace.length;i++) {	
   		if (type=='classN') {
			whatReplace[i].className=style;
		} else if (type=='visibility') {
			whatReplace[i].style.visibility=style;
		} else {
			whatReplace[i].style.display=style;
		}
	}
}
/* RESIZE */
window.onresize = function (evt) {
	if (_('home_flash') && doresize && _('wrapper')) ajust_dispatch();
}
window.onscroll = function (evt) {
	if (_('home_flash') && doresize && _('wrapper')) ajust_dispatch_pos();
}
/* INIT */
window.onload=init;
function init() {
	ie6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
	startList("page");
	// Lancement des flashs
	if (_('home_flash') && _('wrapper')) {
		ajust_dispatch();
	}	
	// Gestion des listes
	prep_defil('full');
	if(popmessage) {
		if (popmessage!="") {
			o=_("sous_popin_popmessage_content");
			oo=_("sous_popin_popmessage");
			if (o && oo) {
				o.innerHTML=popmessage;
				oo.style.display="block";
			}
		}
	}
	
	o_titre_flash = _('titre_flash');
	if (o_titre_flash) {
		le_texte = o_titre_flash.innerHTML;
		// ajustement de l'hauteur pour le flash
		//o_titre = o_titre_flash.parentNode;
		//if (o_titre) o_titre.style.height="33px";
		if (o_titre_flash.nextSibling && o_titre_flash.nextSibling.tagName=='H1') o_titre_flash.nextSibling.style.color="#000000";	


		var flashvars = {};
		var flashvars = {texte:le_texte, taille:36};
		var params = {};
		params.menu = "false";
		params.wmode = "transparent";
		var attributes = {};
		attributes.id = "titre_flash1";
		attributes.name = "titre_flash1";
		swfobject.embedSWF("/swf/titre.swf", "titre_flash", "300", "32", "9.0.0.0", "expressInstall.swf", flashvars, params, attributes);
		o=_("titre_flash1");
		if (o) {
			o.style.position="relative";
			o.style.top="-6px";
			o.style.left="-2px";
		}
	}
	
	o_titre_flash = _('titre_flash_page');
	if (o_titre_flash) {
		
		le_texte = o_titre_flash.innerHTML;
		var flashvars = {};
		var flashvars = {texte:le_texte, couleur:0xFF9000, taille:28};
		var params = {};
		params.menu = "false";
		params.wmode = "transparent";
		var attributes = {};
		attributes.id = "titre_flash2";
		attributes.name = "titre_flash2";
		swfobject.embedSWF("/swf/titre.swf", "titre_flash_page", "250", "30", "9.0.0.0", "expressInstall.swf", flashvars, params, attributes);
	}
	
	o_video_produit = _('video_produit');
	if (o_video_produit) {
		
		le_texte = o_video_produit.innerHTML;

		var flashvars = {};
		var flashvars = {file:le_texte};
		var params = {allowFullScreen:false};
		params.menu = "false";
		params.wmode = "transparent";
		var attributes = {};
		attributes.id = "video_produit";
		attributes.name = "video_produit";
		swfobject.embedSWF("/swf/player.swf", "video_produit", "480", "294", "8.0.0.0", "expressInstall.swf", flashvars, params, attributes);
	}
	
	/*
	// Menu
	if (vmenu>0 && _('menu'+vmenu)) {
		_('menu'+vmenu).className='selected';
	*/
	o=_("section"+courmenu);
	if (o) o.id="active_page";
	applique_fb();
}
function get_results() {
	var xhrRec = xhrRequest('html');
	xhrRec.onreadystatechange = function() {
		if(xhrRec.readyState == 4 && xhrRec.status == 200) {
			// Remise à zéro
			defil_data[4]['nbr_group']=0;
			defil_data[4]['cour_group']=1;
			// Publi
			_('ajout_resultats').innerHTML=xhrRec.responseText;
			// Png fix ie6
			if (ie6) {
				_(defil_data[4]['nom']+'_go_left_img').style.behavior="url(/build/iepngfix.htc);";
				_(defil_data[4]['nom']+'_go_right_img').style.behavior="url(/build/iepngfix.htc);";
			}
			// Gestion du defil
			prep_defil(4);
		}
	}
	xhrRec.open("POST",'/dispatch/ajaxreturn.php',true);
	xhrRec.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhrRec.send("TYPE=res_ajout");	
}
function prep_defil(t) {
	if (t=='full') {
		for (i=0;i<defil_data.length;i++) {
			action_prep_defil(i);
		}
	} else {
		action_prep_defil(t);
	}
}
function action_prep_defil(v) {
	if (_(defil_data[v]['nom']+'_content')) {
		_(defil_data[v]['nom']+'_go_left_img').src=_(defil_data[v]['nom']+'_go_left_img').src.replace('29x29_go_left.','29x29_go_left_fin.');
		mgroup=getElementsByClassName(defil_data[v]['nom']+'_group');
		defil_data[v]['nbr_group']=mgroup.length;
		mywidth=defil_data[v]['nbr_group']*defil_data[v]['elem_width'];
		_(defil_data[v]['nom']+'_go_left').href='javascript:;';
		_(defil_data[v]['nom']+'_go_right').href='javascript:;';		
		if (defil_data[v]['nbr_group']<=defil_data[v]['groups_per_screen']) {
			mywidth=defil_data[v]['groups_per_screen']*defil_data[v]['elem_width'];
			_(defil_data[v]['nom']+'_go_right_img').src=_(defil_data[v]['nom']+'_go_right_img').src.replace('29x29_go_right.','29x29_go_right_fin.');
			gere_defil(defil_data[v]['nom'],v,true);
		} else {
			gere_defil(defil_data[v]['nom'],v,false);
		}
		_(defil_data[v]['nom']+'_content').style.width=(mywidth*1.5)+'px';
	}
}
function gere_defil(o,oo,links_seul) {
	if (defil_data[oo]['liens']) {
		mylinks=getElementsByClassName(o+'_lien');
		for (j=0;j<mylinks.length;j++) {
			mylinks[j].href="javascript:;";
			mylinks[j].onclick=function () {
				myid=this.id;
				myimg=this.innerHTML.replace("48x48","108x108");
				_('photo_profil_current').innerHTML=myimg;
				_('N_AVATAR').value=myid;
				return false;
			}
		}
	}
	if (!links_seul) {
		_(o+'_go_left').onclick=function () {
			if (defil_data[oo]['cour_group']==1) {
				return false;
			} else {
				defil_data[oo]['cour_group']--;
				if (defil_data[oo]['cour_group']<defil_data[oo]['nbr_group']) _(o+'_go_right_img').src=_(o+'_go_right_img').src.replace('29x29_go_right_fin.','29x29_go_right.');
			}
			mypos=((defil_data[oo]['cour_group']-1)*defil_data[oo]['elem_width'])*(1-2);
			_(o+'_content').style.left=mypos+'px';
			if (defil_data[oo]['cour_group']==1) _(o+'_go_left_img').src=_(o+'_go_left_img').src.replace('29x29_go_left.','29x29_go_left_fin.');
		}
		_(o+'_go_right').onclick=function () {
			if (defil_data[oo]['cour_group']+defil_data[oo]['groups_per_screen']>defil_data[oo]['nbr_group']) {
				return false;
			} else {
				defil_data[oo]['cour_group']++;
				if (defil_data[oo]['cour_group']==2) _(o+'_go_left_img').src=_(o+'_go_left_img').src.replace('29x29_go_left_fin.','29x29_go_left.');
			}
			mypos=((defil_data[oo]['cour_group']-1)*defil_data[oo]['elem_width'])*(1-2);
			_(o+'_content').style.left=mypos+'px';
			if (defil_data[oo]['cour_group']+defil_data[oo]['groups_per_screen']>defil_data[oo]['nbr_group']) _(o+'_go_right_img').src=_(o+'_go_right_img').src.replace('29x29_go_right.','29x29_go_right_fin.');
		}
	}
}
function ajust_dispatch() {
	myDiv=_('dispatch');
	myWrap=_('wrapper');
	if (!myDiv || !myWrap) return false;
	screenW=getWidth();	
	screenH=getHeight();
	deltaW=0;
	deltaW=screenW-document.body.offsetWidth;
	scrollPos=getScrollPosition();
	screenW=screenW-deltaW-scrollPos[0];
	oW=getElementWidth('dispatch');
	oH=getElementHeight('dispatch');
	myHpos=parseInt((screenW/2-oW/2)+scrollPos[0]);
	myVpos=parseInt((screenH/2-oH/2)+scrollPos[1]);
	if (myVpos<0) myVpos=0;
	if (myHpos<0) myHpos=0;
	myWrap.style.height=screenH+'px';
	myWrap.style.width=screenW+'px';
	myWrap.style.top=scrollPos[1]+"px";
	myWrap.style.left=scrollPos[0]+"px";	
	myDiv.style.top=myVpos+"px";
/*	myDiv.style.top="105px";*/
	myDiv.style.top="0px";
	myDiv.style.left=myHpos+"px";
	setOpacity(myWrap, 80);
}
function ajust_dispatch_pos() {
	myWrap=_('wrapper');
	scrollPos=getScrollPosition();
	myWrap.style.top=scrollPos[1]+"px";
	myWrap.style.left=scrollPos[0]+"px";	
}

// ouvrir le premier onglet pour la page mode d'emploi
var ouvrir_le_premier_onglet = true;




/*
	STARTLIST
*/
var maxtour=40000;
function startList(n) {
	courant=0;
	if (document.getElementById) {
		
		/* definir l'id popin ouverte */
		if (_('popin_standard') && _('popin_standard').style.display=="block" ) popin_courante_block= _('popin_standard');
		if (_('popin_galerie') && _('popin_galerie').style.display=="block" ) popin_courante_block= _('popin_galerie');
		if (_('popin_atelier') && _('popin_atelier').style.display=="block" ) popin_courante_block= _('popin_atelier');
		if (_('popin_recette') && _('popin_recette').style.display=="block" ) popin_courante_block= _('popin_recette');
		/* fin definir */
		
		navRoot = document.getElementById(n);
		node = navRoot;
		last_node = "";
		while ((node) && (courant<maxtour)) {
			node = getnextnode(navRoot,node);
			courant++;
			if (node) {
				// applique iepngfix sur les png
				if (node.nodeName=="IMG" && ie6) {
					mysplit=node.src.split('.');
					myext=mysplit[mysplit.length-1];
					if (myext.toLowerCase()=='png') node.style.behavior="url(/build/iepngfix.htc);";
				}
				if (node.id=='age_dispatch') {
					if (!_('age_j') || !_('age_m') || !_('age_a')) return false;
					node.onsubmit=function () {
						if (_('st')) {
							if (!_('com')) {
								for(i=0;i<_('age_j').length;++i) {
									if(_('age_j').options[i].selected == true) {
										m_age_j=_('age_j').options[i].value;
									}
								}
								for(i=0;i<_('age_m').length;++i) {
									if(_('age_m').options[i].selected == true) {
										m_age_m=_('age_m').options[i].value;
									}
								}
								for(i=0;i<_('age_a').length;++i) {
									if(_('age_a').options[i].selected == true) {
										m_age_a=_('age_a').options[i].value;
									}
								}
								var m_country=0;
								var m_st='fr';
								if (_('age_country')) {
									for(i=0;i<_('age_country').length;++i) {
										if(_('age_country').options[i].selected == true) {
											m_country=_('age_country').options[i].value;
										}
									}
								}
							} else {
								m_country = _("country").value;
								m_age_j = _("age_j").value;
								m_age_m = _("age_m").value;
								m_age_a = _("age_a").value;
								m_st = _("st").value;
							}
							
						} else {
							m_age_j = _("age_j").value;
							m_age_m = _("age_m").value;
							m_age_a = _("age_a").value;
							m_st = "fr";
						}
						
						/*
						if (_('st')) {
							m_st=_('st').value;
						}
						*/
						var m_remember=0;
						if (_('remember')) {
							m_remember=_('remember').checked;
						}
						
						//if (m_age_j==0 || m_age_m==0 || m_age_a==0) {
						//	_('retour_form_age').innerHTML='Veuillez remplir tous les champs.';
						//} else {
							verif_age_dispatch(m_age_j, m_age_m, m_age_a,m_country,m_st,m_remember);
						//}
						return false;
					}	
				}
				if (node.className=='lien_popin') {
					node.onclick=function () {
						close_all('popin');
						close_all('sous_popin');
						if (this.className=='lien_popin_ouvert') {
							restore_popin_courante();
							ds_respawn();
							this.className='lien_popin';
							mypicto=_('picto_'+this.id);
							if (mypicto) {
								mysrc=mypicto.src;
								mynewsrc=mysrc.replace('_down','');
								mypicto.src=mynewsrc;
							}
						} else {
							raz_popins();
							mytarget=_('popin_'+this.id);
							if (mytarget) {
								ds_kill();
								this.className='lien_popin_ouvert';
								/* 
									
									ACSEO : Initialisation du contenu de la popin : jquery
									
								*/
								
								if (mytarget.id=="popin_inscription") {
									o=$("#popin_identification_content");
									if (o) o.html("");
									$.ajax({
										type: "POST",
											url: "/acseo/actionManager.php",
											data: "controller=user&method=executeCreerCompte",
											success: function(result)
											{
												$("#popin_inscription_content").html(result);
												// on re-parse le retour ajax / fbml
												if ( FB.XFBML.Host.parseDomTree ) setTimeout( FB.XFBML.Host.parseDomTree, 0 );
												$("#PSEUDO_USER").focus();
											}
										});
								} else if (mytarget.id=="popin_identification") {
									o=$("#popin_inscription_content");
									if (o) o.html("");
									$.ajax({
										type: "POST",
											url: "/acseo/actionManager.php",
											data: "controller=user&method=executeLogin",
											success: function(result)
											{
												$("#popin_identification_content").html(result);
												// on re-parse le retour ajax / fbml
												if ( FB.XFBML.Host.parseDomTree ) setTimeout( FB.XFBML.Host.parseDomTree, 0 );
												$("#PSEUDO_USER").focus();
											}
										});
								}
								/* fin ACSEO */
								mytarget.style.display='block';
								mypicto=_('picto_'+this.id);
								if (mypicto) {
									mysrc=mypicto.src;
									mysplit=mysrc.split('/');
									myimg=mysplit[mysplit.length-1];
									mysplitimg=myimg.split('.');
									myimgname=mysplitimg[0];
									myimg=myimgname+'_down.'+mysplitimg[1];
									mynewsrc='';
									for(i=0;i<mysplit.length-1;i++) {
										mynewsrc+=mysplit[i]+'/';
									}
									mynewsrc+=myimg;
									mypicto.src=mynewsrc;
								}
							}
						}
					}
					
					node.href='javascript:;';

				}
				if (node.className=='ferme_popin_') {


					node.onclick=function () {
					
						/* Redirect "violent" vers l'accueil */
						/* modif sherif */
						if (this.id!="ferme_popin_identification" && this.id!="ferme_popin_inscription") {
							self.location="/index.php?intro=0";
							return;
						}
						/* Redirect "violent" vers l'accueil */
						close_all('popin');
						mypicto=_('picto_'+this.id.replace(this.className,''));
						if (mypicto) {
							mysrc=mypicto.src;
							mynewsrc=mysrc.replace('_down','');
							mypicto.src=mynewsrc;
						}
						_(this.id.replace(this.className,'')).className='lien_popin';
						
						restore_popin_courante();
						ds_respawn();

						
					}
					//node.href='javascript:;';
					// Test Romain D. 08/09/10
					if (!ie6) {
						node.href='javascript:;';
					}
				}
				if (node.className=='lien_photo') {
					node.onmouseover=function () {
						lien_photo_up=true;
						_('modif_photo_profil').style.display='block';
					}
					node.onmouseout=function () {
						lien_photo_up=false;
						setTimeout("rollbackmodif();",500);
					}					
				}
				if (node.id=='modif_photo_profil') {
					node.onmouseover=function () {
						lien_photo_up=true;
					}
					node.onmouseout=function () {
						lien_photo_up=false;
						setTimeout("rollbackmodif();",500);
					}
				}

/*
				if (node.id=='new_avatar_submit') {
					node.onclick=function () {
						_('photo_profil_avatar').innerHTML=_('photo_profil_current').innerHTML;
						show_all_select();
						alert(_('N_AVATAR').value);
						// ICI FONCTION AJAX MISE A JOUR DE LA BASE avec _('N_AVATAR').value
						//_('sous_popin_modifie_avatar').style.display='none';
						return false;
					}
				}
*/
				if (node.className=='ferme_sous_popin_') {
					node.onclick=function () {
						show_all_select();
						close_all('sous_popin');
						return false;
					}
					node.href='javascript:;';
				}
				if (node.className=='open_sous_popin') {
					node.onclick=function () {
						close_all('sous_popin');
						hide_all_select();
						_('sous_popin_'+this.id).style.display='block';
						if (this.id=="commandes") {
							o=_("iif_commandes");
							if (o) o.src="/acseo/commandes.php?ts="+Math.floor((new Date()).getTime() / 1000);
						}
						if (this.id=="modifie_email") {	
							o=_('ajax_error_email');
							if (o) { o.innerHTML='';	}
						}

						if (this.id=="modifie_pwd") {
							o=_('ajax_error_pwd');
							if (o) { o.innerHTML='';	}
						}
						
						return false;
					}
					node.href='javascript:;';
				}

		
				if (node.className=='lien_appear_onglet') {
					node.onclick=function () {
						close_all('contenu_onglet');
						for (k=1;k<=4;k++) {
							_('fleche_onglet'+k).src=_('fleche_onglet'+k).src.replace('fleche_bas_onglet_mode_emploi','fleche_droite_onglet_mode_emploi');
						}
						t=this.id.replace('lien_appear_onglet','');
						_('contenu_onglet'+t).style.display='block';
						_('fleche_onglet'+t).src=_('fleche_onglet'+t).src.replace('fleche_droite_onglet_mode_emploi','fleche_bas_onglet_mode_emploi');
						return false;
					}					
					node.href='javascript:;';
				}
				if (node.className=='lien_appear_menu') {
					//if (node.id != 'lien_appear_menu3') {
						node.onclick=function () {
							close_all('contenu_menu');
							for (k=1;k<=4;k++) {
								if (_('fleche_onglet'+k)) _('fleche_onglet'+k).src=_('fleche_onglet'+k).src.replace('fleche_bas_onglet_mode_emploi','fleche_droite_onglet_mode_emploi');
								_('titre_menu'+k).className='';
							}
							t=this.id.replace('lien_appear_menu','');
							if (_('contenu_menu'+t) && _('contenu_menu'+t).className != "contenu_menu_invisible") _('contenu_menu'+t).style.display='block';
							if (_('fleche_onglet'+t)) _('fleche_onglet'+t).src=_('fleche_onglet'+t).src.replace('fleche_droite_onglet_mode_emploi','fleche_bas_onglet_mode_emploi');
							_('titre_menu'+t).className='actif';
							return false; 
						}
					//}
					//node.href='javascript:;';
				}
				if (node.className=='lien_appear_sous_menu') {
					//if (node.id != 'lien_appear_sous_menu1' && node.id != 'lien_appear_sous_menu2') {
						node.onclick=function () {
							close_all('sous_menu');
							for (k=1;k<=7;k++) {
								if (_('fleche_sous_menu'+k)) _('fleche_sous_menu'+k).src=_('fleche_sous_menu'+k).src.replace('fleche_bas_sous_menu','fleche_droite_sous_menu');
								_('lien_appear_sous_menu'+k).className='lien_appear_sous_menu';
							}
							t=this.id.replace('lien_appear_sous_menu','');
							if (_('sous_menu'+t) && _('sous_menu'+t).className != "sous_menu_invisible") _('sous_menu'+t).style.display='block';
							if (_('fleche_sous_menu'+t)) _('fleche_sous_menu'+t).src=_('fleche_sous_menu'+t).src.replace('fleche_droite_sous_menu','fleche_bas_sous_menu');
							this.className='lien_appear_sous_menu actif';
							return false;
						}
					//}					
					//node.href='javascript:;';
				}
			}
		}
		
		if (ouvrir_le_premier_onglet && _('lien_appear_onglet1')) {
			ouvrir_le_premier_onglet = false;
			_('contenu_onglet1').style.display='block';
			_('fleche_onglet1').src=_('fleche_onglet1').src.replace('fleche_droite_onglet_mode_emploi','fleche_bas_onglet_mode_emploi');
		}
	
		if (courpage != "") {
			courmenupage = _('menupage'+courpage);
			if (courmenupage) {
				// init fleche 
				for (k=1;k<=7;k++) {
					if (_('fleche_sous_menu'+k)) _('fleche_sous_menu'+k).src=_('fleche_sous_menu'+k).src.replace('fleche_bas_sous_menu','fleche_droite_sous_menu');
					_('lien_appear_sous_menu'+k).className='lien_appear_sous_menu';
				}
				// ! init fleche 
				
				// ouvrir le menu parent (premier objet au déssus de l'élément)
				if (courmenupage.parentNode) {
					if ((courmenupage.parentNode.className != "contenu_menu_invisible") && (courmenupage.parentNode.className != "sous_menu_invisible")) {
						courmenupage.parentNode.style.display = 'block';
					}
				}
				// mettre en evidence le lien (premier objet à l'interieur de l'élément)
				if (courmenupage.firstChild) courmenupage.firstChild.className='selected';
				
				if (courmenupage.parentNode && courmenupage.parentNode.parentNode) {
					if (courmenupage.parentNode.className=="sous_menu") {
							courmenupage.parentNode.style.display = 'block';
					}

				// mettre en evidence le lien
				lien_sel = courmenupage.parentNode.parentNode.firstChild.nextSibling;
				if (lien_sel && lien_sel.tagName=="A") lien_sel.className='selected';
				
				image_sel = "";
				if (lien_sel.nextSibling && lien_sel.nextSibling.tagName == "IMG") {
					image_sel = lien_sel.nextSibling;
				}
				
				if (lien_sel.nextSibling && lien_sel.nextSibling.nextSibling && lien_sel.nextSibling.nextSibling.tagName == "IMG") {
					image_sel = lien_sel.nextSibling.nextSibling;
				}
				
				if (image_sel) {
					image_sel.src=image_sel.src.replace('fleche_droite_sous_menu','fleche_bas_sous_menu');
				}
					
					o_fleche = courmenupage.parentNode.parentNode;
					if (o_fleche.className != "elem") {
						o_fleche = o_fleche.parentNode;
						if (o_fleche.className == "contenu_menu") {
							o_fleche.style.display = 'block';
						}
						if (o_fleche) o_fleche = o_fleche.parentNode;
					}
					
					if (o_fleche) o_fleche = o_fleche.firstChild;
					
					while (o_fleche) {
						if (o_fleche.tagName == 'H5') {
							o_fleche.className = 'actif';
							// on entre dans le H5
							o_fleche = o_fleche.firstChild;
						} else 	if (o_fleche.tagName == 'IMG') {
							o_fleche.src = o_fleche.src.replace('fleche_droite_onglet_mode_emploi','fleche_bas_onglet_mode_emploi');
						}
						o_fleche = o_fleche.nextSibling;
					}
				}
			}
		}
		
	}
}
function open_sp(o) {
	if (!_(o)) return false; 
	hide_all_select();
	_(o).style.display='block';
	return false;
}
function hide_all_select() {
	if (ie6) {
		myselects=getElementsByClassName('select_to_hide');
		if (myselects) classRepl(myselects,'hidden','visibility');
	}
}
function show_all_select() {
	if (ie6) {
		myselects=getElementsByClassName('select_to_hide');
		if (myselects) classRepl(myselects,'visible','visibility');
	}
}
function rollbackmodif() {
	if (lien_photo_up==false) {
		_('modif_photo_profil').style.display='none';
	}
}
function raz_popins() {
	mylinks=getElementsByClassName('lien_popin_ouvert');
	if (mylinks) classRepl(mylinks,'lien_popin','classN');
	myimgs=getElementsByClassName('picto_menu');
	for(i=0;i<myimgs.length;i++) {	
		mysrc=myimgs[i].src;
		mynewsrc=mysrc.replace('_down','');
		myimgs[i].src=mynewsrc;
	}
}
function close_all(elem) {
	if (elem=='' || !elem) return false;
	s_pop_projet=false;
	if (_('sous_popin_fiche_projet')) {
		if (_('sous_popin_fiche_projet').style.display=='block') s_pop_projet=true;
	}
	mypopins=getElementsByClassName(elem);
	if (mypopins) classRepl(mypopins,'none');
	if (s_pop_projet) _('sous_popin_fiche_projet').style.display='block';
}
function close_projet() {
var NomNav = navigator.appName; 
var VersNav = parseFloat(navigator.appVersion);
if (NomNav == "Microsoft Internet Explorer" && VersNav<=6) {
o=document.getElementById('departe_liste');
if (o) o.style.display = 'block';
p=document.getElementById('TRI');
if (p) p.style.display = 'block';
q=document.getElementById('TRI2');
if (q) q.style.display = 'block';}
	if (!_('sous_popin_fiche_projet')) return false;
	_('sous_popin_fiche_projet').style.display='none';
	if (_('form_ajaxreturn_popin_projet_reload').value==1) {
		_('form_ajaxreturn_popin_projet_reload').value=0;
		var ord=random_stamp();
		var urltab=self.location.href.split("?");
		self.location=urltab[0]+'?ord='+ord;
	}
	return false;
}

function deconnecter() {
	self.location='/acseo/logout.php';
	return false;
}


function open_sous_popin_invitation(id) {
	if (!_('sous_popin_invite_contacts')) return false;
	if (!id) return false;
	if (!_('ajaxreturn_popin_invitation')) return false;
//	if (!_('form_ajaxreturn_popin_invitation_id_projet')) return false;
	_('sous_popin_invite_contacts').style.display='block';
//	_('form_ajaxreturn_popin_invitation_id_projet').value=id;
	ob_get_popin_invitation(id);
	// Contenu popin à ajouter en AJAX
	setTimeout("defil_data[5]['nbr_group']=0;defil_data[5]['cour_group']=1;prep_defil(5);defil_data[6]['nbr_group']=0;defil_data[6]['cour_group']=1;prep_defil(6);",600);
	return false;
}


function open_sous_popin_atelier_statut(id,action) {
	if (!_('sous_popin_atelier_statut')) return false;
	if (!id) return false;
	if (!_('ajaxreturn_popin_atelier_statut')) return false;
	_('sous_popin_atelier_statut').style.display='block';
	ob_get_popin_atelier_statut(id,action);
	// Contenu popin à ajouter en AJAX
	return false;
}



function open_sous_popin_projet(id) {
var NomNav = navigator.appName; 
var VersNav = parseFloat(navigator.appVersion);
if (NomNav == "Microsoft Internet Explorer" && VersNav<=6) {
o=document.getElementById('departe_liste');
if (o) o.style.display = 'none';
p=document.getElementById('TRI');
if (p) p.style.display = 'none';
q=document.getElementById('TRI2');
if (q) q.style.display = 'none';}
	if (!_('sous_popin_fiche_projet')) return false;
	if (!id) return false;
	if (!_('ajaxreturn_popin_projet')) return false;
	if (!_('form_ajaxreturn_popin_projet_id_projet')) return false;
	if (!_('form_ajaxreturn_popin_projet_action')) return false;
	_('sous_popin_fiche_projet').style.display='block';
	_('form_ajaxreturn_popin_projet_id_projet').value=id;
	_('form_ajaxreturn_popin_projet_action').value='voir';
	ob_get_popin_projet('form_ajaxreturn_popin_projet');
	// Contenu popin à ajouter en AJAX

	setTimeout("_('ref_addthis_popin').onclick=_('ref_addthis').onclick;",600);

	z1='1800';
	z2='1900';
	o=_('sous_popin_fiche_projet');
	oo=_('sous_popin_fiche_profil');
	if (o.style.display == "block") {
		o.style.zIndex=z2;
		oo.style.zIndex=z1;
	}


	return false;

}



function open_sous_popin_comments(id) {
	if (!_('sous_popin_comments')) return false;
	if (!id) return false;
	if (!_('ajaxreturn_popin_comments')) return false;
	_('sous_popin_comments').style.display='block';
	ob_get_popin_comments(id);
	// Contenu popin à ajouter en AJAX

	
	o = _('ferme_sous_popin_comments');
	if (o) {
		o.onclick=function () {
			show_all_select();
			close_all('sous_popin');
			open_sous_popin_projet(id);
			return false;
		}
		o.href='javascript:;';
	}
	return false;

}





function open_sous_popin(sous_popin) {
var NomNav = navigator.appName; 
var VersNav = parseFloat(navigator.appVersion);
if (NomNav == "Microsoft Internet Explorer" && VersNav<=6) {
o=document.getElementById('desper_pref');
if (o) o.style.display = 'none';
p=document.getElementById('date_annive');
if (p) p.style.display = 'none';
q=document.getElementById('departe_liste');
if (q) q.style.display = 'none';}
	close_all('sous_popin');
	hide_all_select();
						
	if (!_(sous_popin)) return false;
	_(sous_popin).style.display='block';
	return false;
}



function launch_home_flash() {
	var flashvars = {};
	if (intro==false) {
		flashvars = {intro: 0};
	}
	var params = {};
	params.menu = "false";
	params.wmode = "transparent";
	params.scale = "noscale";
	params.allowScriptAccess="always";
	var attributes = {};
	attributes.id = "home_flash";
	attributes.name = "home_flash";
	swfobject.embedSWF("/swf/home.swf", "home_flash", "978", "618", "9.0.0.0", "expressInstall.swf", flashvars, params, attributes);
}
function verif_age_dispatch(jour, mois, annee, country,st,remember) {
	var xhrRec = xhrRequest('html');
	xhrRec.onreadystatechange = function() {
		if(xhrRec.readyState == 4 && xhrRec.status == 200) {
			oo = xhrRec.responseText;
			if (oo!='ok') {
				_('retour_form_age').style.display = "block";
				_('retour_form_age').innerHTML=oo;
			} else {
				
				self.location.reload();
/* remplacement sherif
				_('dispatch').innerHTML='';
				_('dispatch').style.display='none';
				_('wrapper').style.display='none';
				doresize=false;
				launch_home_flash();
*/
			}
		}
	}
	xhrRec.open("POST",'/dispatch/ajaxreturn.php',true);
	xhrRec.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhrRec.send("TYPE=dispatch_test&jour="+jour+"&mois="+mois+"&annee="+annee+"&country="+country+"&st="+st+"&remember="+remember);
}

function erreurinscription(o) {
	if (!o) return false;
	oo=_('error_inscription');
	if (!oo) return false;
	if (oo.innerHTML==o.title) oo.innerHTML="&nbsp;";
	else oo.innerHTML=o.title;
}
function erreuridentification(o) {
	if (!o) return false;
	oo=_('error_identification');
	if (!oo) return false;
	if (oo.innerHTML==o.title) oo.innerHTML="&nbsp;";
	else oo.innerHTML=o.title;
}

function random_stamp() {
	var rand_no = Math.random();
	return Math.floor(rand_no * 10000000000);
}

function affnotice(typ,rid) {
var NomNav = navigator.appName; 
var VersNav = parseFloat(navigator.appVersion);
if (NomNav == "Microsoft Internet Explorer" && VersNav<=6) {
o=document.getElementById('desper_pref');
if (o) o.style.display = 'none';}
	if (! typ) return false;
	if (! rid) return false;
	
	if (typ==1) {
		open_sous_popin_projet(rid);
	}
	if (typ==2) {
		/*alert("popin profil "+rid);*/
		open_sous_popin_profil(rid);
	} 
	if (typ==3) {
		//alert("popin message de la notification "+rid);
		$.ajax({
			type: "POST",
			url:  "/dynamic/message_notice.php",
			data: "id="+rid,
			success: function(result) 
			{
				$("#sous_popin_popmessage_content").html(result);
				$("#sous_popin_popmessage").show();
			}
		});
	}
}


function popup_window(name,url,w,h) {
	var width=w;
	var height=h;
	var from_top=50;
	var from_left=50;
	var toolbar='no';
	var location='no';
	var directories='no';
	var status='no';
	var menubar='no';
	var scrollbars='yes';
	var resizable='yes';
	var atts='width='+width+'show,height='+height+',top='+from_top+',screenY=';
	atts+= from_top+',left='+from_left+',screenX='+from_left+',toolbar='+toolbar;
	atts+=',location='+location+',directories='+directories+',status='+status;
	atts+=',menubar='+menubar+',scrollbars='+scrollbars+',resizable='+resizable;
	name=window.open(url,name,atts);
	if(name.window.focus){name.window.focus();}
}


function open_sous_popin_big_visuel(id) {
var NomNav = navigator.appName; 
var VersNav = parseFloat(navigator.appVersion);
if (NomNav == "Microsoft Internet Explorer" && VersNav<=6) {
o=document.getElementById('desper_pref');
if (o) o.style.display = 'none';
p=document.getElementById('date_annive');
if (p) p.style.display = 'none';
q=document.getElementById('ID_PRODUIT');
if (q) q.style.display = 'none';}
	if (!_('sous_popin_big_visuel')) return false;
	if (!id) return false;
	if (!_('ajaxreturn_sous_popin_big_visuel')) return false;
	_('sous_popin_big_visuel').style.display='block';
	ob_get_popin_big_visuel(id);
	// Contenu popin à ajouter en AJAX
	return false;
}


function close_sous_popin_big_visuel() {
var NomNav = navigator.appName; 
var VersNav = parseFloat(navigator.appVersion);
if (NomNav == "Microsoft Internet Explorer" && VersNav<=6) {
o=document.getElementById('desper_pref');
if (o) o.style.display = 'block';
p=document.getElementById('date_annive');
if (p) p.style.display = 'block';
q=document.getElementById('ID_PRODUIT');
if (q) q.style.display = 'block';}
	if (!_('sous_popin_big_visuel')) return false;
	if (!_('ajaxreturn_sous_popin_big_visuel')) return false;
	_('sous_popin_big_visuel').style.display='none';
	//ob_get_popin_big_visuel('form_ajaxreturn_popin_projet');
	// Contenu popin à ajouter en AJAX
	return false;
}

function ob_get_popin_big_visuel(id) {
	var poststr ="";
	poststr += "home_id_projet="+encodeURI(id)+"&URL=" + encodeURI( window.location );
	makePOSTRequest('/dynamic/ajaxreturn_sous_popin_big_visuel.php', poststr);
}


function open_sous_popin_profil(id, id_user_request) {

var NomNav = navigator.appName; 
var VersNav = parseFloat(navigator.appVersion);
if (NomNav == "Microsoft Internet Explorer" && VersNav<=6) {
o=document.getElementById('desper_pref');
if (o) o.style.display = 'none';
p=document.getElementById('departe_liste');
if (p) p.style.display = 'none';}

	if (!_('sous_popin_fiche_profil')) return false;
	if (!id) return false;
	if (!_('ajaxreturn_popin_profil')) return false;
	_('sous_popin_fiche_profil').style.display='block';
	ob_get_popin_profil(id, id_user_request);
	// Contenu popin à ajouter en AJAX

	z1='1800';
	z2='1900';
	o=_('sous_popin_fiche_projet');
	oo=_('sous_popin_fiche_profil');
	if (o) {
		if (o.style.display == "block") {
			o.style.zIndex=z1;
			oo.style.zIndex=z2;
		}
	}

	setTimeout("defil_data[7]['nbr_group']=0;defil_data[7]['cour_group']=1;prep_defil(7);defil_data[8]['nbr_group']=0;defil_data[8]['cour_group']=1;prep_defil(8);",600);
	return false;
}

function ob_get_popin_profil(id, id_user_request) {
	var poststr ="";
	poststr += "id_user="+encodeURI(id)+"&URL=" + encodeURI( window.location );
	if (id_user_request)
	{
		poststr +="&id_user_request="+encodeURI(id_user_request);
	}
	makePOSTRequest('/dynamic/ajaxreturn_popin_profil.php', poststr);
}

function ob_get_popin_add_user_form(obj) {
	var poststr = DisplayFormValues(obj);
	poststr += "URL=" + encodeURI( window.location );
	makePOSTRequest('/dynamic/ajaxreturn_popin_profil.php', poststr);
}

function close_profil() {
var NomNav = navigator.appName; 
var VersNav = parseFloat(navigator.appVersion);
if (NomNav == "Microsoft Internet Explorer" && VersNav<=6) {
o=document.getElementById('desper_pref');
if (o) o.style.display = 'block';
p=document.getElementById('departe_liste');
if (p) p.style.display = 'block';}
	if (!_('sous_popin_fiche_profil')) return false;
	_('sous_popin_fiche_profil').style.display='none';
	
	o=_('home_flash');
	oo=_('sous_popin_fiche_produit');
	if (o) {
		if (oo) {
			if (oo.style.display=="none") {
				o.respawn();
			}
		}
	}
	return false;
}

function close_spreadshirt() {
	if (!_('sous_popin_spreadshirt')) return false;
	_('sous_popin_spreadshirt').style.display='none';
	
	
	o=_('home_flash');
	oo=_('sous_popin_fiche_produit');
	if (o) {
		if (oo.style.display=="none") {
			o.respawn();
		}
	}	
	
	return false;
}

function open_sous_popin_spreadshirt() {
	if (!_('sous_popin_spreadshirt')) return false;
	_('sous_popin_spreadshirt').style.display='block';
}

function open_sous_popin_spreadshirt_commandes() {
	if (!_('sous_popin_commandes_spreadshirt')) return false;
	_('iif_commandes_Spreadshop').src='http://desperados.spreadshirt.nl/shop/myorder';
	_('sous_popin_commandes_spreadshirt').style.display='block';
}


var win="";
function opennamewin(u, n, w, h) {
		if (win!="") {if (! win.closed) { win.close();}}
		stats="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes," ;
		stats += "resizable=no,width="+w+",height="+h+",left=0,top=0";
		win= window.open (u,n,stats);
		win.focus();
}

function newuser() {
	window.location = "/dynamic/atelier.php?newuser=1";
	return false;
}

function partageFB(u) {
	opennamewin("http://www.facebook.com/share.php?u=http://www.imagine-desperados.fr/dynamic/fb_share.php?s=" + u, "score", 600, 400);
}

/*
function launch_visuel_3d() {
	var image=_('fichier_image_3d').value;
	if (image=='') return;
	swfobject.createCSS("html", "height:100%;");
	swfobject.createCSS("body", "margin:0; padding:0; height:100%;");
	swfobject.createCSS("#bottleViewer", "margin:auto; width:100px; height:370px;");
	var flashvars = {};
	flashvars.fichier = image;
	var params = {};
	params.menu = "false";
	var attributes = {};
	attributes.id = "bottleViewer";
	attributes.name = "bottleViewer";
	swfobject.embedSWF("/swf/bottleViewer.swf", "visuel_3d", "100", "370", "9.0.0.0", "expressInstall.swf", flashvars, params, attributes);
}


function launch_3d_visuel() {
	setTimeout(function() {
      launch_visuel_3d();
   	}, 500);
}
*/
