// JavaScript Document

function console_log(valore) {
	try {
		console.log(valore);
	} catch (error) {}
}

function initialize() {
var myLatlng = new google.maps.LatLng(44.043936, 12.567501);
var myOptions = {
  zoom: 15,
  center: myLatlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP
}

var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

var contentString = '<div id="content-mappa" class="content-mappa">'+
    '<div id="siteNotice">'+
    '</div>'+
    '<h2><strong>Garden Sporting Center</strong><br>Polisportiva Garden S.R.L</h2>'+
    '<div id="bodyContent">'+
    '<p>via Euterpe, 7 47900 Rimini, Italia<br>'+
    'Tel. 0541 774 230<br>'+
    'email. <a href="mailto:info@gardensportingcenter.it">info@gardensportingcenter.it</a><br>'+
    'web. <a href="http://www.gardensportingcenter.it">www.gardensportingcenter.it</a></p>'+
    '</div>'+
    '</div>';

var infowindow = new google.maps.InfoWindow({
    content: contentString
});

var marker = new google.maps.Marker({
    position: myLatlng,
    map: map,
    title:"Uluru (Ayers Rock)"
});

google.maps.event.addListener(marker, 'click', function() {
  infowindow.open(map,marker);
});
}


$(document).ready(function () {
        
        // Iscrizione alla newsletter
	$('#submit-newsletter').click(function () {
		
		if($('#privacy:checked').val() == "si") {
			$('#subForm').submit();
		}
		
	})
        
	// Comportamenti campi input e textarea
		
	$('input,textarea').emuPlaceholder();
	
	// Grafica dei menu generale
	
	$('#navigation>ul>li:first').addClass("first");
	$('#navigation>ul>li:last').addClass("last");
	$('#navigation>ul>li').each(function () {
		
		if ($(this).find("ul").html() != null) {
			$(this).addClass("over-active");
			$(this).children("ul").children("li:last").addClass("last");
		}
	});
	
	// Spot homepage
	
	$('.spot:last').css("border","none");
	var xx = 0
	var yy = 0;
	
	$('.tooltip').hide();
	
	
	$('.home .spot').mouseenter( function () {
		pos= $(this).offset();
		$('.inside-tooltip').css("background" , "url('" + $(this).attr("url")+ "') center center no-repeat #fff");
		$('.tooltip').show().stop().animate ({ top: "290px" , left: (pos.left - 15) + "px" ,opacity: 0 } ,0).animate({top:"275px" , left: (pos.left-15) +"px" ,opacity: 1});
		
	});
	
	$('.home .spot').mouseleave( function () {
		$('.tooltip').hide();
	});
	
	$('.home .spot').click( function (e) {
		
		e.preventDefault();
		var a = $(this).children("a").attr("href");
		var t = $(this).children("a").attr("target");
		document.location.href = a;
		
	});
	
	
	/*$('.home .spot').each( function(i) {
		
		$('#text-spothome-'+i).mouseenter( function () {
			
			pos= $(this).position();
			alert( pos.left + " " + pos.top);
			$('.tooltip').position({ left: pos.left , top: pos.top });	
			$('.tooltip').show();
		});
		
		$('#text-spothome-'+i).mouseleave( function () {
			$('.tooltip').hide();
		});
			
	})*/
	
	/*
	$('.home .img-spot').each(function (i) {
				
		xx= $('#text-spothome-'+i).position();
		yy = $('#img-spothome-'+i).position();
		
		$('#text-spothome-'+i).mouseenter( function () {
			
			$('.tooltip').offset({ left: xx.left , top:"0px" });	
		});
		
		$('#text-spothome-'+i).mouseleave( function () {
			//$('#img-spothome-'+i).offset({ left: xx.left , top:"-120px" });
		});
		
	});
	*/
	
			
	// Menu laterale 
	$('ul.menu-sidebar').each(function () {
		$(this).children("li:last").css("border","none");
		//$('ul.menu-sidebar li:last').css("border","none");
	});
	
	
	
	// Error page
	if (typeof(errorPage) != "undefined") {
		$('li.current_page_item').removeClass(	"current_page_item");
		$('li.current_page_parent').removeClass("current_page_parent");
	}
	
	// Post page
	$('.post .inside-content:last, .search .inside-content:last').css("border","none");
	
	
	
	// Tab menu
	// inverte la posizione dei menu se escono dalla pagina (970px)
		
	$('#navigation>ul>li').each( function (e) {
		
			var width =  $(this).parent().width()
			var widthme = $(this).children("a").width()
			var parent = $(this);
			var me = $(this).children("ul");
			var posizione =me.position();
			var offset = parent.position();
			
			if (posizione) {
				
				offset.left += 200;
				if (offset.left >= width) {
					
					$(this).children("ul").addClass("invert");
					
				}
				
			}
		
	});
	
	
});


