// <![CDATA[
$(function() {
		   
// -------------------------- //
// -- -- Generic jQuery -- -- //
// -------------------------- //

	//Opens Links In External Window
	$("a[rel='external']").addClass("external").attr('title', function() { return this.title + ' (Opens in New Window)' }).click(function() { window.open(this.href); return false; });
	
	//Scroll To Back to Top
	$("a[href='#backtotop']").click(function() { $.scrollTo(0, 500); return false; }); 
	
	$('label.overlay').labelOver();
	
	$.fn.qtip.styles.motoTip = { // Last part is the name of the style
	   background: '#FFFFFF',
	   color: '#1FA5B1',
	   textAlign: 'center',
	   fontWeight: 'bold',
	   border: {
		  width: 1,
		  radius: 5,
		  color: '#1FA5B1'
	   }//,
	   //name: 'dark' // Inherit the rest of the attributes from the preset dark style
	}
	
	$("a.fancyBox").fancybox({'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': false }); 
	
	//Start Tool Tips
	$(".gmnoprint[src*='/development/']").live("mouseover",																	  
		function() {			
			if ($(this).attr('src') != '/development/map/icons/shadow.png') {
				var tipContent = $(this).attr('title');
				$(this).attr('rel', tipContent);
				$(this).removeAttr('title');
				$(this).qtip({	
					content: tipContent,	
					show: { ready: true },
					style: { name: 'motoTip', textAlign: 'center', tip: 'bottomMiddle'},
					position: { corner: { target: 'topMiddle', tooltip: 'bottomMiddle'}}				
				});	
			}
		}
	);
	
	$(".gmnoprint[src*='/development/']").live("mouseout",																	  
		function() {			
			if ($(this).attr('src') != '/development/map/icons/shadow.png') {
				var tipContent = $(this).attr('rel');
				$(this).attr('title', tipContent);						
			}
		}
	);
	
	twitter_name = 'motoway';
	if(twitter_name) {
		getTwitters('twitterFeed', { 
			id: twitter_name,
			count: 3,
			enableLinks: true,
			ignoreReplies: false,
			clearContents: true,
			template: '<p>%text%<br /><span class=\'tweetTime\'>%time%</span></p>'
		});	
	}	
	
});
function addCurrentToTweet () {
	$('#twitterFeed ul li:first-child').addClass('current')
}
autoAdd = setTimeout(addCurrentToTweet,3000);

function slideTweet() {
	var $active = $('#twitterFeed ul li.current');	
	if ( $active.length == 0 ) $active = $('#twitterFeed ul li:last');
	var $next =  $active.next().length ? $active.next()
        : $('#twitterFeed ul li:first');
	$active.addClass('last-current').hide();
	 $next.hide()
        .addClass('current')
        .fadeIn(1000, function() {
            $active.removeClass('current last-current');
        });	
}
autoCycle = setInterval(slideTweet, 6000);


$('.bannerAd').cycle({
		fx: 'fade',
		speed: 1000,
		timeout: 15500,
		random: 1
});

// ]]>
