/* Nome Cliente 	il Mosnel */
/* Creato:			19/02/2009 */
/* Autore:			simone@evoluzionetelematica.it */
/* Ultima Modifica:	gg/mm/aaaa	Autore: Nome Cognome */

//<![CDATA[

var ilmosnel = {

    // Utilizzare una variabile per fare riferimento al file SWF incorporato.

	startLoad: function(){
		if ($('flashContent')) ilmosnel.injectFlash()
		if ($$('.scroll') != '') ilmosnel.scrollbar()
		//if ($('banner')) ilmosnel.initBanner()
	},
	
	startDomReady: function(){
		//if ($('flashContent')) ilmosnel.injectFlash()
		if ($$('.boxed') != '') ilmosnel.initSqueezeBox()
		if ($$('.tips') != '') ilmosnel.toolTip()
	},	

	// metodo usato per ottenere il percorso giusto in base alla posizione
	returnPath: function()
	{
		var path = location.pathname;
		var li = path.length;
		var lf = path.replace(/\//g,'').length;
		// Windows var n = li-lf-2;
		var n = li-lf-1;
		var resultPath = "";
		
		for(var i=0; i<n; i++)
		{
		  resultPath += "../";
		}
		
		return resultPath
	}, // fine returnPath
	
	injectFlash: function() // inietto il file swf nel codice
	{
		// calcolo le dimensioni da assegnare al movie, "flashContent" varia in base alle sezioni
		var w = $('flashContent').getStyle('width').toInt();
		var h = $('flashContent').getStyle('height').toInt();
		var swf = ilmosnel.returnPath() + 'swf/main.swf';
		
		var myFlash = new Swiff(swf, {
			id: "main",
			width:  w,
			height: h,
			container: $('flashContent'),
			vars:
			{
				path: ilmosnel.returnPath(),
				xmlFile: _xmlFile,
				menuAttivo: _menuAttivo

				//xmlPath: ilmosnel.returnPath() + 'xml/'+_xmlPath+'.xml',
			},
			params:
			{
				salign: "lt"
    		},
			events:
			{
				onLoad: function() {
					// elimino l'img di fondo che funge da loader
					$('flashContent').setStyle('background', 'none');
				}
			}
		});
	},// end unjectFlash

	initBanner: function() // Usata per la Scrollbar dei testi
	{
		var bannerList = $$('#banner li')
		
		bannerList.each(function(element) {
			
			element.set('tween', {duration: 900});
			element.tween('margin-left', '370')
			
			element.addEvents({
				'mouseenter': function(){
					element.tween('margin-left', '0');
				},
				'mouseleave': function(){
					element.tween('margin-left', '370');
				}
			});
		
		})

	},

	scrollbar: function() // Usata per la Scrollbar dei testi
	{
		var myScroll = new MooScroll({selector:'.scroll', disabledOpacity:0});
	},
	

	initSqueezeBox: function() // Inizializzo lo squuezebox x effetto lightbox x iFrame
	{
		SqueezeBox.assign($$('.boxed'), {
			parse: 'rel'
		});
	}, // Fine initSqueezeBox()
	
	toolTip: function () 
	{
		var tooltips = $$('.tips');
		 
		var toolTips = new Tips(tooltips, {
			showDelay: 100,    //default is 100
			hideDelay: 100,   //default is 100
			className: 'tips', //default is null
			//this sets the x and y offets
			offsets: {
				'x': -100,       //default is 16
				'y': -45        //default is 16
			},
			fixed: false,      //default is false
			onShow: function(toolTipElement){
				toolTipElement.fade(1);
			},
			onHide: function(toolTipElement){
				toolTipElement.fade(0);
			}
		});


	} // fine tooltip
	
} // chiusura classe ilMosnel

///////////////////////////////////////////////////////

window.addEvent('domready', ilmosnel.startDomReady);
window.addEvent('load', ilmosnel.startLoad);
//]]>