var mMessage = "Este Campo es Obligatorio rellenarlo."
var mPrecio = "La cifra no es correcta, por favor introduzca una cifra válida."
var mCat = "Debe seleccionar la Familia a la que pertenece el Producto."
var mCantidad = "La Cantidad no es correcta.\nIntroduzca un Número Entero Positivo como Cantidad.\nEjemplo: 2"
var defaultEmptyOK = false

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function statBar (s)

{   window.status = s
}

function warnEmpty (theField)
{   theField.focus()
    alert(mMessage)
    statBar(mMessage)
    return false
}

function warnPrecio (theField)
{ 	theField.focus()
    alert(mPrecio)
    statBar(mPrecio)
    return false
}

function warnCantidad (theField)
{ 	theField.focus()
    alert(mCantidad)
    statBar(mCantidad)
    return false
}

function warnCategoria (theField)
{ 	theField.focus()
    alert(mCat)
    statBar(mCat)
    return false
}	

function mensaje(msg) {
	window.status =  ""+ msg +""
}

function isDigit (c){  
	return ((c >= "0") && (c <= "9"))
}

function isNumber (s) /*Numeros Decimales sin Signo Ej. 35,56 */

{   var i;
    var dotAppeared;
    dotAppeared = false;
    if (isEmpty(s)) 
       if (isNumber.arguments.length == 1) return defaultEmptyOK;
       else return (isNumber.arguments[1] == true);  
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if( i != 0 ) {
            if ( (c == ".")||(c == ",") ) {
                if( !dotAppeared )
                    dotAppeared = true;
                else
                    return false;
            } else     
                if (!isDigit(c)) return false;
        } else { 
            if ( (c == ".")||(c == ",") ) {
                if( !dotAppeared )
                    dotAppeared = true;
                else
                    return false;
            } 
        }
    }

    return true;

}

function EsNumeroPositivo(Dato,Campo) /*Numeros enteros sin Signo Ej. 35 */
{
  var CadenaNumeros="0123456789";
  var EsteCaracter;
  var Contador=0;
  
  if (isEmpty(Dato)==false) 
  {  
  
	  for (i=0;i<Dato.length;i++)
		{
		  EsteCaracter=Dato.substring(i,i+1);
		  if (CadenaNumeros.indexOf(EsteCaracter)!=-1)
				Contador++;
		}
	  if (Contador==Dato.length)
		{
			return(true);
		}
	  else
		{
		  /*alert("Introduzca un Número Entero Positivo como Cantidad.");
		  Campo.focus();*/
		  return(false);
		}
  }
  else
  {
  	return(false);
  }
}

function isNumero (s) /* Numeros Enteros sin signo Ej. 23 */
{   var i;
    if (isEmpty(s)) 
       if (isNumero.arguments.length == 1) return defaultEmptyOK;
       else return (isNumero.arguments[1] == true);
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if( i != 0 ) {
            if (!isDigit(c)) return false;
        } else { 
            if (!isDigit(c)) return false;
        }
    }
    return true;
}

function VerificarTodo()  {	
		
		// Nombre
		if (isEmpty(document.frm_buscamos.contacto.value))
			{
				warnEmpty (document.frm_buscamos.contacto)
				return false;
			}
			
		// telefono
		if (isEmpty(document.frm_buscamos.telefono.value))
			{
				warnEmpty (document.frm_buscamos.telefono)
				return false;
			}
			
		// email
		if (isEmpty(document.frm_buscamos.email.value))
			{
				warnEmpty (document.frm_buscamos.email)
				return false;
			}

		return true;
}


