// ***** Start scroller #1

// Flash detect
function flashdetect(version) {
	var playerversion = version;

	if (navigator.appVersion.indexOf("MSIE 4.5") != -1) {
		return true;
	} else {
		var agent = navigator.userAgent.toLowerCase();
		gotflash = 0;

		if (navigator.mimeTypes
			&& navigator.mimeTypes["application/x-shockwave-flash"]
			&& navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin
			&& navigator.plugins
			&& navigator.plugins["Shockwave Flash"]){
			// NS3+ and Opera3+ (support plugin array):  check for Flash plugin in plugin array
			if (navigator.plugins != null && navigator.plugins.length > 0) {
				var flashPlugin = navigator.plugins['Shockwave Flash'];

				if (typeof flashPlugin == 'object') {
					desc = flashPlugin.description;
					startpnt = desc.indexOf('Flash') +6;
					endpnt = desc.indexOf('.');
					gotflash = parseInt((desc.substring(startpnt, endpnt)));
				}
			}
		}
		
		// Check the browser...we're looking for ie/win, but not aol
		var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
		var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; // true if we're on windows

		// This is a js1.1 code block, so make note that js1.1 is supported.
		jsVersion = 1.1;

		// Write vbscript detection on ie win. IE on Windows doesn't support regular
		// JavaScript plugins array detection.
		if(isIE && isWin) {
			var WM_startTagFix = '</';
			document.writeln('<script language="VBscript">');
			document.writeln('on error resume next');
			document.writeln('if IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.10")) then gotflash = 10');
			document.writeln('if gotflash < 10 and IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9")) then gotflash = 9');
			document.writeln('if gotflash < 9 and IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8")) then gotflash = 8');
			document.writeln('if gotflash < 8 and IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7")) then gotflash = 7');
			document.writeln('if gotflash < 7 and IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6")) then gotflash = 6');
			document.writeln('if gotflash < 6 and IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")) then gotflash = 5');
			document.writeln('if gotflash < 5 and IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")) then gotflash = 4');
			document.writeln('if gotflash < 4 and IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")) then gotflash = 3'); 
			document.writeln(WM_startTagFix+'script>');
		}		

		if (gotflash < playerversion) {
			// Flash 4 or later
			return false;
		} else {
		    // Flash 5 or more
			return true;
		} 
	}
} 



// Genera il flash o l'alternativa statica
function generatorflash(nomefile,width,height,bgcolor,version,playerversion,no1,no2) {
	var playerversion = 7;
	var N1;
	var NNONE;
	NNONE= no1;	
	

	N1=('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + version + '" ID="ticker_news" WIDTH="' + width + '" HEIGHT="' + height + '">');
	N1= N1+ ('<PARAM NAME=movie VALUE="' + nomefile + '">');
	N1= N1+ ('<PARAM NAME=quality VALUE=high>');
	N1= N1+ ('<PARAM NAME=bgcolor VALUE=#' + bgcolor + '>');
	N1= N1+ ('<PARAM NAME=menu VALUE=False>');
	N1= N1+ ('<PARAM NAME=borders VALUE=noborder>');
	N1= N1+ ('<PARAM NAME=loop VALUE=true>');
	N1= N1+ ('<embed src="' + nomefile + '" quality=high loop=true menu=false bgcolor=#' + bgcolor + '');
	N1= N1+ ('swLiveConnect="FALSE" WIDTH="' + width + '" HEIGHT="' + height + '" border="0" TYPE="application/x-shockwave-flash"');
	N1= N1+ ('PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></embed></OBJECT>')
	

	
	if (flashdetect(playerversion)) { 
	 document.write(N1);
	}
	else { 
	document.write(NNONE); 
	//setTimeout("document.location.replace('http://2003server/saleri/index_eng.asp')",5000); 
	}
}
function scrollObject(main, width, height, direct, pause, speed,numero_elementi) {
  
  
  var self = this;
  this.main = main;
  this.width = width;
  this.height = height;
  this.direct = direct;
  this.pause = pause;
  this.speed = Math.max(1.001, Math.min((direct == "up" || direct == "down") ? height : width, speed));
  this.slope = (direct == "up" || direct == "left") ? 5 : -5;
  this.prev = this.offset = 0;
  this.curr = 1;
  this.mouse = false;
  this.scroll = function() {
    this.main = document.getElementById(this.main);
    this.main.style.overflow = "hidden";
    this.main.style.position = "relative";
    this.main.style.width = this.width + "px";
    this.main.style.height = this.height + "px";
    var b = [], c;
    while (this.main.firstChild) if ((c = this.main.removeChild(this.main.firstChild)).nodeName == "DIV") b.push(c);
    for (var x = 0; x < b.length; x++) {
      var table = document.createElement('table');
          table.cellPadding = table.cellSpacing = table.border = "0";
          table.style.position = "absolute";
          table.style.left = table.style.top = "0px";
          table.style.width = table.style.height = "100%";
          table.style.overflow = table.style.visibility = "hidden";
        var tbody = document.createElement('tbody');
		var tr = document.createElement('tr');
		//  tr.setAttribute("valign", "top");
	//	tr.style.vertical-align = "top";
            var td = document.createElement('td');
			 td.setAttribute("valign", "top");
              while (b[x].firstChild)
                  td.appendChild(b[x].removeChild(b[x].firstChild));
              tr.appendChild(td);
            tbody.appendChild(tr);
          table.appendChild(tbody);
      this.main.appendChild(table);
    } b = c = null;
    if (this.main.childNodes.length > 1) {
      this.main.onmouseover = function() { self.mouse = false; };
      this.main.onmouseout = function() { self.mouse = false; };
      setInterval(function() {
        if (!self.offset && self.scrollLoop()) self.main.childNodes[self.curr].style.visibility = "visible";
      }, this.pause);
    } this.main.childNodes[this.prev].style.visibility = "visible";
  };
  this.scrollLoop = function() {
  	
    if (!this.offset) {
      if (this.mouse) return false;
      this.offset = (this.direct == "up" || this.direct == "down") ? this.height : this.width;
    } else this.offset = Math.floor(this.offset / this.speed);
    if (this.direct == "up" || this.direct == "down") {
      this.main.childNodes[this.curr].style.top = (this.offset * this.slope) + "px";
      this.main.childNodes[this.prev].style.top = ((this.offset - this.height) * this.slope) + "px";
    } else {
      this.main.childNodes[this.curr].style.left = (this.offset * this.slope) + "px";
      this.main.childNodes[this.prev].style.left = ((this.offset - this.width) * this.slope) + "px";
    }
    if (!this.offset) {
      this.main.childNodes[this.prev].style.visibility = "hidden";
      this.prev = this.curr;
      if (++this.curr >= this.main.childNodes.length) this.curr = 0;
    } else setTimeout(function() { self.scrollLoop(); }, 30);
    return true;
  };
  if (window.addEventListener) {
    window.addEventListener('load', function() { self.scroll(); }, false); 
  } else if (window.attachEvent)
    window.attachEvent('onload', function() { self.scroll(); });
}
function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}
function newXMLHttpRequest(){
				var xmlreq = false;
				
				//Controllo il tipo di oggetto XMLHttpRequest da utilizzare
				if(window.XMLHttpRequest){
					//Per browser non Microsoft
					xmlreq = new XMLHttpRequest();
				}else if(window.ActiveXObject){
					//Cerco di creare l'oggetto via MS ActiveX
					try{
						//Nuove versioni per browser IE
						xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
					}catch(e1){ //Errore riscontrato durante la creazione dell'oggetto
						try{
							//Precedenti versioni per browser IE
							xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
						}catch(e2){ //Nuovo errore durante la creazione dell'oggetto
							xmlreq = false;
						}
					}
				}
				//Restituisco l'eventuale oggetto XMLHttpRequest
				return xmlreq;
			}

function sendRequest() {
  
	 //Creo un nuovo oggetto XMLHTTPRequest
	var req = newXMLHttpRequest();
	var str="";
	//Invio la richiesta
	req.open("POST", "previsioni_meteo.asp", true);
	req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	
	//Invio i dati POST
	req.send(str);
	
	//Gestore dell'evoluzione dello stato dell'oggetto req
	
	req.onreadystatechange = handleResponse(req);
						
}

function ModalPopupVideo(v,titolo) {
	
	var r='';
	var width='340';
	var height='280';
	var bgcolor='FFFFFF';
	var version='6,0,0,0';
	var playerversion='8';
	var no1='';
	var no2='';
	

	N1=('<OBJECT  wmode="opaque" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + version + '" ID="ticker_news" WIDTH="' + width + '" HEIGHT="' + height + '">');
	N1= N1+ ('<PARAM NAME=movie VALUE="video.swf">');
	
	N1= N1+ ('<param name=flashvars value="vFilmato='+v+'&redirect=test.asp?var='+r +'">');
	N1= N1+ ('<PARAM NAME=quality VALUE=high>');
	N1= N1+ ('<PARAM NAME=bgcolor VALUE=#' + bgcolor + '>');
	N1= N1+ ('<PARAM NAME=menu VALUE=False>');
	N1= N1+ ('<PARAM NAME=borders VALUE=noborder>');
	N1= N1+ ('<PARAM NAME=loop VALUE=true >');
	N1= N1+ ('<PARAM NAME=wmode VALUE=opaque >');	
	N1= N1+ ('<embed src="video.swf?vFilmato=' + v+ '" quality=high loop=true menu=false bgcolor=#' + bgcolor + '');
	
	N1= N1+ ('swLiveConnect="FALSE" WIDTH="' + width + '" HEIGHT="' + height + '" border="0" TYPE="application/x-shockwave-flash"');
	N1= N1+ ('PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></embed></OBJECT>');
	ModalPopups.Custom("layerVideo",
        "<div id='titolo' >"+titolo+"</div>",
        "<div id='contenuto' style='padding: 0px;background-color:#FFFFFF;margin-left:60px'>" + N1+"</div>" , 
        {
            width: 410,
            buttons: "cancel",
         
            cancelButtonText: "Chiudi",
         
            onCancel: "ModalPopupsCancel(\"layerVideo\")"
        }
    )
   
            
   // ModalPopups.GetCustomControl("inputCustom1Name").focus(); 
   }

function ModalPopupsCancel(nomeLayer) {
   
    ModalPopups.Cancel(nomeLayer);
}
function ModalPopupAttesa() {
    ModalPopups.Indicator("waitLayer",
        "Attendere, prego",
        "<div style=''>" + 
        "<div style='float:left;'><img src='web/img/spinner.gif'></div>" + 
        "<div style='float:left; padding-left:10px;'>" + 
        "Invio dati in corso... <br/>" + 
        "L'operazione richiede qualche secondo." + 
        "</div>", 
        {
            width: 350,
            height: 100
        }
    );
            
}


