var newwindow; 
var wheight = 0;
var wwidth  = 0; 


function validateEmail(emailAddress) {
   var match = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/.test(emailAddress);
   return match;
}




function CheckRegisterForm(formulario) {
    
    
        if (formulario.usuario.value == "" ) { 
            alert( "Por favor selecciona un nombre de usuario para continuar." );
            formulario.usuario.focus();
            return false; 
        }
        
        if (formulario.password.value == "" ) { 
            alert( "Por favor, elige una contraseña." );
            formulario.password.focus();
            return false; 
        }
        
        if (formulario.password2.value == "" ) { 
            alert( "Por favor, confirma tu contraseña." );
            formulario.password2.focus();
            return false; 
        }        
        
        if (formulario.password.value != formulario.password2.value ) { 
            alert( "Las contraseñas no coinciden, las 2 tienen que ser iguales.");
            formulario.password.focus();
            return false; 
        }        
        
        if (formulario.email.value == "" ) { 
            alert( "Por favor, introduce tu dirección de correo." );
            formulario.email.focus();
            return false; 
                    }
    
        if (formulario.nombre.value == "" ) { 
            alert( "Por favor, introduce tu nombre." );
            formulario.nombre.focus();
            return false; 
        }

        var checkEmail = formulario.email.value;
	    if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) {
	        alert("La dirección de correo que has escrito no es válida.");
	        formulario.email.focus();
	        return false; 
	    }

        if (formulario.email2.value == "" ) { 
            alert( "Por favor, confirma tu dirección de correo." );
            formulario.email2.focus();
            return false; 
        }

        checkEmail = formulario.email2.value;
	    if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) {
	        alert("La dirección de correo que has escrito en la casilla de verificación del correo no es válida.");
	        formulario.email2.focus();
	        return false; 
	    }

        if (formulario.email.value != formulario.email2.value ) { 
            alert( "Las direccion de correo no coinciden, las 2 tienen que ser iguales." );
            formulario.email.focus();
            return false; 
        }


   //return true;
}






function CheckTellForm(tellform) {
        
        
    if (tellform.name.value == "" ) { 
        alert( "ÇáÑÌÇÁ ÃÏÎá ÇáÅÓã ÈÇáßÇãá" );
        tellform.name.focus();
        return false; 
    }

    if (tellform.email.value == "" ) { 
        alert( "ÃÏÎá ÇáÈÑíÏ ÇáÅáßÊÑæäí" );
        tellform.email.focus();
        return false; 
    }

    
    checkEmail = tellform.email.value
	if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) {
	    alert("ÇáÈÑíÏ  ÇáÅáßÊÑæäí  ÎØÃ!.");
	    tellform.email.focus();
	    return false; 
	}


    if (tellform.fname.value == "" ) { 
        alert( "ÃÏÎá ÅÓã ÕÏíÞß" );
        tellform.fname.focus();
        return false; 
    }


    if (tellform.femail.value == "" ) { 
        alert( "ÃÏÎá ÇáÈÑíÏ ÇáÇáßÊÑæäí ÇáÎÇÕ ÈÕÏíÞß" );
        tellform.femail.focus();
        return false; 
    }

    checkEmail = tellform.femail.value;
	if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) {
	    alert("ÇáÈÑíÏ  ÇáÅáßÊÑæäí  ÎØÃ!.");
	    tellform.femail.focus();
	    return false; 
	}

}



function pop(url) {
    newwindow=window.open(url,'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=1, menubars=0, resizable=0, width=500, height=400');
    if (window.focus) { newwindow.focus(); }
}


function popimg(url) {
    newwindow=window.open(url,'name','height=500,width=650,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');
	if (window.focus) { newwindow.focus(); }
}




function viewimg(url, title, iwidth, iheight, colour) { 
    
    var pwidth, pheight; 

    if ( !newwindow || newwindow.closed ) { 
        pwidth=iwidth+30; 
        pheight=iheight+30; 
        newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=1,top=50,left=10'); 
        wheight=iheight; 
        wwidth=iwidth; 
    } 

    if (wheight!=iheight || wwidth!=iwidth ) { 
        pwidth=iwidth+30; 
        pheight=iheight+60; 
        newwindow.resizeTo(pwidth, pheight); 
        wheight=iheight; 
        wwidth=iwidth; 
    } 

    newwindow.document.clear(); 
    newwindow.focus(); 
    newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>'); 
    newwindow.document.writeln('<a titl="ÅÖÛØ ÇáÕæÑÉ ááÅÛáÇÞ" href="javascript:window.close();"><img src=' + url + ' border=0></a>'); 
    newwindow.document.writeln('<\/center> <\/body> <\/html>'); 
    newwindow.document.close(); 
    newwindow.focus(); 

} 

// Routines to tidy up popup windows when page is left 
// Call with an onUnload="tidy5()" in body tag 

function tidy5() { 
    if (newwindow && !newwindow.closed) { newwindow.close(); } 
} 

