
function overlay_on() {
	$("#overlay").animate({ opacity: 0.6, height: "60px", marginTop: "230px"}, 1000, 'easeOutBounce',
		function () { $("#overlay-texto").fadeIn("slow"); }
	);
	interval_cambio_automatico = window.setInterval("change_promotion()", 7000);
}

function change_promotion(num) {
	if(total_promotions == 1) return;
	if(selected_promotion >= total_promotions) selected_promotion = 0;
	if(!num) num = ++selected_promotion;

	$("a.overlay-link").removeClass("selected");
	$("#img_" + num).addClass("selected");

	$("#promocion-titulo").animate({ opacity: 0 }, "slow");
	$("#promocion-texto").animate({ opacity: 0 }, "slow");
	$("#imagen").animate({ opacity: 0}, "slow");

	$("#imagen").animate({ src: images[num-1] }, "slow", function() { $("#imagen").animate({ queue : true, opacity: 1}, "slow"); texto_on(num); });

}

function texto_on(num) {
	$("#promocion-titulo").text(titulos[num-1])
	$("#promocion-texto").text(textos[num-1])
	$("#promocion-link").attr("href", links[num-1]);

	$("#promocion-titulo").animate({ opacity: 1 }, "slow");
	$("#promocion-texto").animate({ opacity: 1 }, "slow");

}

/*
jQuery.preloadImages = function() {
	for(var i = 0; i < arguments.length; i++) { jQuery('<img>').attr("src", arguments[i]); }
}
*/


function check_politica()  {

	if($("#leido").attr("checked")) {
		$("#boton_envio").attr("disabled", false);
	} else {
		$("#boton_envio").attr("disabled", true);
	}
}


var FormContacto = {
	init : function () {
		$("#CheckBoxAcceptLegalConditions").bind("change", function () {
			if ($(this).val() == "acepto") {
				$("#boton-enviar").attr("disabled", "");
			}
		});

		$.getScript('/resources/js/jquery/metadata.js')
		$.getScript('/resources/js/jquery/validate.js', function() {
			$.getScript('/resources/js/jquery/validate/messages_es.js', function() {
				$("#formulario-contacto").validate();
			});

		});

	}
}
var Slider = {
    init : function() {
        if ($("#slider").length > 0) {
            Slider.slide($("#slider"));
        }

        if ($("#slider-home").length > 0) {
           Slider.slide($("#slider-home"));
        }
    },
    slide : function (item) {
        $(item).nivoSlider({
            effect : 'boxRain',
            controlNav : false,
            directionNav : false,
            pauseTime:5000
        });
    }
};


$(document).ready(function() {
    Slider.init();
	FormContacto.init();
});



