    //////////////////////////////////////////////////////////////////////////////// FLASH FIX ACTIVE-X
var isIE=(navigator.appVersion.indexOf("MSIE")!=-1)?true:false;var isWin=(navigator.appVersion.toLowerCase().indexOf("win")!=-1)?true:false;var isOpera=(navigator.userAgent.indexOf("Opera")!=-1)?true:false;function ControlVersion(){var version;var axo;var e;try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");version=axo.GetVariable("$version")}catch(e){}if(!version){try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");version="WIN 6,0,21,0";axo.AllowScriptAccess="always";version=axo.GetVariable("$version")}catch(e){}}if(!version){try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");version=axo.GetVariable("$version")}catch(e){}}if(!version){try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");version="WIN 3,0,18,0"}catch(e){}}if(!version){try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");version="WIN 2,0,0,11"}catch(e){version=-1}}return version}function GetSwfVer(){var flashVer=-1;if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]){var swVer2=navigator.plugins["Shockwave Flash 2.0"]?" 2.0":"";var flashDescription=navigator.plugins["Shockwave Flash"+swVer2].description;var descArray=flashDescription.split(" ");var tempArrayMajor=descArray[2].split(".");var versionMajor=tempArrayMajor[0];var versionMinor=tempArrayMajor[1];var versionRevision=descArray[3];if(versionRevision==""){versionRevision=descArray[4]}if(versionRevision[0]=="d"){versionRevision=versionRevision.substring(1)}else if(versionRevision[0]=="r"){versionRevision=versionRevision.substring(1);if(versionRevision.indexOf("d")>0){versionRevision=versionRevision.substring(0,versionRevision.indexOf("d"))}}var flashVer=versionMajor+"."+versionMinor+"."+versionRevision}}else if(navigator.userAgent.toLowerCase().indexOf("webtv/2.6")!=-1)flashVer=4;else if(navigator.userAgent.toLowerCase().indexOf("webtv/2.5")!=-1)flashVer=3;else if(navigator.userAgent.toLowerCase().indexOf("webtv")!=-1)flashVer=2;else if(isIE&&isWin&&!isOpera){flashVer=ControlVersion()}return flashVer}function DetectFlashVer(reqMajorVer,reqMinorVer,reqRevision){versionStr=GetSwfVer();if(versionStr==-1){return false}else if(versionStr!=0){if(isIE&&isWin&&!isOpera){tempArray=versionStr.split(" ");tempString=tempArray[1];versionArray=tempString.split(",")}else{versionArray=versionStr.split(".")}var versionMajor=versionArray[0];var versionMinor=versionArray[1];var versionRevision=versionArray[2];if(versionMajor>parseFloat(reqMajorVer)){return true}else if(versionMajor==parseFloat(reqMajorVer)){if(versionMinor>parseFloat(reqMinorVer))return true;else if(versionMinor==parseFloat(reqMinorVer)){if(versionRevision>=parseFloat(reqRevision))return true}}return false}}function AC_AddExtension(src,ext){if(src.indexOf('?')!=-1)return src.replace(/\?/,ext+'?');else return src+ext}function AC_Generateobj(objAttrs,params,embedAttrs){var str='';if(isIE&&isWin&&!isOpera){str+='<object ';for(var i in objAttrs){str+=i+'="'+objAttrs[i]+'" '}str+='>';for(var i in params){str+='<param name="'+i+'" value="'+params[i]+'" /> '}str+='</object>'}else{str+='<embed ';for(var i in embedAttrs){str+=i+'="'+embedAttrs[i]+'" '}str+='> </embed>'}document.write(str)}function AC_FL_RunContent(){var ret=AC_GetArgs(arguments,".swf","movie","clsid:d27cdb6e-ae6d-11cf-96b8-444553540000","application/x-shockwave-flash");AC_Generateobj(ret.objAttrs,ret.params,ret.embedAttrs)}function AC_SW_RunContent(){var ret=AC_GetArgs(arguments,".dcr","src","clsid:166B1BCA-3F9C-11CF-8075-444553540000",null);AC_Generateobj(ret.objAttrs,ret.params,ret.embedAttrs)}function AC_GetArgs(args,ext,srcParamName,classid,mimeType){var ret=new Object();ret.embedAttrs=new Object();ret.params=new Object();ret.objAttrs=new Object();for(var i=0;i<args.length;i=i+2){var currArg=args[i].toLowerCase();switch(currArg){case"classid":break;case"pluginspage":ret.embedAttrs[args[i]]=args[i+1];break;case"src":case"movie":args[i+1]=AC_AddExtension(args[i+1],ext);ret.embedAttrs["src"]=args[i+1];ret.params[srcParamName]=args[i+1];break;case"onafterupdate":case"onbeforeupdate":case"onblur":case"oncellchange":case"onclick":case"ondblclick":case"ondrag":case"ondragend":case"ondragenter":case"ondragleave":case"ondragover":case"ondrop":case"onfinish":case"onfocus":case"onhelp":case"onmousedown":case"onmouseup":case"onmouseover":case"onmousemove":case"onmouseout":case"onkeypress":case"onkeydown":case"onkeyup":case"onload":case"onlosecapture":case"onpropertychange":case"onreadystatechange":case"onrowsdelete":case"onrowenter":case"onrowexit":case"onrowsinserted":case"onstart":case"onscroll":case"onbeforeeditfocus":case"onactivate":case"onbeforedeactivate":case"ondeactivate":case"type":case"codebase":case"id":ret.objAttrs[args[i]]=args[i+1];break;case"width":case"height":case"align":case"vspace":case"hspace":case"class":case"title":case"accesskey":case"name":case"tabindex":ret.embedAttrs[args[i]]=ret.objAttrs[args[i]]=args[i+1];break;default:ret.embedAttrs[args[i]]=ret.params[args[i]]=args[i+1]}}ret.objAttrs["classid"]=classid;if(mimeType)ret.embedAttrs["type"]=mimeType;return ret}
    //////////////////////////////////////////////////////////////////////////////// AJAX
// Esegui il tutto quando il DOM è carico
window.addEvent('domready', function() {
	
	
	
	// HashListener per BACK/FORWARD browser button
	document.id = function (par) { return $(par); }
	var HM =  new HashListener();
	
	//add an event listener to the manager
	HM.addEvent('hash-changed',function(new_hash){
		if (new_hash == '') return;
		new_hash = new_hash.replace("&amp;", "&");
		startAjaxLink(new_hash);
	});

	HM.start(); //Will start listening to hash changes
	
	
	
	// Rendi AJAX possibile anche in locale
	if (location.protocol == 'file:') Request.implement({
		getXHR: function() { return (window.ActiveXObject) ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(); },
		isSuccess: function() { return (!this.status || (this.status >= 200) && (this.status < 300)); }
	});
	
	// Oggetto per la richiesta
	var req = new Request({
		
		// Opzioni
		duration: 'long',
		evalScripts: true, 
		
		// Eventi
		onFailure: function()    { $('contents').set('html', '<b>Fallita</b>'); },
		onSuccess: function(res) {
			$('contents').set('html', res);
			$('contents').getElements('a[rel=ajax]').addEvent('click', function(e) {
				e.stop();
				var url = this.getProperty('href');
				url = url.replace("http://" + window.location.hostname, "");
				url = url.replace("http://www." + window.location.hostname, "");
				HM.updateHash(url);
			});
			if ((typeof hideCiFrame != 'undefined') && ($('ciframe') != null)) hideCiFrame(); // Per nascondere l'iframe nei contatti
			fxL.start({'opacity': 0});
			fxL.chain( function() { 
				$('loading').setStyle('display', 'none');
				fxC.start({'opacity': 1});
			} );
		}
		
	});
	
	// Oggetti per il morph
	var fxC = new Fx.Morph('contents', {link: 'chain'});
	var fxL = new Fx.Morph('loading',  {link: 'chain'});
	
	// Aggiungi evento click ai link AJAX del menu
	$('menu').getElements('a[rel=ajax]').addEvent('click', function(e) {
		e.stop();
		var url = this.getProperty('href');
		url = url.replace("http://" + window.location.hostname, "");
		url = url.replace("http://www." + window.location.hostname, "");
		HM.updateHash(url);
	});
	// Aggiungi evento click ai link AJAX degli eventuali pager
	if ($('pager')) {
	 $('pager').getElements('a[rel=ajax]').addEvent('click', function(e) {
		e.stop();
		var url = this.getProperty('href');
		url = url.replace("http://" + window.location.hostname, "");
		url = url.replace("http://www." + window.location.hostname, "");
		HM.updateHash(url);
	});
	}
	// E anche a link interni... Perchè prima non lo feci?!?!?
	if ($('text')) {
		$('text').getElements('a[rel=ajax]').addEvent('click', function(e) {
			e.stop();
			var url = this.getProperty('href');
			url = url.replace("http://" + window.location.hostname, "");
			url = url.replace("http://www." + window.location.hostname, "");
			HM.updateHash(url);
		});
	}
	// Funzione per lanciare l'Ajax
	function startAjaxLink(url) {
		
		// Crea l'URL per l'AJAX
		if (url.indexOf('?') > 0) url += '&'; else url += "?";
		url += 'ajax=yes';
        
		// Cambia sfondi al flash
		sfwSetVar("bg", "onlyHome", (url.indexOf('index') != -1) ? 1 : 0);
		
		// Aggiorna l'oggetto Request
		req.url = url;
		
		// Lancia la richiesta
		var scroller = new Fx.Scroll(document.body);
		scroller.toTop();
		fxC.start({'opacity': 0});
		fxC.chain( function() {
			$('loading').setStyle('opacity', 0);
			$('loading').setStyle('display', 'block');
			fxL.start({'opacity': 0.5});
			fxL.chain( function() { req.send({url: url}) } );
		} );
		
	}
	
	
});
 
    //////////////////////////////////////////////////////////////////////////////// FLASH BACKGROUND
// Trova il filmato Flash
function swfGet(movieName) {
	if (window.document[movieName]) return window.document[movieName];
	if (navigator.appName.indexOf("Microsoft Internet") == -1)  {
		if (document.embeds && document.embeds[movieName])
			return document.embeds[movieName]; 
	} else return document.getElementById(movieName);
}

// Invia variabile al Flash
function sfwSetVar(swf, name, value) {
	var swfObject = swfGet(swf);
	swfObject.SetVariable("/:" + name, value);
}



    // Javascript Menu
        var previous = null
        var previous_class = null
        
        function activate_menu(which)
        {
            if (previous != null) {
                previous.className = previous_class
            }
            
            previous = which
            previous_class = which.className
            
            which.className = which.className + " menu-hover"

        }
    //////////////////////////////////////////////////////////////////////////////// MP3 PLAYER SHOP
// Script for NiftyPlayer 1.7, by tvst from varal.org
// Released under the MIT License: http://www.opensource.org/licenses/mit-license.php

var FlashHelper =
{
	movieIsLoaded : function (theMovie)
	{
		if (typeof(theMovie) != "undefined") return theMovie.PercentLoaded() == 100;
		else return
		false;
  },

	getMovie : function (movieName)
	{
  	if (navigator.appName.indexOf ("Microsoft") !=-1) return window[movieName];
	  else return document[movieName];
	}
};

function niftyplayer(name)
{
	this.obj = FlashHelper.getMovie(name);

	if (!FlashHelper.movieIsLoaded(this.obj)) return;

	this.play = function () {
		this.obj.TCallLabel('/','play');
	};

	this.stop = function () {
		this.obj.TCallLabel('/','stop');
	};

	this.pause = function () {
		this.obj.TCallLabel('/','pause');
	};

	this.playToggle = function () {
		this.obj.TCallLabel('/','playToggle');
	};

	this.reset = function () {
		this.obj.TCallLabel('/','reset');
	};

	this.load = function (url) {
		this.obj.SetVariable('currentSong', url);
		this.obj.TCallLabel('/','load');
	};

	this.loadAndPlay = function (url) {
		this.load(url);
		this.play();
	};

	this.getState = function () {
		var ps = this.obj.GetVariable('playingState');
		var ls = this.obj.GetVariable('loadingState');

		// returns
		//   'empty' if no file is loaded
		//   'loading' if file is loading
		//   'playing' if user has pressed play AND file has loaded
		//   'stopped' if not empty and file is stopped
		//   'paused' if file is paused
		//   'finished' if file has finished playing
		//   'error' if an error occurred
		if (ps == 'playing')
			if (ls == 'loaded') return ps;
			else return ls;

		if (ps == 'stopped')
			if (ls == 'empty') return ls;
			if (ls == 'error') return ls;
			else return ps;

		return ps;

	};

	this.getPlayingState = function () {
		// returns 'playing', 'paused', 'stopped' or 'finished'
		return this.obj.GetVariable('playingState');
	};

	this.getLoadingState = function () {
		// returns 'empty', 'loading', 'loaded' or 'error'
		return this.obj.GetVariable('loadingState');
	};

	this.registerEvent = function (eventName, action) {
		// eventName is a string with one of the following values: onPlay, onStop, onPause, onError, onSongOver, onBufferingComplete, onBufferingStarted
		// action is a string with the javascript code to run.
		//
		// example: niftyplayer('niftyPlayer1').registerEvent('onPlay', 'alert("playing!")');

		this.obj.SetVariable(eventName, action);
	};

	return this;
}
    //////////////////////////////////////////////////////////////////////////////// GUESTBOOK
function ajax(method,strURL,variable,value,sid) {
    
    var xmlHttpReq = false;
    var self = this;
	

    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open(method, strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
    self.xmlHttpReq.onreadystatechange = function() {
		
	if(value == 'signgb' ){
	document.signgb.signbutton.disabled = true;
	document.getElementById('signdiv').innerHTML = '<center><img src="images/loading.gif"><br><br><b>'+loadtext+'...</b><br></center>';
			
	}else{
	document.getElementById('entries').innerHTML = '<center><br><br><br><br><img src="images/loading.gif"><br><br><b>'+loadtext+'...</b><br><br><br></center>';
	}
	
       if (self.xmlHttpReq.readyState == 4) {
			if(value == 'signgb' ){
			updatepage(self.xmlHttpReq.responseText,'signgb');
			}else{
            updatepage(self.xmlHttpReq.responseText,'page');
			}
	   }
        
    }
	
	if (value == 'signgb'){
	name=document.signgb.name.value;
	//email=document.signgb.email.value;
	//homepage=document.signgb.homepage.value;
	message=document.signgb.message.value;
	
	//Fix the "&" bug
	name2 = name.replace(/&/g, "^amp^");
	message2 = message.replace(/&/g, "^amp^");
	
	self.xmlHttpReq.send('dosign=' + pcode.charAt(0) + pcode.charAt(2) + pcode.charAt(4) + pcode.charAt(1) + pcode.charAt(5) + '&name=' + name2 + '&message=' + message2);
	}else{
    self.xmlHttpReq.send(escape(variable) + '=' + escape(value));
	}
	
}



function updatepage(str, value){
	
	//if (self.xmlHttpReq.readyState == 4) {
	if (value == 'signgb'){
    document.getElementById("signdiv").innerHTML = str;
	showdiv('signdiv');
	document.signgb.signbutton.disabled = false;
	
	//Thanks to Hiric for the fix
	if (str.length <= 4) {  
		//Create cookie
		var date = new Date();
		date.setTime(date.getTime()+(c_minute*60*1000));
		var expires = "; expires="+date.toGMTString();
		document.cookie = "signed=yes"+expires+"; path=/";

		
        hidediv('signform'); 
        ajax('POST','gb_view.php','page','1'); 
      } 

	}else{
	document.getElementById("entries").innerHTML = str;
	showdiv('entries');
	}
	//}
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
	if(id == 'signform'){
	showdiv('entries');
	hidediv('signdiv');
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
	if(id == 'signform')
	hidediv('entries');
}
  function smiley(s){
  document.signgb.message.value = document.signgb.message.value + s;
  document.signgb.message.focus();
}

function newwindow(source,name,width,height) 
{ 
window.open(source,name,'width='+width+',height='+height+',resizable=no'); 
}      
