/*******************************

Funzioni per il menu

Le voci di menu al momento sono 4

è sufficiente impostare un array javascript per la produzione dei menu

var nav = new Array();
nav[0] = '';
nav[1] = '<a href="index.php?fuseaction=login.showLoginForm" class="nav">Login</a> | <a href="index.php?fuseaction=login.logoutAction" class="nav">Logout</a> | <a href="index.php?fuseaction=adminUser.addUser" class="nav">Aggiungi utente</a> | <a href="index.php?fuseaction=adminUser.browseUser" class="nav">Ricerca utente</a>';
nav[2] = '<a href="index.php" class="nav">Generate HTML Code</a> | <a href="http://t1.phplivesupport.com/setup/customize.php?action=colors" class="nav">Colors &amp; Language</a> | <a href="http://t1.phplivesupport.com/setup/customize.php?action=icons" class="nav">Chat Icons</a>';
nav[3] = '[  <a href="index.php" class="nav">Ricerca Impianto</a> | <a href="index.php" class="nav">Nuovo Modello H</a>   ]';
//nav[4] = '<a href="index.php?fuseaction=adminLog.browseLog" class="nav">Log</a> | <a href="index.php?fuseaction=dbdesc.browseDesc" class="nav">Gestione Database</a>';
nav[4] = '<p class="nav"></p>';

*********************************/

var section = 0 ;	// Section number
var nav_start = '<table width="427" border="1" cellspacing="0" cellpadding="3"><tr valig="top"><td valig="top" align="center" class="nav">';
var nav_end = '</td></tr></table>';

/* DEVE ESSERE PRODOTTO DA APP MENU */
var nav = new Array();
nav[0] = '';
nav[1] = '<a href="index.php?fuseaction=login.showLoginForm" class="nav">Login</a> | <a href="index.php?fuseaction=login.logoutAction" class="nav">Logout</a> | <a href="index.php?fuseaction=adminUser.addUser" class="nav">Aggiungi utente</a> | <a href="index.php?fuseaction=adminUser.browseUser" class="nav">Ricerca utente</a>';
nav[2] = '<a href="index.php" class="nav">Generate HTML Code</a> | <a href="http://t1.phplivesupport.com/setup/customize.php?action=colors" class="nav">Colors &amp; Language</a> | <a href="http://t1.phplivesupport.com/setup/customize.php?action=icons" class="nav">Chat Icons</a>';
nav[3] = '[  <a href="index.php" class="nav">Ricerca Impianto</a> | <a href="index.php" class="nav">Nuovo Modello H</a>   ]';
//nav[4] = '<a href="index.php?fuseaction=adminLog.browseLog" class="nav">Log</a> | <a href="index.php?fuseaction=dbdesc.browseDesc" class="nav">Gestione Database</a>';
nav[4] = '<p class="nav"></p>';


var button = new Array();
button[0] = '';
button[1] = 'menu_utenti';
button[2] = 'menu_modello';
button[3] = 'menu_stampe';
button[4] = 'menu_manutenzione';

// Onload
function init(){
	rollOver(section);					// Setup navigation
	if(section>0) sE(gE('navBack'));	// Show back button

	
	}

// Rollover and navigation change
// s = section number; n = button name
function rollOver(s){
	if(button[s] != '' ) MM_swapImage(button[s],'','images/'+button[s]+'-over.gif',1);
	
	// Only show sub-navigation links in none NS4 browsers
	if(!l){
		e = gE('navigation');
		wH(e,nav[s]);
	}
}

// Rollout
function rollOut(s){
	if(!s) s=0;
	if(s>0 && s!=section) MM_swapImgRestore();
}


// Basic functions
d=document;l=d.layers;op=navigator.userAgent.indexOf('Opera')!=-1;var ie=d.all?1:0;var w3c=d.getElementById?1:0;
function gE(e,f){if(l){f=(f)?f:self;var V=f.document.layers;if(V[e])return V[e];for(var W=0;W<V.length;)t=gE(e,V[W++]);return t;}if(d.all)return d.all[e];return d.getElementById(e);} // Get element
function wH(e,h){if(l){Y=e.document;Y.open();Y.write(h);Y.close();}else if(e.innerHTML)e.innerHTML=h;}		// Write html
function sE(e){l?e.visibility='show':e.style.visibility='visible';}
function hE(e){l?e.visibility='hide':e.style.visibility='hidden';}

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];}
}

function confirmBox(theMessage){
	 if(confirm(theMessage)) {
	 	return true;
 	} else {
	 	return false;
 	}
} 

function confirmExit(){
	 if(confirm("Confermi l' uscita ?")) {
	 	return true;
 	} else {
	 	return false;
 	}
} 

function confirmDelete(){
	 if(confirm("Confermi la cancellazione ?")) {
	 	return true;
 	} else {
	 	return false;
 	}
} 


function confirmJumpDelete(url){
	 if(confirm("Confermi la cancellazione ?")) {
		//alert(url);
	 	location.href = url;
 	} else {
	 	return false;
 	}
} 


function saveSearch(formName)
{
	document.forms[formName].elements['FA_SEARCH_ACTION'].value = document.forms[formName].elements['fuseaction'].value;
	document.forms[formName].elements['fuseaction'].value = "personalizzazioni.newPers";
	document.forms[formName].submit();
}


function printPopup(url){
	window.open(url,'Stampe','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480');
    return;
}


// ajax 2b cut away

function ajax_search(ctl,theURL,thewidth,theheight)
{

	var	leftpos=0;
	var	toppos=ctl.offsetHeight;

	aTag = ctl
	do 
	{
		aTag = aTag.offsetParent;
		leftpos	+= aTag.offsetLeft;
		toppos += aTag.offsetTop;
	} while(aTag.tagName!="BODY");
		
	var div_obj = document.getElementById('lookup');
	div_obj.style.top = toppos;
	div_obj.style.left = leftpos;
	div_obj.style.display = "block";
  	document.getElementById('lookupframe').src = theURL;
	if (thewidth != null) 
	{
  		document.getElementById('lookupframe').style.width = thewidth;
	}
	else
	{
  		document.getElementById('lookupframe').style.width = ctl.offsetWidth;
	}
			
	document.getElementById('lookupframe').style.height = 220;
}

function ajax_close_search()
{
	document.getElementById('lookup').style.display = "none";
}

function ajax_populateSELECT(field,theSQL,theFilter)
{
	var anOption = document.createElement("OPTION") 
	document.form1.select1.options.add(anOption) 
	anOption.innerText = "Two" 
	anOption.Value = "2" 
}	



// library


// used for xml
function handleHttpResponse() {
  if (http.readyState == 4) {
    if (http.responseText.indexOf('invalid') == -1) {
      // Use the XML DOM to unpack the city and state data 
      var xmlDocument = http.responseXML;
      var city = xmlDocument.getElementsByTagName('city').item(0).firstChild.data;
      var state = xmlDocument.getElementsByTagName('state').item(0).firstChild.data;
      document.getElementById('city').value = city;
      document.getElementById('state').value = state;
      isWorking = false;
    }
  }
}

function handleHttpResponseSELECT() 
{
	
	var htmlResponse; 
	var arrValues; 
	
  	if (http.readyState == 4) 
  	{
		htmlResponse = http.responseText;
		arrValues = htmlResponse.split("|");
		
		var theWidget = document.getElementById(theSELECTfield.id);
		
		// clear data
		theWidget.options.length=0; 
		
		for(i=0;i<arrValues.length;i++)
		{
			var element = arrValues[i].split(";");
			theWidget.options[theWidget.options.length]= new Option(element[1],element[0]); 
		}
		
		isWorking = false;
    }
  }


function ajax_populateSELECT(theFIELD,theTABLE,theID,theDESC,theFILTER,theDECODE) 
{
	if (!isWorking && http) 
	{
		var theURL = "index.php?fuseaction=lookup.comboDB_ajax&stoplayout=true&theTABLE=" + theTABLE + "&theID=" + theID + "&theDESC=" + theDESC + "&theFILTER=" + theFILTER + "&theDECODE=" + theDECODE;  
		theSELECTfield = document.getElementById(theFIELD);
		
		http.onreadystatechange = handleHttpResponseSELECT;
    	http.open("GET", theURL, true);
    	
    	isWorking = true;
    	
    	http.send(null);
  	}
}

function getHTTPObject() 
{
	var xmlhttp;
	
	/*@cc_on
	
	@if (@_jscript_version >= 5)
    try 
    {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e) 
    {
		try 
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (E) 
		{
			xmlhttp = false;
		}
	}
	@else xmlhttp = false;
	
	@end @*/
	
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
	{
		try 
		{
			xmlhttp = new XMLHttpRequest();
			xmlhttp.overrideMimeType("text/xml");
		} 
		catch (e) 
		{
			xmlhttp = false;
		}
  	}
  	return xmlhttp;
}

var http = getHTTPObject(); 
var theSELECTfield;
var isWorking = false;





// other


function show_obj(sw,obj) {
	// show/hide the divisions
if (sw) {
	if (IE4 || IE5) 
	{
		document.all[obj].style.visibility = 'visible';
		
	}	
	if (NS4){
		document.layers[obj].visibility = 'visible';
	}
	if (NS6){
		document.getElementById(obj).style.visibility='visible';
	}

} else {

	if (IE4 || IE5) document.all[obj].style.visibility = 'hidden';
	if (NS4){
		document.layers[obj].visibility = 'hidden';
	}
	if (NS6){
		document.getElementById(obj).style.visibility='hidden';
	}

}

}

function show_obj2(sw,obj) {
	// show/hide the divisions
if (sw) {
	if (IE4 || IE5) 
	{
		document.all[obj].style.display = 'block';
		
	}	
	if (NS4){
		document.layers[obj].display = 'block';
	}
	if (NS6){
		document.getElementById(obj).style.display='block';
	}

} else {

	if (IE4 || IE5) document.all[obj].style.display = 'none';
	if (NS4){
		document.layers[obj].display = 'none';
	}
	if (NS6){
		document.getElementById(obj).style.display='none';
	}

}

}

