//********************************************************************************************//
//function fncEsTeclaTexto(e)
//function fncEsTeclaLetra(e)
//function fncEsTeclaNumero(e)
//function fncTeclaNoComilla(e)
//function fncEsTeclaDecimal(e)
//function fncEsTeclaRangoNumeros(e)
//--- > <input  name=xx onkeypress="return fncEsTeclaTexto(event);" >
//function fncCompararFecha(strFecha,strFechaMayor)
//function fncEsFecha (day,month,year)
//function fncValidarLongitud(strTexto,intLongitud)
//function fncEsEmail(string)
//function fcnIndexaRadio(obj,cad)
//function fcnIndexaCombo(obj,cad)
//AbrirPopUp(TipVentana,url,nompopup,popW,popH,scroll,resizable)
//********************************************************************************************//
function fncEsTeclaTexto(e) {
var valid = "abcdefghijklmñnopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ .-";
var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf("" + key) == "-1") return false;
}
//********************************************************************************************//
function fncEsTeclasTodas(e) {
var valid = "abcdefghijklmñnopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ :.-/()#&0123456789_";
var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf("" + key) == "-1") return false;
}
//********************************************************************************************//
function fncEsTeclaLetra(e) {
var valid = "abcdefghijklmñnopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXY Z";
var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf("" + key) == "-1") return false;
}
//********************************************************************************************//
function fncEsTeclaLetra2(e) {
var valid = "abcdefghijklmñnopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXY Z%";
var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf("" + key) == "-1") return false;
}
//********************************************************************************************//
function fncEsTeclaNumero(e) {
var valid = "0123456789";
var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf("" + key) == "-1") return false;
}
//********************************************************************************************//
function fncEsTeclaDecimal(e) {
var valid = "0123456789,.";
var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf("" + key) == "-1") return false;
}
//********************************************************************************************//
function fncEsTeclaRangoNumeros(e) {
var valid = "0123456789,-";
var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf("" + key) == "-1") return false;
}
//********************************************************************************************//
function fncEsTeclaTextoNumero(e) {
var valid = "0123456789abcdefghijklmñnopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ .-";
var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf("" + key) == "-1") return false;
}
//********************************************************************************************//
function fncEsTeclaTextoNumero2(e) {
var valid = "0123456789abcdefghijklmñnopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ .-%";
var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf("" + key) == "-1") return false;
}
//********************************************************************************************//
function fncTeclaNoComilla(e) {
var valid = "'" + String.fromCharCode(34);
var key = String.fromCharCode(event.keyCode);
if (valid.indexOf("" + key) != "-1") return false;
}
//********************************************************************************************//
function fncEsEmail(string) //string = cadena que representa al correo electronico
{//valida si la entrada es un correo electronico si es cierto devuelve true
	  if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		  return true;
		else
		  return false;
}
//********************************************************************************************//
function fncCompararFecha(strFecha,strFechaMayor){
	var fecha1 = strFecha.split("/");
	var fecha2 = strFechaMayor.split("/");	

	var strFecha1 = parseFloat(fecha1[2] + fecha1[1] + fecha1[0]);
	var strFecha2 = parseFloat(fecha2[2] + fecha2[1] + fecha2[0]);
		 		 
	if(strFecha1 > strFecha2) {
		return false; }
	else { 
		return true; }  
}
//********************************************************************************************//
function fncValidarLongitud(strTexto,intLongitud){	
	if (strTexto) {
		if (strTexto.length == intLongitud){return true;}
		else{return false;}		
	}	
	else{return false;}	
}
//********************************************************************************************//
function fcnIndexaCombo(obj,cad)
{
	for(i=0;i<obj.length;i++)
	{
		if (obj.options[i].value==cad)
		{
			obj.selectedIndex=i;
			break;
		}
	}
}
//********************************************************************************************//
function fcnIndexaRadio(obj,cad)
{
	for (i=0;i<obj.length;i++)
	{
		if (obj[i].value==cad)
		{
			obj[i].checked=true;
		}
	}
}
//********************************************************************************************//
function y2k(number) { return (number < 1000) ? number + 1900 : number; }
//********************************************************************************************//
function fncEsFecha_old (day,month,year)
{	if (day=="" && mont=="" && year=="")
	{
		return false
	}
	else{
		var today = new Date();
		year = ((!year) ? y2k(today.getYear()):year);
		month = ((!month) ? today.getMonth():month-1);
		if (!day && !month && !year ) return false
		var test = new Date(year,month,day);
		if ( (y2k(test.getYear()) == year) && (month == test.getMonth()) && (day == test.getDate()) )
		   return true
		else
		   return false
	}
}
//********************************************************************************************//
function getYear(d) { 
  return (d < 1000) ? d + 1900 : d;
  }
//********************************************************************************************//
function fncEsFecha (day,month,year) {
  // month argument must be in the range 1 - 12
  month = month - 1;  // javascript month range : 0- 11
  var tempDate = new Date(year,month,day);
  if ( (getYear(tempDate.getYear()) == year) &&
     (month == tempDate.getMonth()) &&
     (day == tempDate.getDate()) )
      return true;
  else
     return false
  }
//********************************************************************************************//
function fncCuentaCadena(cad){  //devuelve el numero de caracteres de una cadena
  var intNum
  intNum = 0;
  for(i=0;i<cad.length;i++){     	
	if (cad.substr(i,1)!= " "){
		  intNum++;		  		   
	}
	}
  return (intNum);
}
//********************************************************************************************//
function DateAdd(startDate, numDays, numMonths, numYears)
{
	var returnDate = new Date(startDate.getTime());
	var yearsToAdd = numYears;
	var month = returnDate.getMonth()	+ numMonths;
	if (month > 11)
	{
		yearsToAdd = Math.floor((month+1)/12);
		month -= 12*yearsToAdd;
		yearsToAdd += numYears;
	}
	returnDate.setMonth(month);
	returnDate.setFullYear(returnDate.getFullYear()	+ yearsToAdd);
	returnDate.setTime(returnDate.getTime()+60000*60*24*numDays);
	return returnDate;
}
//*****************************************************************
function AbrirPopUp(TipVentana,url,nompopup,popW,popH,scroll,resizable){
	hfuncsite = screen.availHeight - 30
	wfuncsite = screen.availWidth - 10
	switch (TipVentana) {
    case 'CAR' :
			var leftPos = (wfuncsite-popW)/2, topPos = 20;
			break;
    case 'CEN':
			var leftPos = (wfuncsite-popW)/2, topPos = (hfuncsite-popH)/2;
			break;
    case 'CAB' :
			var leftPos = (wfuncsite-popW)/2, topPos = (hfuncsite-popH);
			break;
    case 'DAR':
			var leftPos = (wfuncsite-popW)-10, topPos = 10;
			break;
    case 'DCE' :
			var leftPos = (wfuncsite-popW)-10, topPos = (hfuncsite-popH)/2;
			break;
    case 'DAB':
			var leftPos = (wfuncsite-popW)-10, topPos = (hfuncsite-popH);
			break;
		case 'IAR' :
			var leftPos = 10, topPos = 10;
			break;
    case 'ICE':
			var leftPos = 10, topPos = (hfuncsite-popH)/2;
			break;
    case 'IAB':
			var leftPos = 10, topPos = (hfuncsite-popH);
			break;
		default:
			alert('Parametro incorrecto');
	}
	window.open(url,nompopup,'width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos + ',resizable=' + resizable + ',scrollbars=' + scroll );
}
//********************************************************************************************//
function fncRound(number,X) {
    X = (!X ? 2 : X);
    return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}
//********************************************************************************************//
