
//################## JAVASCRIPT FUNCTIONS ##########################
//	Francesco Lai 25/03/08
//
//	Progetto Sito Marconi
//
//#######################################################################

var debug=false;

//______________________________________________________________________
//           FA SCOMPARIRE LA SCRILLBAR SE NON NECESSARIA
//______________________________________________________________________

function disappearScrollTrack(idDivContainer, idDivText, idDivTrack)
{
	var DivHeightContainer = document.getElementById(idDivContainer).clientHeight;
	var DivText = document.getElementById(idDivText).clientHeight;
	var DivTrack = document.getElementById(idDivTrack);


	if(DivText<DivHeightContainer)
	{
		DivTrack.style.display='none';
	}
	else
	{
		DivTrack.style.display='inline';

		//inserisci la scrollbar
		scroller4  = new jsScroller(document.getElementById("03_Scroller-1"), 400, 200);
		scrollbar4 = new jsScrollbar (document.getElementById("03_Scrollbar-Container"), scroller4, false);
	}

	//------------------DEBUG-------------------
	if(debug)
		alert("DivTesto: "+DivText+" - DivContenitore: "+DivHeightContainer);

	//------------------END--------------------
}
//______________________________________________________________________


//______________________________________________________________________
//           FA APPARIRE L'IMMAGINE GRANDE AL CENTRO PAGINA
//______________________________________________________________________

function viewBigImg(img, divImg)
{
	var divImbBig = document.getElementById(divImg);

	divImbBig.innerHTML='<img src="allegati/img/'+img+'" />';


	//------------------DEBUG-------------------
	if(debug)
		alert("IMG->"+img+ "DIV->"+divImg );

	//------------------END--------------------
}
//______________________________________________________________________

//______________________________________________________________________
//           CAMBIA LA CLASSE DI UN DIV
//______________________________________________________________________
function changeClass(id, classElement)
{

	//alert(id);

	var element=document.getElementById(id);
	element.className=classElement;


	return false;

}
//______________________________________________________________________

//______________________________________________________________________
//          CAMBIA IL CSS
//______________________________________________________________________

function newCSS(n)
{

	document.styleSheets[0].disabled = true;
	document.styleSheets[1].disabled = true;
	document.styleSheets[2].disabled = true;

	document.styleSheets[n].disabled = false;
	/*	alert(document.styleSheets[n].href);*/
}
//______________________________________________________________________


//______________________________________________________________________
//          RICERCA
//______________________________________________________________________

function ricerca(id)
{

	var string=document.getElementById(id).value;

	//alert(string);

	if(string!='' && string.length>2)
	{
		if(nCivico('inputRicerca', '20000', 'Testo ricercato nulla o non valido.', 'divAlert', 'resultAlertDiv', '', 1))
			ajaxInviaDati('stringa='+string, 'ajax.php', 'viewResultSearch(req.responseText)');
		else
			alertDiv('inputRicerca', 'Carattere non corretto', 'divAlert', 'resultAlertDiv', '', 1)

	}else{
			alertDiv('inputRicerca', 'Sono necessarie almeno 3 lettere per effettuare la ricerca rapida.', 'divAlert', 'resultAlertDiv', '', 1)

	}

}
//______________________________________________________________________


//______________________________________________________________________
//          CAMBIA LA TABELLA DI RICERCA AL CLICK
//______________________________________________________________________

function cambiaTabellaRicerca(id, tabella)
{

 	document.getElementById(id).value=tabella;

	//------------------DEBUG-------------------
	if(debug)
		alert("Tabella: "+tabella+" - IdInput: "+id);

	//------------------END--------------------

}
//______________________________________________________________________


//______________________________________________________________________
//          CAMBIA LA TABELLA DI RICERCA AL CLICK
//______________________________________________________________________

function cambiaPagina(id, n)
{

 	document.getElementById(id).innerHTML="Pagina "+n+" di";

	//------------------DEBUG-------------------
	if(debug)
		alert("id: "+id+" - numero: "+n);

	//------------------END--------------------

}
//______________________________________________________________________



