<!--


//Formato númerico 1.000,00
function number_format (number, decimals, dec_point, thousands_sep)
{
  var exponent = "";
  var numberstr = number.toString ();
  var eindex = numberstr.indexOf ("e");
  if (eindex > -1)
  {
    exponent = numberstr.substring (eindex);
    number = parseFloat (numberstr.substring (0, eindex));
  }
  
  if (decimals != null)
  {
    var temp = Math.pow (10, decimals);
    number = Math.round (number * temp) / temp;
  }
  var sign = number < 0 ? "-" : "";
  var integer = (number > 0 ? 
      Math.floor (number) : Math.abs (Math.ceil (number))).toString ();
  
  var fractional = number.toString ().substring (integer.length + sign.length);
  dec_point = dec_point != null ? dec_point : ".";
  fractional = decimals != null && decimals > 0 || fractional.length > 1 ? 
               (dec_point + fractional.substring (1)) : "";
  if (decimals != null && decimals > 0)
  {
    for (i = fractional.length - 1, z = decimals; i < z; ++i)
      fractional += "0";
  }
  
  thousands_sep = (thousands_sep != dec_point || fractional.length == 0) ? 
                  thousands_sep : null;
  if (thousands_sep != null && thousands_sep != "")
  {
	for (i = integer.length - 3; i > 0; i -= 3)
      integer = integer.substring (0 , i) + thousands_sep + integer.substring (i);
  }
  
  return sign + integer + fractional + exponent;
}

//Fomarto frances 1.000,00
function formato_frances($num)
{
	return number_format($num,2,',','.')
}

//Solo acepta caracteres numéricos 
function Numerico(texto)
{
	var i=0;
	var caracter = texto.charAt((texto.length)-1);
	
	if( caracter != '0' && caracter != '1' && caracter != '2' && caracter != '3' && caracter != '4' && caracter != '5' && caracter != '6' && caracter != '7' && caracter != '8' && caracter != '9' )
		texto=texto.substring(0,(texto.length)-1);
	
	while(i < texto.length)
	{
		if( texto.charAt(i) != '0' && texto.charAt(i) != '1' && texto.charAt(i) != '2' && texto.charAt(i) != '3' && texto.charAt(i) != '4' && texto.charAt(i) != '5' && texto.charAt(i) != '6' && texto.charAt(i) != '7' && texto.charAt(i) != '8' && texto.charAt(i) != '9' )
			texto=texto.replace(texto.charAt(i),' ');
		i++;
	}
		
	return texto;
}

//Verificar Email
function esMail(campo,obligatorio){
  //var patron1=/&#91;^\w\-@\.&#93;/;
  var patron1=new RegExp(String.fromCharCode(91) + '^\\w\\-@\\.' +  String.fromCharCode(93));
   //var patron2=/&#91;@.&#93;{2}/;
  var patron2=new RegExp(String.fromCharCode(91) + '@.'  +String.fromCharCode(93) + '{2}');
  //var patron3=/^&#91;.@&#93;|&#91;.@&#93;$/;
  var patron3=new RegExp('^' + String.fromCharCode(91) + '.@' +  String.fromCharCode(93) + '|' + String.fromCharCode(91) + '.@' +  String.fromCharCode(93) + '$');
  //var patron4=/@&#91;\w\-&#93;*\.&#91;\w\-&#93;*/;
   var patron4=new RegExp('@' + String.fromCharCode(91) + '\\w\\-' +  String.fromCharCode(93) + '*\\.' + String.fromCharCode(91) + '\\w\\-'  + String.fromCharCode(93) + '*');
  var patron5=/@.*@/;
  //var patron6=/\.&#91;a-z&#93;*\-&#91;a-z&#93;*$/;
  var patron6=new RegExp('\\.' + String.fromCharCode(91) + 'a-z' +  String.fromCharCode(93) + '*\\-' + String.fromCharCode(91) + 'a-z' +  String.fromCharCode(93) + '*$');
  //var patron7=/\.&#91;a-z&#93;*\_&#91;a-z&#93;*$/;
  var patron7=new RegExp('\\.' + String.fromCharCode(91) + 'a-z' +  String.fromCharCode(93) + '*\\_' + String.fromCharCode(91) + 'a-z' +  String.fromCharCode(93) + '*$');
   if(obligatorio && campo.value.length == 0){alert("Formato de correo electrónico incorrecto.");return false;}
   if(campo.value.length > 0)  {if(!(!campo.value.match(patron1)&&!campo.value.match(patron2)&&! campo.value.match(patron3)&&campo.value.match(patron4)&&! campo.value.match(patron5)&&!campo.value.match(patron6)&&! campo.value.match(patron7))){ alert("Formato de correo electrónico incorrecto.");    return false;  } }  
   
   return true;
}

function esTelefono(valor)
{

	if(valor.value.length==9)
		return true;
	else
	{
		alert('El Teléfono o el Fax deben tener 9 dígitos.');
		return false;
	}
}

//////////////////////////////////////////////////////
/////validar que la fecha que se escribe en el formulario (con el evento onBlur="javascript:fecha_valida(this.value)) sea correcta
// Uso: Simple... se debe pasar la cadena de la fecha y devuelve false si no es válida...
// El Formato es dd/mm/aaaa
// Ejemplo: if (fecha_valida('14/08/1981')==false) { alert('Entrada Incorrecta') }
// Uso en formularios: onSubmit="return fecha_valida(this.fecha.value)"
/////////////////////////////////////////////////////
function fecha_valida(Cadena){
	var Fecha= new String(Cadena);	// Crea un string
	var RealFecha= new Date();	// Para sacar la fecha de hoy
	// Cadena Año
	var Ano= new String(Fecha.substring(Fecha.lastIndexOf("/")+1,Fecha.length));
	// Cadena Mes
	var Mes= new String(Fecha.substring(Fecha.indexOf("/")+1,Fecha.lastIndexOf("/")));
	// Cadena Día
	var Dia= new String(Fecha.substring(0,Fecha.indexOf("/")));

	// Valido el año
	if (isNaN(Ano) || Ano.length<4 || parseFloat(Ano)<1900){
       	alert('El formato de fecha no es correcto ( dd/mm/aaaa ).');
	}
	// Valido el Mes
	if (isNaN(Mes) || parseFloat(Mes)<1 || parseFloat(Mes)>12){
		alert('El formato de fecha no es correcto ( dd/mm/aaaa ).');
	}
	// Valido el Dia
	if (isNaN(Dia) || parseInt(Dia, 10)<1 || parseInt(Dia, 10)>31){
		alert('El formato de fecha no es correcto ( dd/mm/aaaa ).');
	}
	if (Mes==4 || Mes==6 || Mes==9 || Mes==11 || Mes==2) {
		if (Mes==2 && Dia > 28 || Dia>30) {
			alert('El formato de fecha no es correcto ( dd/mm/aaaa ).');
		}
	}
}

////////////////////////////////////////////////////////////////
/////Formatos de texto (negrita, rojo...) para los textarea:
//////////////////////////////////////////////////////////////
//TExto en español
function negrita() {
	var str = document.selection.createRange().text;
	document.getElementById('texto').focus();
	var sel = document.selection.createRange();
	sel.text = '<strong>' + str + '</strong>';
	return;
}

function rojo() {
	var str = document.selection.createRange().text;
	document.getElementById('texto').focus();
	var sel = document.selection.createRange();
	sel.text = '<span class=\"txtRojo\">' + str + '</span>';
	return;
}
//Texto en ingles:
function negrita2() {
	var str = document.selection.createRange().text;
	document.getElementById('i_texto').focus();
	var sel = document.selection.createRange();
	sel.text = '<strong>' + str + '</strong>';
	return;
}

function rojo2() {
	var str = document.selection.createRange().text;
	document.getElementById('i_texto').focus();
	var sel = document.selection.createRange();
	sel.text = '<span class=\"txtRojo\">' + str + '</span>';
	return;
}

//Texto en francés:
function negrita3() {
	var str = document.selection.createRange().text;
	document.getElementById('f_texto').focus();
	var sel = document.selection.createRange();
	sel.text = '<strong>' + str + '</strong>';
	return;
}

function rojo3() {
	var str = document.selection.createRange().text;
	document.getElementById('f_texto').focus();
	var sel = document.selection.createRange();
	sel.text = '<span class=\"txtRojo\">' + str + '</span>';
	return;
}

