var win;
function atsPopup(archivo, strtit, alto, ancho, w, h)
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var winprops = "location=no,toolbar=0,scrollbars=yes,menubar=0,status=no,height="+h+",width="+w+",top="+wint+",left="+winl+",resizable=0";
	//win = window.open(mypage, myname, winprops);
	win = window.open("", "Ventana", winprops);
	texto='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"\n   "http://www.w3.org/TR/html4/loose.dtd">\n<html>\n<head>\n<link rel="stylesheet" type="text/css" href="refugio.css">\n';
	texto=texto+'<title>Refugio de Santiago - ' + strtit + '</title>\n';
	texto=texto+'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\n';
	texto=texto+'</head>\n<body style="margin:10px">\n';
	texto=texto+'<div align="center"><center>';
	imagen='<img alt="Refugio de Santiago" title="Haz click aquí para cerrar la ventana!!!" style="cursor:pointer" onclick="self.close()" class="fotos" align="middle" src="' + archivo + '" height="' + alto + '" width="' + ancho + '">\n';
	texto = texto + imagen + '</center></div>\n</body>\n</html>';
	win.document.write(texto);
	win.document.close();
	//win.resizeTo(Ancho,Alto);
	//win.document.close();
	//win.focus();
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
function selcampo(campo,mensaje) {
  alert(mensaje);
  document.formpedido.Cantidad.focus();
  document.formpedido.Cantidad.select();
  return true;
}
function chkNumbers(numero) {
	if(isNaN(numero) || ( parseInt(numero)<=0 || parseInt(numero)>9999) ) {
		selcampo("Cantidad","Error... Ud. debe ingresar un valor numérico para este campo entre 1 y 9,999.");
		return false;
	}
	else {
		return true;
	}
}
function mensaje(texto)
{
	alert(texto);
	document.formpedido.Contacto_CorreoElectronico.focus();
	document.formpedido.Contacto_CorreoElectronico.select();
	return true;
}
function chkmail(correo) {
	if ((correo.indexOf(" ")!=-1)) {
		mensaje("Lo sentimos, la dirección de correo no puede tener espacios!");
		return false;
	}
	p=correo.indexOf('@');
	if( p<1 || p==(correo.length-1) ) {
		mensaje("Lo sentimos, la dirección de correo no es válida!");
		return false;
	}
return true;
}
function checkFormElementInRange(nForm,theFieldName, min, max)
{
	if (nForm == 1)
	{
		var theField         = document.formpedido.elements[theFieldName];
	}
	else
	{
		var theField         = document.formreclamo.elements[theFieldName];
	}
    var val              = parseInt(theField.value);
    var errorMsg1        = "Error... Ud. debe ingresar un valor numérico para este campo.";
    //var errorMsg2        = " no esta dentro del rango aceptado 10-99.";
    if (typeof(min) == 'undefined') {
        min = 0;
    }
    if (typeof(max) == 'undefined') {
        max = Number.MAX_VALUE;
    }
	var errorMsg2        = " no esta dentro del rango aceptado " + min + "-"+ max +".";
    if (isNaN(val)) {
        theField.select();
        alert(errorMsg1);
        theField.focus();
        return false;
    }
    else if (val < min || val > max) {
        theField.select();
        alert(val + errorMsg2);
        theField.focus();
        return false;
    }
    else {
        theField.value = val;
    }
    return true;
}
function valida(elform) {
	var Tot = elform.elements.length;
	for(i = 0; i < Tot-2;++i) {
		var n=elform.elements[i].name;
		if(n.substring(0,1) == "r") {
			if(elform.elements[i].value == "") {
				elform.elements[i].select();
				alert("Debe completar el campo antes de continuar");
				elform.elements[i].focus();
				return false;
			}
		}
	}
	correo=elform.remail.value;
	if (!isEmail(correo))
	{
		elform.remail.select();
		alert("Lo sentimos, la dirección de correo no es válida!!!");
		elform.remail.focus();
		return false;		
	}
	if (elform.npersres.value!="")
	{
		if(!checkFormElementInRange(1,'npersres',1,99)) return false;
	}
	if (elform.nperscasa.value!="")
	{
		if(!checkFormElementInRange(1,'nperscasa',1,99)) return false;
	}	
/*	if (elform.nperscocina.value!="")
	{
		if(!checkFormElementInRange(1,'nperscocina',1,99)) return false;
	}
	if (elform.nperscriollo.value!="")
	{
		if(!checkFormElementInRange(1,'nperscriollo',1,99)) return false;
	}*/
	if (elform.nperscanotaje.value!="")
	{
		if(!checkFormElementInRange(1,'nperscanotaje',1,99)) return false;
	}
return true;
}
function valida2()
{
	correo=document.lista.txtemail.value;
	if( correo == "") {
		alert("Debe completar el campo antes de continuar");
		document.lista.txtemail.focus();
		document.lista.txtemail.select();
		return false;
	}
	if ((correo.indexOf(" ")!=-1)) {
		alert("Lo sentimos, la dirección de correo no puede tener espacios!");
		document.lista.txtemail.focus();
		document.lista.txtemail.select();
		return false;
	}
	p=correo.indexOf('@');
	if( p<1 || p==(correo.length-1) ) {
		alert("Lo sentimos, la dirección de correo no es válida!");
		document.lista.txtemail.focus();
		document.lista.txtemail.select();
		return false;
	}
return true;
}
function isEmail(s)
{
    var sLength = s.length;
    var denied_chars = new Array(" ", "\n", "\t", "\r", "%", "$", "#", "!", "~", "`", "^", "&", "*", "(", ")", "=", "+", "{", "}", "[", "]", ",", ";", ":", "'", "\"", "?", "<", ">", "/", "\\", "|");
    if (s.indexOf("@") == -1) return false;
    if (s.indexOf("@") != s.lastIndexOf("@")) return false;
    for (var z = 0; z < denied_chars.length; z++) {
        if (s.indexOf(denied_chars[z]) != -1) return false;
    }
    if (s.indexOf(".") == -1) return false;
    if (s.indexOf("..") != -1) return false;
    if (s.indexOf("@.") != -1) return false;
    if ((s.charAt(sLength-1) == ".") || (s.charAt(sLength-1) == "_")) return false;
    return true;
}
function valida3(elform)
{
	var Tot = elform.elements.length;
	for(i = 0; i < Tot-2;++i) {
		var n=elform.elements[i].name;
		if(n.substring(0,1) == "r") {
			if(elform.elements[i].value == "") {
				elform.elements[i].select();
				alert("Debe completar el campo antes de continuar");
				elform.elements[i].focus();
				return false;
			}
		}
	}
	correo=elform.rmail1.value;
	if (!isEmail(correo))
	{
		document.recomienda.rmail.select();
		alert("Lo sentimos, la dirección de correo no es válida!!!");
		elform.rmail.focus();
		return false;
	}
	if(elform.mail2.value != "")
	{
		correo=elform.mail2.value;
		if (!isEmail(correo))
		{
			document.recomienda.mail2.select();
			alert("Lo sentimos, la dirección de correo no es válida!!!");
			elform.mail2.focus();
			return false;
		}
		else elform.lmail2.value="s";
	}
	if(elform.mail3.value != "")
	{
		correo=elform.mail3.value;
		if (!isEmail(correo))
		{
			document.recomienda.mail3.select();
			alert("Lo sentimos, la dirección de correo no es válida!!!");
			elform.mail3.focus();
			return false;
		}
		else elform.lmail3.value="s";
	}
return true;
}
function ultmodi() {
//var ulti = new Date(ultima);
//nYear = ulti.getYear();
var ulti = new Date(document.lastModified);
//document.write("<center>\n");
//document.write("<a href=\"quienes.php\">Quienes Somos</a> :: <a href=\"mapasite.php\">Mapa del Sitio</a> :: <a href=\"privacidad.php\">Política de Privacidad</a> :: <a href=\"enlaces.php\">Enlaces de Interés</a> :: <a href=\"amigo.php\">Enviar a un Amigo</a><br />\n");
document.write("Copyright &copy; 2005 <a href=\"http://www.refugiodesantiago.com/index.php\">Refugio de Santiago</a>. Reservados todos los derechos.<br />Revisión: " + ulti + " - Resolución Óptima 800 x 600\n");
document.write("<br />Página creada por <a href=\"mailto:tavox@spymac.com\">Gustavo Cruz O.</a>\n");
//document.write("</center>\n");
}