/**
 * @author Hasan Bjaili
 */


jQuery(document).ready(function(){

//	jQuery("ul#uppermenu li").hover(function(){ //On hover...
//		var thumbOver = jQuery(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
//		jQuery(this).find("a.thumb").css({
//			'background': 'url(' + thumbOver + ') no-repeat center bottom'
//		});
//		//Fade the image to 0 
//		jQuery(this).find("span").stop().fadeTo('normal', 0, function(){
//			jQuery(this).hide() //Hide the image after fade
//		});
//	}, function(){ //on hover out...
//		//Fade the image to 1 
//		jQuery(this).find("span").stop().fadeTo('normal', 1).show();
//	});
	
	jQuery('#ticker').innerfade({
		animationtype: 'slide',
		speed: 750,
		timeout: 6000,
		type: 'random',
		containerheight: '20px'
	});
	
	
	jQuery("div#slider").easySlider({
		auto: true,
		continuous: false,
		vertical: true,
		prevText: '',
		nextText: ''
	});
	
	jQuery("#accordion1").msAccordion({
			defaultid:-1, vertical:true, collapsible:true 
		});
	jQuery("#accordion2").msAccordion({
			defaultid:-1, vertical:true, collapsible:true 
		});	
			
			
	
});

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 = 0;
				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.find("li").each(function(i){
				stripWidth += jQuery(this, i).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", -stripWidth); scrollnews(totalTravel, defTiming);});
				}
				$strip.css('left', -stripWidth);
				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);
				});			
		});	
};
				
jQuery(function(){jQuery("ul#ticker01").liScroll();});

				
