function abre_ventana(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}


function foto(URL,titulo)
{

ventana=window.open('','ventana','resizable=no,scrollbars=no')
ventana.document.write('<html><head><title>' + titulo + '</title></head><body style="overflow:hidden" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" scroll="no"><img src="' + URL + '" onLoad="opener.redimensionar(this.width, this.height)">');
ventana.document.close();

}
function redimensionar(ancho, alto)
{
ventana.resizeTo(ancho+12,alto+28);
ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2); //centra la ventana. Eliminar si no se quiere centrar el popup
}


function construyeURL(){
  	var host = location.host;
  	document.formulario.host.value = host; 
}
 
function validarFormulario(){
	
	 var s = formulario.de.value.toString(); 
	 var ss = formulario.para.value.toString();
	 
	 
	
	if (s==0){
		alert("Debe de introducir un valor en el campo Remitente");
		formulario.de.focus();
		return false;
	}
	if (ss==0){
		alert("Debe de introducir un valor en el campo E-mail receptor");
		formulario.para.focus();
		return false;
	}
	
	
	
	if (!checkmail(formulario.de )){
		alert("Debe de introducir una direccion de correo valida en el campo Remitente");
		formulario.de.focus();
		return false;
	}
	if (!checkmail(formulario.para )){
		alert("Debe de introducir una direccion de correo valida en el campo E-mail Receptor");
		formulario.para.focus();
		return false;
	}
	
	document.forms['formulario'].submit();	
	
}



function checkmail(inputObject)
{
    var s = inputObject.value.toString();
    tieneEspacio = false;
    tieneArroba = false;
    primeroArroba = 0;
    tienePunto = false;
    segundoPunto = 0;
    texArray = new Array();

    for (i = 0;  i < s.length;  i++)
    {
        if (s.charAt(i) == ' ')
            tieneEspacio = true;
        else if (s.charAt(i) == '@')
        {
            tieneArroba = true;
            primeroArroba = i;
        }
        else if (s.charAt(i) == '.')
        {
            tienePunto = true;
            segundoPunto = i;
        }
        else
            texArray[i]=0;
    }

    return (
         ( texArray[primeroArroba-1]==0 )  
           && 
         ( texArray[segundoPunto-1]==0 )  
           && 
         ( texArray[segundoPunto+1]==0 ) 
           && 
         ( tieneEspacio == false )  
           &&  
         ( tieneArroba == true ) 
           &&  
         ( tienePunto == true )  
           &&  
         ( primeroArroba<segundoPunto )
        );
}		