// SMOOTH SCROLL
$(document).ready(function(){
	$(".scroll").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();

		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;

		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];

		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;

		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 500);
	});
});
// CAROSELLO
$(function() {
	$('.headfade .headitem').dumbCrossFade({'slideType':'fade','doHoverPause':false, 'showTime':3000});
});

/* FADE OUT */		
$(document).ready(function() {
	$("li.menu-item a[href!='#'], li.menu-item ul.sub-menu li.menu-item a").click(function(event){
		event.preventDefault();
		linkLocation = $(this).attr('href');
	//	$("#header").fadeOut(1000);
	//	$("#content").fadeOut(1000);		
		$("#page").fadeOut(1000, redirectPage);		

	});
		
	function redirectPage() {
		window.location = linkLocation;
	}
});

// FADE IN
/*
(function(jQuery) {
jQuery.fn.fadeInSequence = function(fadeInTime, timeBetween)
{
    //Default Values
    timeBetween = typeof(timeBetween) == 'undefined' ? 0 : timeBetween;
     fadeInTime = typeof(fadeInTime) == 'undefined' ? 500 : fadeInTime;
 
    //The amount of remaining time until the animation is complete.
    //Initially set to the value of the entire animation duration.
    var remainingTime = jQuery(this).size() * (fadeInTime+timeBetween);
 
    var i=0; //Counter
    return jQuery(this).each(function()
    {
        //Wait until previous element has finished fading and timeBetween has elapsed
        jQuery(this).delay(i++*(fadeInTime+timeBetween));
 
        //Decrement remainingTime
        remainingTime -= (fadeInTime+timeBetween);
 
        if(jQuery(this).css('display') == 'none')
        {
            jQuery(this).fadeIn(fadeInTime);
        }
        else //If hidden by other means such as opacity: 0
        {
            jQuery(this).animate({'opacity' : 1}, fadeInTime);
        }
 
        //Delay until the animation is over to fill up the queue.
        jQuery(this).delay(remainingTime+timeBetween);
 
    }); 
 
};
 
})(jQuery);
*/
// FLOAT MENU
/*
	var name = "#headwrap";
	var menuYloc = null;
	
		$(document).ready(function(){
			menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")))
			$(window).scroll(function () { 
				offset = menuYloc+$(document).scrollTop()+"px";
				$(name).animate({top:offset},{duration:500,queue:false});
			});
		}); 
*/
