/*
con js 1.2 gli array fanno crashare la servlet
*/

// Funzioni per istogrammi
/*
var coloriR = new Array(100, 101, 102, 103, 104, 105, 106);
var coloriG = new Array(100, 101, 102, 103, 104, 105, 106);
var coloriB = new Array(100, 101, 102, 103, 104, 105, 106);

var coloriR = new Array(160, 130, 190, 103, 104, 105, 106);
var coloriG = new Array(180, 170, 180, 103, 104, 105, 106);
var coloriB = new Array(190, 160, 200, 103, 104, 105, 106);
*/

var coloriR = new Array("FF", "80", "FA", "FF", "A0", "82", "BE");
var coloriG = new Array("CC", "B9", "5A", "FF", "B4", "AA", "B4");
var coloriB = new Array("00", "E3", "5A", "99", "BE", "A0", "C8");

var conta = 0;
var Period = new Array();
var TotAmount = new Array();
var IssueDate = new Array();
var min = 0;
var max = 0;
var limiteStrigaLegenda = 18;	//costante per il troncamento
//var tipo = 'para'; //para, cilindro

function loadData(periodo, valore, data) 
{

/*	alert (periodo);
	alert (valore);
	alert (data); */

	if (conta < 7)
	{	 	
		Period[conta] = periodo;	// + " " + conta;
		TotAmount[conta] = valore;
		IssueDate[conta] = data;
		set_min_max(Number(valore));
		conta++;
	}	

/*
	Period[conta] = "ciao";
	TotAmount[conta] = "50.2";
	set_min_max(50.2);
	conta++;
*/


//	alert("Period: " +Period);
	//alert("IssueDate: " +IssueDate);
	//alert("TotAmount: " +TotAmount);
	
/*	alert("conta: " +conta);
	alert("min: " +min);
	alert("max: " +max);*/


}

function callGeneraImg(tipo, imgNome, gType)
{
	/*
		var current_img = document['test_img'].src;
		alert(current_img);
	*/
	//var src = "Compunet.CompanyServicesEntryPoint.GenerateGraph?Period=" +Period+ "&TotAmount=" +TotAmount+ "&Min=" +min+ "&Max=" +max;
	var servlet = "Compunet.CompanyServicesEntryPoint.GenerateGraph";
	var param = "?Period=" +Period+ "&IssueDate=" +IssueDate+ "&TotAmount=" +TotAmount+ "&Min=" +min+ "&Max=" +max+ "&Tipo=" +tipo;
	var paramCol = "&ColoriR=" +coloriR+ "&ColoriG=" +coloriG+ "&ColoriB=" +coloriB + '&colorS=FFFFFF&colorE=FFFFFF';
	var src = servlet + param + paramCol
	if (gType=='torta')
		src = src +  '&gType=' + gType; 
	//document.write(src);	

	document[imgNome].src = src;
}


function cleanData() 
{
	conta = 0;
	Period = new Array();
	TotAmount = new Array();
	IssueDate = new Array();
	min = 0;
	max = 0;
}

function set_min_max(val)
{
	if (val < min) {
		min = val;
	}
	if (val > max) {
		max = val;
	}
}

function generaLegenda() 
{
	//Period = new Array();
	//for (var i=0; i<(conta); i++)
	if (conta > 7)
		conta = 7;
		
	for (var i=(conta-1); i>=0; i--) {
		document.write('<tr><td width="10" height="10" bgcolor="#');
		document.write(coloriR[i] + coloriG[i] + coloriB[i]);
		document.write('"/><img src="/dyna_ebpp/comp_000/images/vuota.gif" border="0" width="9" height="9" title="Periodo: ');
		document.write(Period[i]);
		document.write('"/></td>');
		document.write('<td width="129"><font class="txt_legenda">');
		document.write(troncaStringa(Period[i], limiteStrigaLegenda));
		document.write('</font></td></tr>');
		document.write('<tr height="5"><td colspan="2"><img src="/dyna_ebpp/comp_000/images/vuota.gif" border="0" width="1" height="4"/></td></tr>');		
	}
}


/* legenda grafico importi integrata in prima colonna lista fatture */
function generaLegendaNew() {
	//Period = new Array();
	//for (var i=0; i<(conta); i++)
	if (conta > 7)
		conta = 7;
		
	for (var i=(conta-1); i>=0; i--) {
		var colore = coloriR[i] + coloriG[i] + coloriB[i];
		var idg = i+1;
		
		//document.getElementById('graphPeriod_' + idg).setAttribute('bgcolor',colore);
		document.getElementById('graphPeriod_' + idg).setAttribute('style', "background-color: #" +colore);
	}
}



function troncaStringa(str, limite)
{
	if (str.length > limite)
	{
		str = str.substring(0, limite-3) + "...";
	}
	return (str);
}


// Funzioni per la gestione delle comunicazioni
function new_comunication (sess, pass) {
	var url = "Compunet.CompanyServicesEntryPoint.Comunications?template=SPL_INSMODCOMUNICATIONS&IdSessione=" + sess + "&Password=" + pass + "&IdComunication=0";
	self.location.href = url;
}

function confirm_delete (sess, pass, comid) {
	var url = "Compunet.CompanyServicesEntryPoint.Comunications?template=SPL_EXDELCOMUNICATION&IdSessione=" + sess + "&Password=" + pass + "&com_id=" + comid;
	var msg = "ATTENZIONE!\nSei sicuro di voler cancellare la comunicazione?\n\nPremi 'OK' per confermare.";

	if (confirm(msg)) {
		self.location.href = url;
	}
}

function verifica_GestCommForm () {
	var form = document.GestCommForm;

	if (form.com_title.value == "") {
		alert ("Inserire un titolo.");
		return false;
	}
	
	return true;
}


// Funzioni per l'upload di flussi e Bollette singole
function verifica_uplform () {
	var form = document.uplform;

	if (form.fileInvoice.value == "") {
		alert ("Selezionare il file!");
		return false;
	}
	if (form.Notes.value == "") {
		alert ("Inserire delle note");
		return false;
	}
	if (form.EMail.value == "") {
		alert ("Inserire l'indirizzo e-mail");
		return false;
	}
	return true;
}


// Funzioni per la ricerca delle Bollette
function verifica_srcform () {
	var form = document.srcform;

	if ((form.UserCode.value == "") && (form.NumFatt.value == "") && (form.User.value == "") && (form.Dest.value == "")) {
		alert ("Inserire il codice utente e/o il numero della fattura.");
		return false;
	}

/*	if (!verifica_data(form.DataFatt,form.DataFatt.value,form, true, false)) {
		return false;
	} */
	return true;
}


function logout()

 {
  var vurl = "Compunet.Logout?IdSessione=" + document.logform.IdSessione.value + "&Password=" + document.logform.Password.value;
  self.location.href= vurl;
 }



/*##############################################################################################
funzione per la selezione delle Bollette da pagare
*/
function loadArrayFatture() 
{
	var form = document.paymentform;
	for (var i=0; i<form.length; i++)
	{
		if ((form[i].type == "checkbox") && (form[i].checked)) 
		{
			break;
		}
	}

	if (i >= form.length)
	{
		alert ("Selezionare almeno una fattura dalla lista");
		return;
	}


	for (var i=0; i<form.length; i++) 
	{
		if (form[i].type == "checkbox")
		{
			if(!(form[i].checked))
			{
				form[i+2].value = 0;
			}
		}
	}
	form.submit();	
}
/*##############################################################################################*/



/*##############################################################################################
funzione per la selezione delle Bollette per l'INVIO DUPLICATO NON STANDARD (FOLPATO)
*/
function setArrayDuplicatoNS()
{
    var form = document.sndform;
	if (form.recipients[0].value == '') {
		alert ('Indicare il destinatario');
		return;
	}
    //controlla se e' stata selezionata almeno una fattura
    for (var i=0; i<form.length; i++) {
            if ((form[i].type == "checkbox") && (form[i].checked)) {
            	break;
            }
    }
    
    if (i >= form.length) {
    	alert ("Selezionare almeno una fattura dalla lista");
        return;
    }
    //END controllo 

    for (var i=0; i<form.length; i++) {
   		if (form[i].type == "checkbox") {
      		if(!form[i].checked) {
        		form[i+1].value = 0;
        	}
      	}
    }
    
    form.submit();
}
/*##############################################################################################*/



/* nuove funzioni per la nuova bolletta */

function showSearchForm ()
{

	var component = document.getElementById('searchform');
	


	if (component != null)
	{
       component.style.display='block';
	}
	else
		self.location.href='Compunet.CompanyServicesEntryPoint.Invoices?IdSessione=195128&Password=ytsx6nqdddcxljgqblm6&template=SPL_SRCHINVOICES';
	

}


function showDownLoadForm(event, component, left, top)
{
	var myForms = document.getElementsByName("test");

	var Y = 0;
	var X = 100;
	
	if (navigator.appName == "Microsoft Internet Explorer")
		Y = event.clientY;
	else
		Y = event.pageY;
	
	if (top!=undefined) Y=top;
	if (left!=undefined) X=left;
	for (i=0; i < myForms.length; i++)
		eval ('document.getElementById(' + "'" + myForms[i].value + "'" + ').style.visibility=' + "'hidden'");
	document.getElementById(component).style.visibility='visible';
	document.getElementById(component).style.left=X;
	document.getElementById(component).style.top= Y;
}



function hideDownLoadForm(component)
{

	document.getElementById(component).style.visibility='hidden';
}


function turnDisplay(id)
{
	if (document.getElementById(id).style.display=='none')
		document.getElementById(id).style.display='block';
	else	
			document.getElementById(id).style.display='none';

}

function turnDisplay_img(id, imgid)
{
	if (document.getElementById(id).style.display=='none')
	{
		document.getElementById(id).style.display='block';
		document.getElementById(imgid).src='/dyna_ebpp/comp_000/images/folder_orange_open.gif'; 
	}
	else	
	{
		document.getElementById(id).style.display='none';
		document.getElementById(imgid).src='/dyna_ebpp/comp_000/images/folder_orange.gif';	
	}

}


function display(id)	{
	document.getElementById(id).style.display='block';
}


function hideComboBox (box)	{
	for (i=0; i < box.options.lenght; i++)	{
		box.options[i].display = none;
	}
}


function selectComboCAP (doc)	{
	//var doc = document.searchsupplyaddr;

	for (i=0; i<doc.city.length; i++)
		doc.city.options[i].style.display = 'none';
	doc.city.selectedIndex = 0;
	
	for (i=0; i<doc.comboCitta.length; i++) {
		if (doc.cap.options[doc.cap.selectedIndex].value == doc.comboCitta[i].value)
			doc.city.options[i+1].style.display = 'block';
	}
}


function setuppaPDF()	{
	if (document.getElementById('PDF') != null)	{
		document.getElementById('PDF').setShowToolBar(false);
		document.getElementById('PDF').setCurrentPage(1);
		document.getElementById('PDF').setLayoutMode('SinglePage');
		document.getElementById('PDF').setZoom(67);
	}
}


function printPDF()	{
	if (document.getElementById('PDF') != null)	{
		document.getElementById('PDF').Print();
	}
}


function showPDFToolbar(val) {
	if (document.getElementById('PDF') != null)	{
		document.getElementById('PDF').setShowToolBar(val);
	}
}

function checkAll(val, form, excludeValue) {
	for (var i=0; i<form.length; i++) {
		if (form[i].type == "checkbox" && form[i].value!=excludeValue) {
			form[i].checked=val;
		}
	}
}											

function ctrlCheck(form) {
	for (var i=0; i<form.length; i++)
		if (form[i].type == "checkbox")
			if (form[i].checked) return true;
	return false;
}


function DisplayPayDetails(di, el) {
	if (currentPaymentDiv  != 0)
		hide(currentPaymentDiv);
	
	selectContainerElement(el,currentPaymentDiv, di );
	currentPaymentDiv  = di;
	turnDisplay(di);
}


function selectContainerElement (el, oldTR, newTR) {
	var newRiga = document.getElementById('tr_' + newTR);

	if (oldTR != 0)	{
		var oldRiga = document.getElementById('tr_' + oldTR);
		
		for (i=0; i<oldRiga.childNodes.length; i++) {
			if (oldRiga.childNodes[i].nodeName == 'TD')
				oldRiga.childNodes[i].style.backgroundColor = newRiga.childNodes[i].style.backgroundColor;
		}
	}	
	
	for (i=0; i<newRiga.childNodes.length; i++) {
		if (newRiga.childNodes[i].nodeName == 'TD') {
			newRiga.childNodes[i].style.backgroundColor = '#FFFFFF';
		}
	}
}


function hide(id) {
	document.getElementById(id).style.display='none';
}

function hideDebugDiv(id) {
	document.getElementById(id).style.display='none';
}

function guarda(event) {
	
	var elemento =  event.target;
	
	var trovato = 0;
	if (elemento.tagName == 'IMG')
		elemento = elemento.parentNode;
	
	vid = elemento.id;
	
	var process = 1;
	if ((vid != null) && (vid == 'debugHref'))
		process = 0;
	if ((vid != null) && (vid == 'debugGo'))
		process = 0;
	
	if (process) {
		if (elemento.tagName == 'A') {
			odiv = getDebugDiv(event);
			debugContent = document.getElementById('debugContent');
			
			var attributo = findAttributo(elemento, 'onclick');
			
			if (attributo != null) {
				var contenuto =  attributo.nodeValue;
					
				/* caso di onclick  window.open */
				if (contenuto.indexOf('window.open') >= 0) {
					debugContent.innerHTML = '<b>' +  basePath  + '</b>'+ '<br/>';	
					var vurl = contenuto.substring(contenuto.indexOf('(')+2,   contenuto.indexOf(',')-1);
					var basePath = vurl.substring(0, vurl.indexOf('?'));
					var parameter = vurl.substring(vurl.indexOf('?') + 1);
					debugContent.innerHTML += tokenizeParams(parameter);
				}
				else
					debugContent.innerHTML = contenuto;
			}
			else {
				//attributo onclick non trovato				
				debugContent.innerHTML = elemento.hostname + elemento.pathname + '<br/>' ;
				parameter = elemento.search; 
				debugContent.innerHTML += tokenizeParams(parameter);
			}	
		}
		else if (elemento.tagName == 'INPUT') {
			var attributo = findAttributo(elemento, 'type');
			if ( (attributo != null) && (attributo.nodeValue == 'button')) {
				odiv = getDebugDiv(event);
				debugContent = document.getElementById('debugContent');
				debugContent.innerHTML = "";
				
				attributo = findAttributo(elemento, 'onclick');
				if (attributo != null) {
					debugContent.innerHTML += '<b>Azione: </b>' +  attributo.nodeValue;
					
					if (attributo.nodeValue.indexOf('ubmit') > 0) {
						var f = attributo.nodeValue.substring(0, attributo.nodeValue.indexOf('ubmit')-2);
						var myForm = eval(f);
						if ((myForm != null) && (myForm.tagName == 'FORM')) {
							debugContent.innerHTML += '<br/><b>---Parametri---</b>';
							for (i=0; i < myForm.length; i++)
								debugContent.innerHTML += '<br/><b>' + myForm[i].name + ':</b>' + myForm[i].value;
						}
					}	
				}	
			}	
		}	
	}
}


function tokenizeParams(parameter){
	var rtvalue = "";
	
	toks = new java.util.StringTokenizer(parameter,'&', false);
					
	while (toks.hasMoreTokens()) {
		var par = toks.nextToken();
		rtvalue += '<b>' +  par.substring(0,par.indexOf('=')) + '</b>'  + par.substring(par.indexOf('=')) + '<br/>';
	}

	return rtvalue;
}


function findAttributo (elemento, attr) {
	var rtvalue = null;

	numAttribute = elemento.attributes.length;
	for (i=0; i < numAttribute; i++)
		if (elemento.attributes[i].nodeName == attr)
			rtvalue = elemento.attributes[i];				
	
	return rtvalue;
}


function getDebugDiv(event) {
	var odiv = document.getElementById('debugGo');
	
	if (odiv == null) {
		odiv = document.createElement('DIV') ;	
		odiv.setAttribute('id','debugGo');	
		odiv.innerHTML = '<table class="frame" align="center" cellpadding="0" cellspacing="0">' +
						 '<tr>                                                                        ' +
						 '<td class="frameheader" style="border-right:0px"><b>..: Debug :..</b></td>' +
						 '<td class="frameheader" style="border-left:none" width="3%">                  ' +
						 '<a href="" onclick="hideDebugDiv(\'debugGo\');return false;"  id="debugHref">                            ' +
						 '<img src="/dyna_ebpp/default/images/chiudi.jpg" border="0" />            ' +
						 '</a>                                                                          ' +
						 '</td>                                                                         ' +
						 '</tr>                                                                         ' +
						 '<tr>                                                                          ' +
						 '<td class="framecontent" colspan="2" id="debugContent">                       ' +
						 '                                                                              ' +
						 '                                                                              ' +
						 '                                                                              ' +
						 '                                                                              ' +
						 '</td>                                                                         ' +
						 '</tr>                                                                         ' +
						 '</table>                                                                      ';
					
		content = document.body;
		content.appendChild(odiv);
		new Draggable('debugGo', {});
		
		cx = event.clientX + 15;
		cy = event.clientY;
		var vstyle = 'display:block;  position:absolute; left:20px; top:200px';  
		odiv.setAttribute('style',vstyle);		
	}
	
	return odiv;
}


function inizia() {
	document.body.setAttribute('onmouseover','guarda(event)');
}	
		

function viewXML(par) {
	var vurl = 'jvstorewebapp.ExecRequest?' + par	+ '&trasform=no&content_type=XML';
	window.open( vurl, 'pippo', 'width=600,height=500,scrollbars=yes');
}		

function addContent(tag, content, pos) {
	var nodi = new Array();
	
	if ((tag.childNodes.length == 0) || (pos >= tag.childNodes.length))
		tag.appendChild(content);
	
	else if (tag.childNodes.length > 0) {
		for (i=0; i <  tag.childNodes.length;  i++)
			nodi.push(tag.childNodes[i]);
		while (tag.childNodes.length  > 0)
			tag.removeChild(tag.childNodes[0]);	
		
		var i=0;
		
		while (i < nodi.length){
			if (i == pos)
				tag.appendChild(content);
				
			tag.appendChild(nodi[i]);
			i=i+1;
		}
	}	
}


function expandText (vTitle, vText, vIcon, vId, vElement) {
	//vElement.setAttribute('style', 'background-color:#CDE4FD');
    new AjaxToolTip (vTitle, vText, vIcon, vId, vElement);		
}

function removeText(vId) {
	var vEl = document.getElementById(vId);
	var vParent = vEl.parentNode;
	
	vParent.removeChild(vEl);
	//vParent.setAttribute('style', 'background:transparent')
}

/**
 * Le funzioni che seguono servono per la registrazione area customer e la modifica del profilo
 **/


function isEmail(mail){
	/* controllo sintassi indirizzo email */
	var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
	
	if (espressione.test(mail))
		return 1;
	else
		return 0;
}

function checkForm() {	
	//riferimento form di registrazione
	var form = document.RegForm; 
	var errMsg = "";
	
	//controllo campi obbligatori
	if (form.nome.value == "" ||
		form.indirizzo.value == "" ||
		form.cap.value == "" ||
		form.citta.value == "" ||
		form.provincia.value == "" ||
		form.uPassword.value == "" ||
		form.uPassword1.value == "" ||
		form.email.value == "" || 
		form.email1.value == "") {
			
		errMsg = "- si prega di compilare tutti i campi richiesti;";
	}	

	//controllo lunghezza password
	if (form.uPassword.value != "" && form.uPassword.value.length < 6) {
		if (errMsg != "") errMsg += "\n";
		errMsg += "- il campo 'password' deve contenere almeno 6 caratteri alfanumerici;";
	}
	
	//controllo password di conferma
	if (form.uPassword.value != form.uPassword1.value) {
		if (errMsg != "") errMsg += "\n";
		errMsg += "- i campi 'password' e 'conferma password' non corrispondono;";
	}

	//controllo validità indirizzo
	if (form.email.value != "" && isEmail(form.email.value) == 0 ) {
		if (errMsg != "") errMsg += "\n";
		errMsg += "- l'indirizzo e-mail non e' valido;";
	}
	else {
		//controllo email di conferma
		if (form.email.value != form.email1.value) {
			if (errMsg != "") errMsg += "\n";
			errMsg += "- i campi 'e-mail' e 'conferma e-mail' non corrispondono;";
		}	
	}
	
	if (errMsg != "") {
		alert("Errore nell'inserimento dei dati:\n" + errMsg);
		return false;
	}
	else {
		setComType();
		//return true;
		document.RegForm.submit();
	}
		
}

function checkFormProfile() {	
	//riferimento form di modifica dati
	var form = document.RegForm; 
	var errMsg = "";
	
	//Controllo assenza password
	if (form.uPassword.value == "" &&
		form.uPassword1.value == "" &&
		form.email.value != "" && form.email1.value != "")
			
			errMsg = "- per effettuare la modifica e' necessario inserire anche la password;";
	//controllo campi obbligatori
	else {
		if (form.uPassword.value == "" ||
			form.uPassword1.value == "" ||
			form.email.value == "" || 
			form.email1.value == "")
				errMsg = "- si prega di compilare tutti i campi richiesti;";
	}	
	
	//controllo lunghezza password
	if (form.uPassword.value != "" && form.uPassword.value.length < 6) {
		if (errMsg != "") errMsg += "\n";
		errMsg += "- il campo 'password' deve contenere almeno 6 caratteri alfanumerici;";
	}	
	
	//controllo password di conferma
	if (form.uPassword.value != form.uPassword1.value) {
		if (errMsg != "") errMsg += "\n";
		errMsg += "- i campi 'password' e 'conferma password' non corrispondono;";
	}

	//controllo validità indirizzo
	if (form.email.value != "" && isEmail(form.email.value) == 0 ) {
		if (errMsg != "") errMsg += "\n";
		errMsg += "- l'indirizzo e-mail non e' valido;";
	}
	else {
		//controllo email di conferma
		if (form.email.value != form.email1.value) {
			if (errMsg != "") errMsg += "\n";
			errMsg += "- i campi 'e-mail' e 'conferma e-mail' non corrispondono;";
		}	
	}
	
	if (errMsg != "") {
		alert("Errore nell'inserimento dei dati:\n" + errMsg);
		return false;
	}
	else {
		setComType();
		//return true;
		document.RegForm.submit();
	}
		
}

function setComType()
{
	/*
	Per i poveretti come noi:
	0 NENTI
	1 email
	2 sms (disabled in UI)
	3 email + sms (disabled in UI)
	*/
	retVal=0;
	retVal|=(document.RegForm.comemail.checked ? 1 : 0);
	retVal|=(document.RegForm.comsms.checked ? 2 : 0);
	retVal&=(document.RegForm.comunication[1].checked ? 0 : 3);
	document.RegForm.flagComunication.value = retVal; 
}


function hideCheckBox() {
	document.getElementById("comunic_1").style.display='none';
	document.getElementById("comunic_2").style.display='none';
	document.getElementById("mobile").style.display='none';
	document.RegForm.comemail.checked = false;
}

function showCheckBox() {
	document.getElementById("comunic_1").style.display='block';
	document.getElementById("comunic_2").style.display='block';
	document.getElementById("mobile").style.display=(document.getElementById("comsms").checked ? 'inline' : 'none');
	document.RegForm.comemail.checked = true;
}	


function sel (v){
	for (var i = 0; i < document.RegForm.provincia.options.length; i++) {
    	if (document.RegForm.provincia.options[i].value == v)
     		document.RegForm.provincia.selectedIndex = i;
   	}
} 

 
function turnDisplayVTab(idTabSelector, idTabContentl, idTabToolBar, idTabContentr, imgTabSelector) {
	
	var elImg = document.getElementById(imgTabSelector);
	var source = elImg.getAttribute("src");

	if (document.getElementById(idTabToolBar).style.display=='none') {
		document.getElementById(idTabToolBar).style.display='block';
		var el = document.getElementById(idTabSelector);
		el.setAttribute("class", "tabSelector");
		
		var indx =  source.indexOf(".png",0); 
		
		if (indx >= 0) {
			var baseSource = source.substring(0, indx);
			elImg.setAttribute("src", baseSource + "_hide.png");
		}
	}	
	else {
		var el = document.getElementById(idTabSelector);
		el.setAttribute("class", "tabSelectorHide");
		document.getElementById(idTabToolBar).style.display='none';
		
		var indx =  source.indexOf("_hide.png",0); 
		
		if (indx >= 0) {
			var baseSource = source.substring(0, indx);
			elImg.setAttribute("src", baseSource + ".png");
		}
	}	
		
	if (document.getElementById(idTabContentr).style.display=='none')
		document.getElementById(idTabContentr).style.display='block';
	else	
		document.getElementById(idTabContentr).style.display='none';	
}
 

function highlight(id) {
	var sH = document.getElementById("alertMonId").clientHeight;
	document.getElementById("succhia").scrollTop = sH;
}


function setPageTitle (title) {
	var titArea = null;
	var tit = null;
	
	titArea = document.getElementById('titlearea');
	tit = document.getElementById('title');
	titArea.style.display = 'none';
	if ((tit != null) && (titArea != null))
	{
		tit.innerHTML = title;
	}
	
	Effect.Appear(titArea);	
}


// Browser Detection Javascript
// copyright 1 February 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function whichBrs() {
	var agt=navigator.userAgent.toLowerCase();
	
	if (agt.indexOf("opera") != -1) return 'Opera';
	if (agt.indexOf("staroffice") != -1) return 'Star Office';
	if (agt.indexOf("webtv") != -1) return 'WebTV';
	if (agt.indexOf("beonex") != -1) return 'Beonex';
	if (agt.indexOf("chimera") != -1) return 'Chimera';
	if (agt.indexOf("netpositive") != -1) return 'NetPositive';
	if (agt.indexOf("phoenix") != -1) return 'Phoenix';
	if (agt.indexOf("firefox") != -1) return 'Firefox';
	if (agt.indexOf("safari") != -1) return 'Safari';
	if (agt.indexOf("skipstone") != -1) return 'SkipStone';
	if (agt.indexOf("msie") != -1) return 'Internet_Explorer';
	if (agt.indexOf("netscape") != -1) return 'Netscape';
	if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
	
	if (agt.indexOf('\/') != -1) {
		if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
			return navigator.userAgent.substr(0,agt.indexOf('\/'));
		}
		else return 'Netscape';
	} 
	else if (agt.indexOf(' ') != -1)	
		return navigator.userAgent.substr(0,agt.indexOf(' '));
	else 
		return navigator.userAgent;
}


function setTitoloMail () {
	var formFields = $A($('sendFormId').getElementsByTagName('INPUT'));

	document.sndform.title.value = "Rif. Inoltro fatture ";	
	formFields.each(function(item) {
		if ((item.type=='checkbox') && (item.checked == true)) {
			var t = document.sndform.title.value;
			document.sndform.title.value = t + " - " + item.value;
		}
	});
}

/** 
 * @param component il meta tag da invocare con la request
 * @param lista di parametri in formato query string encodata */

function showAjaxURL(component, params, container) {

	var vurl = 'jvstorewebapp.ExecRequest?template=' + component + '&' +  params;

	$(container).innerHTML ='<img src="/dyna_ebpp/default/images/loading.gif"/>';

	new Ajax.Request(vurl, {
		method: 'get',
		onSuccess: function(transport) {
			var contentDiv = $(container);
			contentDiv.innerHTML = transport.responseText; 
		}
	});
}


