
//------------------------------------
//   champsok()
//------------------------------------
function champsok() 
{ 
	var str = "";
	
	// Controle Nb Pièces
	if (document.form1.nb_pieces_mini.selectedIndex > document.form1.nb_pieces_maxi.selectedIndex) 
		{ 
		alert("Attention !\nIl faut que le nombre de pièces minimum soit inférieur\nau nombre de pièces maximum"); 
		document.form1.nb_pieces_mini.focus();
		return false; 
		}
	//Endif

	// Controle Surface Mini
	/*---
	str = document.form1.surface_mini.value;
	if (str.length != 0 && !IsNumeric(str))
		{
		alert("Attention !\nLa surface minimum doit être un nombre entier");
		document.form1.surface_mini.select(); 
		return false; 
		}
	//Endif
	---*/

	// Controle Prix
	if (document.form1.prix_mini.selectedIndex > document.form1.prix_maxi.selectedIndex+1) 
		{ 
		if (document.form1.vente_loc1.checked == true)
			alert("Attention !\nIl faut que le prix minimum soit inférieur\nau prix maximum"); 
		else
			alert("Attention !\nIl faut que le loyer minimum soit inférieur\nau loyer maximum"); 
		//Endif
		
		document.form1.prix_mini.focus();
		return false; 
		}
	//Endif
	 
	// Controles des Zones Alerte Email	
	//if (document.form1.alerte_email.checked == true)
	//	{
		/*if (Trim(document.form1.nom.value) == '')
			{
			alert("Attention !\nIl faut saisir votre nom\npour recevoir les nouvelles annonces"); 
			document.form1.nom.focus();
			return false; 
			} */
		//Endif

		/*if (Trim(document.form1.email.value) == '')
			{
			alert("Attention !\nIl faut saisir votre Email\npour recevoir les nouvelles annonces"); 
			document.form1.email.focus();
			return false; 
			}*/
		//Endif
		/*var re = new RegExp("^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$");
		if (re.test(document.form1.email.value)==false)
			{
			alert("Attention !\nL'Email saisi n'est pas correct"); 
			document.form1.email.focus();
			return false; 
			}
		//Endif

		if (Trim(document.form1.codevalemail.value) == '')
			{
			alert("Attention !\nIl faut saisir le code de validation\npour recevoir les nouvelles annonces"); 
			document.form1.codevalemail.focus();
			return false; 
			}*/
		//Endif
		
		// Controle Code Validation par rapport au N° de l'image modèle : "Code_Validation_Mail_x.jpg"
		/*var tcode = new Array("Q2SX","Z8VY","H1R6","DFA9","CK7T","N3UP","L5MJ","BI8W","GS4I","EM9Z");
		var img = document.form1.imgvalemail.src;
		var numimg=0;
		if (img.charAt(img.length-6)=='_')
			numimg = parseInt(img.charAt(img.length-5));
		else
			numimg = parseInt(img.charAt(img.length-6)+img.charAt(img.length-5));
		//Endif
		if (document.form1.codevalemail.value != tcode[numimg-1])
			{
			alert("Attention !\nLe code de validation n'est pas identique au modèle (en majuscules)"); 
			document.form1.codevalemail.focus();
			tcode=null;	
			return false; 
			}*/
		//Endif	
		//tcode=null;		
	//	}
	//Endif
	return true; 
}



//------------------------------------
//   IsNumeric()
//------------------------------------
function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber   = true;
   var Char;
 
   for (i=0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      //Endif
      }
   //Endfor
   
   return IsNumber;
}



//------------------------------------
//   IsEmpty()
//------------------------------------
function IsEmpty(sText) 
{
   if (sText.length==0 || sText==null) 
		return true;
	//Endif

	return false; 
}	



//------------------------------------
//   LTrim()
//------------------------------------
function LTrim(str) 
{ 
    return str.replace(/^[ ]+/, ''); 
} 

//------------------------------------
//   RTrim()
//------------------------------------
function RTrim(str) 
{ 
    return str.replace(/[ ]+$/, ''); 
} 

//------------------------------------
//   Trim()
//------------------------------------
function Trim(str) 
{ 
    return LTrim(RTrim(str)); 
} 


