// Original code for ExtraFunctions:  Gianluca Ventani - www.madde.it -->
// Copyright © 2002-2003 Ventani Gianluca [www.madde.it]

// Original code for MENU A TENDINA:  Angus Turnbull -->

// --------------Inizio Madde---------------------,
function CheckString(Stringa) {
	for (i=0; i<=Stringa.length; i++) {
		StrChar=Stringa.substring(i,i+1);
		if (!isNumberChar(StrChar)){
			return false;
		}
	}
	return true;
}

function isNumberChar(Stringa) {
	if (Stringa.length!=1){
		return(false);
	}

	RefStringa="1234567890-+ /";
	if (RefStringa.indexOf(Stringa,0)==-1){
		alert("Il numero di telefono non e' valido:\n\rI caratteri di separazione disponibili sono\n\r -  +  spazio  / ");
		return(false);
	}
	return(true);
}

function leggi() {
	//alert("Leggi");
	// settaggio variabili
	ritcap = "%0A" //qui potremo inserire il controllo del browser
	Azienda = document.MailForm.Azienda.value;
	Telefono = document.MailForm.Telefono.value;
	Cognome = document.MailForm.Cognome.value;
	Nome = document.MailForm.Nome.value;
	Indirizzo = document.MailForm.Indirizzo.value;
	Citta = document.MailForm.Citta.value;
	Cap = document.MailForm.Cap.value;
	Provincia = document.MailForm.Provincia.value;
	Fax = document.MailForm.Fax.value;
	Nazione = document.MailForm.Nazione.value;
	Sito = document.MailForm.SitoInternet.value;
	EMail = document.MailForm.EMail.value;
	Oggetto = document.MailForm.Oggetto.value;
	Messaggio = document.MailForm.Messaggio.value;
	Settore = document.MailForm.Settore.value;
	Materiali = document.MailForm.Materiali.value;

	// --------------ANAGRAFICA -----------------------------------
	pippo = "Anagrafica cliente:" + ritcap;
	if (Azienda != "" && Cognome != "" && Telefono != "" && EMail != "")
	{
		//alert("Inizio");
		pippo += "Azienda: " + Azienda + ritcap;
		pippo += "Cognome: " + Cognome + ritcap;
		if (Nome != "") pippo += "Nome: " + Nome + ritcap;
		pippo += "Telefono: " + Telefono + ritcap;
		if (Fax != "") pippo += "Fax: " + Fax + ritcap;
		if (Indirizzo != "") pippo += "Indirizzo: " + Indirizzo + ritcap;
		if (Cap != "") pippo += "Cap: " + Cap + ritcap;
		if (Citta != "") pippo += "Citta: " + Citta + ritcap;
		if (Provincia != "") pippo += "Provincia: " + Provincia + ritcap;
		if (Nazione != "") pippo += "Nazione: " + Nazione + ritcap;
		if (Sito != "") pippo += "Sito Internet: " + Sito + ritcap;
		if (EMail.indexOf("@")!=-1){
			pippo += "E-Mail: " + EMail + ritcap;
		}
		else{
		alert("Inglese: La mail non è corretta.");
		return false
		}
		
		// --------------SETTORE DI APPARTENENZA ----------------------
		//pippo += "Settore di appartenenza: [ " + Settore + " ]" + ritcap;
		// --------------MATERIALI LAVORATI ---------------------------
		//pippo += "Materiali lavorati: [ " + Materiali + " ]" + ritcap;
		// --------------Test nella TextArea --------------------------
		//pippo += "Messaggio:" + ritcap + Messaggio + ritcap + "[fine mail]"
		// --------------INVIO E-MAIL ---------------------------------
		//StringaMail = "mailto:info@trecsrl.com?subject=" + Oggetto + "&body=";
		//StringaMail += pippo;
		//alert(StringaMail);
		//document.location = StringaMail;
		return true
	}
	else {
		alert("Comply with the obligatory fields");
		return false
	}
}

function autoUrl(sufX)
{
	if(top.frames.length==0)
	{
	top.document.location = top.document.title + "_" + sufX + ".html";
	}
	else
	{
		for(var i=0; i<top.frames.length; i++)
		{
		top.frames[i].document.location = top.frames[i].document.title + "_" + sufX + ".html";
		}
	}
}

function multiurl(deturl,menurl,topper){
	if (menurl != "")
	{
		window.top.menu.location=menurl;
	}
	if (deturl != "")
	{
		window.top.details.location=deturl;
	}
	if (topper != "")
	{
		window.top.location=topper;
	}
}
function winhope(imgUrl,dimX,dimY)
{
	Attributi="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+dimX+",height="+dimY;
	var q = window.open("", "Zooom", Attributi);
	q.document.open();
	q.document.writeln("<html><body bgcolor=\"#FFFFFF\" marginheight=\"0\" bottommargin=\"0\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" onload=\"window.focus();\"><table height=\"100%\" width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><td width=\"100%\" height=\"100%\" valign=\"middle\" align=\"center\"><img src=\""+imgUrl+"\"></td></table></body></html>");
	q.document.close();
}
// -------------------fine Madde---------------------'


// Original code for MENU:  Angus Turnbull
var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
function getRef(id) {
if (isDOM) return document.getElementById(id);
if (isIE4) return document.all[id];
if (isNS4) return document.layers[id];
}
function getSty(id) {
return (isNS4 ? getRef(id) : getRef(id).style);
} 
var popTimer = 0;
var litNow = new Array();
function popOver(menuNum, itemNum) {
clearTimeout(popTimer);
hideAllBut(menuNum);
litNow = getTree(menuNum, itemNum);
changeCol(litNow, true);
targetNum = menu[menuNum][itemNum].target;
if (targetNum > 0) {
thisX = parseInt(menu[menuNum][0].ref.left) + parseInt(menu[menuNum][itemNum].ref.left);
thisY = parseInt(menu[menuNum][0].ref.top) + parseInt(menu[menuNum][itemNum].ref.top);
with (menu[targetNum][0].ref) {
left = parseInt(thisX + menu[targetNum][0].x);
top = parseInt(thisY + menu[targetNum][0].y);
visibility = 'visible';
      }
   }
}
function popOut(menuNum, itemNum) {
if ((menuNum == 0) && !menu[menuNum][itemNum].target)
hideAllBut(0)
else
popTimer = setTimeout('hideAllBut(0)', 500);
}
function getTree(menuNum, itemNum) {
itemArray = new Array(menu.length);
while(1) {
itemArray[menuNum] = itemNum;
if (menuNum == 0) return itemArray;
itemNum = menu[menuNum][0].parentItem;
menuNum = menu[menuNum][0].parentMenu;
   }
}
function changeCol(changeArray, isOver) {
for (menuCount = 0; menuCount < changeArray.length; menuCount++) {
if (changeArray[menuCount]) {
newCol = isOver ? menu[menuCount][0].overCol : menu[menuCount][0].backCol;
with (menu[menuCount][changeArray[menuCount]].ref) {
if (isNS4) bgColor = newCol;
else backgroundColor = newCol;
         }
      }
   }
}
function hideAllBut(menuNum) {
var keepMenus = getTree(menuNum, 1);
for (count = 0; count < menu.length; count++)
if (!keepMenus[count])
menu[count][0].ref.visibility = 'hidden';
changeCol(litNow, false);
}
function Menu(isVert, popInd, x, y, width, overCol, backCol, borderClass, textClass) {
this.isVert = isVert;
this.popInd = popInd
this.x = x;
this.y = y;
this.width = width;
this.overCol = overCol;
this.backCol = backCol;
this.borderClass = borderClass;
this.textClass = textClass;
this.parentMenu = null;
this.parentItem = null;
this.ref = null;
}
function Item(text, href, frame, length, spacing, target) {
this.text = text;
this.href = href;
this.frame = frame;
this.length = length;
this.spacing = spacing;
this.target = target;
this.ref = null;
}

function writeMenus(MenuLoc) {
//if (MenuLoc !=""){ //Solo se gli passo un dato dall'hatml carica il menu relativo
//	parent.menu.location = MenuLoc; //manualmente carica menu in base alla pagina visualizzata
//}
if (!isDOM && !isIE4 && !isNS4) return;
for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0]) {
var str = '', itemX = 0, itemY = 0;
for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem]) {
var itemID = 'menu' + currMenu + 'item' + currItem;
var w = (isVert ? width : length);
var h = (isVert ? length : width);

if (isDOM || isIE4) {
str += '<div id="' + itemID + '" style="position: absolute; left: ' + itemX + '; top: ' + itemY + '; width: ' + w + '; height: ' + h + '; visibility: inherit; ';
if (backCol) str += 'background: ' + backCol + '; ';
str += '" ';
}
if (isNS4) {
str += '<layer id="' + itemID + '" left="' + itemX + '" top="' + itemY + '" width="' +  w + '" height="' + h + '" visibility="inherit" ';
if (backCol) str += 'bgcolor="' + backCol + '" ';
}
if (borderClass) str += 'class="' + borderClass + '" ';
str += 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' + currMenu + ',' + currItem + ')">';
str += '<table width="' + (w - 8) + '" border="0" cellspacing="0" cellpadding="' + (!isNS4 && borderClass ? 3 : 0) + '"><tr><td align="left" height="' + (h - 7) + '"';


// MODIFICA
str += ' class="mousecursor"';
if (frame=='_top') {
	str += ' onclick="javascript:window.top.location=\'' + href + '\';">';
	//alert(' onclick="javascript:window.top.location=\'' + href + '\';">');
}
else {
	if (frame=='') {
		str += '>'; //se non ci sono link non scrivo niente e chiudo il tag
		//alert(str);
	}
	else {
		str += ' onclick="javascript:window.top.' + frame + '.location=\'' + href + '\';">';
		//alert(str);
	}
}
str += '<a class="' + textClass + '" href="' + href + '"' + (frame ? ' target="' + frame + '">' : '>') + text + '</a></td>';
// fine modifica madde



if (target > 0) {
menu[target][0].parentMenu = currMenu;
menu[target][0].parentItem = currItem;
if (popInd) str += '<td class="' + textClass + '" align="right">' + popInd + '</td>';
}
str += '</tr></table>' + (isNS4 ? '</layer>' : '</div>');
if (isVert) itemY += length + spacing;
else itemX += length + spacing;
}
if (isDOM) {
var newDiv = document.createElement('div');
document.getElementsByTagName('body').item(0).appendChild(newDiv);
newDiv.innerHTML = str;
ref = newDiv.style;
ref.position = 'absolute';
ref.visibility = 'hidden';
}
if (isIE4) {
document.body.insertAdjacentHTML('beforeEnd', '<div id="menu' + currMenu + 'div" ' + 'style="position: absolute; visibility: hidden">' + str + '</div>');
ref = getSty('menu' + currMenu + 'div');
}
if (isNS4) {
ref = new Layer(0);
ref.document.write(str);
ref.document.close();
}
for (currItem = 1; currItem < menu[currMenu].length; currItem++) {
itemName = 'menu' + currMenu + 'item' + currItem;
if (isDOM || isIE4) menu[currMenu][currItem].ref = getSty(itemName);
if (isNS4) menu[currMenu][currItem].ref = ref.document[itemName];
   }
}
with(menu[0][0]) {
ref.left = x;
ref.top = y;
ref.visibility = 'visible';
   }
}
// Syntaxes: *** START EDITING HERE, READ THIS SECTION CAREFULLY! ***
var menu = new Array();
var defOver = '#2582CF', defBack = '#005EAD';
var defLength = 24; // Altezza tastino indipendente da tutti i distacchi e spostamenti
//alert("allora!" + spostX);
menu[0] = new Array();
// se false mette oriz - se true mette in vert
// item ('testo','url','target',numlarghezzaX, numdistaccoDX, Arraysottomenu);
menu[0][0] = new Menu(false, '', spostX, 4, 17, defOver, defBack, '', 'itemText');
menu[0][1] = new Item('Company', '#', '', 55, 5, 1);
menu[0][2] = new Item('Products', '#', '', 50, 5, 2);
menu[0][3] = new Item('Contacts', 'hmail_en.html', '_top', 50, 5, 0);
menu[0][4] = new Item('Images', '#', '', 45, 5, 4);
menu[0][5] = new Item('Events', '#', '', 45, 5, 3);

menu[1] = new Array();
							/*   V- spostamento in X del sottomenu */
							/* 	 |  V- distacco verticale */
							/* 	 |  |   V- larghezza sottotastino */
menu[1][0] = new Menu(true, '>', 0, 17, 90, defOver, defBack, 'itemBorder', 'itemText');
										  /* V- Altezza tasto */
										  /* |         V- Distacco verticale tra bassotastino e altotastino*/
										  /* |         |   V- numero id sottomenu */
menu[1][1] = new Item('Who we are', 'hchis_en.html', '_top', defLength, 0, 0);
menu[1][2] = new Item('Where we are', 'hdove_en.html', '_top', defLength, 0, 0);

menu[2] = new Array();
menu[2][0] = new Menu(true, '>', 0, 17, 125, defOver, defBack, 'itemBorder', 'itemText');
menu[2][1] = new Item('Bending machine', 'hcurv_en.html', '_top', defLength, 0, 0);
menu[2][2] = new Item('Cutting off machine', 'htron_en.html', '_top', defLength, 0, 0);
//menu[2][3] = new Item('Milling machine', 'hinte_en.html', '_top', defLength, 0, 0);
//menu[2][4] = new Item('Copying routers', 'hpant_en.html', '_top', defLength, 0, 0);
//menu[2][5] = new Item('Drilling machines', 'hfora_en.html', '_top', defLength, 0, 0);
menu[2][3] = new Item('Assembly', 'hasse_en.html', '_top', defLength, 0, 0);

menu[3] = new Array();
menu[3][0] = new Menu(true, '>', 0, 17, 80, defOver, defBack, 'itemBorder', 'itemText');
menu[3][1] = new Item('Trade fairs', 'hfiere_en.html', '_top', defLength, 0, 0);

menu[4] = new Array();
menu[4][0] = new Menu(true, '>', 0, 17, 140, defOver, defBack, 'itemBorder', 'itemText');
menu[4][1] = new Item('Bending works', 'hflavo_en.html', '_top', defLength, 0, 0);
menu[4][2] = new Item('Performance of bends', 'hfesec_en.html', '_top', defLength, 0, 0);
// *** OPTIONAL CODE FROM HERE DOWN ***
var popOldWidth = window.innerWidth;
nsResizeHandler = new Function('if (popOldWidth != window.innerWidth) location.reload()');
if (isNS4) document.captureEvents(Event.CLICK);
document.onclick = clickHandle;
function clickHandle(evt)
{
 if (isNS4) document.routeEvent(evt);
 hideAllBut(0);
}
function moveRoot()
{
 with(menu[0][0].ref) left = ((parseInt(left) < 100) ? 100 : 5);
}
//  End -->
