///// Abre ventana con html dentro

var ImprimeVentana
function carolina(destino,ancho,alto,resi,scroll) {
	if (ImprimeVentana != null && !ImprimeVentana.closed) {
		VentanaVieja = ImprimeVentana;
		VentanaVieja.name = "VentanaVieja";
		VentanaVieja.close();
	 }
	ImprimeVentana=window.open(destino,"VentanaNueva","toolbar=no,location=no, status=no,menubar=no,left=0,top=0,resizable="+resi+",scrollbars="+scroll+",width="+ancho+",height="+alto);
	if (ImprimeVentana.opener == null)	{
		ImprimeVentana.opener = carolina;
	}
		ImprimeVentana.opener.name = "VentanaOriginal";
        ImprimeVentana.focus();
}

function closeWin()	{
	this.close();
	ImprimeVentana = null;
}

///// Ventanita fotos
// usa también closeWin() declarada antes.
var MuestraVentana
function marcos(imagen,ancho,alto,titulo) 
{
	if (MuestraVentana != null && !MuestraVentana.closed) {
		CuadroViejo = MuestraVentana;
		CuadroViejo.name = "CuadroViejo";
		CuadroViejo.close();
	 }
	MuestraVentana=window.open("","CuadroNuevo","toolbar=no,location=no, status=no,menubar=no,left=0,top=0,resizable=no,scrollbars=no,width="+ancho+",height="+alto);
	MuestraVentana.document.write("<html><head><title>"+titulo+"</title>");
	MuestraVentana.document.write("</head><body>");
	MuestraVentana.document.write('<div style="position:absolute;width:'+ancho+'px;height:'+alto+'px;left:0px;top:0px">');
	MuestraVentana.document.write("<img src="+imagen+" alt=\""+titulo+"\"></div></body></html>");
	MuestraVentana.document.close();
	if (MuestraVentana.opener == null)	{
		MuestraVentana.opener = carolina;
	}
		MuestraVentana.opener.name = "VentanaOriginal";
        MuestraVentana.focus();
}

/// los tradicionales
function preloadImages() { //v3.0
	var d=document; 
	if(d.images){ 
		if(!d.p) d.p=new Array();
		var i,j=d.p.length,a=preloadImages.arguments; 
		for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ 
			d.p[j]=new Image; 
			d.p[j++].src=a[i];
		}
	}
}

function swapImgRestore() { //v3.0
	var i,x,a=document.sr; 
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function findObj(n, d) { //v4.01
	var p,i,x;  
	if(!d) d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
	}
	if (!(x=d[n])&&d.all) x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for (i=0;!x&&d.layers&&i<d.layers.length;i++) 	x=findObj(n,d.layers[i].document);
	if (!x && d.getElementById) x=d.getElementById(n); 
	return x;
}

function swapImage() { //v3.0
	var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=findObj(a[i]))!=null){
		document.sr[j++]=x; 
		if (!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	}
}

function showHideLayers() { 
	var i,v,obj,args=showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) 
	if ((obj=findObj(args[i]))!=null) { 
		v=args[i+2];
		if (obj.style) { 
			obj=obj.style; 
			v=(v=='si')?'visible':(v=='no')?'hidden':v; 
		}
		obj.visibility=v; 
	}
}

function validar() {

	if(document.formulario.Nombre.value==""){
		alert("Olvidó ingresar su Nombre y Apellido");
		document.formulario.Nombre.focus(); 
		return false;
	}

	Cadena=document.formulario.Email.value;
	if (Cadena!="") {
		Punto = Cadena.substring(Cadena.lastIndexOf('.') + 1, Cadena.length)			// Cadena del .com
		Dominio = Cadena.substring(Cadena.lastIndexOf('@') + 1, Cadena.lastIndexOf('.')) 	// Dominio @lala.com
		Usuario = Cadena.substring(0, Cadena.lastIndexOf('@'))					// Cadena lalala@
		Reserv = "@/º\"\'+*{}\\<>?¿[]áéíóú#·¡!^*;,:"						// Letras Reservadas
	
		valido = true
	
		for (var Cont=0; Cont<Usuario.length; Cont++) {
			X = Usuario.substring(Cont,Cont+1)
			if (Reserv.indexOf(X)!=-1)
				valido = false
		}

		for (var Cont=0; Cont<Punto.length; Cont++) {
			X=Punto.substring(Cont,Cont+1)
			if (Reserv.indexOf(X)!=-1)
				valido = false
		}
                        
		for (var Cont=0; Cont<Dominio.length; Cont++) {
			X=Dominio.substring(Cont,Cont+1)
			if (Reserv.indexOf(X)!=-1)
				valido = false
			}

		if (Punto.length<2 || Dominio <1 || Cadena.lastIndexOf('.')<0 || Cadena.lastIndexOf('@')<0 || Usuario<1) {
			valido = false
		}
	
		if (!valido) {
			alert('Dirección de correo no válida.')
			document.formulario.Email.focus();
			return false;
		}
	} else {
		alert("Olvidó ingresar su e-mail");
		document.formulario.Email.focus();
		return false;
	}
	
	if(document.formulario.Telefono.value==""){
		alert("Por favor, ingrese un número de Teléfono");
		document.formulario.Telefono.focus(); 
		return false;
	}else{
		var checkOK = "0123456789 -+()"; 
		var checkStr = document.formulario.Telefono.value; 
		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) { 
			alert("El campo \"Teléfono\" contiene caracteres no válidos.");
			document.formulario.Telefono.focus(); 
			return false; 
		} 
	}

	if(document.formulario.Consulta.value==""){
		alert("Olvidó ingresar una Consulta");
		document.formulario.Consulta.focus(); 
		return false;
	}

return true;
}

