
/////////////////////////////////////////////////////////////////////////
// variabili globali
//
//
//
// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// the version of javascript supported
var jsVersion = 1.0;
//
//
//
// -----------------------------------------------------------------------------
alternateContent = '<strong>Non è stato rilevato alcun tipo di flash player !!!<\/strong><br>'
  		+ 'Questo contenuto richiede la presenza di Macromedia Flash Player.<br>'
		+ "<em>"+document.title+" garantisce l'autenticità del contenuto da installare<\/em><br>"
		+ "Per utenti Windows Xp sp si raccomanda di leggere attentamente <br>"
		+ "i consigli di Macromedia durante l'installazione<br><br>"
		+ 'Per utenti Firefox, Mozzilla, Netscape, Opera il software non si installerà automaticamente<br>'
		+ 'ma richiederà il download di una applicazione, di cui si assicura il contenuto<br><br>'
   		+ '<a href=http://www.macromedia.com/go/getflash>Cliccare quì per iniziare il download</a>';
/////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
//
//
//
//
// FLASH OBJECT
/**
 * SWFObject v1.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formarly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
	if (!document.createElement || !document.getElementById) { return; }
	this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if(swf) { this.setAttribute('swf', swf); }
	if(id) { this.setAttribute('id', id); }
	if(w) { this.setAttribute('width', w); }
	if(h) { this.setAttribute('height', h); }
	if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute('version'), useExpressInstall);
	if(c) { this.addParam('bgcolor', c); }
	var q = quality ? quality : 'high';
	this.addParam('quality', q);
	this.setAttribute('useExpressInstall', useExpressInstall);
	this.setAttribute('doExpressInstall', false);
	var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
	this.setAttribute('xiRedirectUrl', xir);
	this.setAttribute('redirectUrl', '');
	if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	getAttribute: function(name){
		return this.attributes[name];
	},
	addParam: function(name, value){
		this.params[name] = value;
	},
	getParams: function(){
		return this.params;
	},
	addVariable: function(name, value){
		this.variables[name] = value;
	},
	getVariable: function(name){
		return this.variables[name];
	},
	getVariables: function(){
		return this.variables;
	},
	getVariablePairs: function(){
		var variablePairs = new Array();
		var key;
		var variables = this.getVariables();
		for(key in variables){
			variablePairs.push(key +"="+ variables[key]);
		}
		return variablePairs;
	},
	getSWFHTML: function() {
		var swfNode = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
			if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "PlugIn");
			swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
			swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
			var params = this.getParams();
			 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
			var pairs = this.getVariablePairs().join("&");
			 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
			swfNode += '>';
		} else { // PC IE
			if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "ActiveX");
			swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
			swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" >';
			var params = this.getParams();
			for(var key in params) {
			 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" >';
			}
			var pairs = this.getVariablePairs().join("&");
			if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" >';}
			swfNode += "</object>";
		}
		return swfNode;
	},
	write: function(elementId){
		if(this.getAttribute('useExpressInstall')) {
			// check to see if we need to do an express install
			var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
			if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
				this.setAttribute('doExpressInstall', true);
				this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title);
			}
		}
		if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
			var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
			n.innerHTML = this.getSWFHTML();
			return true;
		}else{
			if(this.getAttribute('redirectUrl') != "") {
				document.location.replace(this.getAttribute('redirectUrl'));
			}
		}
		return false;
	}
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(reqVer, xiInstall){
	var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
	if(navigator.plugins && navigator.mimeTypes.length){
		var x = navigator.plugins["Shockwave Flash"];
		if(x && x.description) {
			PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
		}
	}else{
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			for (var i=3; axo!=null; i++) {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
				PlayerVersion = new deconcept.PlayerVersion([i,0,0]);
			}
		}catch(e){}
		if (reqVer && PlayerVersion.major > reqVer.major) return PlayerVersion; // version is ok, skip minor detection
		// this only does the minor rev lookup if the user's major version 
		// is not 6 or we are checking for a specific minor or revision number
		// see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
		if (!reqVer || ((reqVer.minor != 0 || reqVer.rev != 0) && PlayerVersion.major == reqVer.major) || PlayerVersion.major != 6 || xiInstall) {
			try{
				PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
			}catch(e){}
		}
	}
	return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
	this.major = parseInt(arrVersion[0]) != null ? parseInt(arrVersion[0]) : 0;
	this.minor = parseInt(arrVersion[1]) || 0;
	this.rev = parseInt(arrVersion[2]) || 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
	if(this.major < fv.major) return false;
	if(this.major > fv.major) return true;
	if(this.minor < fv.minor) return false;
	if(this.minor > fv.minor) return true;
	if(this.rev < fv.rev) return false;
	return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
	getRequestParameter: function(param){
		var q = document.location.search || document.location.hash;
		if(q){
			var startIndex = q.indexOf(param +"=");
			var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
			if (q.length > 1 && startIndex > -1) {
				return q.substring(q.indexOf("=", startIndex)+1, endIndex);
			}
		}
		return "";
	}
}

/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}
/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;
//
//
//
//
<!-- // Detect Client Browser type
//
//
//
//
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;
jsVersion = 1.1;
//
//
//
// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	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;
			descArray = flashDescription.split(" ");
			tempArrayMajor = descArray[2].split(".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
      	} else {
			flashVer = -1;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	// Can't detect in all other cases
	else {
		
		flashVer = -1;
	}
	return flashVer;
}
//
//
//
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
{
 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
   	// loop backwards through the versions until we find the newest version	
	for (i=25;i>0;i--) {	
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer(i);		
		}
		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(".");
			}
			versionMajor      = versionArray[0];
			versionMinor      = versionArray[1];
			versionRevision   = versionArray[2];
			
			versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
			versionNum        = parseFloat(versionString);
        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
				return true;
			} else {
				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
			}
		}
	}	
}
// 
//
//
//
function leggi_variabile(vars) { 
	var indirizzo = window.location.toString() + '&';
	var posizione_nome = indirizzo.indexOf(vars + '='); 
	if (posizione_nome==-1){ 
		return ('')
	}; 
	var sottostringa = indirizzo.substring(posizione_nome); 
	var inizio=sottostringa.indexOf('='); 
	var fine=sottostringa.indexOf('&'); 
	var vars=sottostringa.substring(inizio + 1, fine); 
	return (vars);
}
//
//
//
//
function printCorrectHtml(){
	var hasProductInstall = DetectFlashVer(6, 0, 65);
	var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	if ( hasProductInstall && !hasReqestedVersion ) {
		return(1);
	} else if (hasReqestedVersion) {
		return(2);
  	}	else {
		return(3);
  	}
}
//
//
//
//
function apripopup(file,w,h) {
			if(w=="100%" && h=="100%"){
				w=screen.width;
				h=screen.height;
			}
			X = (screen.width - w) / 2;
        	Y = (screen.height - h) / 2;
        	P = "width=" + w + ",height=" + h + ",";
        	P+= "top=" + Y + ",left=" + X + ",";
        	P+= "scrollbars=no,status=no,resizable=no";
        	win = window.open(file, "popup", P);
			win.focus();
}
////////////////////////////////////////////////////////////////////////////////////
////funzione di scrittura html di flash bypassando protezione explorer
function printCorrectFlashHtml(file,destinazione,w,h,wmode,tipo,folder){
	if(printCorrectHtml()==2){
		if(tipo){
			fo = new FlashObject(file, "gallery", w, h, "8");
   			fo.addVariable("xmlFile",folder+tipo+".xml");
			if(wmode) fo.addParam("wmode","transparent");
			fo.addVariable("classid","clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");
			fo.addVariable("codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0");
			fo.addParam("pluginspage","http://www.macromedia.com/go/getflashplayer");
			fo.addParam("type","application/x-shockwave-flash");
			fo.addParam("allowScriptAccess","always");
			fo.write(destinazione);
		
		} else {
			fo = new FlashObject(file, "mymovie", w, h, "8");
			if(wmode) fo.addParam("wmode","transparent");
			fo.addVariable("classid","clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");
			fo.addVariable("codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0");
			fo.addParam("pluginspage","http://www.macromedia.com/go/getflashplayer");
			fo.addParam("type","application/x-shockwave-flash");
			fo.addParam("allowScriptAccess","always");
			fo.write(destinazione);
		}
	} else if(printCorrectHtml()==1){
		var MMredirectURL = window.location;
		document.title = document.title.slice(0, 47) + "";
		var MMdoctitle = document.title;
		fo = new FlashObject("playerProductInstall.swf", "detectiontest", w, h, "8");
   		fo.addVariable("MMredirectURL",MMredirectURL);
   		fo.addVariable("MMplayerType","PlugIn");
   		fo.addVariable("MMdoctitle",MMdoctitle);
   		fo.addVariable("MMplayerType","ActiveX");
		fo.write(destinazione);
		var nu = (typeof destinazione == 'string') ? document.getElementById(destinazione) : destinazione;
		nu.innerHTML = fo.getSWFHTML();
	} else {
		var n = (typeof destinazione == 'string') ? document.getElementById(destinazione) : destinazione;
		n.innerHTML = alternateContent;
	}
}
////////////////////////////////////////////////////////////////////////////////////
//
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//
function cambiaSfondo(folder,baseName,type){
	nSfondo = 4;
	nAdesso = Math.floor(Math.random()*nSfondo);
	document.write('<style type="text/css">\n');
	document.write('.sfondo_texture{background-image:url('+folder+baseName+nAdesso+type+')}\n');
	document.write('<\/style>\n');
}
////////////////////////////////////////////////////////////////////////
function validaMail(mail){
   filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
   if (filtro.test(mail)){
      return true;
   } else {
      return false;
   }
}
function validaTelefono(tel){
	if(tel.match(/\d{3}/)){
		return (true);
	} else {
		return (false);
	};
}
//////////////////////////////////////////////////////////////////////////
function fattura(num){
	file = 'showFattura.php?fattura='+num
	apripopup(file,800,600);
}
//////////////////////////////////////////////////////////////////////////
function preventivo(num){
	file = 'showPreventivo.php?preventivo='+num
	apripopup(file,800,600);
}

//////////////////////////////////////////////////////////////////////////
var sel=new Array()
		function MemMulti(ss){
			selezionePrecedente=sel.length-1
			sel.length=0
			trovato=0
			for(var i=0;i<ss.options.length;i++){
				if(ss.options[i].selected){
				sel[sel.length]=i	
				trovato++
				}
			}		
			//alert (selezionePrecedente)	
			if ((selezionePrecedente==1 && selezionePrecedente==trovato)||(selezionePrecedente==-1&& trovato==1)){
				for(i=0;i<ss.options.length;i++)
				ss.options[i].selected=false
			}
		}
		function SelMulti(ss){
			var ultimo='nessuno'
			for(var i=0;i<ss.options.length;i++)
				if(ss.options[i].selected)
					ultimo=i
			for(i=0;i<ss.options.length;i++)
				ss.options[i].selected=false
			for(i=0;i<sel.length;i++)
				ss.options[sel[i]].selected=true
			if(ultimo!='nessuno')
				ss.options[ultimo].selected=!ss.options[ultimo].selected
		}

