function popUp_avisale() {
         window.open('a_avisale.ngmf?id=1','Avisale','width=400,height=220,resizable=no,scrollbars=no');
 }
 function email_valido(email) {
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
	return email.match(re)
}
function popup(url)
{
	newwindow=window.open(url,'PASSWORD','height=300,width=450');
	if (window.focus) {newwindow.focus()}
	return false;
}
function recuperar_mail(){
    if (email_valido(document.RecupPass.diremail.value)){
          recuxajax();
    }else {
    		var errormsj= document.getElementById('traduerror').value;
            document.getElementById('ERRORMAIL').innerHTML=errormsj;
      }
}

function recuxajax(){
        $.ajax({
	        type: "GET",
	        url: "a_recuperarpwd.ngmf?MAIL="+document.RecupPass.diremail.value,
	        success: function(datos) {
				if (datos.indexOf("@") != -1){
						document.getElementById('caja_olvido').innerHTML='';
						$('#caja_olvido').remove();
						$('#MSJMAIL').fadeIn(2000);
	                    document.getElementById('rmail').innerHTML= datos;
						return false;

            	}else {
            			document.getElementById('ERRORMAIL').innerHTML=datos;
            	}
			}
		});
}
function desaparece(){

var informacion = '<form name="RecupPass"  action="javascript:recuperar_mail()"; method="post">Si olvidó su contraseña ingrese su e-mail para recuperarla';
		informacion += '<input size="8" name="diremail" class="input2" /> ';
		informacion += '<input type="image" name="PERDI" src="images/botones/btn_green.gif" alt="enviar" />';
		informacion +=' <div id="ERRORMAIL" align="center" class="Error"></div></form>';

			document.getElementById('caja_olvido').innerHTML=informacion;

}
function startajax()
    {

        if (window.XMLHttpRequest){
            xml= new XMLHttpRequest();
        }
        else if(window.ActiveXObject){
                xml = new ActiveXObject("Microsoft.XMLHTTP");
        }

            xml.open("GET","validar_usr.ngmf?USR="+ document.HOME.UUSERNAME.value+"&PWD="+document.HOME.PPASSWORD.value,true);
            xml.onreadystatechange = callback;
            xml.send(null);
    }
function callback(){

        if (xml.readyState==1){
            document.getElementById('MSJ').innerHTML='<img src="/aplicantes/images/spin_32.gif" />';
        }
        if (xml.readyState==4 && xml.status==200){
            document.getElementById('MSJ').innerHTML='';
            var rta=xml.responseText;

            if (rta==1){
                        document.location="a_panel.ngmf";
                        document.getElementById('MSJ').innerHTML='';
            }else{
            	   document.getElementById('MSJ').innerHTML=rta;
            }
        }

    }

$(function() {
	if(document.getElementById('MSJMAIL') != undefined) {
		document.getElementById('MSJMAIL').style.display = 'none';
		document.getElementById('MSJMAIL').style.textAlign = 'center';
		$('div.bd').css('background', 'transparent url(images/mail_foward.png) no-repeat scroll center center').css('padding', '4px').css('height', '30px');
	}
});

function showAvisale(url) {
	if($.browser.msie && $.browser.version < 7) {
		popUp_avisale();
		return;
	}

	if(window.innerHeight) {
		height = window.innerHeight;
		width = window.innerWidth;
	} else {
		 height = document.body.clientHeight;
		 width = document.body.clientWidth;
	}


	var gris = document.createElement('div');
	gris.style.zIndex = 5;
	gris.style.width = '100%';
	gris.style.height = '100%';
	gris.id = 'gris';
	gris.style.position = (window.innerHeight?'fixed':'absolute');
	gris.style.left = '0px';
	gris.style.top = '0px';
	gris.style.backgroundColor = '#666666';
	gris.className = 'translucent';
	document.getElementsByTagName('body')[0].appendChild(gris);

	var caja = document.createElement('div');
	caja.style.position = (window.innerHeight?'fixed':'absolute');
	caja.style.width = '400px';
	caja.style.height= '220px';



	caja.style.left = (width / 2 - parseInt(caja.style.width.replace("px", "")) / 2) + 'px';
	//alert((height / 2 - parseInt(caja.style.height.replace("px", "")) / 2) + 'px');
	caja.style.top = (height / 2 - parseInt(caja.style.height.replace("px", "")) / 2) + 'px';
	caja.style.backgroundColor = 'white';
	caja.style.opacity = 1;
	caja.style.zIndex = 7;
	caja.style.overflow = 'hidden';
	caja.style.padding = '12px';
	caja.id = 'caja';
	$(caja).load(url);
	document.getElementsByTagName('body')[0].appendChild(caja);

	//var iframe = document.createElement('iframe');
	//caja.appendChild(iframe);
}
$(document).ready(function() {
	$('#amigo').click(function() { showAvisale('a_avisale.ngmf?id=1'); });
});