var nome_azienda="intelligence security group, servizi di intelligence e sicurezza aziendale";
var indirizzo_azienda_piva="";

document.title=nome_azienda+"";

var thiscop;
var timenow = new Date();
var buffer="";
var buffer2="";

// nuova sezione scripting
	var menuid=""; // serve per passare il valore del menu id alla print_submenu
	var xml_path="/xmlmaker/";

	function openwin(thisurl,wid,hei) {
		if (wid==undefined | wid==null) {wid=520}
		if (hei==undefined | hei==null) {hei=700}
		window.open(thisurl,'new','toolbar=no,scrollbars=yes,directories=no,menu=no,location=no,width='+wid+',height='+hei+',resizable=yes')
	}

	function menu_read() {
		print_top_menu();
		return
	}
	
	var div_target="";
	function print_top_menu(div_target) {
		if (div_target=="" | div_target==null | div_target==undefined) {
			div_target="menu_top_sup"
		}
		
		var time_interval=new Date();
		var now=time_interval.getTime();

		var indirizzo="xmlmaker/topmenu.xml?"+now;

		http_request5 = false;
		if (window.XMLHttpRequest) { // browser Mozilla
			http_request5 = new XMLHttpRequest();
			if (http_request5.overrideMimeType) http_request5.overrideMimeType('text/xml');
		} else if (window.ActiveXObject) { // browser Microsoft InternetExplorer
			try {
				http_request5 = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request5 = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (!http_request5) {
			alert('ERRORE : Impossibile inizializzare XMLHTTPRequest');
			return false;
		}
		http_request5.onreadystatechange =  function menu_print() {
			if (http_request5.readyState == 4) {
				if (http_request5.status == 200) {
					// qui faccio roba

					var write_this_html=""; // contenuto html per il video
					var xmldoc_html = http_request5.responseXML; // assegnazione a variabile di contenuto XML
					var artlist_html = xmldoc_html.getElementsByTagName('menu'); // nodo xml da scansionare
					elemento_html = document.getElementById(div_target); // target della scrittura a video
					var id="";
					
					var titolo="";
					var title="";
					var title_de="";
					var title_fr="";
					var title_esp="";
					var selected="";
					
					var thiscount=0;
					var write_this="";
					
					//ricerca del selezionato
						for (i=0;i<artlist_html.length;i++) {
							art_html = artlist_html.item(i);
							id=art_html.getAttribute('id');
							titolo=art_html.getAttribute('titolo');
							selected=art_html.getAttribute('selected');
							if (selected == "on") {
								var titolo_selected=titolo;
								//alert(titolo_selected);
								selected=id;
								document.getElementById("subtitle").innerHTML=titolo;
								break
							}
						}
					//fine ricerca del selezionato
					
					//stampa menu
						for (i=0;i<artlist_html.length-1;i++) {
							art_html = artlist_html.item(i);
							id=art_html.getAttribute('id');
							titolo=art_html.getAttribute('titolo');
							titolo=titolo.replace("'","´");

							write_this+="<a href=\"javascript:search_submenu('"+id+"','"+titolo+"','"+selected+"','"+titolo_selected+"')\">"+titolo+"</a>";

							//apre il sottomenu della prima voce di menu ma stampando a lato il sottomenu selected
							if (i==0) {
								//titolo menu principale
								search_submenu(id,titolo,selected,titolo_selected)
							}
						}
					//fine stampa menu
					elemento_html.innerHTML=write_this;
					
					// stampa ultimo elemento nel footer
						art_html = artlist_html.item(artlist_html.length-1);
						id=art_html.getAttribute('id');
						titolo=art_html.getAttribute('titolo');
						titolo=titolo.replace("'","´");
						
						write_this="<a href=\"javascript:search_submenu('"+id+"','"+titolo+"','"+selected+"','"+titolo_selected+"')\" class=\"terms\">"+titolo+"</a>";
						document.getElementById("terms").innerHTML=write_this
					// fine stampa ultimo elemento nel footer
				} else {
					alert('Si è verificato un problema con la risposta AJAX print_top_menu');
				}

			}
		}
		http_request5.open('GET', indirizzo, true);
		http_request5.send(null);
	}

	var this_title="";
	function search_submenu(this_id,this_title,this_selected,titolo_selected) {
		//scansionare il file dei cantieri e stampare le chiamate al search_cant(id)
		this_title=this_title; // titolo menu principale
		var titolo_selected=titolo_selected;
		
		var time_interval=new Date();
		var now=time_interval.getTime();
		
		var indirizzo="xmlmaker/html.xml"+"?now="+now;
		
		http_request5 = false;
		if (window.XMLHttpRequest) { // browser Mozilla
			http_request5 = new XMLHttpRequest();
			if (http_request5.overrideMimeType) http_request5.overrideMimeType('text/xml');
		} else if (window.ActiveXObject) { // browser Microsoft InternetExplorer
			try {
				http_request5 = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request5 = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (!http_request5) {
			alert('ERRORE : Impossibile inizializzare XMLHTTPRequest');
			return false;
		}
		http_request5.onreadystatechange =  function subtopmenu_print() {
			// qui c'è la funzione di funzione
			if (http_request5.readyState == 4) {
				if (http_request5.status == 200) {
					// qui faccio roba

					var write_this_html=""; // contenuto html per il video
					var xmldoc_html = http_request5.responseXML; // assegnazione a variabile di contenuto XML
					var artlist_html = xmldoc_html.getElementsByTagName('cantiere'); // nodo xml da scansionare
					elemento_html = document.getElementById('menu_top'); // target della scrittura a video
					//id cantiere non è this_id e tipologia cui corrisponde this_id ma verificando dalla descrizione estesa che, dunque, devo passare
					
					var id="";
					var titolo="";
					var titolo_eng="";
					var title_de="";
					var title_fr="";
					var title_esp="";
					var write_this="";
					var alternate_write_this="";
					
					var first_submenu=0;
					
					write_this+="<ul class=\"secondo\">";
					for (i=0;i<artlist_html.length;i++) {
						art_html = artlist_html.item(i);
						tipologia=art_html.getAttribute('tipologia');
						
						if (tipologia == this_id) {
							id=art_html.getAttribute('id');
							titolo=art_html.getAttribute('titolo');// titolo del sottomenu
							alternate_write_this+="<li><a href=\"javascript:get_cant('"+id+"','"+titolo+"','"+this_title+"')\">"+titolo+"</a></li>";
							first_submenu++;
							if (first_submenu==1) {
								var first_id=id;
								var first_titolo=titolo
							}
						}
					}

					//con questo stampo il submenu solo se contiene più di una voce
					//diversamente stampa nel div il menu selected o nulla
					
					short_navbar=false;
					if (first_submenu<2) {
						document.getElementById("subtitle").innerHTML=titolo_selected;
						//verificare qui se non ho nulla voglio la stampa dei submenu del menu selected
						//elemento_html.innerHTML=this_selected
						
						alternate_write_this="";
						for (i=0;i<artlist_html.length;i++) {
							art_html = artlist_html.item(i);
							tipologia=art_html.getAttribute('tipologia');

							if (tipologia == this_selected) {
								id=art_html.getAttribute('id');
								titolo=art_html.getAttribute('titolo');
								//alert(titolo_selected);
								alternate_write_this+="<li><a href=\"javascript:get_cant('"+id+"','"+titolo+"','"+titolo_selected+"')\">"+titolo+"</a></li>";
								short_navbar=true;
								first_submenu++;
								if (first_submenu==1) {
									var first_id=id;
									var first_titolo=titolo;
									var first_menu=this_title
								}
							}
						}
					} else {
						document.getElementById("subtitle").innerHTML=this_title
					}
					
					write_this+=alternate_write_this;
					write_this+="</ul>"
					
					elemento_html.innerHTML=write_this;
					get_cant(first_id,first_titolo,this_title,short_navbar)
					
				} else {
					alert('Si è verificato un problema con la risposta AJAX search_submenu');
				}

			}
		}
		http_request5.open('GET', indirizzo, true);
		http_request5.send(null);
	}
	
	function get_cant(menuid,this_title,title_menu,short_navbar) {

		document.getElementById('pagesx').innerHTML="<center><br /><br /><br /><img src=\""+xml_path+"img/progressbar1.gif\" width=\"100\" height=\"5\" alt=\"\" border=\"0\" vspace=\"100\" /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></center>";

		this_title=this_title;
		title_menu=title_menu;
		var short_navbar=short_navbar;
		
		menuid=menuid;
		var time_interval=new Date();
		var now=time_interval.getTime();
		var indirizzo="xmlmaker/html.xml"+"?"+now; // mi occorre per eludere la persistente cache degli oggetti caricati tramite xmlhttprequest. i meta pragma funzionano solo nella fantasia di qualcuno
		//var indirizzo="xmlmaker/html.xml"; // mi occorre per eludere la persistente cache degli oggetti caricati tramite xmlhttprequest. i meta pragma funzionano solo nella fantasia di qualcuno


		http_request5 = false;
		if (window.XMLHttpRequest) { // browser Mozilla
			http_request5 = new XMLHttpRequest();
			if (http_request5.overrideMimeType) http_request5.overrideMimeType('text/xml');
		} else if (window.ActiveXObject) { // browser Microsoft InternetExplorer
			try {
				http_request5 = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request5 = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (!http_request5) {
			alert('ERRORE : Impossibile inizializzare XMLHTTPRequest');
			return false;
		}
		http_request5.onreadystatechange =  function print_search() {
			// qui c'è la funzione di funzione
			if (http_request5.readyState == 4) {
				if (http_request5.status == 200) {
					var write_this_html=""; // contenuto html per il video
					var xmldoc_html = http_request5.responseXML; // assegnazione a variabile di contenuto XML
					var artlist_html = xmldoc_html.getElementsByTagName('cantiere'); // nodo xml da scansionare
					elemento = document.getElementById('pagesx'); // target della scrittura a video
					elemento.innerHTML="";
					
					var id="";
					var titolo="";
					var anno="";
					var citta="";
					var selected="";
					var tipologia="";
					var descrizione="";
					var html="";
					var allegato1="";
					var allegato2="";
					var allegato3="";

					var cantiere_partners="";
					var partner_list=new Array;

					var counter_risultati=0;
					var menutitolo="";
					var write_this_html="";

					for (i=0;i<artlist_html.length;i++) {
						art_html = artlist_html.item(i);
						id=art_html.getAttribute('id');

						if (id == menuid) {
							titolo=art_html.getAttribute('titolo');
							tipologia=art_html.getAttribute('tipologia');
							//descrizione=art_html.getAttribute('descrizione');
							html=art_html.getAttribute('italiano_html');

							anno=art_html.getAttribute('anno');
							selected=art_html.getAttribute('selected');
							citta=art_html.getAttribute('citta');

							allegato1=art_html.getAttribute('allegato1');
							allegato2=art_html.getAttribute('allegato2');
							allegato3=art_html.getAttribute('allegato3');

							cantiere_partners=art_html.getAttribute('fornitori');
							partner_list=cantiere_partners.split(/¯/);

							//if (anno != "") {
								//write_this_html+="<center><b><big>"+titolo+" ("+anno+")</big></b></center><br /><br />"
							//} else {
								//write_this_html+="<center><b><big>"+titolo+"</big></b></center><br /><br />"
							//}
							


							//write_this_html+="<br />";

							if ((allegato1 != "" && allegato1 != "/xmlmaker/" && allegato1 != "/public/xmlmaker/" && allegato1 != "/xmlmaker/") | (allegato2 != "" && allegato2 != "/xmlmaker/" && allegato2 != "/public/xmlmaker/" && allegato2 != "/xmlmaker/") | (allegato3 != "" && allegato3 != "/xmlmaker/" && allegato3 != "/public/xmlmaker/" && allegato3 != "/xmlmaker/")) {
								//qui ci sono allegati, immagini o files
								//write_this_html+="<br /><br /><b>Sezione download:</b><br /><br />"
								
								//fare split su . in modo da identificare l'estensione del file e se è jpg, png o gif caricare
								//mediante tag img, diversamente lascia così com'è
								
								var file_name=new Array();

								file_name=allegato1.split(".");
								var file_extension=file_name[1];
								if (allegato1 != "" && allegato1 != null && allegato1 != xml_path && allegato1 != "/xmlmaker/") {
									if (file_extension.match(/jpg|gif|png/i)) {
										write_this_html+="<div style=\"position:relative;width:"+elemento.style.width+"px;overflow-x:hidden\"><img src=\""+allegato1+"\" alt=\"\" align=\left\" /></div>";
									} else {
										write_this_html+="<a href=\""+allegato1+"\" target=\"_blank\"><img src=\"xmlmaker/graffetta.png\" width=\"32\" height=\"32\" hspace=\"2\"alt=\"scarica allegato\" border=\"0\" /></a> "+allegato1.replace("\/xmlmaker\/","")
									}
								}
								if (allegato2 != "" && allegato2 != null && allegato2 != xml_path && allegato2 != "/xmlmaker/") {
									file_name=allegato2.split(".");
									file_extension=file_name[1];

									if (file_extension.match(/jpg|gif|png/i)) {
										write_this_html+="<div style=\"position:relative;width:"+elemento.style.width+"px;overflow-x:hidden\"><img src=\""+allegato2+"\" alt=\"\" align=\left\" /></div>";
									} else {
										write_this_html+="<a href=\""+allegato2+"\" target=\"_blank\"><img src=\"xmlmaker/graffetta.png\" width=\"32\" height=\"32\" hspace=\"2\"alt=\"scarica allegato\" border=\"0\" /></a> "+allegato2.replace("\/xmlmaker\/","")
									}
								}
								if (allegato3 != "" && allegato3 != null && allegato3 != xml_path && allegato3 != "/xmlmaker/") {
									file_name=allegato3.split(".");
									file_extension=file_name[1];

									if (file_extension.match(/jpg|gif|png/i)) {
										write_this_html+="<div style=\"position:relative;width:"+elemento.style.width+"px;overflow-x:hidden\"><img src=\""+allegato3+"\" alt=\"\" align=\left\" /></div>";
									} else {
										write_this_html+="<a href=\""+allegato3+"\" target=\"_blank\"><img src=\"xmlmaker/graffetta.png\" width=\"32\" height=\"32\" hspace=\"2\"alt=\"scarica allegato\" border=\"0\" /></a> "+allegato3.replace("\/xmlmaker\/","")
									}
								}
							}
							
							write_this_html+="<br />";
							write_this_html+=html;
							
							elemento.innerHTML=write_this_html;
							if (short_navbar) {
								print_navbar(title_menu,"")
							} else {
								print_navbar(title_menu,this_title)
							}

							write_this_html+=html;

						}
					}
				} else {
					alert('Si è verificato un problema con la risposta AJAX get_cant');
				}
			}
		}
		http_request5.open('GET', indirizzo, true);
		http_request5.send(null);
	}
	
	function print_navbar(menutitolo,titolo) {
		document.getElementById('navigation_bar').innerHTML="<font class=\"my_title\">"+menutitolo+" ></font><font class=\"my_title2\"> "+titolo+"</font>";
	}

	function openall(url,type,wid,hei,title) {
		//type: htm,url,img
		if (type=="htm") {
			MOOdalBox.open(url,title,wid+" "+hei)
		} else if (type=="img" | type=="url") {
			MOOdalBox.open("openall.php?mylink="+url+"&mytype="+type,title,wid+" "+hei)
		} else {
			alert("TIPO deve essere alternativamente:\rhtm - pagina residente sul server\rurl - pagina su altro server\rimg - immagine (jpg,gif,png)")
		}
	}

	function slideshow_load() {
		
		var time_interval=new Date();
		var now=time_interval.getTime();
		var indirizzo="xmlmaker/testata.xml"+"?"+now; // mi occorre per eludere la persistente cache degli oggetti caricati tramite xmlhttprequest. i meta pragma funzionano solo nella fantasia di qualcuno

		http_request65 = false;
		if (window.XMLHttpRequest) { // browser Mozilla
			http_request65 = new XMLHttpRequest();
			if (http_request65.overrideMimeType) http_request65.overrideMimeType('text/xml');
		} else if (window.ActiveXObject) { // browser Microsoft InternetExplorer
			try {
				http_request65 = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request65 = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (!http_request65) {
			alert('ERRORE : Impossibile inizializzare XMLHTTPRequest');
			return false;
		}
		http_request65.onreadystatechange =  function print_search() {
			// qui c'è la funzione di funzione
			if (http_request65.readyState == 4) {
				if (http_request65.status == 200) {
					var write_this_html=""; // contenuto html per il video
					var xmldoc_html = http_request65.responseXML; // assegnazione a variabile di contenuto XML
					var artlist_html = xmldoc_html.getElementsByTagName('img'); // nodo xml da scansionare
					elemento = document.getElementById('slideshow'); // target della scrittura a video

					var src="";
					var title="";

					for (i=0;i<artlist_html.length;i++) {
						art_html = artlist_html.item(i);
						src=art_html.getAttribute('src');
						title=art_html.getAttribute('title');
						if (i==0) {
							write_this_html+="<img src=\""+src+"\" alt=\""+title+"\" class=\"active\" />"
						} else {
							write_this_html+="<img src=\""+src+"\" alt=\""+title+"\" />"
						}
					}
					//alert(write_this_html);
					elemento.innerHTML=write_this_html
				} else {
					alert('Si è verificato un problema con la risposta AJAX get_cant');
				}
			}
		}
		http_request65.open('GET', indirizzo, true);
		http_request65.send(null);
	}

	function slideSwitch() {
	    var $active = $('#slideshow img.active');

	    if ( $active.length == 0 ) $active = $('#slideshow img:last');

	    // use this to pull the images in the order they appear in the markup
	    var $next =  $active.next().length ? $active.next()
		: $('#slideshow img:first');

	    // le tre linee che seguono servono per gestire in random le immagini

	     var $sibs  = $active.siblings();
	     var rndNum = Math.floor(Math.random() * $sibs.length );
	     var $next  = $( $sibs[ rndNum ] );


	    $active.addClass('last-active');

	    $next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
		    $active.removeClass('active last-active');
		});
	}
	
		//----------------------------
			var delta1=0;    	// spostamento
			var inizio1=0;   	// posizione iniziale del testo in pixel
			var attesa1=50;  	// millisecondi di attesa
			var pos1=inizio1; 	// variabile corrente che memorizza la posizione
			var speedscroll1=7;	// amplificatore di velocità
			var fine1="";    	// posizione finale del testo

			var scroll_this_element1="header";

			function movecontent1() {
				if (document.getElementById(scroll_this_element1).offsetWidth>document.getElementById('clip1').offsetWidth) {
					if (((pos1*speedscroll1<=(document.getElementById('clip1').offsetWidth-document.getElementById(scroll_this_element1).offsetWidth))&&(delta1==-1))||((pos1==inizio1)&&(delta1==1))) delta1=0;
						pos1=pos1+delta1;
						document.getElementById('scroll_content1').style.left=pos1*speedscroll1+"px";
						if (delta1!=0) setTimeout('movecontent1()',attesa1)
					}
			}
			function setend1() {
				fine1=document.getElementById('clip1').offsetWidth-document.getElementById(scroll_this_element1).offsetWidth;
			}

		//swap image
			trasp=new Image(16,16);
			trasp.src="images/trasp.gif";

			bul1=new Image(16,16);
			bul1.src="images/sx.gif";

			bul1_a=new Image(16,16);
			bul1_a.src="images/sx_move.gif";

			bul2=new Image(16,16);
			bul2.src="images/dx.gif";

			bul2_a=new Image(16,16);
			bul2_a.src="images/dx_move.gif";

			function swap_image(id,id_a) {
				img_buff=new Image(16,16);
				img_buff.src=id.src;

				id.src=id_a.src;
				id_a.src=img_buff.src;
			}
		// fine swap image

		// posizionamento scroller	
			var spacer_height;
			function spacer() {
				spacer_height=document.body.clientHeight
				document.getElementById("spacer").style.height=spacer_height+"px"
				alert(spacer_height)
			}
		// fine posizionamento scroller
		
// fine nuova sezione scripting



