/*****     fonction pour flash     *****/
function RunFoo(swf, hauteur, largeur, couleur, Mozcolor, nom)
{
	document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\""
				   +hauteur+"\" height=\""+largeur+"\" id=\""+nom+"\" align=\"middle\">\n");
	if (couleur == "transparent")
	{
		document.write("<param name=\"wmode\" value=\"transparent\" />\n");
	}
	else
	{
		document.write("<param name=\"bgcolor\" value=\""+couleur+"\" />\n");
	}
	document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />\n");
	//document.write("<param name='loop' value='false'>")
	document.write("<param name=\"movie\" value=\""+swf+"\" /><param name=\"quality\" value=\"high\" /><embed src=\""+
				   swf+"\" quality=\"high\" width=\""+hauteur+"\" bgcolor=\""+Mozcolor+"\" height=\""+largeur+"\" name=\""+
				   nom+"\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\"pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />\n");
	document.write("</object>\n");
}

/*****     fonction utilisé sur la page d'accueil     *****/
function AfficheHomePage()
{
    if (document.all && document.getElementById)
    {
        document.write('<a href="#" onClick="HomePage(this);return(false);"><font color="blue"><u>Page de démarrage</u></font></a><br/>');
    }
}

function HomePage(obj)
{
	obj.style.behavior='url(#default#homepage)';
	obj.setHomePage('http://www.infologis.fr/');
}

/*****     fonctions utilisées sur la page contact     *****/

function MM_findObj(n, d) 
{ //v4.01
	var p,i,x;
	
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) 
	{
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n);
	return x;
}

function MM_validateForm() 
{ //v4.0
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	
	for (i=0; i<(args.length-2); i+=3)
	{ 
		test=args[i+2];
		val=MM_findObj(args[i]);
		if (val)
		{
			nm=val.name;
			if ((val=val.value)!="") 
			{
				if (test.indexOf('isEmail')!=-1)
				{
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
				}
				else if (test!='R')
				{
					num = parseFloat(val);
					if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
					if (test.indexOf('inRange') != -1) 
					{
						p=test.indexOf(':');
						min=test.substring(8,p); 
						max=test.substring(p+1);
						if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
					}
				} 
			}
			else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; 
		}
	} 
	if (errors) alert('The following error(s) occurred:\n'+errors);
	document.MM_returnValue = (errors == '');
}

function champsok()
{
	var msg, cpt;
	msg='Veuillez renseigner : \n';
	
	if (document.envoiemail.nom.value.length == 0)
	{
		msg= msg + '  - Le nom \n';
		cpt = false;
	}
	if (document.envoiemail.raisonsociale.value.length == 0)
	{
		msg= msg + '  - La raison sociale \n';
		cpt = false;
	}
	if (document.envoiemail.adresse.value.length == 0)
	{
		msg = msg + "  - L'adresse \n";
		cpt = false;
	}
	if (document.envoiemail.codepostal.value.length != 5)
	{
		if (document.envoiemail.codepostal.value.length == 0)
		{
			msg += "  - Code Postal non renseigner\n";
		}
		else
		{
			msg += "  - Code Postal erroné (5 chiffres)\n";
		}
		cpt = false;
	}
	if (document.envoiemail.commune.value.length == 0)
	{
		msg = msg + "  - La commune \n";
		cpt = false;
	}
	if (document.envoiemail.email.value.length == 0)
	{
		msg += "  - Email non renseigner\n";
		cpt = false;
	}
	else
	{
		var exp = new RegExp("^[a-zA-Z0-9\-_]+[a-zA-Z0-9\.\-_]*@[a-zA-Z0-9\-_]+\.[a-zA-Z\.\-_]{1,}[a-zA-Z\-_]+","g");
		if (exp.test(document.envoiemail.email.value) == false)
		{
			msg += "  - Email invalide\n";
			cpt = false;
		}
	}
	if (document.envoiemail.pays.value.length == 0)
	{
		msg = msg + '  - Le pays \n';
		cpt = false;
	}
	if (document.envoiemail.telephone.value.length > 0 && document.envoiemail.telephone.value.length < 14)
	{
		msg += '  - Le numéro de téléphone est incomplet\n';
		cpt = false;
	}
	if (document.envoiemail.fax.value.length > 0 && document.envoiemail.fax.value.length < 14)
	{
		msg += '  - Le numéro de fax est incomplet\n';
		cpt = false;
	}
	if (cpt == false)
	{
		alert(msg);
		return false;
	}
		return true;
}

/*****     fonctions utilisées sur page logiciels     *****/

function HideDIV(nom) 
{
	var d=document;
	d.getElementById(nom).style.visibility="hidden";
}

function ShowDIV(nom)
{
	var d=document;
	if(d.getElementById(nom).style.visibility=="visible")
	{
		d.getElementById(nom).style.visibility="hidden";
		nom="Detail";
	}
	d.getElementById(nom).style.visibility="visible";
}

/*****     fonctions utilisées sur page plan     *****/

function MM_swapImgRestore()
{
	var i,x,a=document.MM_sr;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() 
{
	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];
		}
	}
}

function MM_swapImage() 
{
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null)
	{
		document.MM_sr[j++]=x;
		if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	}
}

function MM_popupMsg(msg)
{
	alert(msg);
}

function MM_findObj(n, d)
{
	var p,i,x;

	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length)
	{
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for (i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); 
	return x;
}

function OuvreFenetre()
{
	neo=window.open("plan_ville.html","","status=no,scrollbars=no,resizable=no,width=600,height=580,location=,directories=no,menubar=no");
}

function Navigateur()
{
	if (navigator.appName.indexOf("Netscape") > -1)
	{
		return "Netscape";
	}
	if (navigator.appName.indexOf("Explorer") > -1)
	{
		return "Explorer";
	}
	return "Unknown";
}
	
var a
a= new Array();
a[0]=new Image;
a[0].src="img/puce_enable.gif";
a[1]=new Image;
a[1].src="img/puce_disable.gif";
	
function roll(img,nb)
{
	eval("img.src=a["+nb+"].src");
}
	
function trans(img,nb)
{
	if (Navigateur() == "Explorer")
	{
		img.filters[0].apply();
		eval("img.src=a["+nb+"].src");
		img.filters[0].play();
	}
	else
	{
		eval("img.src=a["+nb+"].src");
	}
}
	
function makevisible(img,flag)
{
	if (flag==0)
	{
		img.filters.alpha.opacity=100;
	}
	else
	{
		img.filters.alpha.opacity=50;
	}
}
	
function showDiv1()
{
	if(document.getElementById)
	{
		document.getElementById("Div1").style.visibility = 'visible';
	}
	else
	{
		document.location.href='';
	}
}
	
function showDiv2()
{
	if(document.getElementById)
	{
		document.getElementById("Div2").style.visibility = 'visible';
	}
	else
	{
		document.location.href='';
	}
}
	
function showDiv3()
{
	if(document.getElementById)
	{
		document.getElementById("Div3").style.visibility = 'visible';
	}
	else
	{
		document.location.href='';
	}
}
	
function showDiv4()
{
	if(document.getElementById)
	{
		document.getElementById("Div4").style.visibility = 'visible';
	}
	else
	{
		document.location.href='';
	}
}
	
function showDiv5()
{
	if(document.getElementById)
	{
		document.getElementById("Div5").style.visibility = 'visible';
	}
	else
	{
		document.location.href='';
	}
}
	
function showDiv6()
{
	if(document.getElementById)
	{
		document.getElementById("Div6").style.visibility = 'visible';
	}
	else
	{
		document.location.href='';
	}
}
	
function showDiv7()
{
	if(document.getElementById)
	{
		document.getElementById("Div7").style.visibility = 'visible';
	}
	else
	{
		document.location.href='';
	}
}

function showDiv8()
{
	if(document.getElementById)
	{
		document.getElementById("Div8").style.visibility = 'visible';
	}
	else
	{
		document.location.href='';
	}
}
	
function showDiv9()
{
	if(document.getElementById)
	{
		document.getElementById("Div9").style.visibility = 'visible';
	}
	else
	{
		document.location.href='';
	}
}
		
function closeoption()
{
	if(document.getElementById)
		document.getElementById("Div1").style.visibility = 'hidden';
	document.getElementById("Div2").style.visibility = 'hidden';
	document.getElementById("Div3").style.visibility = 'hidden';
	document.getElementById("Div4").style.visibility = 'hidden';								
	document.getElementById("Div5").style.visibility = 'hidden';
	document.getElementById("Div6").style.visibility = 'hidden';
	document.getElementById("Div7").style.visibility = 'hidden';
	document.getElementById("Div8").style.visibility = 'hidden';
	document.getElementById("Div9").style.visibility = 'hidden';												
}
/****************** fonctions pour les listes à onglet **************/
function ChangeOnglet(active, nombre, tab_prefix, contenu_prefix)
{
	for (var i=1; i < nombre + 1; i++)
	{
		document.getElementById(contenu_prefix + i).style.display = 'none';
		document.getElementById(tab_prefix + i).className = '';
	}
	document.getElementById(contenu_prefix + active).style.display = 'block';
	document.getElementById(tab_prefix + active).className = 'active';
}

/********************** fonction pour le formulaire admin **********************/
function Verif_Form_GestionBD()
{
	res=true;
	if (document.Engr.NomAssoc.value=="" ||
		document.Engr.Pseudo.value=="" ||
		document.Engr.TypeRue.value=="" ||
		document.Engr.Adr1.value=="" ||
		document.Engr.CP.value=="" ||
		document.Engr.Ville.value=="")
	{
		res=false;
		alert("Veuillez remplir les lignes dont le libéllé est suivi d'un '*'");
	}
	return res;
}
