function ouvre_cartegrd() {
	if ((window.cartegrd) &&(! window.cartegrd.closed)) {
			window.cartegrd.focus();
	}
	else {
			window.cartegrd = window.open('cartes/index.php?grand=vrai','','width=600,height=600');
			window.cartegrd.commercedville = window;
	}
}

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the the FSCommand messages in a Flash movie
function mapfrance_DoFSCommand(command, args) {
	var mapfranceObj = InternetExplorer ? mapfrance : document.mapfrance;
	if (command == 'ouvrirville') {
	var newurl = 'index.php?navigville='+args;
	window.location = newurl;
	}
	else {
	if (command == 'status') {
			window.status = args;
	}
	}
}
// Hook for Internet Explorer 
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
		navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub mapfrance_FSCommand(ByVal command, ByVal args)\n');
	document.write('call mapfrance_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}

function vide(nom,defaut) {
	var champ = MM_findObj(nom);
	if (champ) {
			if (champ.value == defaut) {
				champ.value = '';
			}
	}
}

function messageErreur(erreur) {
	switch (erreur) {
			case 0:break;
			case 1:alert('Veuillez saisir des critères de recherche d\'au moins deux caractères.');break;
			case 2:alert('Veuillez saisir au moins un critère de recherche.');break;
	}
}

function testChamp(obj) {
	if (obj) {
			if (obj.disabled) {
				return 2;
			}
			if (obj.value.length == 0) {
				return 2;
			}
			if (obj.value.length<2) {
				return 1;
			}
	}
	return 0;
}

function verfierrech() {
	var form = MM_findObj('recherche');
	if (form) {
			
			var cregion = MM_findObj('rech_departement');
			var cville = MM_findObj('rech_ville');
			var ccommercant = MM_findObj('rech_commerce');
			if(cregion.value=="departement") {
				cregion.value="";
			}
			if(cville.value=="ville") {
				cville.value="";
			}
			if(ccommercant.value=="commercant") {
				ccommercant.value="";
			}

			erreur_region = testChamp(cregion);
			erreur_ville = testChamp(cville);
			erreur_commercant = testChamp(ccommercant);
			if ((erreur_region + erreur_ville + erreur_commercant) == 6) {
				messageErreur(2);
				return false;
			}
			if ((erreur_region == 1) || (erreur_ville == 1) || (erreur_commercant == 1)) {
				messageErreur(1);
				return false;
			}
	}
	return true;
}
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+' doit contenir une adresse exacte.\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+' est demandé.\n'; }
  } if (errors) alert('En indiquant vos coordonnées vous nous permettez de vous faire parvenir les informations souhaitées :\n'+errors);
  document.MM_returnValue = (errors == '');
}
