
$(document).ready(function() {

	//$("div.overlay").css("opacity", 0.5);

	Portada.init();
	Funciones.init();
    ExpedientesIva.init();
	if ($("a.fancybox-iva").length > 0)
		$("a.fancybox-iva").fancybox( { width : 654, height : 500,'type'	: 'iframe' } );


	if ($(".pago-online").length > 0)
		$(".pago-online").fancybox( { width: 650, height: 500, hideOnContentClick: false, 'type' : 'iframe'});

	if ($("a.mapa").length > 0)
		$("a.mapa").fancybox( { width: 625, height: 545, hideOnContentClick: false, 'type'	: 'iframe'});

	if ($("a.fancybox").length > 0)
		$("a.fancybox").fancybox( { width: 650, height: 540, "hideOnContentClick" : false, 'type' : 'iframe'} );

});

var interval;
var Portada = {
	child : 0,
	clearUser : 1,
	clearPass : 1,
	init : function() {

		if ($("ul#portada").length > 0) {
			$('ul#portada').roundabout({
				btnNext: '#portada-next',
				btnPrev: '#portada-prev',
				easing: 'easeOutElastic',
				"shape" : "square"
			}).bind("focus", function() {

			});

			$("#portada-prev").bind("click", function() {
				clearInterval(interval);
				//$('ul#portada').roundabout_animateToPreviousChild();
				//$('ul#portada').roundabout_updateChildPositions();
			});
			$("#portada-next").bind("click", function() {
				clearInterval(interval);
				//$('ul#portada').roundabout_animateToNextChild();

			});

			interval = setInterval(function() {
				$('ul#portada').roundabout_animateToPreviousChild();
			}, 5000);

		}

		if (jQuery().jCarouselLite)  {
			$(".scroll").jCarouselLite({
				btnNext: ".banner-next",
				btnPrev: ".banner-prev",
				visible: 3,
				scroll : 1

			});
		}


		$("#login-user").bind("click", function() {	if (Portada.clearUser-- > 0) $(this).val(""); });
		$("#login-password").bind("click", function() {	 if (Portada.clearPass-- > 0) $(this).val(""); });

	}
};



var Funciones = {
	init : function() {
		$("#select-subservicios").bind("change", function() { document.location = $(this).val(); })
	}
};

var ExpedientesIva = {
    init : function() {
        $("a.desplegar").click(function() {
            var detalle = $(this).parent().parent().next().find(".detalle");
            if (detalle.hasClass("desplegado")) {
                $(this).removeClass("desplegado");
                detalle.hide("slow").removeClass("desplegado");
            } else {
                detalle.show("slow").addClass("desplegado");
                $(this).addClass("desplegado");            
            }
            return false;
        });
    }
};


