$(document).ready(function(){
	$.popup = function(pth,sz){
		return window.open( pth, null, "width=" + sz.width + ",height=" + sz.height + ",top=" + ( screen.availHeight - sz.height ) / 2  + ",left=" + ( screen.availWidth - sz.width ) / 2 + ",toolbar=no,location=no,directories=no,menubar=no,status=no");
	}
	$("a[rel='popup']").each(function(i,el){
		$(el).attr('lnk',$(el).attr('href'));
		$(el).attr('href','javascript:void(0);');
		var wdt = 440;
		var hgt = 340;
		if( $(el).attr('class') == 'flash' ){
			wdt = 750;
			hgt = 430;
		}
		$(el).click(function(){
			$("#inner").hide('slow')
			$.popup($(this).attr('lnk'),{width:wdt,height:hgt})
		})
	})	
	$("#menu a[rel='inner']").each(function(i,el){
		$(el).attr('lnk',$(el).attr('href'));
		$(el).attr('href','javascript:void(0);');
		$("#inner").hide('slow')
		$(el).click(function(){
			$.ajax({
			  type: "GET",
              url: $(this).attr('lnk'),
              success: function(data){
				  $("#inner").html(data).hide().show('slow')
			  }}
		    )
		})
	})	
	$("#content").height( $(window).height() - 80 );
})

function submitForm(){
	var url = "/servlets/montferrant.altaMailing/html/plantilla.html?mail="+$('input[name="email"]').val();
	
	var msg = "";
	
	if( $('input[name="email"]').val().match(/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i) ){
		msg = "<center><b>Gracias por dejarnos tu e-mail.</b><br>Nos pondremos en contacto contigo tan<br> pronto como tengamos algo nuevo que contarte.</center>";
		$.ajax({
			  type: "POST",
              url: url,
              success: function(){
				  $("#inner").html(msg).hide().show('slow')
			  }}
		    )
	}else{
		msg = "<center><b>Por favor</b>,<br /> comprueba tu dirección de correo.</center>";
		$("#inner").html(msg).hide().show('slow')
	};
}

