var isNS4=document.layers?true:false;
var isIE=document.all?true:false;
var isNS6=!isIE&&document.getElementById?true:false;
var isDOM = (document.getElementById) ? true : false;

function oggi(element){
    var mD = new Date();
    var el=document.getElementById(element);
    //el.value=mD.getFullYear() + "-" + (mD.getMonth()+1) + "-" + mD.getDate();
	el.value=mD.getDate() + "/" + (mD.getMonth()+1) + "/" + mD.getFullYear();
}

function doPassVar(pag){
    HM_DOM = (document.getElementById) ? true : false;
    HM_NS4 = (document.layers) ? true : false;
    HM_IE = (document.all) ? true : false;

	
    
	if (HM_IE){   //IE
		//alert('IE');
		var mF = document.getElementById("myFlash");
		mF.SetVariable("menu", pag);        
    }else{
        if (HM_DOM){
			var mF = document.getElementById("myFlash");
			mF.SetVariable("menu", pag);
            alert('DOM');
        }else{  //Netscape
			alert('NS');
            var mF=document.myFlash;
			mF.SetVariable("menu", pag);
			alert('NS');
        }
    }	
}

function delCheck(){
	if(window.confirm("You're delete this record. Are you sure?"))
		return true;
	else
		return false;
}

function isblank(s){
	for (var i=0; i < s.length; i++){
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\t')) return false;
	}
	return true;
}

function checkDelSelected(){
	//usata onSubmit per delSelected....
	if(window.confirm("Deleting selected records. Are you sure?"))
		return true;
	else
		return false;
}


function delRows(scheda){
// 	var mF=document.getElementById("scheda");
// 	alert(document.forms['scheda'].elements.length)
	
	
	if(window.confirm("Stai cancellando le righe selezionate. Sei sicuto?"))
		doAction(scheda);
		
		
}

function delcheck(){
	if(window.confirm("Deleting selected record. Are you sure?"))
		return true;
	else
		return false;
}


var invioOK='Richiesta inviato correttamente.<br><br>Neiko Team <div id="thumbs"/>';
var invioNO='Errore nell\'invio della richiesta.<br><br>Ci scusiamo per l\'inconveniente e la preghiamo di riprovare pi&#249; tardi.<br><br>Neiko Team <div id="thumbs"/>';
function checkForm() {
	var formOK=true;
	if( $('azienda').value==''){
		$('azienda').style.borderColor="#f00";
		formOK=false;
	}else{
		$('azienda').style.borderColor="#d2d2d2";
	} 
	
	if( $('email').value=='' || !checkMail($('email').value)){
		$('email').style.borderColor="#f00";
		formOK=false;
	}else{
		$('email').style.borderColor="#d2d2d2";
	}  

	if( !$('s1').checked  && !$('s2').checked ){
		$('sCell').style.cssText="border:solid 1px #f00;width:180px;";
		formOK=false;
	}else{
		$('sCell').style.cssText="border:solid 0px #f00;width:180px;";
	}  
	
	if( !$('privacy').checked  ){
		$('pCell').style.cssText="border:solid 1px #f00;width:180px;";
		formOK=false;
	}else{
		$('pCell').style.cssText="border:solid 0px #f00;width:180px;";
	}  
			
	if(formOK){
		return true;
	}else{
		$('form_msg').innerHTML='ATTENZIONE!! Il form presenta degli errori. Verificare i campi bordati in rosso';
	}
	return false;
}

function checkMail(src) {
	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	var regex = new RegExp(emailReg);
	return regex.test(src);
}

function aggiorna(){
	location.reload(true);
}

function vaia(url){
    if (isIE){
		document.URL=url;
	}else{
		window.location=url;
	}
}

function vaiaSelected(sel){
	// come vaia, ma con la gestione di selectedItem
	var mS = document.getElementById(sel);
	url=mS.selectedIndex;
	url=mS.options[url].value;
	//alert(url);
	vaia(url);
}

function focusOn(id){
	var mF=document.getElementById(id);
	mF.focus();
}

function over(obj,bgcolor){
	obj.style.backgroundColor=bgcolor;
}

function login(f) {
	//attenzione, lunghezza PSW 
	if( f['psw'].value.length > 3){
		f['psw'].value = hex_md5(f['psw'].value);
		return true;
	}else{
		alert('Password lunga solo '+f['psw'].value.length + ' caratteri!')
	}
	return false;
}

function editPsw(f) {
	if(f['new'].value==f['retype'].value){
		f['old'].value = f['id'].value + hex_md5(f['old'].value);
		f['new'].value = f['id'].value + hex_md5(f['new'].value);
		return true;
	}else{
		alert('RE-TYPE non corrisponde a NEW! Verifica la correttezza del dato');
		return false;
	}
}

function onEnter(f){
	var campi = new Array('nome','cognome','email','indirizzo','cap','comune','provincia','telefono','fax')
	var valori = new Array('nome*','cognome*','email*','indirizzo*','cap','comune*','provincia*','telefono*','fax')
// 	alert(f.name)
	var v_old=f.value
	for(var i=0;i<campi.length;i++)
		if(campi[i]==f.name.substring(2,f.name.length)){
// 			alert('(' + i + ')' + campi[i] + ': ' + v_old + '-' + valori[i])
			if(v_old == valori[i])
				f.value=''
			else if(v_old == '') 
				f.value=valori[i]
			break;
		}
}

function onEnter2(f){
	var campi = new Array('nome','cognome','email')
	var valori = new Array('nome','cognome','email*')
// 	alert(f.name)
	var v_old=f.value
	for(var i=0;i<campi.length;i++)
		if(campi[i]==f.name.substring(2,f.name.length)){
// 			alert('(' + i + ')' + campi[i] + ': ' + v_old + '-' + valori[i])
			if(v_old == valori[i])
				f.value=''
			else if(v_old == '') 
				f.value=valori[i]
			break;
		}
}

function MM_findObj(n, d) { //v4.0
	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 && document.getElementById) 
		x=document.getElementById(n);
	return x;
}

//gestione blocchi --------------------------------------------
var hasCookies = false;

// tests whether the user accepts cookies, and sets a flag.
if(document.cookie == '') {
	document.cookie = 'hasCookies=yes';
	if (document.cookie.indexOf('hasCookies=yes') != -1) hasCookies = true;
}
else hasCookies = true;

function blockState(divID) {
	var theCookie = readCookie(divID);
	var state="e";
	if ((theCookie == "e") || (theCookie == "")) {
		state="c";
	}
	setCookie(divID,state,'Wed 01 Jan 2020 00:00:00 GMT','/');
	return state;
}

// reads a cookie from the browser
function readCookie(name) {
	if (document.cookie == '') return '';
	else {
		var firstChar, lastChar;
		var theBigCookie = document.cookie;
		firstChar = theBigCookie.indexOf(name);
		if (firstChar != -1) {
			firstChar += name.length + 1;
			lastChar = theBigCookie.indexOf(';', firstChar);
			if (lastChar == -1) lastChar = theBigCookie.length;
			return unescape(theBigCookie.substring(firstChar, lastChar));
		}
	else return '';
	}
}

// sets a cookie in the browser.
function setCookie (name, value, hours, path) {
	if (hasCookies) {
	if(hours) {
		if ( (typeof(hours) == 'string') && Date.parse(hours) ) var numHours = hours;
		else if (typeof(hours) == 'number') var numHours = (new Date((new Date()).getTime() + hours*3600000)).toGMTString();
	}
	document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'');
	}
}

if (!isIE) document.captureEvents(Event.MOUSEMOVE)
function getMouseXY(e) {
  if (isIE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
	return tempY;
}

function showLayer(divID){
	var divIDobj = MM_findObj(divID);
	divIDobj.style.visibility = "visible"
}

function hideBlock(divID){

	//nel caso di FAQ	chiudo tutti i div
	if(divID.substr(0,3)=='faq'){
		for(var i=0;i<16;i++)
			if($('faq'+i))
				$('faq'+i).style.display = "none";
	}
	
	var divIDobj = $(divID);

	if(divIDobj.style.display == "none"){
		divIDobj.style.display = "block";
	}else{
		divIDobj.style.display = "none";
	}

}

function hideSub(divID){
	var divIDobj = MM_findObj(divID);
	var toggleobj = MM_findObj(divID +"Toggle");

	if(divIDobj.style.display == "none"){
		toggleobj.src = "images/subOpen.gif";
		divIDobj.style.display = "block";
	}else{
		toggleobj.src = "images/subClosed.gif";
		divIDobj.style.display = "none";
	}
}

//FINE gestione blocchi --------------------------------------------

function help(){

}

//gestione menu--------------------------------------------
function showMenu(menu){
	var mM=isDOM?document.getElementById(menu).style: isNS4 ? document.layers[menu]: document.all[menu].style;

	//alert(mM.visibility);

	if (mM.visibility == "hidden")
		mM.visibility =  "visible";
	else
		mM.visibility =  "hidden";


}

function closeMenu(menu){
	var mM=isDOM?document.getElementById(menu).style: isNS4 ? document.layers[menu]: document.all[menu].style;
	mM.visibility =  "hidden";
}
//FINE gestione menu--------------------------------------------

function overCal(id){
	alert(id);
}

function checkNumber(f,e){
	var code = (window.Event) ? e.which : e.keyCode;
	var myD = MM_findObj("f_MaxAmount2");
	

	n=f.value;
	if(  (code<47 || code>58) && (code<36 || code>41) &&  (code<15 || code>21) &&  (code<32 || code>36) && code!=0 && code!=13 && code!=8 && code!=45 && code!=27 && code!=46 &&  (code<111 || code>124)){
		
		if (code==190){
			punto=n.lastIndexOf(".") - n.indexOf(".");
			if(punto>0)
				n=n.substr(0,n.length-1)
		}else if (code==188){	
			punto=n.indexOf(".");
// 			alert(", p:"+punto)
			if(punto>0)
				n=n.substr(0,n.length-1)
			else
				n=n.replace(/,/,".");
// 		}else if (  (code>=37 || code<=40) || code==13 || code==8 || code==46        ){
			// 37-40 frecce
			// 13 invio
			// 8 del
			// 46 canc
		}else{
			n=n.substr(0,n.length-1)
// 			myD.value+="-"+code;
		}
		
	}
	f.value=n;
}

function modGroup(){
	alert(document.forms.length)
	var f=document.forms['list'];
	f.submit();
// 	return false;
}


function showEditForm_(quale){
	var scheda = MM_findObj('scheda');
// 	var myform = document.form;
// 	alert(document.form.length);
// 	alert(scheda.childNodes.length)


/*	for(i=0;i<scheda.childNodes.length;i++){
		layer.innerHTML += i + '> ' + scheda.childNodes[i].id+'<br>';
	}*/
	var elementi = new Array();
	elementi=getCampi(scheda);

	var layer = document.createElement('div');
	layer.setAttribute('id', 'editForm');
	scheda.appendChild(layer);
	layer.innerHTML='elements:<br>';

	for(i=0;i<elementi.length;i++){
		layer.innerHTML += i + '> ' + elementi[i] +'<br>';
	}

// 	alert(s)
}

function getCampi(nodo,myLay){
// 	alert(nodo.childNodes.length)
	for(x=0;nodo.childNodes[x];x++){
// 		alert(nodo.childNodes[x].nodeName)
		getCampi2(nodo.childNodes[x],myLay)
	}

}

function getCampi2(nodo,myLay){
	

// 		if(nodo.nodeType==1) alert(nodo.attributes['id'].nodeValue)
// 		alert('a: ' + nodo.nodeType + ' - name:' + nodo.nodeName)
		switch(nodo.nodeName){
			case 'ROW':
// 				alert('row')
				var myTR=document.createElement('tr');
				myLay.appendChild(myTR)
// 				alert(nodo.childNodes.length)
				for( var x = 0; nodo.childNodes[x]; x++ ) {
// 					outStr += showDomTree( topElement.childNodes[x], topCode+'_'+x );
// 					alert(nodo.childNodes[x].nodeName)
					getCampi2(nodo.childNodes[x],myTR)
				}
				break;
			case 'RH': 
// 				alert('rh:' + nodo.firstChild.nodeValue)
				var myTH=document.createElement('th');
				var cell=document.createTextNode(nodo.firstChild.nodeValue);
				myTH.appendChild(cell);
				myLay.appendChild(myTH)
				break;
			case 'RD':
// 				alert('rd:' + nodo.firstChild.nodeValue)
				var myTD=document.createElement('td');
				var cell=document.createTextNode(nodo.firstChild.nodeValue);
// 				var cell=document.createTextNode('ccc');
				myTD.appendChild(cell);
				myLay.appendChild(myTD)
				break;
			default:
// 				alert('def:' + nodo.nodeName)
		}


}

function resetForm(f){
	var myF = MM_findObj(f);
	myF.reset();
}

function showScheda(n){
   for(var i=1;i<=2;i++){
   	var myS = MM_findObj('scheda' + i);
   	myS.style.visibility='hidden';
   }
   var myS = MM_findObj('scheda' + n);
   myS.style.visibility='visible';
}
//##############################################################################
inElaborazione=false;

//##############################################################################
function systemBusy(status){
   //alert(status)
   if(status){
      inElaborazione=true;

      //$(loading).innerHTML='<div style="border:solid 1px;"><img src="gui/images/loading.gif"/></div>';
      var w=$(load_dove).clientWidth;
      var h=$(load_dove).clientHeight;            
      var mD=document.createElement('DIV');
      mD.id='loading';
      mD.style.cssText = 'position:absolute;top:0;left:0;height:'+h+'px;width:'+w+'px;text-align:center;vertical-align:middle;background-color:#fff;filter:alpha(opacity=60);-moz-opacity:0.60;opacity:0.6; -khtml-opacity:.6;';
      mD.innerHTML='<img style="padding-top:'+(h/2 - 10)+'px" src="gui/images/loading.gif"/>';
      $(load_dove).innerHTML='';
      $(load_dove).appendChild(mD);    
               
   }else{
      inElaborazione=false;
      //$('footer').innerHTML='<div style="font-size:10px;"><img src="'+gui_path+'/images/loading5_off.gif"/></div>';  
      
   }
}

//##############################################################################
var load_dove='';
function loadHTML(s,dove){
   
   //alert('loadData: ' + s + ' - ' + dove)
   //alert(':2:' + cache.getChiamata(dove+'2'))
   
   if(s=='') return false; 
   
   // verifico che il sistema non sia occupato in altro...
   //attendo che l'elaborazione sia finita!
   if(inElaborazione)
      return;
		
	load_dove=dove
	systemBusy(true);
	//return;
	
	if(!dove || dove==''){
      alert('manca DOVE, r.489');
   } 

	var pars = 'pag=' + s;
   	//alert(pars)
   
	$(dove).innerHTML='<img style="margin-left:80px;margin-top:50px;" src="gui/images/loading.gif"/>';
	
	new Ajax.Request(
		'main.php', 
		{
			method: 'get', 
			parameters: pars, 
			onComplete: success,
			onFailure: failure,
			onException: exception 			
		});
		
	function failure(risp){
	  alert("Failure\npars: "+pars+'\nrisp: '+risp.responseText)
   }	
	function exception(risp){
	  alert("Exception\npars: "+pars+'\nrisp: '+risp.responseText)
   }   
   function success(risp){
      //alert('dove: '+dove)
      //alert(risp.responseText.substr(0,9));
      $(dove).innerHTML= risp.responseText;
      systemBusy(false);
   }		
}
//##############################################################################
function checkHeight(){
	//alert('x')
	if ( isIE ){
		var h=document.body.clientHeight;
		//h+=10;
	}else{
		var h=window.innerHeight;
	}	
	
	var s='<b>debug checkHeight:</b>';
	s+='<br>winH: '+h;
	
	
	if(h>692){
		$('footer').style.height=(h-642)+'px';
		$('siteContainer').style.height=h+'px';
		
		s+='<br>winH>692, new footer h: '+(h-642)+'; new siteContainer h: '+h;
		
	}else{
		$('siteContainer').style.height=692+'px';
		s+='<br>winH<692, new siteContainer h: '+692;
		//alert(h)
	}
	
	if($('debug'))
		$('debug').innerHTML=s;
	
}
//##############################################################################
function center_popup(obj,win_w,win_h){
	if ( isIE ){
		var w=document.body.clientWidth;
		var h=document.body.clientHeight;
		var yOffest=ietruebody().scrollTop;
		
		//centro la finestra
		$(obj).style.left= ((w-win_w)/2) +'px';		
		
		//alert('h:' + h + ' - os: '+ yOffest )
		
		//posizione verticale
		if(yOffest >0 ){
			$(obj).style.top= (yOffest +70) +'px';
		}else{
			$(obj).style.top= '70px';
		}				
	}else{
		var w=window.innerWidth;
		var h=window.innerHeight;
		var yOffest=window.pageYOffset;

		//alert('h:' + h + ' - os: '+ yOffest )

		//centro la finestra
		$(obj).style.left= ((w-win_w)/2) +'px';		
		
		//posizione verticale
		if(yOffest >0 ){
			$(obj).style.top= ((h-win_h)/2 + yOffest - 30) +'px';
		}else{
			$(obj).style.top= ((h-win_h)/2)+'px';
		}				
	}	
}

function mappa(){
	var s='<img src="' + guiPath + '/images/cartina.gif" />';
	s+='<div id="indicazioni" style="position:absolute;right:10px;top:10px;width:200px;height:480px;overflow:auto;"></div>';
	divPopup('Come raggiungerci',s,700,490);
	loadHTML('indicazioni','indicazioni');
	
}

function showFlash(url,w,h){
	var s='';
	if(url.substr(url.length-4)=='.jpg' || url.substr(url.length-4)=='.gif'){
		s='<img src="'+ guiPath + '/'+url+'"/>';
	}else{
		s='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
		s+='width="'+w+'" height="'+h+'">';
		s+='<param name="movie" value="' + guiPath + '/' + url + '">';
		s+='<param name=quality value=high>';
			s+='<embed src="' + guiPath + '/' + url + '" quality=high ';
			s+='pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" ';
			s+='width="'+w+'" height="'+h+'">';
		s+='</embed>';
		s+='</object>';		
	}
	
	return s;
}

function fixflash(containerID){
	if(!isIE) return false;
	//alert('x')
	var flashContainer = $(containerID);
	var flashMovie = document.createElement("div");
	flashMovie.innerHTML = flashContainer.innerHTML.replace(/</g, "<").replace(/>/g, ">");
	flashContainer.parentNode.insertBefore(flashMovie, flashContainer);
	flashContainer.parentNode.removeChild(flashContainer);
	flashMovie.setAttribute("id",containerID);
}
//##############################################################################
function mostraScheda(rif){

	if(rif == undefined){
		alert('ATTENZIONE manca il riferimento al progetto!');
		return;
	}
	
	$('blkWindow').style.cssText='display:block;height:'+screen.availHeight+'px;';
	//alert(screen.availHeight)
	
	new Ajax.Updater(
		'tmpContainer', 
		'prj/'+rif+'.html', 
		{
			method: 'get', 
			parameters: '',
			/*onComplete: success,*/
			onFailure: failure,
			onException: exception 				
		});   
		
	function failure(risp){
		alert("Failure\nrisp: "+risp.responseText)
	}	
	function exception(risp){
		alert("Exception\nrisp: "+risp.responseText)
	}   
}

function mostraScheda_success(){
	if( $('tmpContainer').innerHTML=='' ) return;
	
	//alert( 'h:'+$('tmpContainer').offsetHeight +' - w:'+$('tmpContainer').offsetWidth );
	//alert( 'h:'+$('tpl_table').offsetHeight +' - w:'+$('tpl_table').offsetWidth );
	if($('tpl_table')){
		var h=$('tpl_table').offsetHeight;
		var w=$('tpl_table').offsetWidth;			
		//alert(w+'-'+h)
	}else{
		var h=$('tmpContainer').offsetHeight;
		var w=$('img_big').offsetWidth;
	}
	
	var mwin=new myWindow(' ',$('tmpContainer').innerHTML, w, h);
	mwin.resize();
	mwin.show();
	$('tmpContainer').innerHTML='';
}


function img_over(img) { 
	if( typeof img  == 'object' )
		img=img;
	else
		img=$(img);

	if(img==null) return;
	
	src=img.src;
	est=src.substring(src.length-4);
	
	if(src.substr(src.length-6,2)=='_o')
		src=src.substring(0,(src.length-6)) +est;
	else
		src=src.substring(0,(src.length-4)) + '_o'+est;
	
	img.src=src;
}

function show_content(id){
	
	if($('servizi2') && $('servizi2').style.display=='none'){
		//alert($('servizi2').style.display)
		Effect.Fade('servizi1');
		$('servizi2').style.display='block';
		$('footer').style.classText="margin-left:200px";
		Effect.Appear('vociSubMenu');		
		
	}

	var par=$('content'+id).parentNode;
	var divs=par.getElementsByTagName('div');
	//alert(divs.length)
	for(var i=0;i<divs.length;i++){
		if(divs[i].id.substr(0,7)=='content' && divs[i].id!='content'+id)
			Effect.Fade(divs[i].id);
	}
	
	Effect.Appear('content'+id);
	if($('servizi2') && $('servizi2').style.display=='block'){
		$('servizi0').style.height='412px';
		$('footer').style.marginLeft='200px';

	}
		
}

function show_dett(id){
	$('areaDx').innerHTML='<img style="margin-left:80px;margin-top:50px;" src="gui/images/loading_b.gif"/>';

	var par=$('dett_'+id).parentNode;
	var divs=par.getElementsByTagName('div');
	//alert(divs.length)
	for(var i=0;i<divs.length;i++){
		if( divs[i].id.substr(0,5)=='dett_' && i!=id ){
			//Effect.Fade(divs[i].id);
			
			$('link_dett_'+ divs[i].id.substr(5) ).style.color='#636363';
		}
			
	}
	
	$('link_dett_'+id).style.color='#f00';
	
	setTimeout("$('areaDx').innerHTML=$('dett_"+id+"').innerHTML;",300);
	
}

function zoom(obj,foto){
	var par=obj.parentNode;
	var imgs=par.getElementsByTagName('img');
	for(var i=0;i<imgs.length;i++){
		imgs[i].style.border="solid 2px #eee";	
	}

	obj.style.border="solid 2px #fba40d";
	$('img_big').src='/prj/imgs/'+foto;
	//alert($('img_big').src)
}

function show_prj_browser(id){
	
	$('lista_or').innerHTML='<img style="margin-left:45%;margin-top:100px;" src="{$guiPath}/images/loading_b.gif"/>';
	
	//alert($('box_empty').style.display)
	if($('box_empty').style.display!='none')
		$('box_empty').style.display='none';
	
	$('lista').style.display='none';
	//$('lista_media').style.display='none';
	//$('lista_video').style.display='none';
	//$('lista_3d').style.display='none';
	
	var x=35;
	var dir='top-left';
	var pars='pag=lista&t=web';
	switch(id){
		case 'lista_media': 
			x+=204;
			dir='top-left';
			$('lista_tit').src='gui/images/tit_multimedia2.gif';
			pars='pag=lista&t=multimedia';
			break;
		case 'lista_video': 
			x+=204*2;	
			dir='top-right';
			$('lista_tit').src='gui/images/tit_video2.gif';
			pars='pag=lista&t=video';
			break;
		case 'lista_3d': 
			x+=204*3;
			dir='top-right';
			$('lista_tit').src='gui/images/tit_3d2.gif';
			pars='pag=lista&t=virtual';
			break;
		default:
			$('lista_tit').src='gui/images/tit_web_solution2.gif';
	}
	$('box_empty').style.left=x+'px';
	
	Effect.Appear('box_empty');	
	
	Effect.Grow('lista', {direction: dir});
	
	
	//carica lista
	new Ajax.Updater(
		'lista_or', 
		'main.php', 
		{
			method: 'get', 
			parameters: pars,
			onComplete: success,
			onFailure: failure,
			onException: exception 				
		});   
		
	function failure(risp){
		alert("Failure\nrisp: "+risp.responseText)
	}	
	function exception(risp){
		alert("Exception\nrisp: "+risp.responseText)
	}   
	function success(risp){
		//alert( 'h:'+$('tmpContainer').offsetHeight +' - w:'+$('tmpContainer').offsetWidth );
		//alert( 'h:'+$('tpl_table').offsetHeight +' - w:'+$('tpl_table').offsetWidth );

	}	
}

function close_lista(){
	$('box_empty').style.display='none';
	$('lista').style.display='none';
}

function mostraMenu(menu,mode){
	//alert(menu)
	var m=$$('div.menuSx2');	
	var h=0;

	//ritiro i sottomenu'
	for(var i=0;i<m.length;i++){
		if(m[i].style.left!='' && m[i].style.left!='-2px'){
			if(mode=='fix')
				m[i].style.left='-2px';
			else
				new Effect.Move(m[i], { x: -2, y: 0, mode: 'absolute', duration: 0.3, queue: { position: 'front', scope: 'menu2' } });				
		}
	}
	
	//riprisino il menu principale
	var m=$$('#menuSx1 li');
	for(var i=0;i<m.length;i++){
		//alert(m[i].id)
		m[i].style.backgroundColor="transparent";
		m[i].onmouseover = function(){ menuOver(this)	} 
		m[i].onmouseout = function(){	menuOut(this)	}		
	}
	//evidenzio menu1
	if($('li_'+menu)){
		$('li_'+menu).style.backgroundColor="#3b3b3b";
		$('li_'+menu).onmouseout=null;			
	}
	//----------------------------
	
	
	if($(menu)){
		if(mode=='fix'){
			$(menu).style.left='102px';
			$(menu).style.top=h+'px';
		}else{
			//alert($(menu).id)			
			//$(menu).style.left='102px';
			new Effect.Move($(menu), { x: 102, y: h, mode: 'absolute', duration: 0.5, queue: { position: 'end', scope: 'menu2' } });	
		}
	}
}

function mostraTesto(t){
	var blocks=$$('div.hidden_txt');
	
	for(var i=0;i<blocks.length;i++){
		id=blocks[i].id
		$(id).hide();
		$('img_'+id.substr(4)).src='gui/images/freccia_off.png';
	}

	//alert(blocks.length)
	
	$('txt_'+t).show();
	//Effect.SlideDown('txt_'+t, { duration: .3 });
	$('img_'+t).src='gui/images/freccia_on.png';
}

var sessionLoading=false;
function mostraSessione(sess){
	if(sess=='') return;

	
	if( !$(sess) ){
		//window.location = "main.php?pag=home";
		alert('r.915 - non trovo il div \''+sess+'\'')
		return;
	} 	
	
	if(sessionLoading==true){
		//alert('x');
		return;
	} 
	sessionLoading=true;
		
	var pagine=$$('div.pageContainer');
	for(var i=0;i<pagine.length;i++){
		new Effect.Fade(pagine[i], { duration: 0.1, queue: { position: 'front',	scope: 'pageContainer'} } );
	}		
	new Effect.Appear(sess, { duration: 0.3, queue: { position: 'end',	scope: 'pageContainer'} });

	//gestione dei subMenu
	if( $('sm_'+sess) ){
		var m=$$('#menu_'+currentPage+' li');
		for(var i=0;i<m.length;i++){
			m[i].style.backgroundColor="transparent";
			m[i].onmouseover = function(){
				menuOver(this)
			} 
			m[i].onmouseout = function(){
		 		menuOut(this)
		 	}
		}
		
		$('sm_'+sess).style.backgroundColor="#3b3b3b";
		$('sm_'+sess).onmouseout=null;		
		
	}
	
	//realizzazioni per tipologia
	if(sess=='ptip')
		loadHTML('main.php?pag=prjsList&t=11','prjsList1');
		
		
	setTimeout("sessionLoading=false",1200);
	//sessionLoading=false;
}



function mostraPag(pag){
	window.location = "main.php?pag="+pag
}


// http://www.quirksmode.org/js/detect.html
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

function ridim(quando){

	if(BrowserDetect.browser=='Explorer' && BrowserDetect.version<7){
		//alert('Attenzione! Sito ottimizzato per Internet Explorer 7');	
	}	
	
	pagescroll=Viewport();
	//alert(screen.availHeight)
	if(quando==0){  //onload case
	

		//var track = new Image();
		//track.src='main.php?pag=track&sw='+screen.availWidth+'&sh='+screen.availHeight;
		//document.write("<img src='restracker.gif?sw="+screen.width+"&sh="+screen.height+"' width='1' height='1' />");
	}
	
	//alert(BrowserDetect.browser)
	if($('flashBckContent')){
		var fx=pagescroll.pageX+'px';
		var fy=pagescroll.pageY+'px';
		
		if(BrowserDetect.browser=='Explorer' && BrowserDetect.version<7){
			//alert('isie')
			//fx='100%';
			//fy='100%';			
		}
		//fx='300px';
		//fy='300px';		
		
		var flash='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ' +
			'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" ' +
			'width="'+fx+'" height="'+fy+'" align="middle" style="z-index:1;position:absolute;top:0px;left:0px;display:block;" id="back_flash">	';	
		flash += '<param name="allowScriptAccess" value="sameDomain" />';
		flash += '<param name="allowFullScreen" value="false" />';
		flash += '<param name="movie" value="gui/swf/sfondo.swf" />';
		flash += '<param name="quality" value="high" />';
		flash += '<param name="bgcolor" value="#ffffff" />';
		flash += '<param NAME="wmode" VALUE="transparent">';
		flash += '<embed src="gui/swf/sfondo.swf" quality="high" bgcolor="#ffffff" width="'+fx+'" height="'+fy+'" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';		
		flash += '</object>';
		
		flash='<embed style="width:'+fx+'; height:'+fy+';z-index:1;position:absolute;top:0px;left:0px;"'
			+ 'type="application/x-shockwave-flash" '
			+ 'src="gui/swf/sfondo.swf" '
			+ 'quality="best" '
			+ 'wmode="transparent"></embed>';
		$('flashBckContent').innerHTML=flash;
	}

	//ZOCCOLO NERO
	if( $('zoccolo_') ){
		alert(pagescroll.pageY)
		if(pagescroll.pageY > 650){
			$('zoccolo').style.bottom='-'+(pagescroll.pageY - 591)+'px';
			$('zoccolo').style.height=(pagescroll.pageY - 591)+'px';
		}
	}
	
	//FINE zoccolo
	
	
	

/*
	<img src="#" onerror="mostraSessione('{$s}')" style="display:none;"/>
	<img src="" onerror="mostraMenu('menu_{$pag}','fix')" style="display:none;"/>	
*/	
 
}

function Viewport(){ 
	this.windowX = (document.documentElement && document.documentElement.clientWidth) || window.innerWidth || self.innerWidth || document.body.clientWidth; 
	this.windowY = (document.documentElement && document.documentElement.clientHeight) || window.innerHeight || self.innerHeight || document.body.clientHeight; 
	this.scrollX = (document.documentElement && document.documentElement.scrollLeft) || window.pageXOffset || self.pageXOffset || document.body.scrollLeft; 
	this.scrollY = (document.documentElement && document.documentElement.scrollTop) || window.pageYOffset || self.pageYOffset || document.body.scrollTop; 
	this.pageX = (document.documentElement && document.documentElement.scrollWidth) ? document.documentElement.scrollWidth : (document.body.scrollWidth > document.body.offsetWidth) ? document.body.scrollWidth : document.body.offsetWidth; 
	this.pageY = (document.documentElement && document.documentElement.scrollHeight) ? document.documentElement.scrollHeight : (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight;

	return this;
}

function menuOver(o){
	o.style.backgroundColor="#3b3b3b";
}
function menuOut(o){
	o.style.backgroundColor="transparent";
}
function showImg(g,t){
	//alert(g+' - '+t)
	for(var i=1;i<=t;i++){
		if( $('im_'+i) ) 
			if(i==g){
				$('im_'+i).show();
				if( $('bp_'+i) )
					$('bp_'+i).style.color="#00f";
			}else{
				$('im_'+i).hide();
				$('bp_'+i).style.color="#011b3c";
			}
	}
}
