$.preloadImages = function () {
    for (var a = 0; a < arguments.length; a++) {
        jQuery("<img>").attr("src", arguments[a])
    }
};
$(document).ready(function () {
    $.preloadImages("img/amore.png");
	$.preloadImages("img/corazon.png");
	$.preloadImages("img/chocolate.png");
	$.preloadImages("img/chesse.png");
	$.preloadImages("img/garibaldi.png");
	$.preloadImages("img/1.png");
    $.preloadImages("img/2.png");
	$.preloadImages("img/3.png");
	$.preloadImages("img/4.png");
	$.preloadImages("img/5.png");
    var a = 0;
    $("#carruselhome").carouFredSel({
        infinite: true,
        circular: true,
        width: 594,
        height: 377,
		pagination  : "#navegacion",

		/*
        pagination: {
            container: "#navegacion"
        },
		*/
		next : "#flechader",
		prev : "#flechaizq",
        scroll: {
            onAfter: function () {
                $("#carruselhome").trigger("currentPosition", function (a) {
                    if (a == 5) {
                        $("#back-home").removeClass("backrosca", 100);
                        $("#back-home").addClass("backlimon", 100)
                    } else {
                        $("#back-home").removeClass("backlimon", 100);
                        $("#back-home").addClass("backrosca", 100)
                    }
                })
            },
            pauseOnHover: true,
            duration: 1e3
        }
    });
    $("#recetachocolate").click(function () {
        $("#imgatole,#imgcafe").fadeOut(function () {});
        $("#imgchoco").fadeIn()
    });
    $("#recetacafe").click(function () {
        $("#imgatole,#imgchoco").fadeOut(function () {});
        $("#imgcafe").fadeIn()
    });
    $("#recetaatole").click(function () {
        $("#imgcafe,#imgchoco").fadeOut(function () {});
        $("#imgatole").fadeIn()
    });
    $("#tradicion").click(function () {
        $("#back-home").removeClass();
        $("#back-home").addClass("backtradicion");
        $("#backhomelargo").animate({
            marginLeft: "-1054px"
        });
        $("#cont-home").removeClass();
        $("#cont-home").addClass("back2")
    });
    $("#home , #linklogo").click(function () {
        $("#back-home").removeClass();
        $("#back-home").addClass("backrosca");
        $("#backhomelargo").animate({
            marginLeft: "-0px"
        });
        $("#cont-home").removeClass();
        $("#cont-home").addClass("back1")
    });
    $("#acompana").click(function () {
        $("#back-home").removeClass();
        $("#back-home").addClass("backrecetas");
        $("#backhomelargo").animate({
            marginLeft: "-2112px"
        });
        $("#cont-home").removeClass();
        $("#cont-home").addClass("back2")
    });
    $("#sucursales").click(function () {
        $("#back-home").removeClass();
        $("#cont-home").removeClass();
        $("#cont-home").addClass("back2");
        $("#back-home").addClass("backsucursales");
        $("#backhomelargo").animate({
            marginLeft: "-3162px"
        });
    });
	//menu productos
		$('.p1').click(function(){
			$('.p1').addClass('current');
			$('.p2,.p2,.p2,.p2').removeClass('current');
			$('#img-producto').attr('src','img/amore.png');
			$('#img-producto').attr('alt','Amore');
			$('#img-producto').attr('title','Amore');
		});
		$('.p2').click(function(){
			$('.p2').addClass('current');
			$('.p1,.p3,.p4,.p5').removeClass('current');
			$('#img-producto').attr('src','img/corazon.png');
			$('#img-producto').attr('alt','Corazón');
			$('#img-producto').attr('title','Corazón');
		});
		$('.p3').click(function(){
			$('.p3').addClass('current');
			$('.p1,.p2,.p4,.p5').removeClass('current');
			$('#img-producto').attr('src','img/chocolate.png');
			$('#img-producto').attr('alt','Chocolate');
			$('#img-producto').attr('title','Chocolate');
		});
		$('.p4').click(function(){
			$('.p4').addClass('current');
			$('.p1,.p2,.p3,.p5').removeClass('current');
			$('#img-producto').attr('src','img/chesse.png');
			$('#img-producto').attr('alt','Cheesecake');
			$('#img-producto').attr('title','Cheesecake');
		});
		$('.p5').click(function(){
			$('.p5').addClass('current');
			$('.p1,.p2,.p3,.p4').removeClass('current');
			$('#img-producto').attr('src','img/garibaldi.png');
			$('#img-producto').attr('alt','Garibaldi');
			$('#img-producto').attr('title','Garibaldi');
		});
})
