jQuery.fn.liScroll = function(settings) {
  	settings = jQuery.extend({
		travelocity: 0.07
		}, settings);		
		return this.each(function(){
				var $strip = jQuery(this);
				$strip.addClass("newsticker")
				var stripWidth = 1;
				$strip.find("li").each(function(i){
				stripWidth += jQuery(this, i).outerWidth(true); // thanks to Michael Haszprunar and Fabien Volpi
				});
				var $mask = $strip.wrap("<div class='mask'></div>");
				var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");								
				var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width 	
				$strip.width(stripWidth);			
				var totalTravel = stripWidth+containerWidth;
				var defTiming = totalTravel/settings.travelocity;	// thanks to Scott Waye		
				function scrollnews(spazio, tempo){
				$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth);scrollnews(totalTravel, defTiming);});
				}
				scrollnews(totalTravel, defTiming);				
				$strip.hover(function(){
				jQuery(this).stop();
				},
				function(){
				var offset = jQuery(this).offset();
				var residualSpace = offset.left + stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollnews(residualSpace, residualTime);
				});			
		});	
};

$(document).ready(function(){
       /* Binding a click event handler to the links: */
       $('.child').hide();
 //      $('.slider-wrapper').css('display', 'block');
      $('#ticker').css('display', 'block');
    $('.parent').click(function(){
        $('.parent').css('color','black');
        $(this).css('color','white');
        /* Finding the drop down list that corresponds to the current section: */
        var dropDown = $(this).parent().children('ul');
 
        /* Closing all other drop down sections, except the current one */
        $('.parent').parent().children('ul').not(dropDown).slideUp('slow');
        dropDown.slideDown('slow');
        /* Preventing the default event (which would be to navigate the browser to the link's address) */
        event.preventDefault();
        
    })
    
    $('#slider').nivoSlider({
        effect:'fold',
        slices:15,
        animSpeed:1000,
        pauseTime:8000,
        directionNav:false,
        controlNav:false
    });
    $("#ticker").liScroll({travelocity: .05});
});
$(window).load(function(){
    
    $('.slider-wrapper').css('display', 'block');
})

