var IE=document.all?1:0 ;
var NS=document.layers?1:0 ;

window.onerror = null;
var bName = navigator.appName;
var bVer = parseInt(navigator.appVersion);
var NS4 = (bName == "Netscape" && bVer >= 4);
var IE4 = (bName == "Microsoft Internet Explorer" && bVer >= 4);
var NS3 = (bName == "Netscape" && bVer < 4);
var IE3 = (bName == "Microsoft Internet Explorer" && bVer < 4);
var menuActive = 0
var menuOn = 0
var onLayer
var timeOn = null// LAYER SWITCHING CODE
if (NS4 || IE4) {
	if (navigator.appName == "Netscape") {
		layerStyleRef="layer.";
		layerRef="document.layers";
		styleSwitch="";
	}else{
		layerStyleRef="layer.style.";
		layerRef="document.all";
		styleSwitch=".style";
	}
}
 



var DateMsg1 = "Date n'est pas correcte." ;
var DateMsg2 = "Seconde date doit être supérieure à la première date." ;


var AlertMsg1 = "Email n'est pas valide." ;

var AddressMsg3 = "Veuillez saisir le champ nom." ;
var AddressMsg4 = "Veuillez saisir le champ prénom." ;
var AddressMsg5 = "Veuillez saisir le champ email." ;
var AddressMsg6 = "Veuillez saisir le champ télephone." ;
var AddressMsg7 = "Veuillez saisir le champ adresse." ;
var AddressMsg8 = "Veuillez saisir le champ code postal." ;
var AddressMsg9 = "Veuillez saisir le champ ville." ;

function validate(mode){
	var mainForm=document.genpanier;
	mainForm.action= "CompleterPanier.asp";
	//alert(mainForm.action);
	mainForm.Mode.value=mode;
	mainForm.submit();
	return;
}

function logon1(){
	
	alert(emailValid(document.frmlogon.Email.value));
	document.frmlogon.submit();
}


function logon(){
	//var mainForm=document.frmlogon;		
	//if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailAddress))
	//document.frmlogon.submit();	
	//alert(checkEmail(frmlogon.Email.value));
	//frmlogon.submit();	
	
	if (checkEmail(document.frmlogon.Email.value)){		
		document.frmlogon.Mode.value='Logon';
		//window.open('logon.asp');
		//alert('test');
		document.frmlogon.submit();			
		return;	
	} 
	else 
	{
		alert(AlertMsg1);
		document.frmlogon.Email.focus();	
	}	
	//return;
}

function validateaddress(){

	var mainForm=document.coordonnees;
	//alert('test ' +	mainForm.radAdresse.checked);
	if (mainForm.Nom.value.length<1) {
		alert(AddressMsg3);
		mainForm.Nom.focus();
		return; 
	}
	
	if (mainForm.Prenom.value.length<1) {
		alert(AddressMsg4);
		mainForm.Prenom.focus();
		return; 
	}
	
	if (mainForm.Email.value.length<1) {
		alert(AddressMsg5);
		mainForm.Email.focus();
		return; 
	}
	
	if (mainForm.Telephone.value.length<1) {
		alert(AddressMsg6);
		mainForm.Telephone.focus();
		return; 
	}
	
	if (mainForm.Adresse1.value.length<1) {
		alert(AddressMsg7);
		mainForm.Adresse1.focus();
		return; 
	}
	
	if (mainForm.CP.value.length<1) {
		alert(AddressMsg8);
		mainForm.CP.focus();
		return; 
	}
	
	if (mainForm.Ville.value.length<1) {
		alert(AddressMsg9);
		mainForm.CP.focus();
		return; 
	}
	mainForm.submit();
}


function searcheadv(){
	var mainForm=document.SearchForm;
	mainForm.submit();
	return;
	
}

// Show address in the module adr_organismes
function showadr(){
	
	var idorg = document.all("orgliste").options[document.all("orgliste").selectedIndex].value;		
	window.open('organismes.asp?idorganisme=' + idorg + '#signet'+idorg,"_self"  );

}

function formsubmit()
{	
	
	var mainForm=document.SearchForm;
	
	var startdate=IE?mainForm.all("DateInf"):document.SearchForm.DateInf;	
	var enddate=IE?mainForm.all("DateSup"):document.SearchForm.DateSup;	
	
	
	
	// Check date
	if ((startdate.value.length !=0) && ! check_date(startdate.value)){
			alert(DateMsg1);
			startdate.focus();
			return ;					
	} 	
	if ((enddate.value.length !=0) && ! check_date(enddate.value)){
			alert(DateMsg1);
			enddate.focus();
			return ;					
	} 	
	if ((enddate.value.length !=0) && (startdate.value.length !=0)){
			
			if (! datecomp(startdate.value,enddate.value))		
			{
				alert(DateMsg2);
				enddate.focus();
				return ;				
			}
	} 	
	
	mainForm.submit();
	return;
}


function showme(el, level) {
	el="document.all['" + el +"']" ;
	if (IE) {	// case IE
		whichIm = window.event.srcElement;
		//alert(eval(el).style.display);
		alert(el);
		if (whichIm.name == "expand") {
			
			 eval(el).style.visibility = "inline";
			 if (level!=4) {
				whichIm.src = "../images/collapse.gif";
			 }
			 whichIm.name = "collapse";
		}
		else {
		
			 eval(el).style.visibility = "none";
			 if (level!=4) {
				whichIm.src = "../images/expand.gif";
			 }
			 whichIm.name = "expand";
		}
		// setTimeout
	}
	if (NS)	{
		
		alert("test");
		alert("dis " + classes);
		//document.maForme.Div18.style.display="block";
		//Div18.style.display.value="block";
		
	}
	return;
}

function expandall(){
	var mainForm=document.hierarchy;
	var i;
	var alldiv;
	alldiv=document.all.tags('DIV')
	allimg=document.all.tags('IMG')
	for (i=0;i<=alldiv.length-1; i++ ){
		
		if(alldiv[i].id.substr(0,3)=='Div') {
			
			if (document.maForme.OpenAll.checked){
				alldiv[i].style.display = "inline";
			}
			else
			{
				alldiv[i].style.display = "none";
			}
		}
	}
	
	for (i=0;i<=allimg.length-1; i++ ){		
		
		if(allimg[i].name.substr(0,3)=='Img') {			
			if (document.maForme.OpenAll.checked){
				//alert(allimg[i].name);		
				allimg[i].src = "../images/collapse.gif";
			}
			else
			{
				allimg[i].src = "../images/expand.gif";
			}
		}
	}
	
	
}



function showLayer(id,x1,y1,x2,y2) {
	var i,j;	
	if (document.all) {
		for (i = x1; i <= x2; i++) {
			for (j = y1; j <= y2; j++) { 
				eval((id+i)+'_'+j).style.display = 'inline';
				whichIm = window.event.srcElement;
				whichIm.src= "../images/collapse.gif";
			}
		}
		eval(id+'plus').style.display = 'none';
		eval(id+'moins').style.display = 'inline';
	}
	
	if (document.layers) {
		return;
	}
}


function hideLayer(id,x1,y1,x2,y2) {
	var i,j;
	if (document.all) {
		for (i = x1; i <= x2; i++) {
			for (j = y1; j <= y2; j++) { 
				eval((id+i)+'_'+j).style.display = 'none';
			}
		}
		eval(id+'moins').style.display = 'none';
		eval(id+'plus').style.display = 'block';
	}

	if (document.layers) {
		return;
	}
}

function showCalendar(tbDate) {
	var URL, Name, Features;
	
	document.all.tbDateName.value = tbDate;
	URL = '../calendar2.asp';
	Name = 'Calendrier';
	Features = 'height=200,width=190,status=no,toolbar=no,menubar=no,location=no';
	window.open(URL,Name,Features);
	return;
}

function checkDate() {
	var day = document.all.dayOfBirth.options(document.all.dayOfBirth.selectedIndex).value;
	alert(day);
//	var month = 
	//var year = 
	
}