/*
	@author gpx
	@version 0.1 del 2011 07 19
*/

var current_agenda;
var browser = false;


// -- youtube javascript API

function caricaFilmato( id )
{
	id = id.replace("https://www.youtube.com/watch?v=", "").replace("http://www.youtube.com/watch?v=", "");
	
	// da decommentare se si vuole mostrare il frame post video
	//$('div#post_video').hide();
	//$('#visore').show('fast');
	if ( browser || true)
	{
		var params = { allowScriptAccess: "always" };
		var atts = { id: "visore" };
		swfobject.embedSWF("http://www.youtube.com/e/"+id+"?enablejsapi=1&playerapiid=visore", "visore", "280", "156", "8", null, null, params, atts);
	} else {
	{
		$('#visore').html( '<iframe width="280" height="156" src="http://www.youtube.com/embed/'+id+'" frameborder="0" allowfullscreen></iframe>' );
	}
}
}

function onYouTubePlayerReady(playerId) {
	ytplayer = document.getElementById("visore");
	ytplayer.addEventListener("onStateChange", "onPlayerStateChange");
	ytplayer.addEventListener("onError", "onPlayerError");
}

function onPlayerStateChange( newState ) {
	
	
	// ended state
	if ( newState == 0 )
	{
		
		//$('#visore').hide();
		
		// da decommentare se si vuole mostrare il frame post video
		//$('div#post_video').fadeIn('fast');
	}
}


function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
	var rv = -1; // Return value assumes failure.
	if (navigator.appName == 'Microsoft Internet Explorer')
	{
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
			rv = parseFloat( RegExp.$1 );
	}
	return rv;
}
function checkVersion()
{
	var msg = "You're not using Internet Explorer.";
	var ver = getInternetExplorerVersion();
	
	if ( ver > -1 )
	{
		if ( ver >= 8.0 ) 
			msg = "You're using a recent copy of Internet Explorer."
		else {
			msg = "Attenzione! E' richiesta almeno la versione 7.0 di Microsoft Internet Explorer. Aggiorna il tuo browser e riprova, grazie!";
			alert( msg );
		}
	}
	browser = false;
	
}
//---



$(document).ready(function(){
	$('div#agende div' ).hover(
	function() {
		//alert( current_agenda );
		//$(current_agenda).stop(true,true);
		//$('div#agende div').stop(true, true );
		//$('div#agende div').css( 'margin', -100 );
		
		$('div#nomi_agende div#' +  $(this).attr('id') ).show(200);
		
		if ( $(this).attr('id')==( "agenda13" ) ) return;
		$(this).css( 'margin-right', 50 );
		//$(this).animate( {marginRight: 50}, 100 );
	}, 
	function() { 
		current_agenda = $(this).attr('id');
		//alert( current_agenda );
		//$(this).animate( {margin: -100}, 40 ); 
		$('div#agende div').css( 'margin-right', -70 );
		$('div#nomi_agende div').hide(30);
	});
	
	$('div#canarino').hover( 
		function(){ $('div#canarino a').show(); },
		function() { $('div#canarino a').hide(); } 
	);
	$('div#pappagallo').hover( 
		function(){ $('div#pappagallo a').show(); },
		function() { $('div#pappagallo a').hide(); } 
	);
});


