$(document).ready(function() {		
	//Menu
	
	$(".topMenuAction").click( function() {
		if ($("#openCloseIdentifier").is(":hidden")) {
			$("#slider").animate({ 
				marginTop: "-400px"
				}, 500 );
			$("#topMenuImage").html('<img src="/images/general/img-liston-rojo.png" alt="Abrir"/>');
			$("#openCloseIdentifier").show();
		} else {
			$("#slider").animate({ 
				marginTop: "0px"
				}, 500 );
			$("#topMenuImage").html('<img src="/images/general/img-liston-rojo.png" alt="Cerrar"/>');
			$("#openCloseIdentifier").hide();
		}
	});
	
	//Login
	$(".topMenuAction-login").click( function() {
		if ($("#openCloseIdentifier-login").is(":hidden")) {
			$("#slider-login").animate({ 
				marginTop: "-100px"
				}, 500 );
			$("#topMenuImage-login").html('<img src="/images/login/img-login.png" alt="McCormick"/>');
			$("#openCloseIdentifier-login").show();
		} else {
			$("#slider-login").animate({ 
				marginTop: "10px"
				}, 500 );
			$("#topMenuImage-login").html('<img src="/images/login/img-cerrar.png" alt="McCormick"/>');
			$("#openCloseIdentifier-login").hide();
		}
	});
	$('#example1 .kwicks').kwicks({
		max: 400,
		spacing:  5
	});
	
	$("a.tab-1").click(function () {
		var content_show = $(this).attr("title");
		$(".activa").fadeOut("normal",function(){
			$("#"+content_show).fadeIn();
			$(".activa").removeClass("activa");
			$("#"+content_show).addClass("activa");		
		});
	});
	
	$("a.tac").click(function () {
		var content_show = $(this).attr("title");
		$(".activ").fadeOut("normal",function(){
			$("#"+content_show).fadeIn();
			$(".activ").removeClass("activ");
			$("#"+content_show).addClass("activ");		
		});
	});
	//Videos
	$("a.video-mx").click(function () {
		var content_show = $(this).attr("title");
		$(".video-active").slideUp("normal",function(){
			$("#"+content_show).slideDown("normal");
			$(".video-active").removeClass("video-active");
			$("#"+content_show).addClass("video-active");		
		});
	});
	
		
	jQuery('#mycarousel').jcarousel();

	jQuery('#submenu').jcarousel();
	  
	$(".pwdname").click(function(){
	var pwd = $(this).next().html();
		$(".input").fadeIn(300);
	});
	$(".close").click(function(){
		$(".input").fadeOut(300);
	});

	$("a.socialtab").click(function(){
		var content_show = $(this).attr("title");
		$("#tabsocial").removeClass("socialtab-facebook");
		$("#tabsocial").removeClass("socialtab-twitter");
		$("#twittercontain").addClass("invisible");
		$("#facebookcontain").addClass("invisible");
		$("#tabsocial").addClass("socialtab-"+content_show);
		$("#"+content_show+"contain").removeClass("invisible");
		$(".socialactive").removeClass("socialactive");
		$("#"+content_show+"contain").addClass("socialactive");
	});	

	$("#rec").click(function(){
		mimasterpwd = $("#masterpwd").attr("value");
		$("#masterpwd").attr("value", "");
		$(".input").fadeOut(300);
		setTimeout(olvidar, 10 * 60 * 1000);
	});

	$(".pwdname1").click(function(){
		var pwd = $(this).next().html();
		$(".input1").fadeIn(300);
	});
	$(".close1").click(function(){
		$(".input1").fadeOut(300);
	});
	 
	$("#rec1").click(function(){
		mimasterpwd = $("#masterpwd1").attr("value");
	$("#masterpwd1").attr("value", "");
	$(".input1").fadeOut(300);
		setTimeout(olvidar, 10 * 60 * 1000);
	});

	$("img[rel]").overlay();
	$("a[rel]").overlay();
	//comienza();
	$("#titleFlavorsShow").click( function() {
		$(".input").vAlign();
		$(".input").hAlign();
	});
});
//Termina Slider Menu Home

//Inicia MENU

startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

window.onload=startList;

(function ($) {
$.fn.vAlign = function() {
	return this.each(function(i){
	var h = $(this).height();
	var oh = $(this).outerHeight();
	var mt = (h + (oh - h)) / 2;	
	$(this).css("margin-top", "-" + mt + "px");	
	$(this).css("top", "700px");
	$(this).css("position", "absolute");	
	});	
};
})(jQuery);

(function ($) {
$.fn.hAlign = function() {
	return this.each(function(i){
	var w = $(this).width();
	var ow = $(this).outerWidth();	
	var ml = (w + (ow - w)) / 2;	
	$(this).css("margin-left", "-" + ml + "px");
	$(this).css("left", "50%");
	$(this).css("position", "absolute");
	});
};
})(jQuery);

function comienza()
{
	$(".input").vAlign();
	$(".input").hAlign();
}

