function checkEmail(email)
{	
	var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var emailVal = $("#" + email).val();
	return pattern.test(emailVal);
}
	
$(document).ready(function() {
	$.preloadCssImages();
	$("#social_boton").hover(
	  function () {
    	$("#social_ampliado").show();
	  },
	  function () {
//    	$("#social_ampliado").hide();
	  }
	);
	$("#social_ampliado").hover(
	  function () {
//    	$("#social_ampliado").show();
	  },
	  function () {
    	$("#social_ampliado").fadeOut();
	  }
	);
	$("#link_panel").click(function(){
		$("#panel_footer").slideToggle("slow");
//		$(this).toggleClass("active"); return false;
	});
	$("#globalmenu .dropdown ul li").click(function () {
		$("#globalmenu>ul>li").removeClass("current");
		$("#globalmenu .dropdown").addClass("hidden")
	});
		$("#globalmenu .btn-close").click(function () {
			$(this).parent().parent().addClass("hidden");
			$(this).parent().parent().trigger("close");
			$("a.main").parent().removeClass("current open");
			return false;
			this.blur()
		});
		$("#globalmenu .menu").bind("close", function () {
			$(this).removeClass("current open");
			$(this).children(".dropdown").addClass("hidden");
			$(window).unbind("click")
		});
		$("#globalmenu .menu").bind("open", function () {
			$(this).addClass("current open");
			$(this).children(".dropdown").removeClass("hidden");
			$(this).removeClass("hidden");
			var a = $(this);
			$(this).click(function (b) {
				b.stopPropagation()
			});
			$(window).click(function (b) {
				if (b.target != a) {
					a.trigger("close")
				}
			})
		});
		$("#globalmenu a.main:not(.link)").click(function () {
			if (!$(this).parent().hasClass("current")) {
				$("#globalmenu .menu.current").trigger("close");
				$(this).siblings().removeClass("hidden");
				$(this).parent().trigger("open");
				$(".global-popup").addClass("hidden")
			} else {
				$(this).parent().trigger("close")
			}
			return false;
			this.blur()
		});
		
		/*
		$("#subForm input:submit").click(function() {	
			
			// First, disable the form from submitting
			$('form#subForm').submit(function() { return false; });
			
			// Grab form action
			formAction = $("form#subForm").attr("action");
			
			// Hacking together id for email field
			// Replace the xxxxx below:
			// If your form action were http://mysiteaddress.createsend.com/t/r/s/abcde/, then you'd enter "abcde" below
			emailId = "thujld";
			emailId = emailId.replace("/", "");
			emailId = emailId + "-" + emailId;
			
			// Validate email address with regex
			if (!checkEmail(emailId)) 
			{
				alert("Introduce una direcci\u00D3n v\u00C1lida");
				return;
			}
			
			// Serialize form values to be submitted with POST
			var str = $("form#subForm").serialize();
			
			// Add form action to end of serialized data
			final = str + "&action=" + formAction;
			
			// Submit the form via ajax
			$.ajax({
				url: "/proxy.php",
				type: "POST",
				data: final,
				success: function(html){
					$("#theForm").hide(); // If successfully submitted hides the form
					$("#confirmation").slideDown("slow");  // Shows "Thanks for subscribing" div
				}
			});
		});*/

});