/* 
  	Déclaration des fonctions globales de l'éditeur editisonline.free.Fr
 	Tous droits réservés à editisonline.free.Fr
  	All right reserved to editisonline.free.Fr 
*/	
	var _menu = new Array;
	
	function SetClass(id, style)
	{
		oEl.get(id).className = ( oEl.get(id).className.indexOf("upper") != -1 ) ? style + " upper" : style;
	}

	function overLigne(event)
	{
		var el = ( !oNav.msie ) ? event.target : window.event.srcElement;
		
		var parent = el.parentNode;
		if( (el.tagName.toLowerCase() == "td") && (parent.className == "ejstableimpaire" || parent.className == "ejstablepaire") )
		{
			var parent = el.parentNode;
			while( parent.tagName.toLowerCase() != "table" )
			{
				parent = parent.parentNode;
			}
			for( var i = 0; i < parent.rows.length; i++ )
			{
				if( parent.rows[i].className == "ejstableselect" ){
					parent.rows[i].className = ( (i-1) % 2 ) ? "ejstablepaire" : "ejstableimpaire";
				}
			}
			 el.parentNode.className = "ejstableselect";
		}
	}
	
	function TestPwd(el, lang)
	{
		if( !oEl.isobject(el) )
		{
			if( !oEl.test(el) )
			{
				return false;
			}
			else{
				var el = oEl.get(el);
			}
		}
		var value = oText.trim(el.value);

		var parent = el.parentNode.parentNode;
		var divs = oEl.gettags("div", parent);
		for( var i = 0; i < divs.length; i++ ){
			if( divs[i].className.indexOf("ejsmdp") != -1 ){
				parent.removeChild(divs[i]);
				break;
			}
		}
		if( value == "" ){ return false; }
		var i = 0;	
		if( value.length > 5 ){
			i++;
			if( value.search("[A-Z]") != -1 ){ i++; }
			if( value.search("[0-9]") != -1 ){ i++; }
			if( value.length >= 8 && value.search("[\x20-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]") != -1 ){i++;}
			if( !isNaN(value) ){ i = 1; }
		}
		var div = oEl.create("div");
		switch( i )
		{
			case 0:
				div.className="ejsmdp";
				div.innerHTML = "&nbsp;";
				break;
			case 1:
				div.className = "ejsmdp ejsbad";
				div.innerHTML = ( lang == null || lang == 1 ) ? "Mauvais" : "Bad";
				break;
		case 2:
				div.className = "ejsmdp ejsmedium";
				div.innerHTML = ( lang == null || lang == 1 ) ? "Moyen" : "Medium,";
				div.innerHTML = "Moyen";
				break;
			default:
				div.className = "ejsmdp ejsgood";
				div.innerHTML = ( lang == null || lang == 1 ) ? "Fort" : "Good";
		}
		parent.appendChild(div);
	}
	
	function AffBox(type, text, poxY)
	{
		oBox.type = type;
		oBox.html = text;
		oBox.poxY = (poxY != null) ? poxY: 0;
		oBox.show();	
	}
	
	function AffFormulaire(url, nom, param)
	{
		if( param == "" )
		{
			param = "width=700,height=500,top=50,left=50,titlebar=no,toolbar=no,scrollbars=yes,resizable=yes,location=no,menubar=no";
			window.open(url, nom, param);
			return false;
		}
	}
	
	function goTo(url)
	{
		window.location.href = url;
	}

	function Language(id)
	{
		var c = new String("1_2;2_21;3_15");
		var t = c.split(";");
		for(var i = 0; i < t.length; i++ )
		{
			var c = new String(t[i]);
			var st = c.split("_");
			if(id == st[0])
			{
				oNav.goto("page"+st[1]+".html");
				break;
			}
		}
	}
	
	function ScrollMenu()
	{
		if(oEl.test("MENU"))
		{			
			oEl.get("MENU").style.top = oText.toPx(oNav.scrollY);
			if(oEl.test("SMENU")){
				oEl.get("SMENU").style.top = oText.toPx(oNav.scrollY + oEl.get("MENU").offsetHeight);
			}
			setTimeout("ScrollMenu()",1);
		}		
	}

	function Rechercher()
	{
		if( oEl.test("SEARCH") )
		{
			var wMot = new String(oEl.get("SEARCH").value);
			if( wMot == "" || wMot.length < 3 )
			{
				return false;
			};
			oNav.goto("recherche.php?terme=" + escape(wMot));
		}
	}
	
	function getCell(obj)
	{
		if( oEl.test("MENU") )
		{
			var t = oEl.get("MENU");
			for( var i = 0; i < t.rows[0].cells.length; i++ )
			{
				var cell = t.rows[0].cells[i];
				if( cell == obj )
				{
					return i;
				}
			}
		}
		return 0;
	}

	function Smenu(obj)
	{	
		if( oEl.test("MENU") && oEl.isobject(obj) ){
			var num = getCell(obj)
			if(_menu[num][0][3] == "")
			{
				oEl.del("SMENU");
				var num = parseInt(getCell(obj));
				var div = oEl.create("div");
				div.id = "SMENU";
				div.className = "ejspopper";
				div.style.left = oText.toPx(obj.offsetLeft);
				div.style.top = oText.toPx(obj.offsetTop + obj.offsetHeight);
				oNav.body.appendChild(div);
				for( var i = 0; i < _menu[num].length; i++)
				{			
					var sdiv = oEl.create("div");
					sdiv.className = _style;
					sdiv.id=num+"_"+i;
					//oEl.opacity(sdiv, 70);
					sdiv.innerHTML = _menu[num][i][2];
					sdiv.onmouseover = function()
					{
						//oEl.opacity(this, 100);
						this.className = _style + "over";
					};
					sdiv.onmouseout = function()
					{
						//oEl.opacity(this, 70);
						this.className = _style;
					};
					sdiv.onclick = function()
					{
						var id = (this.id).toString();
						var t = id.split("_");
						oNav.goto(_menu[parseInt(t[0])][parseInt(t[1])][1]);
						return false;
					};
					div.appendChild(sdiv);
				}
				if( div.offsetWidth < obj.offsetWidth ){
					div.style.width =  oText.toPx(obj.offsetWidth);
				}
			}
		}
	}
	
	function GenereMenu()
	{
		if( oEl.test("MENU") && oEl.isobject(_menu) ){
			var tab = oEl.get("MENU");
			for( var i = 0; i < _menu.length; i++)
			{			
				var cell = tab.rows[0].insertCell(i);
				cell.className = _style + "1";
				cell.innerHTML = _menu[i][0][0];
				cell.onmouseover=function()
				{
					oEl.del("SMENU");
					this.className = _style + "over1";			
				};
				cell.onmouseout=function()
				{					
					this.className = _style + "1";					
				};
				switch (_menu[i][0][3])
				{
				case "LANGUE":
					cell.innerHTML = "";
					for( var y = 0; y < _menu[i].length; y++)
					{				
						cell.id = _menu[i][y][1];
						var img = oEl.create("img");
						img.style.width = "31px";
						img.style.height = "20px";
						img.src = "images/drapeaux/" + _menu[i][y][0];
						cell.onclick = function(){
							Language(this.id);
						};
						cell.appendChild(img);
						if( _menu[i].length > (y + 1) ){
							var cell = tab.rows[0].insertCell(i);
							cell.className = _style + "1";
							cell.onmouseover=function()
							{
								oEl.del("SMENU");
								this.className = _style + "over1";			
							};
							cell.onmouseout=function()
							{
								this.className = _style + "1";					
							};
						}
					}
					break;
				case "RECHERCHE":					
					var input = oEl.create("input");
					input.type = "text";
					input.id = "SEARCH";
					input.className = "ejsChampRech";					
					cell.appendChild(input);
					var a = oEl.create("a");
					a.href = "javascript:Rechercher()";
					var img = oEl.create("img");
					img.src = "images/divers/loupe.gif";
					img.className = "ejsloupe";
					img.title = _menu[i][0][2];
					a.appendChild(img);
					cell.appendChild(a);
					break;
				case "CONTACT":
					cell.id = _menu[i][0][1];
					cell.onclick = function(){
						oNav.goto("formulaire.php?lang=" + this.id);
					};
					break;
				case "CATALOGUE":
				case "COMPTE":
					cell.id = i;
					cell.onclick = function(){
						oNav.goto(_menu[parseInt(this.id)][0][1])
					};				
					break;
				case "FIN":
					cell.style.width = "100%";
					//cell.style.height = "25px";
					cell.innerHTML = "&nbsp;"
					break;
				default:
					cell.onmouseover=function()
					{
						this.className = _style + "over1";			
						if( this.onclick == undefined )
						{
							Smenu(this);
						}			
					};
				}		
			}
		}	
	
	}
	
	function Load()
	{
		var bs = oNav.body.style;
		var cs = document.body.className;		
		if( parent.frames.length >= 1)
		{			
			var f = parent.frames[0].name;
			if(f == "banniere" || f == "menu" )
			{
				parent.frames[f].className = cs;				
				try
				{
					var s = parent.frames[f].document.body.style;
					if( s.backgroundImage != bs.backgroundImage || s.backgroundColor != bs.backgroundColor )
					{
						s.backgroundColor = bs.backgroundColor;
						s.backgroundImage = bs.backgroundImage;
					}
				}
				catch(e){}
			}
		}
		if(parent.frames.length >= 2)
		{
			var f = parent.frames[1].name;
			if( f == "menu" )
			{
				parent.frames.fr.document.body.className = cs;
				try
				{
					var s = parent.frames.menu.document.body.style;
					if( s.backgroundImage != bs.backgroundImage|| s.backgroundColor != bs.backgroundColor )
					{
						s.backgroundColor = bs.backgroundColor;
						s.backgroundImage = bs.backgroundImage;
					}
				}
				catch(e){}
			}
		}
		GenereMenu();
	}

	oNav.addevent("onscroll", ScrollMenu);	
	oNav.addevent("onload", Load);

