jQuery().ready(function(){      
	$("ul#ticker02").liScroll();

	
	$('#top-picks-slideshow').after('<div id="nav" class="nav">').cycle({ 
			fx:     'fade', 
			speed:  1000, 
    		timeout: 4000,    
			pager:  '#nav' 
		});
	
	$('#eventCarousel').cycle({ 
			fx:     'fade', 
			speed:  2000, 
    		timeout: 10000 
		});
	
	$('#toursCarousel').cycle({ 
			fx:     'fade', 
			speed:  2000, 
    		timeout: 10000 
		});
	
	 // Expand Panel
	$("#loginPanelOpen").click(function(){
		$("div#panelLogin").slideDown("slow");
		$("#loginPanelClose").removeClass('hide');
		$("#loginPanelOpen").hide();
		$(".topPanel").css({'z-index' : '1'});	
		$("#topPanelLogin").css({'z-index' : '9999'}); 
		$("#pollingPanelClose").click();
		$("#contactPanelClose").click();
		$("#languagePanelClose").click();
	});	
	
	// Collapse Panel
	$("#loginPanelClose").click(function(){
		$("div#panelLogin").slideUp("slow").css({'z-index' : '1'});	
		$("#loginPanelClose").addClass('hide');
		$("#loginPanelOpen").show();
		
	});	 
	
	$("#pollingPanelOpen").click(function(){
		$("div#panelPolling").slideDown("slow");
		$("#pollingPanelClose").removeClass('hide');
		$("#pollingPanelOpen").hide();
		$(".topPanel").css({'z-index' : '1'});	
		$("#topPanelPolling").css({'z-index' : '9999'});
		$("#loginPanelClose").click();
		$("#contactPanelClose").click();
		$("#languagePanelClose").click();
	});	
	
	//$("#PanelPollingForm").hide();
	$("#PanelPollingSelect").hide();
	
	$("#selectPolling").change(function() {
		$("#PanelPollingForm").show();
	});
	
	// Collapse Panel
	$("#pollingPanelClose").click(function(){
		$("div#panelPolling").slideUp("slow").css({'z-index' : '1'});		
		$("#pollingPanelClose").addClass('hide');
		$("#pollingPanelOpen").show(); 
	});	
	
	$("#contactPanelOpen").click(function(){
		$("div#panelContact").slideDown("slow");
		$("#contactPanelClose").removeClass('hide');
		$("#contactPanelOpen").hide();
		$(".topPanel").css({'z-index' : '1'});	
		$("#topPanelContact").css({'z-index' : '9999'});
		$("#pollingPanelClose").click();
		$("#loginPanelClose").click();
		$("#languagePanelClose").click();
	});	
	
	// Collapse Panel
	$("#contactPanelClose").click(function(){
		$("div#panelContact").slideUp("slow").css({'z-index' : '1'});		
		$("#contactPanelClose").addClass('hide');
		$("#contactPanelOpen").show(); 
	});	
	
	$("#languagePanelOpen").click(function(){
		$("div#panelLanguage").slideDown("slow");
		$("#languagePanelClose").removeClass('hide');
		$("#languagePanelOpen").hide();
		$(".topPanel").css({'z-index' : '1'});	
		$("#topPanelLanguage").css({'z-index' : '9999'});
		$("#pollingPanelClose").click();
		$("#contactPanelClose").click();
		$("#loginPanelClose").click();
	});	
	
	// Collapse Panel
	$("#languagePanelClose").click(function(){
		$("div#panelLanguage").slideUp("slow").css({'z-index' : '1'});	
		$("#languagePanelClose").addClass('hide');
		$("#languagePanelOpen").show(); 
	});	
	
	// Collapse Panel
	$("#navLevelTwoInner li a").hover(function() {  
		$(this).next(".navLevelThree").show();
		}, function(){	//On Hover Out
		$(this).next(".navLevelThree").hide();
	});
	
	$(".navLevelThree").hover(function() {  

		$(this).show();
		}, function(){	//On Hover Out
		$(this).hide();
  
	});
	
	 $('#blogTab').tabs({ fxFade: true, fxSpeed: 'fast' });
	 $("#blogTab li a").click(function(){
		return false;
	});	
	 
	
}); 

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).outerWidth(true); // thanks to Michael Haszprunar
				});
				$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);
				});			
		});	
};

