$(function() {
	$('#globalMap a').bind('mouseover', function() {
		if ($.browser.msie && $.browser.version.substr(0,1)<7) {
			$(this).next('p').show();
		}
		else {
			$(this).next('p').fadeIn();
		}
	});
	$('#globalMap a').bind('mouseout', function() {
		if ($.browser.msie && $.browser.version.substr(0,1)<7) {
			$(this).next('p').hide();
		}
		else {
			$(this).next('p').fadeOut();
		}
	});
	
	$('#quote').cycle('fade');
	
	$('.showTab').bind('click', function() {
		if (!$(this).is('.tabSelected')) {
			$('.tabSelected').removeClass('tabSelected');
			$(this).addClass('tabSelected');
			var tabIDToShow = $(this).attr('id').substring(3);
			$('.tabbedContent').hide();
			$('#tab'+tabIDToShow+'Content').show();
		}
	});
	
	$('#tickerSlider').serialScroll({
		items:'li',
		duration:8000,
		force:true,
		easing:'linear',
		interval:1,
		step:1,
		cycle:false, //don't pull back once you reach the end
		lazy: true,
		onBefore:function(e, elem, $pane, $items, pos) {
			/**
			* 'this' is the triggered element 
			* e is the event object
			* elem is the element we'll be scrolling to
			* $pane is the element being scrolled (#slideshow)
			* $items is the items collection at this moment
			* pos is the position of elem in the collection
			* if it returns false, the event will be ignored
			*/
			//those arguments with a $ are jqueryfied, elem isn't.
			e.preventDefault();
			var slideshowList = $pane.children('ul');
			slideshowList.children('li').eq(pos-1).clone().appendTo(slideshowList);
		}
	});
	
	$('#slideshow').serialScroll({
		items:'li',
		duration:5000,
		force:true,
		easing:'linear',
		interval:1,
		step:1,
		cycle:false, //don't pull back once you reach the end
		lazy: true,
		onBefore:function(e, elem, $pane, $items, pos) {
			/**
			* 'this' is the triggered element 
			* e is the event object
			* elem is the element we'll be scrolling to
			* $pane is the element being scrolled (#slideshow)
			* $items is the items collection at this moment
			* pos is the position of elem in the collection
			* if it returns false, the event will be ignored
			*/
			//those arguments with a $ are jqueryfied, elem isn't.
			e.preventDefault();
			var slideshowList = $pane.children('ul');
			slideshowList.children('li').eq(pos-1).clone().appendTo(slideshowList);
		}
	});
	
	$('#accordion h3').bind('click', function() {
		if (!$(this).siblings('.element').is(':visible')) {
			$('.openedAccordion').slideUp().removeClass('openedAccordion');
			$(this).siblings('.element').slideDown().addClass('openedAccordion');
		}
	});
});
