function decision(message, url){
	if(confirm(message) )
  {
    parent.location.href = url;
  }
}

function abrir(pagina,tipo) {
	if(tipo==1){
		w=(screen.width-470)/2;//(screen.width-653)/2;
		h=(screen.height-450)/2;//(screen.height-492)/2;
		//window.open(pagina,'window',"width=653,height=492,scrollbars=no,menubar=no,dependent=yes,left="+w+",top=0");
		window.open(pagina,'',"width=470,height=450,resizable=1,scrollbars=yes,menubar=no,dependent=yes,left="+w+",top=0");
	}
	else if(tipo==2){
		w=(screen.width-450)/2;
		h=(screen.height-580)/2;	
		window.open(pagina,'',"width=450,height=580,scrollbars=yes,menubar=no,dependent=yes,left="+w+",top=0");
	}
	else if(tipo==3){
		w=(screen.width-550)/2;
		h=(screen.height-450)/2;	
		window.open(pagina,'',"width=550,height=450,scrollbars=yes,menubar=no,dependent=yes,left="+w+",top=0");
	}
	else if(tipo==4){
		w=(screen.width-520)/2;
		h=(screen.height-500)/2;	
		window.open(pagina,'',"width=520,height=500,scrollbars=yes,menubar=no,statusbar=no,toolbar=no,resizable=no,dependent=yes,left="+w+",top=0");
	}
	else if(tipo==5){
		w=(screen.width-390)/2;
		h=(screen.height-590)/2;	
		window.open(pagina,'',"width=390,height=590,scrollbars=yes,menubar=no,statusbar=no,toolbar=no,resizable=no,dependent=yes,left="+w+",top=0");
	}
	else if(tipo==6){
		w=(screen.width-450)/2;
		h=(screen.height-420)/2;	
		window.open(pagina,'',"width=450,height=420,scrollbars=yes,menubar=no,statusbar=no,toolbar=no,dependent=yes,left="+w+",top=0");
	}
	else if(tipo==7){
		w=(screen.width-500)/2;
		h=(screen.height-600)/2;	
		window.open(pagina,'',"width=500,height=600,location=no,scrollbars=yes,menubar=no,statusbar=no,toolbar=no,dependent=yes,left="+w+",top=0");
		//window.open('./informacion.html','','width=550,height=300,top=50,left=50,location=no,scrollbars=yes,menubar=no,statusbar=no,toolbar=no,resizable=yes,dependent=yes');

	}
	else if(tipo==8){
		w=(screen.width-600)/2;
		h=(screen.height-800)/2;	
		window.open(pagina,'',"width=600,height=800,location=yes,resizable=yes,scrollbars=yes,dependent=yes,left="+w+",top=0");
		//window.open('./informacion.html','','width=550,height=300,top=50,left=50,location=no,scrollbars=yes,menubar=no,statusbar=no,toolbar=no,resizable=yes,dependent=yes');

	}
	else if(tipo==9){
		w=screen.width-60;
		h=screen.height-60;	
		window.open(pagina,'',"width="+w+",height="+h+",location=no,resizable=no,toolbar=no,scrollbars=yes,menubar=yes,dependent=yes,left=30,top=30");
		//window.open('./informacion.html','','width=550,height=300,top=50,left=50,location=no,scrollbars=yes,menubar=no,statusbar=no,toolbar=no,resizable=yes,dependent=yes');

	}
	
	else if(tipo==21){
		w=(screen.width-470)/2;//(screen.width-653)/2;
		h=(screen.height-450)/2;//(screen.height-492)/2;
		//window.open(pagina,'window',"width=653,height=492,scrollbars=no,menubar=no,dependent=yes,left="+w+",top=0");
		window.open(pagina,'',"width=470,height=450,resizable=0,scrollbars=yes,menubar=no,dependent=yes,left="+w+",top=0");
	}
}
function abrir2(pagina,tipo,ancho,alto)
	{
	if(tipo==1){
		w=(screen.width-470)/2;//(screen.width-653)/2;
		h=(screen.height-450)/2;//(screen.height-492)/2;
		//window.open(pagina,'window',"width=653,height=492,scrollbars=no,menubar=no,dependent=yes,left="+w+",top=0");
		window.open(pagina,'',"width="+ancho+",height="+alto+",resizable=1,scrollbars=yes,menubar=no,dependent=yes,left="+w+",top=0");
	}
	else if(tipo==2){
		w=(screen.width-550)/2;
		h=(screen.height-580)/2;	
		window.open(pagina,'',"width="+ancho+",height="+alto+",scrollbars=yes,menubar=no,dependent=yes,left="+w+",top=0");
	}
}

function numFormat(valor,dec, miles){
var num = valor, signo=3, expr;
var cad = ""+valor;
var ceros = "", pos, pdec, i;
for (i=0; i < dec; i++) ceros += '0';
pos = cad.indexOf('.')
if (pos < 0)
    cad = cad+"."+ceros;
else
    {
    pdec = cad.length - pos -1;
    if (pdec <= dec)
        {
        for (i=0; i< (dec-pdec); i++)
            cad += '0';
        }
    else
        {
        num = num*Math.pow(10, dec);
        num = Math.round(num);
        num = num/Math.pow(10, dec);
        cad = new String(num);
        }
    }
pos = cad.indexOf('.')
if (pos < 0) pos = cad.lentgh
if (cad.substr(0,1)=='-' || cad.substr(0,1) == '+') 
       signo = 4;
if (miles && pos > signo)
    do{
        expr = /([+-]?\d)(\d{3}[\.\,]\d*)/
        cad.match(expr)
        cad=cad.replace(expr, RegExp.$1+','+RegExp.$2)
        }
while (cad.indexOf(',') > signo)
    if (dec<0) cad = cad.replace(/\./,'')
        return cad;
}
function nFormatNum(cadena){
	var cad="";
	var ja = new Array();
	
	ja = cadena.split(",");	
	for(i=0; i < ja.length; i++)
		cad+=ja[i];
	return parseFloat(cad);
}
function validaCorreo(emailStr){
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	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 +")*$")
	
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		return "es incorrecto.\n\t\t - La dirección de correo parece inválida (comprobar @ y los puntos '.')\n"//false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	
	// See if "user" is valid 
	if (user.match(userPat)==null) {
		return "es incorrecto.\n\t\t - El usuario no parece ser válido.\n";//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) {
			return "es incorrecto.\n\t\t - IP de destino incorrecta.\n";//false
			}
		}
		return "Correo valido";//true
	}
	
	// Domain is symbolic name
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		return "es incorrecto.\n\t - El dominio no parece ser válido.\n";//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.
	   return "es incorrecto.\n\t\t - La dirección debe terminar con un dominio de 3 letras, o un nombre de país de dos letras.\n";
	}
	
	// Make sure there's a host name preceding the domain.
	if (len<2) {
	   var errStr="es incorrecto.\n\t\t - ¡A esta dirección le falta un nombre de host!\n"
	   return errStr;
	}
	
	// If we've gotten this far, everything's valid!
	return "Correo valido";
}
//  End -->

function validaCorreo2(txt){
	
	if (txt.indexOf("@")<3){
		return "es incorrecto.\n\t Por favor, "
		+" comprueba el prefijo y el signo '@'.\n";
	}
	/*if ((txt.indexOf(".com")<5)&&(txt.indexOf(".org")<5)
	&&(txt.indexOf(".gob")<5)&&(txt.indexOf(".net")<5)
	&&(txt.indexOf(".gov")<5)&&(txt.indexOf(".edu")<5)){
		return "es incorrecto.\n Por favor,"
		+" comprueba el sufijo (que debe incluir alguna terminación como: "
		+".com, .edu, .net, .org, .gob o .gov)\n";
	}*/
	return "Correo valido";
}

function validarEntero(valor){
	var checkOK = "0123456789-*";
	var checkStr = valor;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++){
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j)) break;
		  if (j == checkOK.length){
			  allValid = false;
			  break;
		  }
		  allNum += ch;
	}
	
	if (!allValid){
		return false;
	}
	else return true;
} 

function validarFlotante(fieldValue) {
	decallowed = 2;  // how many decimals are allowed?
	punto=false;
	if (isNaN(fieldValue) || fieldValue == "") {
		return false;
	}
	else {
		if (fieldValue.indexOf('.') == -1){ 
			fieldValue += ".";
		}
		else punto=true;
		
		dectext = fieldValue.substring(fieldValue.indexOf('.')+1, fieldValue.length);
		
		if (dectext.length > decallowed){
			return true;
		}
		else {
			if(punto==true && dectext.length==0){
				return false;
			}
			else{
				return true;
			}
		}
	}
}

//----------------FECHA--------------------------------------

function ValidarFecha(Cadena,Hoy){
	var Fecha= new String(Cadena);	// Crea un string
	var RealFecha= new String(Hoy);	// Crea un string
	
	// 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("-")));
	
	// Cadena Año
	var thisyear= new String(RealFecha.substring(RealFecha.lastIndexOf("-")+1,RealFecha.length));
	// Cadena Mes
	var thismonth= new String(RealFecha.substring(RealFecha.indexOf("-")+1,RealFecha.lastIndexOf("-")));
	// Cadena Día
	var thisday= new String(RealFecha.substring(0,RealFecha.indexOf("-")));

	// Valido el año
	if (isNaN(Ano) || Ano.length<4 || parseFloat(Ano)<1900){
        return 'tiene Año inválido';
	}
	// Valido el Mes
	if (isNaN(Mes) || parseFloat(Mes)<1 || parseFloat(Mes)>12){
		return 'tiene Mes inválido';
	}
	// Valido el Dia
	if (isNaN(Dia) || parseInt(Dia)<1 || parseInt(Dia)>31){
		return 'tiene Día inválido';
	}
	if (Mes==4 || Mes==6 || Mes==9 || Mes==11 || Mes==2) {
		if (Mes==2 && Dia > 28 || Dia>30) {
			return 'tiene Día inválido';
		}
	}
	//alert(thisday+"-"+thismonth+"-"+thisyear);
	if( (parseFloat(Ano)>=parseFloat(thisyear)) && (parseFloat(Mes)>=parseFloat(thismonth)) && (parseFloat(Dia)>=parseFloat(thisday)) )
		return "correcta.";
	else return "ya paso, favor de revisarla..";
	
  //para que envie los datos, quitar las  2 lineas siguientes
	return "correcta.";	
}
