// JavaScript Document

var sottomenu;
var negozio_attivo="";

$(document).ready( function() {

	$(".leftCol ul.mainmenu>li>a").click( function() {
		
		if(negozio_attivo==$(this).attr("href")) {

			$(".leftCol ul.mainmenu li a."+negozio_attivo).parent().animate({
				height: '49px'
			}, 800, function() {
				//$(this).children("ul").fadeOut(0);

			});	
			negozio_attivo = '';
		} else {
			
			if(negozio_attivo!="") {

				$(".leftCol ul.mainmenu li a."+negozio_attivo).parent().animate({
					height: '49px'
				}, 800, function() {
					//$(this).children("ul").fadeOut(0);
	
				});
			}
			
			$(this).parent().animate({
				height: $(this).parent().children("ul").height()+70
			}, 800, function() {
				//$(this).children("ul").fadeIn(500);

			});
			negozio_attivo = $(this).attr("href");
		}
		return false;
	});
	
	$(".rightCol .bannerone").fadeOut(0);
	$(".rightCol .bannerone").fadeIn(1500);

	$('#orari').mouseenter( function() {
		//$('.popuporari').fadeIn(500);
		$('.popuporari').show();
	});
	
	$('#orari').mouseleave( function(event) {
		//$('.popuporari').fadeOut(500);
		$('.popuporari').hide();
	});
	
	$('#indicazioni').mouseenter( function() {
		//$('.popuporari').fadeIn(500);
		$('.popupindicazioni').show();
	});
	
	$('#indicazioni').mouseleave( function(event) {
		//$('.popuporari').fadeOut(500);
		$('.popupindicazioni').hide();
	});
	
	$('#mainMenu .voci ul li.submenu a').click( function() {
		$("."+sottomenu).hide();
		sottomenu = $(this).attr("href");
		$('#mainMenu').animate({
			height: '168px'
		}, 800, function() {
			$("."+sottomenu).fadeIn(500);
		});
		return false;
	});
	
	$('#mainMenu .voci ul li.submenu').mouseleave( function() {
		$("."+sottomenu).fadeOut(200);

		$('#mainMenu').animate({
			height: '42px'
		}, 800, function() {
			$("."+sottomenu).hide();
		});
	});
	
	//create a bubble popup for each DOM element with class attribute as "text", "button" or "link" and LI, P, IMG elements.
	$('.baloon').CreateBubblePopup({

		position : 'top',
		align	 : 'center',

		innerHtml: 'Questa sezione sar&agrave;<br/> presto online.',

		innerHtmlStyle: {
			color:'#FFFFFF',
			'text-align':'center'
		},

		themeName: 	'all-black',
		themePath: 	'img'

	});

})

function resizeCol() {

	if($(".leftCol").height()<$(".rightCol").height()) {
		$(".leftCol").css("min-height",$(".rightCol").height())
	}

}

function attivaScheda(id){
	//$('#scheda'+id).parent().prev().click();
	$('#scheda'+id).parent().parent().height('auto');
	negozio_attivo=$('#scheda'+id).parent().prev().attr('href');
	$('#scheda'+id).addClass('selected');
}

function ShareUrl(tipo, linkStatus)
	{
		var myActualUrl = document.location.href;
		var myFinalUrl = '';
		var myTitle = document.title;
		var myText="Fiordaliso - " + linkStatus;
		switch (tipo.toLowerCase())
		{
			case 'facebook' :
				myFinalUrl = 'http://www.facebook.com/sharer.php?u=' + myActualUrl + '&t=' + myText;
				break;
			case 'twitter' :
				myFinalUrl = 'http://twitter.com/?status=' + linkStatus + ' ' +  myActualUrl
				break;
		}
		var stile = "top=10, left=10, width=730, height=660, status=no, menubar=no, toolbar=no scrollbar=no";
		Popup(myFinalUrl,'scrollbars=1, location=1, status=1, resizable=1, toolbar=1, menubar=1');
	}
	

function Popup(url, stile) 
	{
		var stile = "top=10, left=10, width=730, height=660, status=no, menubar=no, toolbar=no scrollbar=no";
		window.open(url, "popup", stile);
	}
