////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PopUpWindow
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SIN SCROLL
function PopUpWindow(URL,Ancho,Alto) {
	Izquierda = (screen.width-Ancho)/2;
	Arriba= (screen.height-Alto)/2; 
	ventana = window.open(URL, "", 'width='+Ancho+',height='+Alto+',left='+Izquierda+',top='+Arriba+',fullscreen=no,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrolling=0,scrollbars=0');
}
// CON SCROLL
function PopUpWindow2(URL,Ancho,Alto) {
	Izquierda = (screen.width-Ancho)/2;
	Arriba= (screen.height-Alto)/2; 
	ventana = window.open(URL, "", 'width='+Ancho+',height='+Alto+',left='+Izquierda+',top='+Arriba+',fullscreen=no,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrolling=1,scrollbars=1');
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Boletin
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function Boletin(Email){
	if (Email){
		if ( EmailCheck(Email) ){
			PopUpWindow('data/suscribir.php?Email='+Email,300,200);
			document.getElementById('CampoBoletin').value = '';
		}else{	
			alert('Dirección de e-mail inválida');
		}
	}else{
		alert('No has esrito tu dirección de correo');	
	};
};


function EmailCheck(str) {
		var at='@';
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		//
		if (str.indexOf(at)==-1) return false;
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
		if (str.indexOf(at,(lat+1))!=-1) return false;
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
		if (str.indexOf(dot,(lat+2))==-1) return false;
		if (str.indexOf(" ")!=-1) return false;
		return true					
};