//
// Librería de funciones generales de validación
//

var maxlength;

var buttonBack      = false;
var backgroundFocus = '#FFFF80';
var backgroundBlur  = '#ECE9D8';


// Estado de los botones para evitar la validacion de los campos
function setBackButton( status ) {
	buttonBack = status ? true : false;
}

//
// Comienzo del mecanismo despachador de validaciones
//
function dispatcher(validationFunc) {
   this.doValidate = validationFunc
}

var dispatchLookup = new Array()
dispatchLookup["validAlpha"]	    = new dispatcher(validAlpha);
dispatchLookup["validPassword"]  	= new dispatcher(validPassword);
dispatchLookup["validTexto"]	    = new dispatcher(validTexto);
dispatchLookup["validAscii"]	    = new dispatcher(validAscii);
dispatchLookup["validMonto"]	    = new dispatcher(validMonto);
dispatchLookup["Fecha"]           = new dispatcher(Fecha);
dispatchLookup["FechaDMA"]        = new dispatcher(FechaDMA);
dispatchLookup["rangoFechas"]     = new dispatcher(rangoFechas);
dispatchLookup["rangoFechasDMA"]  = new dispatcher(rangoFechasDMA);
dispatchLookup["validaArchivo"]   = new dispatcher(validaArchivo);
dispatchLookup["validaImpArchivo"]= new dispatcher(validaImpArchivo);
dispatchLookup["validTelefono"]   = new dispatcher(validTelefono);
dispatchLookup["validEmail"]      = new dispatcher(validEmail);
dispatchLookup["validNumerico"]   = new dispatcher(validNumerico);
dispatchLookup["validCUIT"]       = new dispatcher(validCUIT);
dispatchLookup["validIP"]         = new dispatcher(validIP);
dispatchLookup["validIPx"]        = new dispatcher(validIPx);
dispatchLookup["validTime"]       = new dispatcher(validTime);
dispatchLookup["validTimex"]      = new dispatcher(validTimex);
dispatchLookup["validRango"]      = new dispatcher(validRango);


// Validación principal llamada por otros eventos del formulario
function validate(field0, field1, length, method) {
	// gFrame  = frame
	gField0 =  document.getElementById(field0);

	if ( field1 != null ) {
		gField1 =  document.getElementById(field1);
	}

	maxlength = length;

	var args = validate.arguments
	for (i = 3; i < args.length; i++) {
		if (!dispatchLookup[args[i]].doValidate()) {
			return false
		}
	}
	return true
}

// Cambia el Color de fondo del Campo 
function setHighLight(el, state) {
    //bg = new Array('yellow', 'white');
    bg = new Array('#CEC097', backgroundBlur);

    var obj = document.getElementById(el.name);
    
    if (!state) {
		setTimeout('document.getElementById(\'' + el.name + '\').focus()',10);
		obj.select();
    }

    if (obj.style) 
        obj.style.backgroundColor = bg[state];
}

// Función para determinar si la variable de ingresada es numerico
function isNumber(inputStr) 
{
    var pattern = /[^0-9]/;
    if (pattern.test( inputStr )) {
		alert("Por favor, Ingrese sólo números.");
		return false;
    }
    else {
        return true;
    }
}

// Función para determinar si la variable es numerico, (, ), - o /
function isPhone(inputStr) {
    var pattern = /[^0-9\-\/\(\)]/;
    if (pattern.test( inputStr )) {
		alert("Por favor, Ingrese correctamente el Nro. Telefónico!.");
		return false;
    }
    else {
        return true;
    }
}

// Función para determinar que la variable ingresada no es
// nulo o vacía
function isEmpty(inputStr) {
	var length = maxlength < 0 ? 0: maxlength;
	
	if ( length == 0 )
	{
		return false;
	}

	if (inputStr.length < length) {
		if ( length == 1 )
			alert("Por favor, asegúrese que el campo no se encuentre vacío.");
		else
			alert("Por favor, ingrese al menos " + maxlength + " caracteres en el campo.");
		
		return true;
	}
	return false;
}

function isAlpha( inputStr ) 
{
    var pattern = /[^a-zA-Z0-9áéíóúñÁÉÍÓÚÑ_\-\$ ]/;
    if (pattern.test( inputStr )) {
		alert("Por favor, ingrese sólo letras y/o números en este campo.");
		return false;
    }
    else {
        return true;
    }
}   

function isAscii( inputStr )
{
    var pattern = /[^a-zA-Z_\-\$\ ]/;
    if (pattern.test( inputStr )) {
			alert("Por favor, ingrese sólo letras en este campo.");	
			return false;
    }
    else {
        return true;
    }
}

// Función para verificar que la fecha ingresada (DDMMAAAA) sea válida
function isDate(form, supress) {
	var inputStr = form.value;

	var ddStr, mmStr, yyStr;
	var dd,	mm, yyyy;
	

	if ( supress ) {
		var separator = inputStr.substring( 2, 3 );
		var inputTmp  = inputStr.substring( 0, 2 ) + inputStr.substring( 3, 5 ) + inputStr.substring( 6, 10 );
		inputStr      = inputTmp;
	}

	if ( parseInt(inputStr, 10) == 0 ) {
		ddStr = mmStr = '00';
		yyStr = '0000';
	} else {
		if ( parseInt(inputStr, 10) == 999999 )
				ddStr = mmStr = yyStr = '99';
		else {	
			if ( isEmpty( inputStr ) || !isNumber(inputStr)) {
				setHighLight(form, 0);	
				return false;
			}

			if (inputStr.length != 8) {
				alert("Por favor, Ingrese fecha como \"DDMMAAAA\" en este campo.");
				setHighLight(form, 0);	
				return false;
			}
			else {
				ddStr = inputStr.substring( 0, 2 );
				mmStr = inputStr.substring( 2, 4 );
				yyStr = inputStr.substring( 4, 8 );
	
				dd   = parseInt(ddStr, 10);
				mm   = parseInt(mmStr, 10);
				yyyy = parseInt(yyStr, 10);
	
				if (dd < 1 || dd > 31) {
					// determina si el día no se encuentra entre 1 y 31
					alert("Los Días deben encontrarse entre 01 y un máximo de 31\n(dependiendo del mes del año).");
					setHighLight(form, 0);	
					return false;
				}
		
				if (mm < 1 || mm > 12) {
					// determina se el mes no se encuentra entre 1 y 12
					alert("El Mes debe encontrarse entre 01 (Enero) and 12 (Diciembre).");
					setHighLight(form, 0);	
					return false;
				}

				/*
				// valida el año
				if (yyyy < 100) {
					// combierte el año de 2 dígitos en un rango entre 1930-2029
					if (yyyy >= 30) {
						yyyy += 1900;
					} else {
						yyyy += 2000;
					}
				}
				*/

				// valida el mes
				if (!checkMonthLength(mm,dd)) {
					setHighLight(form, 0);	
					return false;
				}

				// es bisiesto?
				if (mm == 2) {
					if (!checkLeapMonth(mm,dd,yyyy)) {
						setHighLight(form, 0);	
						return false;
					}
				}
			}
		}
	}
	
	// asigna y combierte el dato ingresado al formato DD-MM-AAAA
	form.value = ddStr + separator + mmStr + separator+ yyStr;

	setHighLight(form, 1);	
	return true;
}

// controla que los días ingresados se correspondan con el mes en cuestion
function checkMonthLength(mm,dd) {
	var months = new Array("","Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
	if ((mm == 4 || mm == 6 || mm == 9 || mm == 11) && dd > 30) {
		alert(months[mm] + " tiene solamente 30 días.");
		return false;
	} else if (dd > 31) {
		alert(months[mm] + " tiene solamente 31 días.");
		return false;
	}
	return true;
}

// controla si Febreo es bisiesto 
function checkLeapMonth(mm,dd,yyyy) {
	if (yyyy % 4 > 0 && dd > 28) {
		alert("Febrero de " + yyyy + " tiene solamente 28 días.");
		return false;
	} else if (dd > 29) {
		alert("Febrero de " + yyyy + " tiene solamente 29 días.");
		return false;
	}
	return true;
}

// Función para convertir DD-MM-AAAA en AAAAMMDD
function dateToAMD( inputStr ) {
	var dd, mm, yyyy;

	yyyy = inputStr.substring( 6, 10);
	mm   = inputStr.substring( 3, 5 );
	dd   = inputStr.substring( 0, 2 );

	if ( parseInt(yyyy + mm + dd, 10) != 0 ) {
		if ( parseInt(yyyy + mm + dd, 10) == 999999 ) {
			yyyy = '99' + yyyy;
                mm   = '12';
                dd   = '31';
		}
/*		else {
			// valida el año
			if (parseInt(yyyy, 10) < 100) {
				// combierte el año de 2 dígitos en un rango entre 1930-2029
				if (parseInt(yyyy, 10) >= 30) {
					yyyy = '19' + yyyy;
				} 
				else {
					yyyy = '20' + yyyy;
				}
			}
		}
*/
		return ( yyyy + mm + dd );
	}
    return (0);
}

function ValidTimeHMS(h, m, s) {
    with (new Date(0, 0, 0, h, m, s)) {
        return getHours() == h && getMinutes() == m;
    }
}

function ReadISO8601time(Q) {
    var T;
    if ((T = /^(\d\d):(\d\d):(\d\d)$/.exec(Q)) == null) {
        return -2;
    }
    if (!ValidTimeHMS(T[1], T[2], T[3])) {
        return -1;
    }
    return [T[1], T[2], T[3]];
}

// Función para determinar si la variable es JPG
function isArchivo(inputStr, inputExt, flag) {
	var newStr = inputStr.substr(inputStr.length - 3, 3).toLowerCase();

	if ( flag ) {
		if ( isEmpty( inputStr ) )
			return false;
	} else {
		if ( inputStr.length < 1 )
			return true;
	}

	if ( newStr != inputExt ) {
		alert("Por favor, seleccione solamente archivo con extención " + inputExt.toUpperCase() + " para importar!!.");
		return false;
	} else 
		return true;
	
}

// Función para controlar el campo importe 
function isMonto( form ) 
{ 
	// Reemplaza la coma como separador decimal por el punto para 
	// permitir la validacion
	form.value = form.value.replace(new RegExp(',','g'),'.');
	
	// decimal number check/complainer 
	var val= parseFloat( form.value );

	if(isNaN(val))
	{ // parse error 
		alert("Por favor, Ingrese sólo números ó '.'. Tenga presente que la ',' no es considerado como separador decimal.");
		return false;
	}

	form.value = val
	return true;
}

// Funcion para controlar la direccion de IP
function isValidIPAddress(ipaddr) {
   var re = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
   if (re.test(ipaddr)) {
      var parts = ipaddr.split(".");
      if (parseInt(parseFloat(parts[0])) == 0) { return false; }
      for (var i=0; i<parts.length; i++) {
         if (parseInt(parseFloat(parts[i])) > 255) { return false; }
      }
      return true;
   } else {
      return false;
   }
}

// Funcion para validar la direccion de correo electronico
function emailCheck (emailStr) {

	if (emailStr.length < 1) 
	{
		if ( maxlength == 0 )
			return true;
	}


/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is
   valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	alert("La dirección de Email parece ser incorrecta (controle @ y .'s)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("El Nombre de Usuario no parece ser válido.")
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("El IP de Destino es Inválido!")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("El Dominio no parece ser válido.")
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   alert("La dirección debe finalizar con un dominio de 3 letras o con 2 letras de un país.")
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="Falta el Nombre del Host en la dirección!"
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!
return true;
}

// Limpia el Formulario y posiciona el curson en el campo indicado
function setFocus( inputStr ) {
	var f	= document.forms[0];
	var field = eval("f." + inputStr)

	// Limpia los campos del formulario
	f.reset();

	// Posiciona el cursor en el campo indicado
	if (field){field.focus()}
}


//
// Funciones de Validacion de los campos
//


// Función para controlar el dato ingresado
function validAlpha() {
	var inputStr = gField0.value;


	if ( buttonBack ) {
		return true;
	}

	if ( !isAlpha( inputStr ) || isEmpty( inputStr ) ) {	
      	setHighLight(gField0, 0);	
		return false;
	}
	else {
	   	setHighLight(gField0, 1);
		return true;
	}
}

// Función para controlar la clave
function validPassword() {
	var inputStr = gField0.value;
	var len      = inputStr.length;
	var re       = new RegExp( '\\*{' + len + '}' );
	
	if ( buttonBack ) {
		return true;
	}
  
  // Si los caractares son todos *
  
  if ( inputStr.match(re) ) {		
	  setHighLight(gField0, 1);
		return true;
	}

	if ( !isAlpha( inputStr ) || isEmpty( inputStr ) ) {	
      	setHighLight(gField0, 0);	
		return false;
	}
	else {
	   	setHighLight(gField0, 1);
		return true;
	}
}

// Función para controlar el dato ingresado
function validTexto() {
	var inputStr = gField0.value;


	if ( buttonBack ) {
		return true;
	}


	if ( isEmpty( inputStr ) ) {	
      	setHighLight(gField0, 0);	
		return false;
	}
	else {
	   	setHighLight(gField0, 1);
		return true;
	}
}

// Función para controlar el dato ingresado
function validAscii() {
	var inputStr = gField0.value;


	if ( buttonBack ) {
		return true;
	}


	if ( !isAscii( inputStr ) || isEmpty( inputStr ) ) {	
      	setHighLight(gField0, 0);	
		return false;
	}
	else {
	   	setHighLight(gField0, 1);
		return true;
	}
}

// Función para controlar el importe ingresado
function validMonto() {

	if ( buttonBack ) {
		return true;
	}

	if ( !isMonto( gField0 ) ) {
      	setHighLight(gField0, 0);	
		return false;
	} 
	else {
		setHighLight(gField0, 1);
		return true;
	}
}

// Función para controlar el campo numerico
function validNumerico() {
	var inputStr = gField0.value;

	if ( buttonBack ) {
		return true;
	}

	if ( isEmpty( inputStr ) || !isNumber( inputStr ))
	{
      	setHighLight(gField0, 0);	
		return false;
	}
	else
	{
		setHighLight(gField0, 1);
		return true;
	}
}

// Función para controlar si el valor ingresado es tipo telefonico
function validTelefono() {
	var inputStr = gField0.value;

	if ( !isPhone( inputStr ) || isEmpty( inputStr ) )
	{
      	setHighLight(gField0, 0);	
		return false;
	}
	else {
		setHighLight(gField0, 1);
		return true;
	}
}

// Función para controlar si el valor ingresado es tipo Email
function validEmail() {
	var inputStr = gField0.value;

	if ( !emailCheck( inputStr ) )	{
      	setHighLight(gField0, 0);	
		return false;
	}
	else {
		setHighLight(gField0, 1);
		return true;
	}
	
}

// Valida la Fecha
function validFecha( format ) {
	if ( isDate( gField0, format ) )
	{
		setHighLight(gField0, 1);
		return true;	
	}
	else
	{        
      	setHighLight(gField0, 0);	
		return false;
	}
}

// Función para controlar el IP ingresado
function validIP() {

	if ( buttonBack ) {
		return true;
	}

	if ( !isValidIPAddress( gField0.value ) ) {
   	    alert("La direccion IP ingresada no es válida.");            
      	setHighLight(gField0, 0);	
		return false;
	} 
	else {
		setHighLight(gField0, 1);
		return true;
	}
}

// Función para controlar el IP ingresado
function validIPx() {
	var inputStr = gField0.value;

	if ( buttonBack ) {
		return true;
	}

	if ( inputStr.length ) {
		    return( validIP() );
	} 
	else {
		return true;
	}
}

// Función para controlar el rango de numeros Enteros
function validRango() {
	var inputStr1 = gField1.value;
	var inputStr0;
	var date0;
	var date1;


	if ( validNumerico() ) {
		inputStr0 = gField0.value;

		if (parseInt( inputStr1, 10) >
		    parseInt( inputStr0, 10)) {
			alert("El Nro. del límite superior del rango no puede ser menor\nal Nro. del límite inferior.");		
	
			setHighLight(gField0, 0);	
			return false;
		}

		setHighLight(gField0, 1);
		return true;		
	}

	setHighLight(gField0, 0);	
	return false;
}

// Función para controlar la Hora ingresado
function validTime() {

	if ( buttonBack ) {
		return true;
	}

    S = ReadISO8601time( gField0.value );
    
    if ( S <= -1 ) {
    	alert("La hora ingresada no es válida. Ingrese la hora como (HH:MM:SS)");
      	setHighLight(gField0, 0);	
		return false;
    }
	else {
		setHighLight(gField0, 1);
		return true;
	}
}

// Función para controlar la Hora ingresado
function validTimex() {
	var inputStr = gField0.value;
	
	if ( buttonBack ) {
		return true;
	}

if ( inputStr.length ) {
		    return( validTime() );
	} 
	else {
		return true;
	}
}

// Función para controlar el rango de Fechas en formato DD-MM-AAAA
function validFechas( format ) {
	var inputStr1 = gField1.value;
	var inputStr0;
	var date0;
	var date1;

	if (isDate( gField0, format )) {
		inputStr0 = gField0.value;

		if (parseInt(dateToAMD( inputStr1 ), 10) >
		    parseInt(dateToAMD( inputStr0 ), 10)) {
			alert("La Fecha del límite superior del rango no puede ser menor\na la Fecha del límite inferior.");		
	
			setHighLight(gField0, 0);	
			return false;
		}

		setHighLight(gField0, 1);
		return true;		
	}

	setHighLight(gField0, 0);	
	return false;
}

// Valida una fecha dada con formato DD-MM-AAAA
function FechaDMA() {
    return ( validFecha( true ));
}

// Función para controlar la Fecha
function Fecha() {
    return ( validFecha( false ));
}

// Valida una fecha dada con formato DD-MM-AAAA
function FechaDMA() {
    return ( validFecha( true ));
}

// Función para controlar el rango de Fechas
function rangoFechas() {
    return ( validFechas( false ));
}
    
// Función para controlar el rango de Fechas en formato DD-MM-AAAA
function rangoFechasDMA() {
    return ( validFechas( true ));
}

// Función para controlar el Campo File
function validaArchivo() {
	var inputStr = gField0.value;
	var inputExt = gField1.value;

	if ( !isArchivo( inputStr, inputExt, false ) )
	{		
      	setHighLight(gField0, 0);	
		return false;
	}
	else
		setHighLight(gField0, 1);
		return true;
}

// Función para controlar el Campo File no se encuentre vacio cuando se
// presiona agregar
function validaImpArchivo() {
	var inputStr = gField0.value;
	var inputExt = gField1.value;

	if ( !isArchivo( inputStr, inputExt, true ) )
		return false;
	else
		return true;
}

// Función para validar el CUIT
function validCUIT() {
	var inputStr = gField0.value;

	//      if (parseInt(inputStr) == 0 || parseInt(inputStr) == 99999999999 ) {
	//              setHighLight(gField0, 1);
	//              return true;
	//      }

	if ( inputStr.length < 10 ) {
		alert( "El CUIT debe contener 11 dígitos." );

		setHighLight(gField0, 0);

		return false;
	}

	cuit_modulo = ((parseInt( inputStr.charAt(0) ) * 5) +
								(parseInt( inputStr.charAt(1) ) * 4) +        
								(parseInt( inputStr.charAt(2) ) * 3) +
								(parseInt( inputStr.charAt(3) ) * 2) +
								(parseInt( inputStr.charAt(4) ) * 7) +
								(parseInt( inputStr.charAt(5) ) * 6) +
								(parseInt( inputStr.charAt(6) ) * 5) +
								(parseInt( inputStr.charAt(7) ) * 4) +
								(parseInt( inputStr.charAt(8) ) * 3) +
								(parseInt( inputStr.charAt(9) ) * 2)) % 11;
								
	if (cuit_modulo < 2)
		cuit_digitoverificador = 0;
	else
		cuit_digitoverificador = 11 - cuit_modulo;

	if (cuit_digitoverificador != parseInt( inputStr.charAt(10) )) {
		alert( "El CUIT ingresado no es correcto.");

		setHighLight(gField0, 0);

		return false;
	}

	setHighLight(gField0, 1);
	return true;                                                            
}

function setBGFocusColor ( color )
{
		backgroundFocus = color;
}

function setBGBlurColor ( color )
{
		backgroundBlur = color;
}

function validateForm(what)
{
    //clearErrorReport() ;

    //var theErrorRow = document.getElementById("errorRow") ;
    var theResult = true ;

    //
    // Skip through all the element and validate them.
    //

    for (var i = 0; i < what.elements.length; i++)
    {
        var theValidateString = what.elements[i].getAttribute("validate") ;

        if ((theValidateString != null) &&
            (theValidateString !=""))
        {
        	if (!validateField( what.elements[i] ))
		    {
		        return false ;
		    }
        }

    }  
    
	return true;  
}

function validateField( what ) {
    var theResult         = true ;
	var theValidateString = what.getAttribute("validate") ;

	if ((theValidateString != null) &&
	    (theValidateString !=""))
	{
	    var theValidateFunction ;
	    
		  showStatus( what );
		
	    theValidateFunction = new Function("what", theValidateString) ;
	    
	    theResult &= theValidateFunction(what) ; 
	    
	    if (!theResult)
	    {
	        return false ;
	    }
	}
	
	return true;
}

function showStatus( what ) {		
	var required = what.getAttribute("required") ;
	
		window.status = "";
		
    if (required != null && required != "" )
    {
        window.status =  required ;
    }    
}	

function onBlur( what ) {		
	var status = window.status;
	
	what.style.background = backgroundBlur;

    if (status != "")
    {
        window.status = "" ;
    }    
}	

function onFocus( what ) {		
	var help = what.getAttribute("help") ;
	
	what.style.background = backgroundFocus;

	window.status = "";
	
    if (help != null && help != "")
    {
        window.status =  help;
    }        
}	

