<!--
	// Googlemap
	//<![CDATA[
	//var WINDOW_HTML = '<font style="font-family: Verdana; font-size: 10px;"><font style="font-weight: bold; color: #003366;">OMATEC S.r.l.</font><br />Via Piemonte 11, 23018 Talamona (SO)</font>';
	
	function initialize(){
		if(GBrowserIsCompatible()){
			var map = new GMap2(document.getElementById("mappa"));
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
			map.setCenter(new GLatLng(46.135500, 9.601500), 13);
			var marker = new GMarker(new GLatLng(46.135500, 9.601500));
      map.addOverlay(marker);
      //GEvent.addListener(marker, "click", function(){
        //marker.openInfoWindowHtml(WINDOW_HTML);
      //});
      //marker.openInfoWindowHtml(WINDOW_HTML);
			var ovcontrol = new GOverviewMapControl(new GSize(150,150)); 
      map.addControl(ovcontrol);
		}
	}
	//]]>
	
	// Preload immagini
	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_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_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];}
	}
	
	// Apre una pop-up centrata
	function centerPopup(prod_id, qnt_prod, action, w, h){
		var l = Math.floor((screen.width-w)/2);
		var t = Math.floor((screen.height-h)/2);
		var page = "pages/info.php?id_prod=" + prod_id + "";
		
		if(action == 'modify')
			var page = "pages/info.php?id_prod=" + prod_id + "&qnt_prod=" + qnt_prod + "&action=" + action + "";
		
		var site = window.open(page, "popup", "toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=no, width=" + (w+40) + ", height=" + (h+30) + ", top=" + t + ", left=" + l);
		site.focus();
	}
	
	// Mostra/nasconde la visibility del <tbody> sub_categoria
	function showHideDiv(divId, divTot){
		if(divId == 'block'){
			for(var i=0; i<divTot; i++){
				document.getElementById('arrow_' + i).src = "images/arrow_minus.gif";
				document.getElementById(i).style.display = "block";
			}
		}
		else if(divId == 'none'){
			for(var i=0; i<divTot; i++){
				document.getElementById('arrow_' + i).src = "images/arrow_plus.gif";
				document.getElementById(i).style.display = "none";
			}
		}
		else{
			if(document.getElementById(divId).style.display == "none"){
				document.getElementById('arrow_' + divId).src = "images/arrow_minus.gif";
				document.getElementById(divId).style.display = "block";
			}
			else{
				document.getElementById('arrow_' + divId).src = "images/arrow_plus.gif";
				document.getElementById(divId).style.display = "none";
			}
		}
	}
	
	// Mostra/nasconde il display dell'elemento "id"
	function displayDiv(id, what){
		if(what == "block"){
			if(navigator.appName == "Microsoft Internet Explorer")
				document.getElementById('' + id + '').style.display = "block";
			else if(navigator.appName == "Netscape")
				document.getElementById('' + id + '').style.display = "table-row";
		}
		else if(what == "none")
			document.getElementById('' + id + '').style.display = "none";
	}
	
	// Controlla l'invio della form "contatti"
	function checkContatti(){
		var item = document.forms[0];
		var goodEmail = item.mail.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
		
		if(item.societa.value == ''){
			alert("Attenzione!\nIl campo NOMINATIVO SOCIETA' non è stato compilato correttamente...");
			item.societa.focus();
		}
		else if(item.name.value == ''){
			alert("Attenzione!\nIl campo NOME non è stato compilato correttamente...");
			item.name.focus();
		}
		else if(item.surname.value == ''){
			alert("Attenzione!\nIl campo COGNOME non è stato compilato correttamente...");
			item.surname.focus();
		}
		else if(!goodEmail){
			alert("Attenzione!\nIl campo E-MAIL non è stato compilato correttamente...");
			item.mail.focus();
		}
		else if(item.phone.value != '' && isNaN(item.phone.value)){
			alert("Attenzione!\nIl campo TELEFONO/CELLULARE non è numerico...");
			item.phone.focus();
		}
		else if(item.what.value == ''){
			alert("Attenzione!\nIl campo RICHIESTA non è stato compilato correttamente...");
			item.what.focus();
		}
		else if(item.privacy.checked == false)
			alert("Attenzione!\nE' necessario confermare la lettura dell'informativa sulla PRIVACY...");
		else{
			item.go.value = 'Y';
			item.submit();
		}
	}
	
	// Controlla la form "searches"
	function checkSearch(){
		var item = document.searches;
		
		if(item.search_cod.value == '' && item.search_desc.value == '')
			alert("Attenzione!\nNessun campo di RICERCA è stato compilato correttamente...");
		else
			item.submit();
	}
	
	// Passa l'id del menù principale alla select del sub-menù
	function passMainId(idValue){
		var arr_content_0 = new Array();
		var arr_content_1 = new Array();
		var arr_content_2 = new Array();
		var arr_content_3 = new Array();
		var arr_content_4 = new Array();
		var elem_select = document.getElementById('sub_categoria');
		
		if(document.content.id_sub_menu_0){
			var sub_menu_id_0 = document.content.id_sub_menu_0.value;
			var id_sub_menu_0 = sub_menu_id_0.split("||");
			
			var sub_menu_desc_0 = document.content.desc_sub_menu_0.value;
			var desc_sub_menu_0 = sub_menu_desc_0.split("||");
			arr_content_0[0] = new Option("Selezionare la sotto-categoria...", "N");
			for(q=1; q<=desc_sub_menu_0.length; q++)
				arr_content_0[q] = new Option("- " + desc_sub_menu_0[q-1].toLowerCase(), id_sub_menu_0[q-1]);
		}
		
		if(document.content.id_sub_menu_1){
			var sub_menu_id_1 = document.content.id_sub_menu_1.value;
			var id_sub_menu_1 = sub_menu_id_1.split("||");
			
			var sub_menu_desc_1 = document.content.desc_sub_menu_1.value;
			var desc_sub_menu_1 = sub_menu_desc_1.split("||");
			arr_content_1[0] = new Option("Selezionare la sotto-categoria...", "N");
			for(k=1; k<=desc_sub_menu_1.length; k++)
				arr_content_1[k] = new Option("- " + desc_sub_menu_1[k-1].toLowerCase(), id_sub_menu_1[k-1]);
		}
		
		if(document.content.id_sub_menu_2){
			var sub_menu_id_2 = document.content.id_sub_menu_2.value;
			var id_sub_menu_2 = sub_menu_id_2.split("||");
			
			var sub_menu_desc_2 = document.content.desc_sub_menu_2.value;
			var desc_sub_menu_2 = sub_menu_desc_2.split("||");
			arr_content_2[0] = new Option("Selezionare la sotto-categoria...", "N");
			for(j=1; j<=desc_sub_menu_2.length; j++)
				arr_content_2[j] = new Option("- " + desc_sub_menu_2[j-1].toLowerCase(), id_sub_menu_2[j-1]);
		}
		
		if(document.content.id_sub_menu_3){
			var sub_menu_id_3 = document.content.id_sub_menu_3.value;
			var id_sub_menu_3 = sub_menu_id_3.split("||");
			
			var sub_menu_desc_3 = document.content.desc_sub_menu_3.value;
			var desc_sub_menu_3 = sub_menu_desc_3.split("||");
			arr_content_3[0] = new Option("Selezionare la sotto-categoria...", "N");
			for(j=1; j<=desc_sub_menu_3.length; j++)
				arr_content_3[j] = new Option("- " + desc_sub_menu_3[j-1].toLowerCase(), id_sub_menu_3[j-1]);
		}
		
		if(document.content.id_sub_menu_4){
			var sub_menu_id_4 = document.content.id_sub_menu_4.value;
			var id_sub_menu_4 = sub_menu_id_4.split("||");
			
			var sub_menu_desc_4 = document.content.desc_sub_menu_4.value;
			var desc_sub_menu_4 = sub_menu_desc_4.split("||");
			arr_content_4[0] = new Option("Selezionare la sotto-categoria...", "N");
			for(j=1; j<=desc_sub_menu_4.length; j++)
				arr_content_4[j] = new Option("- " + desc_sub_menu_4[j-1].toLowerCase(), id_sub_menu_4[j-1]);
		}
		
		if(idValue == 'N')
			arr_rif = new Array();
		else if(idValue == 1){
			arr_rif = new Array();
			arr_rif = arr_content_0;
		}
		else if(idValue == 2){
			arr_rif = new Array();
			arr_rif = arr_content_1;
		}
		else if(idValue == 3){
			arr_rif = new Array();
			arr_rif = arr_content_2;
		}
		else if(idValue == 4){
			arr_rif = new Array();
			arr_rif = arr_content_3;
		}
		else if(idValue == 5){
			arr_rif = new Array();
			arr_rif = arr_content_4;
		}
		
		for(var x = elem_select.length-1; x>=0; x--)
			elem_select.remove(x);
		
		for(i=0; i<arr_rif.length; i++){
			document.content.sub_categoria.options[i] = arr_rif[i];
			
			if(document.content.sub_categoria.options[i].text == '- ')
				alert("Attenzione!\nLa categoria selezionata NON contiene alcuna sotto-categoria.\nÈ PRIMA necessario inserire una sotto-categoria...");
		}
	}
	
	// Passa l'id del sub-menù
	function passSubmainId(idValue, list_id_content){
		document.content.id_sub_content.value = idValue;
		var isInArr = 'N';
		
		if(list_id_content != ''){
			var arr_id_content = list_id_content.split(",");
		
			for(s=0; s<arr_id_content.length; s++){
				thisEntry = arr_id_content[s].toString();
				
				if(thisEntry == idValue){
					isInArr = 'Y';
					break;
				}
			}
		}
		
		if(isInArr == 'N')
			document.content.cmd.value = 'news';
		else if(isInArr == 'Y')
			document.content.cmd.value = 'modnews';
		
		if(idValue != 'N')
			document.content.submit();
	}
	
	// Passa l'id del prodotto
	function passSubmainCont(idValue, contValue){
		if(contValue != 'N'){
			split_result = new Array();
			split_result = contValue.split("||");
			
			document.content.id_sub_content.value = idValue;
			document.content.id_codice.value = split_result[0];
			document.content.descrizione_codice.value = split_result[1];
			document.content.testo_codice.value = split_result[2];
			document.content.url_immagine.value = split_result[3];
			
			if(split_result[4] == 'Y')
				document.content.prod_visibile.value = 'Y';
			else
				document.content.prod_visibile.value = 'N';
			
			if(split_result[5] == 'Y')
				document.content.prod_offerta.value = 'Y';
			else
				document.content.prod_offerta.value = 'N';
			
			document.content.descrizione_codice_en.value = split_result[6];
			document.content.testo_codice_en.value = split_result[7];
			document.content.descrizione_codice_ro.value = split_result[8];
			document.content.testo_codice_ro.value = split_result[9];
			document.content.cmd.value = 'modnews';
			document.content.submit();
		}
		else
			alert("Attenzione!\nIl campo CODICE PRODOTTO non è stato selezionato...");
	}
	
	// Controlla la form d'inserimento dei contenuti
	function insContent(idValue, actionType){
		if(document.content.categoria.value == 'N')
			alert("Attenzione!\nIl campo CATEGORIA non è stato selezionato...");
		else if(document.content.sub_categoria.value == 'N')
			alert("Attenzione!\nIl campo SOTTO-CATEGORIA non è stato selezionato...");
		else if(actionType == 'Nuovo' && document.content.codice.value == ''){
			alert("Attenzione!\nIl campo CODICE PRODOTTO non è stato compilato correttamente...");
			document.content.codice.focus();
		}
		else if(actionType == 'Modifica' && document.content.codici.value == 'N')
			alert("Attenzione!\nIl campo CODICE PRODOTTO non è stato selezionato...");
		else if(document.content.descrizione.value == ''){
			alert("Attenzione!\nIl campo DESCRIZIONE PRODOTTO IT non è stato compilato correttamente...");
			document.content.descrizione.focus();
		}
		else if(document.content.descrizione_en.value == ''){
			alert("Attenzione!\nIl campo DESCRIZIONE PRODOTTO EN non è stato compilato correttamente...");
			document.content.descrizione_en.focus();
		}
		else if(document.content.descrizione_ro.value == ''){
			alert("Attenzione!\nIl campo DESCRIZIONE PRODOTTO RO non è stato compilato correttamente...");
			document.content.descrizione_ro.focus();
		}
		else if(document.content.testo.value == ''){
			alert("Attenzione!\nIl campo SPECIFICHE PRODOTTO IT non è stato compilato correttamente...");
			document.content.testo.focus();
		}
		else if(document.content.testo_en.value == ''){
			alert("Attenzione!\nIl campo SPECIFICHE PRODOTTO EN non è stato compilato correttamente...");
			document.content.testo_en.focus();
		}
		else if(document.content.testo_ro.value == ''){
			alert("Attenzione!\nIl campo SPECIFICHE PRODOTTO RO non è stato compilato correttamente...");
			document.content.testo_ro.focus();
		}
		else{
			if(actionType == 'Nuovo')
				document.content.cmd.value = 'do_news';
			else if(actionType == 'Modifica'){
				document.content.id_codice.value = idValue;
				document.content.cmd.value = 'do_modnews';
			}
			
			document.content.submit();
		}
	}
	
	// Passa l'id del menù principale per gli input text di modifica dei sub-menù
	function passForSubId(idValue){
		document.sub_category.id_main.value = idValue;
		document.sub_category.cmd.value = 'cat';
		
		document.sub_category.submit();
	}
	
	// Controlla la form d'inserimento delle sotto-categorie
	function insCategory(idValue, numberSub){
		if(document.sub_category.categoria.value == 'N')
			alert("Attenzione!\nIl campo CATEGORIA non è stato selezionato...");
		else{
			if(document.getElementById('cat_presenti').style.display == "none")
				numberSub = 0;
			
			if(numberSub == 0){
				if(document.sub_category.sub_categoria.value == ''){
					alert("Attenzione!\nIl campo SOTTO-CATEGORIA non è stato compilato...");
					document.sub_category.sub_categoria.focus();
				}
				else if(document.sub_category.sub_categoria_link.value == ''){
					alert("Attenzione!\nIl campo LINK della SOTTO-CATEGORIA non è stato compilato...");
					document.sub_category.sub_categoria_link.focus();
				}
				else if(document.sub_category.sub_categoria_img.value == ''){
					alert("Attenzione!\nIl campo IMMAGINE della SOTTO-CATEGORIA non è stato compilato...");
					document.sub_category.sub_categoria_img.focus();
				}
				else{
					document.sub_category.number_sub.value = numberSub;
					document.sub_category.id_main.value = idValue;
					document.sub_category.cmd.value = 'do_modcat';
					document.sub_category.submit();
				}
			}
			else{
				for(i=0; i<numberSub; i++){
					if(eval("document.sub_category.sub_categoria_" + i + ".value == ''")){
						alert("Attenzione!\nIl campo SOTTO-CATEGORIA non è stato modificato correttamente...");
						eval("document.sub_category.sub_categoria_" + i + ".focus()");
						return false;
					}
				}
				
				document.sub_category.number_sub.value = numberSub;
				document.sub_category.id_main.value = idValue;
				document.sub_category.cmd.value = 'do_modcat';
				document.sub_category.submit();
			}
		}
	}
	
	// Elimina la sotto-categoria
	function delCategory(idValue, tableValue, imgValue){
		if(confirm("Sei sicuro di voler eliminare questa sotto-categoria?")){
			document.sub_category.id_sub.value = idValue;
			document.sub_category.id_main.value = tableValue;
			document.sub_category.img_value.value = imgValue;
			document.sub_category.cmd.value = 'do_delcat';
			document.sub_category.submit();
		}
	}
	
	// Elimina il prodotto
	function delProd(idValue){
		if(idValue == '' || idValue == 'N')
			alert("Attenzione!\nE' necessario selezionare un CODICE PRODOTTO per effettuarne l'eliminazione...");
		else{
			if(confirm("Sei sicuro di voler eliminare questo prodotto?")){
				document.content.id_codice.value = idValue;
				document.content.cmd.value = 'do_delprod';
				document.content.submit();
			}
		}
	}
	
	// Inserisce il prodotto nel carrello
	function putAcq(id_prod, nome, action, qnt, id_cat, id_sub_cat){
		if(isNaN(qnt)){
			alert("Attenzione!\nE' necessario inserire una QUANTITA' numerica...");
			eval("document.orders." + nome + ".focus()");
		}
		else if(qnt == 0){
			alert("Attenzione!\nE' necessario inserire una QUANTITA' superiore a 0...");
			eval("document.orders." + nome + ".focus()");
		}
		else{
			document.orders.submit();
			
			if(action == 'modify'){
				opener.document.write('<form name="orders_pass" method="post" action="../index.php?cmd=order">\n');
				opener.document.write('<input type="hidden" name="id_prod" value="' + id_prod + '">\n');
				opener.document.write('<input type="hidden" name="qnt_prod" value="' + qnt + '">\n');
				opener.document.write('<input type="hidden" name="is_session" value="Y">\n');
				opener.document.write('</form>\n');
			}
			else{
				opener.document.write('<form name="orders_pass" method="post" action="../index.php?cmd=catalogo&id_cat=' + id_cat + '&id_sub_cat=' + id_sub_cat +'">\n');
				opener.document.write('<input type="hidden" name="id_prod" value="' + id_prod + '">\n');
				opener.document.write('<input type="hidden" name="qnt_prod" value="' + qnt + '">\n');
				opener.document.write('<input type="hidden" name="is_session" value="Y">\n');
				opener.document.write('</form>\n');
			}
			
			opener.document.orders_pass.submit();
		}
	}
	
	// Effettua l'acquisto dei prodotti presenti nel carrello
	function doAcq(arr_orders, is_ok){
		if(is_ok == 'Y')
			document.location.href = 'index.php?cmd=order';
		else
			document.location.href = 'index.php?cmd=catalogo';
	}
	
	// Elimina il prodotto dal carrello
	function delProdBasket(idValue){
		if(idValue != ""){
			if(confirm("Sei sicuro di voler eliminare questo prodotto dal carrello?"))
				document.location.href = 'index.php?cmd=order&id_prod_del=' + idValue + '';
		}
	}
	
	// Effettua l'invio della mail di acquisto
	function checkAcq(){
		var item = document.forms[0];
		var goodEmail = item.mail.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
		
		if(item.societa.value == ''){
			alert("Attenzione!\nIl campo NOMINATIVO SOCIETA' non è stato compilato correttamente...");
			item.societa.focus();
		}
		else if(item.name.value == ''){
			alert("Attenzione!\nIl campo NOME non è stato compilato correttamente...");
			item.name.focus();
		}
		else if(item.surname.value == ''){
			alert("Attenzione!\nIl campo COGNOME non è stato compilato correttamente...");
			item.surname.focus();
		}
		else if(!goodEmail){
			alert("Attenzione!\nIl campo E-MAIL non è stato compilato correttamente...");
			item.mail.focus();
		}
		else if(item.phone.value != '' && isNaN(item.phone.value)){
			alert("Attenzione!\nIl campo TELEFONO/CELLULARE non è numerico...");
			item.phone.focus();
		}
		else if(item.privacy.checked == false)
			alert("Attenzione!\nE' necessario confermare la lettura dell'informativa sulla PRIVACY...");
		else{
			item.go.value = 'Y';
			item.submit();
		}
	}
	
	// Modificano lo stile dei pulsanti di bold e italic
	function mouseover(el){
  	el.className = "raised";
	}
	
	function mouseout(el){
		el.className = "button";
	}
	
	function mousedown(el){
		el.className = "pressed";
	}
	
	function mouseup(el){
		el.className = "raised";
	}
	
	// Inserisce gli stili bold e italic nella textarea "testo"
	function format_sel_testo(v){
		if(v == 'br'){
	  	var str = document.selection.createRange().text;
  		document.content.testo.focus();
  		var sel = document.selection.createRange();
  		sel.text = str + "<" + v + " />";
			return;
		}
		else{
	  	var str = document.selection.createRange().text;
  		document.content.testo.focus();
  		var sel = document.selection.createRange();
  		sel.text = "<" + v + ">" + str + "</" + v + ">";
			return;
		}
	}
	
	// Inserisce gli stili bold e italic nella textarea "testo_en"
	function format_sel_testo_en(v){
		if(v == 'br'){
	  	var str = document.selection.createRange().text;
  		document.content.testo_en.focus();
  		var sel = document.selection.createRange();
  		sel.text = str + "<" + v + " />";
			return;
		}
		else{
	  	var str = document.selection.createRange().text;
  		document.content.testo_en.focus();
  		var sel = document.selection.createRange();
  		sel.text = "<" + v + ">" + str + "</" + v + ">";
			return;
		}
	}
	
	// Inserisce gli stili bold e italic nella textarea "testo_ro"
	function format_sel_testo_ro(v){
		if(v == 'br'){
	  	var str = document.selection.createRange().text;
  		document.content.testo_ro.focus();
  		var sel = document.selection.createRange();
  		sel.text = str + "<" + v + " />";
			return;
		}
		else{
	  	var str = document.selection.createRange().text;
  		document.content.testo_ro.focus();
  		var sel = document.selection.createRange();
  		sel.text = "<" + v + ">" + str + "</" + v + ">";
			return;
		}
	}
//-->

var bo_noscript_id = 0;

function isIE() {
  var strBrowser = navigator.userAgent.toLowerCase();
  return (strBrowser.indexOf("msie") > -1 && strBrowser.indexOf("mac") < 0);
}

function startIeFix() {
  if (isIE()) {
   document.write('<div style="display: none;" id="bo_noscript_id_' + bo_noscript_id + '">');
  }
}

function endIeFix() {
  if (isIE()) {
   document.write('</div>');
   var theObject = document.getElementById("bo_noscript_id_" + bo_noscript_id++);
   theObject.outerHTML = theObject.innerHTML;
  }
}

