	

			

	function Validaciones()

	{ 

		/* propiedades */

		this.error           		= new Boolean();           	//boolean que controla si ha habido error, Se inicializa a false cuando no pasas ningún valor al constructor  

		this.errorInterno    		= new Boolean();           	//boolean que controla si ha habido error interno, Se inicializa a false cuando no pasas ningún valor al constructor  

		this.msgError     	 		= new Array();				

		this.indicemsgError	 		= 0;	

		this.msgCorrecto     		= new String();  			//Cadena que contiene el mensaje que indica que no ha habido ningun error.

		this.msgErrorInterno 		= new String();  			//error interno de la clase 

		this.errorClassName  		= "FieldErr";              	//estilo css que pasará a tener el campo en caso de encontrar error  

		this.formatoHora     		= "24";                    	//validaciones de hora, solo puede valer  "24" o "12"

		this.formatoFecha    		= "EURO";                  	//Validaciones de fecha, puede valer "EURO", "ISO" y "ANSI"

		this.prueba 				= new String();

		//metodos	

		this.EliminarError    		= EliminarError;

		this.AgregarError     		= AgregarError; 	

		this.mal 					= new Boolean();

		this.mensajeError         	= mensajeError;

		this.mensajeErrorInterno  	= mensajeErrorInterno;

		

		/* Metodos que se utilizan para validar formularios */

		this.campoVacio         	= campoVacio;     			//parametros: idCampo, msg, css 

		this.campoVacioHtml			= campoVacioHtml;

		//this.RegistroUnico		= RegistroUnico

		this.email              	= email;          			//parametros: idCampo, msg, css

		this.longitudCampo      	= longitudCampo;  			//parametros: idCampo, operador, longitud, msg,  css

		this.camposIguales      	= camposIguales;  			//parametros: idCampo1, idCampo2, msg, css

		this.soloNumeros        	= soloNumeros;    			//parametros: idCampo, msg, css

		this.Entero        			= Entero;    				//parametros: idCampo, msg, css

		this.Real        			= Real;    					//parametros: idCampo, msg, css

		this.soloLetras         	= soloLetras;     			//parametros: idCampo, msg, css

		this.variosCamposVacios 	= variosCamposVacios;   	//parametros: ver comentario de la funcion

		this.IgualCero				=  IgualCero;

		this.SelectorMultiple2  	= SelectorMultiple2;

		this.DiferenteQue 			= DiferenteQue;

		this.IgualQue 				= IgualQue;

		

		this.TelefonoCompleto		= TelefonoCompleto;

		this.longitud				= longitud;

		this.SonNumeros				= SonNumeros;

		this.TelefonoCorrecto		= TelefonoCorrecto;

        this.Booleano 				= Booleano;

        this.Unico					= Unico;

        this.EsUnico				= EsUnico;

        this.RadioPriceFlyer		= RadioPriceFlyer;

		this.EsReal					= EsReal;

		this.RadioSquare_footageFlyer= RadioSquare_footageFlyer;

		this.RadioBedroomsFlyer		= RadioBedroomsFlyer;

		this.RadioBathroomsFlyer	= RadioBathroomsFlyer;	

		this.RadioFeesFlyer			= RadioFeesFlyer;

        this.CommissionFlyer		= CommissionFlyer;			

		

		this.nerrores = 0; 	

	}

	

	

	function mensajeError()

	{ 	

		//this.msgError[0]     = "No se han introducido los datos correctamente";	

		return this.msgError;		

		//alert(this.msgError + "\n \n Total de errores ("+ this.nerrores + ")"); 	

		//document.getElementById(this.campoRes).focus(); 	  

	}

	

	

	function mensajeErrorInterno(functionName, comment)

	{ 

		this.msgErrorInterno += functionName + comment;        

		this.msgError    = "Error Interno";

		this.msgCorrecto = "Cero Errores";

		this.errorInterno = true;

		this.error        = true;

		alert(this.msgErrorInterno); 

	}

	

	

	function EliminarError()

	{   

		for(var i=1; i<arguments.length ; i++) 

		document.getElementById(arguments[i]).className= arguments[0];		

	}

	

	

	function AgregarError(msg, idCampo) 

	{	

		if(this.nerrores == 0)

		this.campoRes = idCampo;			

		

		this.nerrores++;

		this.error = true;

		this.msgError[ this.indicemsgError ] = new String ( arguments[0] )

		this.indicemsgError++; 

		

		for(var i=1; i < arguments.length ; i++) 

			document.getElementById(arguments[i]).className = this.errorClassName;		

	}

	

	

	function IgualCero(idCampo, msg, css)

	{

		if (this.errorInterno == true) 

		return false;  //si hay error interno no hace nada, sale directamente de la función

		

		this.EliminarError(css, idCampo);

		

		if (document.getElementById(idCampo).value == 0)

		{

		this.AgregarError(msg, idCampo);

		return false;

		} 

		

		return true;

	}	

	

    

	function SelectorMultiple2(idCampo, msg, css)

	{		

		if(this.errorInterno == true) 

		return false;  //si hay error interno no hace nada, sale directamente de la función

		

		this.EliminarError(css, idCampo);

		

		if(document.getElementById(idCampo).options.length == 0)

		{

		this.AgregarError(msg, idCampo);

		return false;

		}

		

		return true;

	}	

	

	

	function DiferenteQue(idCampo, msg, css, valor)

	{

		if (this.errorInterno == true) 

			return false;  //si hay error interno no hace nada, sale directamente de la función

						

		if(document.getElementById(idCampo).value == valor)

		{

			this.AgregarError(msg, idCampo);

			return false;

		}

		

		return true;

	}	

	

    

	function IgualQue(idCampo, msg, css, valor)

	{

		if (this.errorInterno == true) 

		return false;  //si hay error interno no hace nada, sale directamente de la función

		

		this.EliminarError(css, idCampo);

		

		if(document.getElementById(idCampo).value != valor)

		{

		this.AgregarError(msg, idCampo);

		return false;

		}

		

		return true;

	}	

	

	

	function Comparacion(idCampo, msg, css, valor, operador)

	{

		if (this.errorInterno == true) 

		return false;  //si hay error interno no hace nada, sale directamente de la función

		

		this.EliminarError(css, idCampo);

		

		if(eval("document.getElementById(idCampo).value"+ operador+ "valor"))

		{

		this.AgregarError(msg, idCampo);

		return false;

		}

		

		return true;

	}	

	 

	

	function campoVacio(idCampo, msg, css)

	{ 	

		if (this.errorInterno == true) 

			return false;  //si hay error interno no hace nada, sale directamente de la función

		

		this.EliminarError(css, idCampo);

		document.getElementById(idCampo).value = document.getElementById(idCampo).value.replace(/^\s+/,'').replace(/\s+$/,'');

		

		if ((/^\s*$/.test(document.getElementById(idCampo).value)))

		{

			this.AgregarError(msg, idCampo);

			return false;

		} 

		

		return true;

	}

	

	

	function campoVacioHtml(idCampo, msg, css)

	{ 	

		if (this.errorInterno == true) 

		return false;  //si hay error interno no hace nada, sale directamente de la función

		

		this.EliminarError(css, idCampo);

		document.getElementById(idCampo).value = document.getElementById(idCampo).value.replace(/^\s+/,'').replace(/\s+$/,'');

		

		if ((/^\s*$/.test(tinyMCE.getInstanceById(idCampo).getBody().innerHTML)))

		{

		this.AgregarError(msg, idCampo);

		return false;

		} 

		

		return true;

	}



    

	function email(idCampo, msg, css)

	{

		if (this.errorInterno == true) return false;  //si hay error interno no hace nada, sale directamente de la función

		

		this.EliminarError(css, idCampo);

		document.getElementById(idCampo).value = document.getElementById(idCampo).value.replace(/^\s+/,'').replace(/\s+$/,'');

		

		if (document.getElementById(idCampo).value != ""){

		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById(idCampo).value))){

		this.AgregarError(msg, idCampo);

		return false;

		}  

		}

		return true;

	}

	

	

	function longitudCampo(idCampo, operador, longitud, msg,  css)

	{	

		if (this.errorInterno == true) return false;  //si hay error interno no hace nada, sale directamente de la función

		

		this.EliminarError(css, idCampo);

		//quitamos los posibles espacios en blanco

		document.getElementById(idCampo).value = document.getElementById(idCampo).value.Trim();

		

		if ( !(eval("document.getElementById(idCampo).value.length "+ operador +"longitud")) ){      

		this.AgregarError(msg, idCampo);

		return false;

		}

		return true;

	}

	

	

	function camposIguales(idCampo1, idCampo2, msg, css)

	{	

		if (this.errorInterno == true) return false;  //si hay error interno no hace nada, sale directamente de la función

		

		this.EliminarError(css, idCampo1, idCampo2);

		

		if(document.getElementById(idCampo1).value != document.getElementById(idCampo2).value){		

		this.AgregarError(msg, idCampo1, idCampo2);	

		return false;

		}  

		return true;

	}

	

	

	function soloNumeros(idCampo, msg, css)

	{

		if (this.errorInterno == true) return false;  //si hay error interno no hace nada, sale directamente de la función

		

		this.EliminarError(css, idCampo);

		document.getElementById(idCampo).value = document.getElementById(idCampo).value.replace(/^\s+/,'').replace(/\s+$/,'');

		

		if(document.getElementById(idCampo).value != "")

		if (!(/^[0-9]*.[0-9]*$/.test(document.getElementById(idCampo).value))){

		this.AgregarError(msg, idCampo);	

		return false;

		} 

		return true;

	}

	

	

	function Entero(idCampo, msg, css)

	{

		if (this.errorInterno == true) return false;  //si hay error interno no hace nada, sale directamente de la función

		

		this.EliminarError(css, idCampo);

		document.getElementById(idCampo).value = document.getElementById(idCampo).value.replace(/^\s+/,'').replace(/\s+$/,'');

		

		if(document.getElementById(idCampo).value != "")

			if (!(/^(?:\+|-)?\d+$/.test(document.getElementById(idCampo).value)))

			{

				this.AgregarError(msg, idCampo);	

				return false;

			} 

		return true;

	}

	

	

	function Real(idCampo, msg, css)

	{

		if (this.errorInterno == true) return false;  //si hay error interno no hace nada, sale directamente de la función

		

		this.EliminarError(css, idCampo);

		document.getElementById(idCampo).value = document.getElementById(idCampo).value.replace(/^\s+/,'').replace(/\s+$/,'');

		

		if(document.getElementById(idCampo).value != "")

		if (!(/^(?:\+|-)?\d+\.?\d*$/.test(document.getElementById(idCampo).value))){

		this.AgregarError(msg, idCampo);	

		return false;

		} 

		return true;

	}

	

	

	function soloLetras(idCampo, msg, css)

	{

		if (this.errorInterno == true) return false;  //si hay error interno no hace nada, sale directamente de la función

		

		this.EliminarError(css, idCampo);

		document.getElementById(idCampo).value = document.getElementById(idCampo).value.replace(/^\s+/,'').replace(/\s+$/,'');

		

		if (!(/^([a-z\sáéíóúÁÉÍÓÚ])+$/i.test(document.getElementById(idCampo).value))){

		this.AgregarError(msg, idCampo);

		return false;

		} 

		return true;

	}

	

	

	function bisiesto(fecha, formato) 

	{	

		if (formato == "EURO") {  

		  var dia  = fecha.substr(0,2);

		  var mes  = fecha.substr(3,2);

		  var anyo = fecha.substr(6,4);

		} 

		else {

		  var dia  = fecha.substr(8,2);

		  var mes  = fecha.substr(5,2);

		  var anyo = fecha.substr(0,4);

		}

		            

		if ( parseFloat(anyo)%4!=0 && mes=='02' && dia=='29') //no es bisiesto    

		return false;         

		else       

		return true;  

	}

	

	

	function variosCamposVacios()

	{		

		if (this.errorInterno == true) return false;  //si hay error interno no hace nada, sale directamente de la función

		

		for (var i=2; i < arguments.length ; i++){ 

		document.getElementById(arguments[i]).className= arguments[1];	

		document.getElementById(arguments[i]).value = document.getElementById(arguments[i]).value.replace(/^\s+/,'').replace(/\s+$/,'');

		}    

		

		var instruccion="(";

		for (var i=2; i<arguments.length-1; i++)

		instruccion += "(/^\s*$/.test(document.getElementById('"+arguments[i]+"').value)) && ";

		

		instruccion += "(/^\s*$/.test(document.getElementById('"+arguments[arguments.length-1]+"').value)))";

		

		if ( eval(instruccion) ){

		this.error=true;

		this.msgError += "\n" + arguments[0];

		

		for (var i=2; i < arguments.length ; i++) 

		document.getElementById(arguments[i]).className = this.errorClassName;

		

		return false;

		}

		return true;

	}

	

	

	/* Valida si el campo telefono esta escrito completamente */

	function TelefonoCompleto(idCampo, msg, css, extension)

	{

		if (this.errorInterno == true) 

		   return false;  //si hay error interno no hace nada, sale directamente de la función

		

		idCampo1 = idCampo + "1"

		idCampo2 = idCampo + "2"

		idCampo3 = idCampo + "3"		

		

		this.EliminarError(css, idCampo1);

		this.EliminarError(css, idCampo2);

		this.EliminarError(css, idCampo3);

		

		//quitamos los posibles espacios en blanco

		document.getElementById(idCampo1).value = document.getElementById(idCampo1).value.Trim();

		document.getElementById(idCampo2).value = document.getElementById(idCampo2).value.Trim();

		document.getElementById(idCampo3).value = document.getElementById(idCampo3).value.Trim();				

		

		if ( !longitud(idCampo1, ">=", 3) )    

			document.getElementById( idCampo1 ).className = this.errorClassName;

			

		if ( !longitud(idCampo2, ">=", 3) )    

			document.getElementById( idCampo2 ).className = this.errorClassName;

			

		if ( !longitud(idCampo3, ">=", 4) )    

			document.getElementById( idCampo3 ).className = this.errorClassName;

			

        

        if( extension == 1 )

        {   

        	idCampo4 = idCampo + "4"

            this.EliminarError(css, idCampo4)             

        }		

      		        

        if ( !longitud(idCampo1, ">=", 3) || !longitud(idCampo2, ">=", 3) || !longitud(idCampo3, ">=", 4) )    

		{	

			this.AgregarError( msg );	

			return false;									

		}

								

		return true;

	}	

	

	

	/* Metodo que valida la longitud de un campo */

	function longitud(idCampo, operador, longitud)

	{	

		if (this.errorInterno == true) 

		   return false;  //si hay error interno no hace nada, sale directamente de la función

				

		if ( !(eval("document.getElementById(idCampo).value.length "+ operador +"longitud")) )      

		   return false;

		

		return true;

	}	

	

	

	function SonNumeros(idCampo, css)

	{

		if (this.errorInterno == true) 

		   return false;  //si hay error interno no hace nada, sale directamente de la función		

		

		if( document.getElementById(idCampo).value != "" )

			if (!(/^[0-9]*.[0-9]*$/.test(document.getElementById(idCampo).value)))

			   return false;

		

		return true;

	}	

	

	

	function TelefonoCorrecto(idCampo, msg, css, extension)

	{	

		idCampo1 = idCampo + "1"

		idCampo2 = idCampo + "2"

		idCampo3 = idCampo + "3"

            

            		

		this.EliminarError(css, idCampo1);

		this.EliminarError(css, idCampo2);

		this.EliminarError(css, idCampo3);

        

                		        

		if ( !SonNumeros( idCampo1, css) )    

			document.getElementById( idCampo1 ).className = this.errorClassName;		

			

		if ( !SonNumeros( idCampo2, css ) )    

			document.getElementById( idCampo2 ).className = this.errorClassName;	

			

		if ( !SonNumeros( idCampo3, css ) )    

			document.getElementById( idCampo3 ).className = this.errorClassName;

			

        if( extension == 1 )

        {   

        	idCampo4 = idCampo + "4"

            this.EliminarError(css, idCampo4) 

            

			if ( !SonNumeros( idCampo4, css ) )    

				document.getElementById( idCampo4 ).className = this.errorClassName;            

            

	        if ( !SonNumeros( idCampo1, css ) || !SonNumeros( idCampo2, css ) || !SonNumeros( idCampo3, css ) || !SonNumeros( idCampo4, css ) )    

			{

				this.AgregarError( msg );	

				return false;

			}            

        }		

        else        

	        if ( !SonNumeros( idCampo1, css ) || !SonNumeros( idCampo2, css ) || !SonNumeros( idCampo3, css ) )    

			{

				this.AgregarError( msg );	

				return false;

			}	

			

		return true;																

	}

    

    

	function Booleano(idCampo, msg, css)

	{

		if (this.errorInterno == true) 

			return false;  //si hay error interno no hace nada, sale directamente de la función

						        

        if(document.getElementById(idCampo).checked == false)

		{

			this.AgregarError(msg, idCampo);

			return false;

		}

        

		return true;

	}

      

    

	function objetus() 

	{  

		var objetus;

		

		try 

			{

			objetus = new ActiveXObject("Msxml2.XMLHTTP");

	        } 

		catch (e) 

			{

			try {

				objetus= new ActiveXObject("Microsoft.XMLHTTP");

				} 

			catch (E) 

				{

				objetus= false;

				}

	        }	

		

		if (!objetus && typeof XMLHttpRequest != 'undefined' ) 

			{

			objetus = new XMLHttpRequest();

	        }

			 

			 

		return objetus

	}

    

    

    /*devuelve 1 sino existe el registro, 0 si existe*/

	function EsUnico( tabla, campo, valor ) 

	{     		        

	    var _objetus = objetus()

        

        _values_send="op=Unico" + "&tabla=" + tabla + "&campo=" + campo + "&valor=" + valor + "&fh=" + FechaHora();

	    _URL_="control.validacion.php?"			 

		

        _objetus.open("GET",_URL_+_values_send, false);

	    

        _objetus.onreadystatechange=function() 

        {				

            if (_objetus.readyState == 4)

				{

					if(_objetus.status == 200) 

						{ 

							

                            if(_objetus.responseText == 1)

								{

                                    this.mal = true;

								}

							else

								{					

									this.mal = false;                                                                     

								}

						}

		        }

	    }



        _objetus.send(null);

        return _objetus.responseText;    

    }

    

    

	function Unico( idCampo, msg, css, tabla, campo )

    {  

		if (this.errorInterno == true) 

        	return false;  //si hay error interno no hace nada, sale directamente de la función

		

		this.EliminarError(css, idCampo);

		document.getElementById(idCampo).value = document.getElementById(idCampo).value.replace(/^\s+/,'').replace(/\s+$/,'');

        

        if( EsUnico( tabla, campo, document.getElementById(idCampo).value ) == 0 )

        {

            this.AgregarError(msg, idCampo);

            return false;    

        }

        

        return true;        	

    }   

    

    

	function RadioPriceFlyer(idCampo, msg, css)

	{				 		        	   

		this.EliminarError(css, "set_price");

        this.EliminarError(css, "price_min");

		this.EliminarError(css, "price_max");	   

       	

		//nume = document.getElementById("set_price").value.replace(",","");//nume = parseFloat( document.getElementById("set_price").value);

		//string texto = tucaja.text.replace(",",".");

		//alert( nume )

        

		seleccionado = 0        

        

        if( document.getElementById(idCampo).checked )

	   		seleccionado = parseInt( document.getElementById(idCampo).value	)

		else

			if( document.getElementById(idCampo+2).checked )

				seleccionado = parseInt( document.getElementById(idCampo+2).value )		

		   		

        switch(seleccionado)

		{            

            

            case 1:	

					this.EliminarError(css, "set_price");

					document.getElementById("set_price").value = document.getElementById("set_price").value.replace(/^\s+/,'').replace(/\s+$/,'');				

					

					if( this.campoVacio("set_price", msg + " is required", css) )

						if( EsReal("set_price") == false )

							this.AgregarError("Incorrect " + msg, "set_price");	

					break

		

			case 2:	

					document.getElementById("price_min").value = document.getElementById("price_min").value.replace(/^\s+/,'').replace(/\s+$/,'');				

					document.getElementById("price_max").value = document.getElementById("price_max").value.replace(/^\s+/,'').replace(/\s+$/,'');	

					

					if( this.campoVacio("price_min", msg + " is required", css) )

					{

						if( EsReal("price_min") == false )

						{

							this.AgregarError("Incorrect " + msg, "price_min");

							return false

						}

					}

					else

                        return false	

                        							

							

					if( this.campoVacio("price_max", msg + " is required", css) )

					{

						if( EsReal("price_max") == false )

						{

							this.AgregarError("Incorrect " + msg, "price_max");

							return false	

						}

					}

					else

                        return false		                        

							

					if( parseFloat( document.getElementById("price_max").value.replace(",","") ) < parseFloat( document.getElementById("price_min").value.replace(",","") ) )	

					{	

						document.getElementById("price_min").className = this.errorClassName; 

						document.getElementById("price_max").className = this.errorClassName; 						

						this.AgregarError( msg +" Min > " + msg + " Max");	

					}

															

					break		

		}

        

		return true;

	}

	

	

	function RadioSquare_footageFlyer(idCampo, msg, css)

	{				 		        	   

		this.EliminarError(css, "square_footage");

        this.EliminarError(css, "square_footage_min");

		this.EliminarError(css, "square_footage_max");	   

       	

        seleccionado = 0

		

		if( document.getElementById(idCampo + 1).checked )

	   		seleccionado = parseInt( document.getElementById(idCampo + 1).value	)

		else

			if( document.getElementById(idCampo + 2).checked )

				seleccionado = parseInt( document.getElementById(idCampo + 2).value )		

		   		

        switch(seleccionado)

		{            

            

            case 0:	

					return true

					break            

			

			case 1:	

					this.EliminarError(css, "square_footage");

					document.getElementById("square_footage").value = document.getElementById("square_footage").value.replace(/^\s+/,'').replace(/\s+$/,'');				

					

					if( this.campoVacio("square_footage", msg + " is required", css) )

						if( EsReal("square_footage") == false )

							this.AgregarError("Incorrect " + msg, "square_footage");	

					break

		

			case 2:	

					document.getElementById("square_footage_min").value = document.getElementById("square_footage_min").value.replace(/^\s+/,'').replace(/\s+$/,'');				

					document.getElementById("square_footage_max").value = document.getElementById("square_footage_max").value.replace(/^\s+/,'').replace(/\s+$/,'');	

					

					if( this.campoVacio("square_footage_min", msg + " is required", css) )

					{

						if( EsReal("square_footage_min") == false )

						{

							this.AgregarError("Incorrect " + msg, "square_footage_min");

							return false

						}

					}

					else

                        return false	

                        							

							

					if( this.campoVacio("square_footage_max", msg + " is required", css) )

					{

						if( EsReal("square_footage_max") == false )

						{

							this.AgregarError("Incorrect " + msg, "square_footage_max");

							return false	

						}

					}

					else

                        return false		                        

							

					if( parseFloat( document.getElementById("square_footage_max").value.replace(",","") ) < parseFloat( document.getElementById("square_footage_min").value.replace(",","") ) )	

					{	

						document.getElementById("square_footage_min").className = this.errorClassName; 

						document.getElementById("square_footage_max").className = this.errorClassName; 						

						this.AgregarError( msg +" Min > " + msg + " Max");	

					}

															

					break		

		}

        

		return true;

	}

	

	

	function RadioBedroomsFlyer(idCampo, msg, css)

	{	

		this.EliminarError(css, "bedrooms_min");

        this.EliminarError(css, "bedrooms_max");

		this.EliminarError(css, "bedrooms");

				

        seleccionado = 0 

		

		if( document.getElementById(idCampo + 1).checked )

	   		seleccionado = parseInt( document.getElementById(idCampo + 1).value	)

		else

			if( document.getElementById(idCampo + 2).checked )

				seleccionado = parseInt( document.getElementById(idCampo + 2).value )		

		

        switch(seleccionado)

		{            

            

            case 0:	

					return true

					break

					

            case 1:	/*
					if( document.getElementById("bedrooms").value == "N/A" )
					{

						document.getElementById("bedrooms").className = this.errorClassName; 				

						this.AgregarError( msg +" is required");

						return false								

					}
					*/
					return true

					break

					

            case 2:	

					min = document.getElementById("bedrooms_min").value

					max = document.getElementById("bedrooms_max").value

					

					if( isNaN(min) == false && isNaN(max) == false )
                    {
						if( parseInt( min ) > parseInt( max ) )

						{

							document.getElementById("bedrooms_min").className = this.errorClassName; 

							document.getElementById("bedrooms_max").className = this.errorClassName; 						

							this.AgregarError( msg +" Min > " + msg + " Max");							

						}	
                    }
					else
					{
						if( min == "N/A" )
						{

							document.getElementById("bedrooms_min").className = this.errorClassName; 				

							this.AgregarError( msg +" Min is required");							

						}
						else
						{
							if( max == "N/A" )
							{
	
								document.getElementById("bedrooms_max").className = this.errorClassName; 						
	
								this.AgregarError( msg +" Max is required");	
	
							}	
						}
					}
																		

					break															  

		}

		

		return true						

	}		

	

	

	function RadioBathroomsFlyer(idCampo, msg, css)

	{	

		this.EliminarError(css, "bathrooms_min");

        this.EliminarError(css, "bathrooms_max");

		this.EliminarError(css, "bathrooms");

		

        seleccionado = 0 



		if( document.getElementById(idCampo + 1).checked )

	   		seleccionado = parseInt( document.getElementById(idCampo + 1).value	)

		else

			if( document.getElementById(idCampo + 2).checked )

				seleccionado = parseInt( document.getElementById(idCampo + 2).value )		

		

        switch(seleccionado)

		{            

            

            case 0:	

					return true

					break

					

            case 1:	/*
					if( document.getElementById("bathrooms").value == "N/A" )
					{

						document.getElementById("bathrooms").className = this.errorClassName; 				

						this.AgregarError( msg +" is required");

						return false								

					}
					*/
					return true

					break

					

            case 2:	

					min = document.getElementById("bathrooms_min").value

					max = document.getElementById("bathrooms_max").value

					

					if( isNaN(min) == false && isNaN(max) == false )
                    {
						if( parseFloat( min ) > parseFloat( max ) )

						{

							document.getElementById("bathrooms_min").className = this.errorClassName; 

							document.getElementById("bathrooms_max").className = this.errorClassName; 						

							this.AgregarError( msg +" Min > " + msg + " Max");							

						}
					}
					else
					{
						if( min == "N/A" )
						{

							document.getElementById("bathrooms_min").className = this.errorClassName; 				

							this.AgregarError( msg +" Min is required");							

						}
						else
						{
							if( max == "N/A" )
							{
	
								document.getElementById("bathrooms_max").className = this.errorClassName; 						
	
								this.AgregarError( msg +" Max is required");	
	
							}	
						}
					}	

																		

					break															  

		}

		

		return true						

	}

	

	

	function RadioFeesFlyer(idCampo, msg, css)

	{	//fees association_fees_unit association_fees_ini  association_fees_end			 		        	   

		this.EliminarError(css, "association_fees_unit");

        this.EliminarError(css, "association_fees_ini");

		this.EliminarError(css, "association_fees_end");	   

       	

        seleccionado = 0

		

		if( document.getElementById(idCampo+1).checked )

	   		seleccionado = parseInt( document.getElementById(idCampo+1).value	)

		else

			if( document.getElementById(idCampo+2).checked )

				seleccionado = parseInt( document.getElementById(idCampo+2).value )		

		

        switch(seleccionado)

		{            

            

            case 1:	

					this.EliminarError(css, "association_fees_unit");

					document.getElementById("association_fees_unit").value = document.getElementById("association_fees_unit").value.replace(/^\s+/,'').replace(/\s+$/,'');				

					

					if( this.campoVacio("association_fees_unit", msg + " is required", css) )

						if( EsReal("association_fees_unit") == false )

							this.AgregarError("Incorrect " + msg, "association_fees_unit");	

					break

		

			case 2:	

					document.getElementById("association_fees_ini").value = document.getElementById("association_fees_ini").value.replace(/^\s+/,'').replace(/\s+$/,'');				

					document.getElementById("association_fees_end").value = document.getElementById("association_fees_end").value.replace(/^\s+/,'').replace(/\s+$/,'');	

					

					if( this.campoVacio("association_fees_ini", msg + " is required", css) )

					{

						if( EsReal("association_fees_ini") == false )

						{

							this.AgregarError("Incorrect " + msg, "association_fees_ini");

							return false

						}

					}

					else

                        return false	

                        							

							

					if( this.campoVacio("association_fees_end", msg + " is required", css) )

					{

						if( EsReal("association_fees_end") == false )

						{

							this.AgregarError("Incorrect " + msg, "association_fees_end");

							return false	

						}

					}

					else

                        return false		                        

							

					if( parseFloat( document.getElementById("association_fees_end").value.replace(",","") ) < parseFloat( document.getElementById("association_fees_ini").value.replace(",","") ) )	

					{	

						document.getElementById("association_fees_ini").className = this.errorClassName; 

						document.getElementById("association_fees_end").className = this.errorClassName; 						

						this.AgregarError( msg +" Min > " + msg + " Max");	

					}

															

					break		

		}

           

		return true;

	}	 	

	

	

	function EsReal(idCampo)

	{

		document.getElementById(idCampo).value = document.getElementById(idCampo).value.replace(/^\s+/,'').replace(/\s+$/,'');

		

		if(document.getElementById(idCampo).value != "")

			if (!(/^(?:\+|-)?\d+\,?\d*$/.test(document.getElementById(idCampo).value.replace(",",""))))

				return false;

		

		return true;

	} 

    

    

	function CommissionFlyer(idCampo, msg, css, msg2)

	{    

		if (this.errorInterno == true) 

			return false;  //si hay error interno no hace nada, sale directamente de la función

			

            			        

        if( parseFloat( document.getElementById(idCampo).value ) < 0 )

		{

			this.AgregarError(msg2, idCampo);

			return false;

		}        

             

        

        if( parseFloat( document.getElementById(idCampo).value ) > 10 )

		{

			this.AgregarError(msg, idCampo);

			return false;

		}

        

		return true;

	}       

	

	                       	

	

	/*********************************************************************/ 

	/*  EL SIGUIENTE CÓDIGO NO PERTENERCE A LA CLASE, AUNQUE EN LA CLASE SE UTILIZA. */

	/*********************************************************************

	

	Al utilizar mucho expresion regular para quitar los espacios en blanco

	he decidido añadir varios métodos que los eliminan  de las cadenas

	En algunas funciones utiliza las funciones aqui descritas y en otras <pre></pre>

	utiliza la expresion regular. Ambas son válidas.

	Son los siguientes:

	

	/*********************************************************************/ 		

	/* Trim(), LTrim(), RTrim() */

	/* Metodos que eliminan los espacios en blanco de una cadena */

	

	String.prototype.Trim = function()

	{

	    return this.replace(/\s+$|^\s+/g,""); 

	}

	

	String.prototype.LTrim = function()

	{

	     return this.replace(/^\s+/,""); 

	}

	

	String.prototype.RTrim = function()

	{

	      return this.replace(/\s+$/,""); 

	}          