$(window).load(function () {
	miNivo();
	login_control();
	menu_control();
	control_pie();
});

function menu_control() {
	$("nav > div").hover(
		function () {
			$("a:first",$(this)).toggleClass("actv",true);
			$(".subNav",$(this)).stop(true,true).fadeIn('fast');
			//alert("hgas")
		},
		function () {
			$("a:first",$(this)).toggleClass("actv",false);
			$(".subNav",$(this)).stop(true,true).fadeOut('normal');
		}
	)
	$("nav2 > div").hover(
		function () {
			$("a:first",$(this)).toggleClass("actv",true);
			$(".subNav",$(this)).stop(true,true).fadeIn('fast');
			//alert("hgas")
		},
		function () {
			$("a:first",$(this)).toggleClass("actv",false);
			$(".subNav",$(this)).stop(true,true).fadeOut('normal');
		}
	)
}


function login_control() {
	var $loginPanel	= $("#loginPanel");
	$loginPanel.css({
		
	})
	$("#access .acceso").click(function () {
		if ($loginPanel.is(":visible")) {
			$loginPanel.animate({
				opacity: 0,
				top: '+=15px'
			},'fast','', function () {
				$loginPanel.css("display","none");
			});
			//$loginPanel.fadeOut();
			/*$loginPanel.stop(0,0).animate({
				
			},'normal','');*/
		} else {
			$loginPanel.css("display","block").animate({
				opacity: 1,
				top: '-=15px'
			},'fast','');
			//$loginPanel.fadeIn();
			/*
			$loginPanel.stop(0,0).animate({
				
			},'normal','');*/
		}
		return false;
	})
}

function miNivo() {
	
	$('#slider').nivoSlider({
        effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:500, // Slide transition speed
        pauseTime:2500, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:true, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:true, // 1,2,3... navigation
        controlNavThumbs:false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav:true, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });
	
	$('#sliderFld').nivoSlider({
        effect:'boxRandom', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:500, // Slide transition speed
        pauseTime:2500, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:true, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:true, // 1,2,3... navigation
        controlNavThumbs:false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav:true, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });
	$(".cicle_pie").cycle({ 
		fx:    'fade', 
		sync:   0, 
		delay: -4000 ,
		speed:  3000 
	 });
	
	
}

function control_pie(){
	$("#aviso_legal").die().live("click",function(){
		var dialog = $("<div id='aviso_legal' title='Aviso legal'></div>").insertAfter('body');
		$(dialog).load("aviso_legal.php", function () {
			$(dialog).dialog({
				resizable: false,
				modal: true,
				position: ['center',150],
				overlay: {
					opacity: 0.5,
					background: "black"
				},
				width: 600,
				height: 400/*,
				buttons:botones,
				open:function(){
					dominios_acciones("dominios",'validar');
					$.unblockUI();		
				}*/
			});
		});
	});
	
	$("#privacidad").die().live("click",function(){
		var dialog = $("<div id='privacidad' title='Pol&iacute;tica de privacidad'></div>").insertAfter('body');
		$(dialog).load("privacidad.php", function () {
			$(dialog).dialog({
				resizable: false,
				modal: true,
				position: ['center',150],
				overlay: {
					opacity: 0.5,
					background: "black"
				},
				width: 600,
				height: 400/*,
				buttons:botones,
				open:function(){
					dominios_acciones("dominios",'validar');
					$.unblockUI();		
				}*/
			});
		});
	});
}

