// @info 	Check current pag
// @usage	if($.isPage('pageName'))
jQuery.isPage = function(checkFor) {

	var url = window.location.pathname;	
	var page = url.split('/');
	
	if(checkFor == page[1]){
		return true;
	}else{
		return false;
	}
	
}


jQuery.fn.aniMove = function(e) {
	var $this = e;
	
	var first 	= 0;
	var speed 	= 1000;
	var pause 	= 2000;
	var h 		= $this.children(':first').height();
	var m 		= 21;
	var m 		= h + m;

	setInterval(
		function (){
			content = '<div class="sponsor-container">'+ $this.children(':first').html() + '</div><!-- /sponsor-container -->';
			$this.children(':first')
			.animate({'marginTop': '-'+ m +'px'}, speed)
			.fadeOut('200', 
				function() {
					jQuery(this).remove();
				}
			);
			$this.append(content)
			$this.children(':last').fadeIn('slow');

			jQuery('a.sponsor')
				.hover(
					function(){
						jQuery(this).stop().animate({'marginTop':'-60px'}, 300);
					}, function(){
						jQuery(this).stop().animate({'marginTop':'0'}, 300);
					}
				)

		}, 
	pause);
		

};

jQuery(document).ready(function($) {
/*
	$('li.page-item-8, li.page-item-5').children('a').click(function(){
		return false;
	});
*/	
/*
	$('li.page-item-3').children('a').click(function(){
		window.open('piu-cavalli-alla-tua-moto/', '_self');
		return false;
	});
*/

	$('li.page-item-5 > ul > li > a').click(function(){
		return false;
	});
	
	$('a.sponsor')
		.hover(
			function(){
				$(this).stop().animate({'marginTop':'-60px'}, 300);
			}, function(){
				$(this).stop().animate({'marginTop':'0'}, 300);
			}
		)
		.click(
			function(){
				window.open($(this).attr('href'), '_blank')
				return false;
			}
		);

	$('div.scroller').aniMove($('div.scroller'));
	
	if($.isPage('contatti')){
		$('div#google').googleMap({
			  coord			: '45.731398,12.240709'
			, mapZoom		: 15
			, tipWidth		: 126
			, tipHeight		: 65
			, tipImage		: '/wp-content/themes/teambaroni/style/images/tipGoogleMap.png'

		});
	}
	
});

