//----------------------------------------------------------------------------------------------------------------------------------------
//--- 
//--- 
//--- Description: 
//--- Author: eTT s.r.l. - SS, UG, FP, AF
//--- Edited: 16 June 2003
//---
//--- INDICE
//--- FUNZIONI JAVASCRIPT
//--- function logosHeader(): stampa la tabella di intestazione delle pagine [SS, UG, FP, AF 16 June 2003]
//--- function PiePrivacy(): [SS, UG, FP, AF 16 June 2003]
//--- Linguetta(testo, percorso, attiva): [SS, UG, FP, AF 16 June 2003]
//--- Bottone(testo, percorso): [SS, UG, FP, AF 16 June 2003]
//--- Finestra(link): [SS, FP 19 September 2003]
//--- Submit(percorso): [SS, UG, FP, AF 16 June 2003]
//--- trim(stringa): [SS, UG, FP, AF 16 June 2003]
//--- l_trim(stringa): [SS, UG, FP, AF 16 June 2003]
//--- r_trim(stringa): [SS, UG, FP, AF 16 June 2003]
//--- ApriFinestra(link): [SS, UG, FP, AF 16 June 2003]
//--- Titolo(sx,dx): [SS, UG, FP, AF 16 June 2003]
//--- Sezione(testo): [SS, UG, FP, AF 16 June 2003]
//--- Messaggio(testo): [SS, UG, FP, AF 16 June 2003]
//--- Icona(img, js, alt): [SS, UG, FP, AF 16 June 2003]
//--- SezioneTabella(testo, table, img, js, alt): [SS, UG, FP, AF 16 June 2003]
//--- ArraySezioneTabella(testo, table, img, js, alt): [SS, UG, FP, AF 16 June 2003]
//--- function SvuotaHDN (objCod, objDescr, objHidden, isChangedCod): [SS, FP 06 October 2003]
//--- FUNZIONI ASP
//--- Titolo(sx,dx):  [SS, UG, FP, AF 16 June 2003]
//--- Sezione(testo):  [SS, UG, FP, AF 16 June 2003]
//--- SezioneTabella(testo):  [SS, UG, FP, AF 16 June 2003]
//--- ReplaceSingleQuoteSQL(stringa):  [SS, UG, FP, AF 16 June 2003]
//--- ReplaceSingleQuoteJS(stringa):  [SS, UG, FP, AF 16 June 2003]
//--- Sesso(IdLavoratore):  [SS, UG, FP, AF 16 June 2003]
//--- IndicePagine(pageassoluta, PageCount):  [SS, UG, FP, AF 16 June 2003]
//--- URLCompleto(): restituisce l'URL completo di parametri POST e GET della pagina visualizzata [SS, FP 19 September 2003]
//----------------------------------------------------------------------------------------------------------------------------------------

function copiaResidenzaInDomicilio(suffisso)
{
	eval('document.TheForm.txtLAVIndirizzoDomicilio_' + suffisso + '.value = document.TheForm.txtLAVIndirizzo_' + suffisso + '.value;');
//	eval('document.TheForm.txtLAVCivicoDomicilio_' + suffisso + '.value = document.TheForm.txtLAVCivico_' + suffisso + '.value;'); //@Ab (10840) - commento il civico
	eval('document.TheForm.txtLAVCAPDomicilio_' + suffisso + '.value = document.TheForm.txtLAVCAP_' + suffisso + '.value;');
	eval('document.TheForm.hdnLAVComuneDomicilio_' + suffisso + '.value = document.TheForm.hdnLAVComune_' + suffisso + '.value;');
	eval('document.TheForm.txtLAVComuneDomicilio_' + suffisso + '.value = document.TheForm.txtLAVComune_' + suffisso + '.value;');
	eval('document.TheForm.hdnCodLAVComuneDomicilio_' + suffisso + '.value = document.TheForm.hdnCodLAVComune_' + suffisso + '.value;');

	if (eval('document.TheForm.txtLAVCentroImpiego_' + suffisso + '.type == "hidden"')) //modifica lav: copia cpi residenza in hidden cpi
	{
		//if (document.TheForm.appDescrCPI.value != "") //variazione residenza: copia cpi residenza in hidden cpi
		//{
			eval('document.TheForm.hdnDescrCPI.value = document.TheForm.appDescrCPI.value;');
			eval('document.TheForm.hdnIdCPI.value = document.TheForm.appIdCPI.value;');
		/*}
		else //copia cpi residenza in hidden cpi
		{
			eval('document.TheForm.hdnIdCPI.value = document.TheForm.hdnLAVComune_' + suffisso + '.value;');
			eval('document.TheForm.hdnDescrCPI.value = document.TheForm.txtLAVComune_' + suffisso + '.value;');
		}*/

		/*
		 if (confirm("Si sta per cambiare il domicilio del lavoratore.\n\nSi vuole effettuare anche il trasferimento del Centro\nper l'Impiego di competenza?"))
		{
			window.open ("trasfLav/trasfLavGestione.asp?hdnidAnag=" + document.TheForm.hdnId.value + "&step=modify", "dettagli", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=400'");
		}
		*/
	}
	else //inserimento lav e upload movimento: copia cpi residenza in cpi
	{
		//if (document.TheForm.appDescrCPI.value != "") //variazione residenza: copia cpi residenza variato in cpi
		//{
			eval('document.TheForm.txtLAVCentroImpiego_' + suffisso + '.value = document.TheForm.appDescrCPI.value;');
			eval('document.TheForm.hdnLAVCentroImpiego_' + suffisso + '.value = document.TheForm.appIdCPI.value;');
		/*}
		else //copia cpi residenza in hidden cpi
		{
			eval('document.TheForm.hdnIdCPI.value = document.TheForm.hdnLAVComune_' + suffisso + '.value;');
			eval('document.TheForm.hdnDescrCPI.value = document.TheForm.txtLAVComune_' + suffisso + '.value;');
		}*/
	}
//    eval('document.TheForm.txtProvDomicilio' + suffisso + '.value = document.TheForm.txtProvResid' + suffisso + '.value;');
//    eval('document.TheForm.hdnIdCirc' + suffisso + '.value = document.TheForm.hdnIdCircRes' + suffisso + '.value;');
}

//--- function logosHeader(): stampa la tabella di intestazione delle pagine [SS, UG, FP, AF 16 June 2003]
function logosHeader()
{
	document.write ("<table STYLE=\"position:relative;text-align:center;PADDING-TOP: 10pt;width:100%;PADDING-BOTTOM: 8pt;PADDING-LEFT: 10pt;PADDING-RIGHT: 10pt;\">")
	document.write ("<tr STYLE=\"BORDER: windowtext 1pt solid; BORDER-COLOR: white;position:relative;text-align:center;PADDING: 0pt;\">")
	document.write("<td STYLE=\"width:33%;vertical-align:middle;text-align:center;\"><img border=\"0\" src=\"" + NomeSito + "images_" + SiglaProvincia + "/LogoProvincia.jpg\" >&nbsp;&nbsp;</td>") //@Ab - LOGHI
	document.write("<td STYLE=\"width:34%;vertical-align:middle;text-align:center;\"><img border=\"0\" src=\"" + NomeSito + "images_" + SiglaProvincia + "/LogoServizioPiccolo.jpg\" >&nbsp;&nbsp;</td>")
	//@Ab - LOGHI
	//document.write ("<td STYLE=\"width:33%;vertical-align:middle;text-align:center;\"><img border=\"0\" src=\"" + NomeSito + "images_" + SiglaProvincia + "/LogoEuropa.jpg\">&nbsp;&nbsp;<img border=\"0\" src=\"" + NomeSito + "images_" + SiglaProvincia + "/LogoCPIPiccolo.jpg\" ></td>")
	document.write("<td STYLE=\"width:33%;vertical-align:middle;text-align:center;\"><img border=\"0\" src=\"" + NomeSito + "images_" + SiglaProvincia + "/LogoInvestiamoFuturo.jpg\" ></td>") //@Ab - LOGHI
	//fine @Ab
	document.write ("</tr>")
	document.write ("</table>")
}
//--- function PiePrivacy(): [SS, UG, FP, AF 16 June 2003]
function PiePrivacy()
{
	document.write ("<div ID =\"PREPIE\" STYLE=\"margin-bottom: 20px;\"></div>");
	window.document.body.style.margin = 0;
	if (window.document.body.offsetHeight<=(PREPIE.offsetTop+20)) 
		PREPIE.style.height =  0;
	else
		PREPIE.style.height =  window.document.body.offsetHeight - PREPIE.offsetTop - 20;
	document.write ("&nbsp;&nbsp;&nbsp;<a href=\"" + NomeSito + "privacy.asp\" target=\"_blanck\"><font CLASS=\"Note\">Informativa ai sensi del decreto legislativo 196/2003 sulla tutela dei dati personali.</font></a>");
}

//--- Linguetta(testo, percorso, attiva): [SS, UG, FP, AF 16 June 2003]
function Linguetta(testo, percorso, attiva)
{
	document.write ("&nbsp;");
	document.write ("<input type='button' name='"+testo+"' value='" + testo.toLowerCase() + "' ");
	if (attiva == "1") document.write (" class='input-Linguetta-attiva'"); else document.write (" class='input-Linguetta'");
	document.write (" onClick='javascript: "+percorso+"'>");	
	document.write ("&nbsp;");
}

//--- Linguetta(testo, percorso, attiva): [SS, UG, FP, AF 16 June 2003]
function LinguettaLav(testo, percorso, attiva)
{
	document.write ("&nbsp;");
	document.write ("<input type='button' name='"+testo+"' value='" + testo.toLowerCase() + "' ");
	if (attiva == "1") document.write (" class='input-LinguettaLav-attiva'"); else document.write (" class='input-LinguettaLav'");
	document.write (" onClick='javascript: "+percorso+"'>");	
	document.write ("&nbsp;");
}
//--- Linguetta(testo, percorso, attiva): [SS, UG, FP, AF 16 June 2003]
function LinguettaGen(testo, percorso, attiva)
{
	document.write ("&nbsp;");
	document.write ("<input type='button' name='"+testo+"' value='" + testo.toLowerCase() + "' ");
	if (attiva == "1") document.write (" class='input-LinguettaLav-attiva'"); else document.write (" class='input-LinguettaLav'");
	document.write (" onClick='javascript: "+percorso+"'>");	
	document.write ("&nbsp;");
}


//--- Bottone(testo, percorso): [SS, UG, FP, AF 16 June 2003]
function Bottone(testo, percorso)
{
	document.write ("&nbsp;");
	
	//switch	(testo)
	//{	
		//case 'salva':
		//case 'elimina':
		//case 'iscrivi':
		//case 'invia':
		//case 'avanti':
		//case '  ok  ':
		//case 'inoltra adempimento':
		//case 'componi risposta':
		//case 'inoltra':
		//case 'salva ed esci' :
		//	document.write ("<input type='button' name='"+testo+"' value='" + testo.toLowerCase() + "' class='input-pulsante' onClick='javascript: this.disabled=true;"+percorso+"'>");	
		//break
		//default :
		document.write ("<input type='button' name='"+DeleteSpaces(testo)+"' value='" + testo.toLowerCase() + "' class='input-pulsante' onClick='javascript: "+percorso+"'>");	
		//break
	//}
	document.write ("&nbsp;");
}

//--- Finestra(link): [SS, FP 19 September 2003]
function Finestra(link)
{
	var widthFinestra = 1000;
	var heightFinestra = 600;
	return ("var finestra; finestra = window.open (\"" + link + "\", \"dettagli\", \"scrollbars=yes, width="+widthFinestra+", height="+heightFinestra+"\"); if (finestra.screen) { finestra.moveTo(screen.availWidth - "+widthFinestra+" - 12, screen.availHeight - "+heightFinestra+" - 50);  finestra.focus(); }");	
}

// @Ab (12021) - funzione Finestra con opzione resizable
//--- FinestraReSize(link): [Ab 17 June 2008]
function FinestraReSize(link)
{
	var widthFinestra = 1000;
	var heightFinestra = 600;
	return ("var finestra; finestra = window.open (\"" + link + "\", \"dettagli\", \"scrollbars=yes, resizable=yes, width="+widthFinestra+", height="+heightFinestra+"\"); if (finestra.screen) { finestra.moveTo(screen.availWidth - "+widthFinestra+" - 12, screen.availHeight - "+heightFinestra+" - 50);  finestra.focus(); }");	
}
//fine @Ab

//--- Submit(percorso): [SS, UG, FP, AF 16 June 2003]
function Submit(percorso)
{
	return ("TheForm.action=(\"" + NomeSito + "" + percorso + "\"); TheForm.submit();");
}
//--- SubmitAndDisable(percorso,bottone): [SS, UG, FP, AF 16 June 2003]
function SubmitAndDisable(percorso,bottone)
{
	var jsCode;
	jsCode = "TheForm.action=(\"" + NomeSito + "" + percorso + "\");";
	jsCode += "TheForm." + bottone + ".disabled = true;";
	jsCode += "TheForm.submit();";
	return jsCode;
}

//--- trim(stringa): [SS, UG, FP, AF 16 June 2003]
function trim(stringa) 
{
	stringa=l_trim(stringa);
	stringa=r_trim(stringa);
	return stringa;
}

//--- l_trim(stringa): [SS, UG, FP, AF 16 June 2003]
function l_trim(stringa) 
{
	RE = /^\ +/gi
	return stringa.replace(RE, "");
}

//--- r_trim(stringa): [SS, UG, FP, AF 16 June 2003]
function r_trim(stringa) 
{
	RE = /\ +$/gi
	return stringa.replace(RE, "");
}

//--- ApriFinestra(link): [SS, UG, FP, AF 16 June 2003]
function ApriFinestra(link)
{
	var finestra
	finestra = window.open (link, "dettagli", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=1000, height=550");
	if (finestra.screen)
	{ 
	  finestra.window.moveTo(10,100);
	  finestra.focus();
	}
}

//ApriFinestraCC: popup per visualizzare dettaglio azienda consulente/cliente
function ApriFinestraCC(link)
{
	var finestra
	finestra = window.open (link, "dettaglio", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=850, height=550");
	if (finestra.screen)
	{ 
	  finestra.window.moveTo(30,100);
	  finestra.focus();
	}
}

//--- Titolo(sx,dx): [SS, UG, FP, AF 16 June 2003]
function Titolo(sx,dx)
{
	document.write ("<table><tr height='8'><td></td></tr></table>");				
	document.write ("<table width='97%' height='50' align='center' cellspacing='1' border='1' bordercolor='#000066' >");
	document.write ("<tr>");
	if (dx=="")
	{
		document.write ("<td width='100%' class='Titolo' STYLE='text-align: left; '>"+sx+"</td>"); 
	}
	else
	{
		document.write ("<td width='50%' class='Titolo' STYLE='text-align:left;'>"+sx+"</td>"); 
		document.write ("<td width='50%' class='Titolo' STYLE='text-align:right;'>"+dx+"</td>");
	}
	document.write ("</tr></table>");
	//distanziatore inferiore
	document.write ("<table><tr height='2'><td></td></tr></table>");				
}

//--- Sezione(testo): [SS, UG, FP, AF 16 June 2003]
function Sezione(testo)
{
	document.write ("<table><tr height='6'><td></td></tr></table>");				
	document.write ("<table width='97%' height='20' align='center' cellspacing='1' border='1' bordercolor='#000066'>");
	document.write ("<tr align='center' valign='top' bordercolor='#cccccc'>");
	document.write ("<td><b>"+testo+"</b></td></tr></table>");
	//distanziatore inferiore
	document.write ("<table><tr height='1'><td></td></tr><tr height='1'><td></td></tr></table>");				
}

//--- Messaggio(testo): [SS, UG, FP, AF 16 June 2003]
function Messaggio(testo)
{
	document.write ("<table border=0 align=center cellspacing='1' width='97%'>");
	document.write ("<tr align='center'> ");
	document.write ("<td CLASS='Messaggio'>" + testo +"</td>");
	document.write ("</tr>");
	document.write ("</table>");
}

//--- Icona(img, js, alt): [SS, UG, FP, AF 16 June 2003]
function Icona(img, js, alt)
{
	if (js == undefined)	js="";
	if (alt == undefined)	alt="";
	if (js!="") document.write ("<a href='Javascript: " + ReplaceSingleQuoteJS(js) + "'>");
	document.write ("<img src='" + NomeSito + "images/" +  img + "' align='absmiddle' valign='middle' "); /* width='20' height='18'*/
	//document.write ("STYLE='BORDER: windowtext 2px solid; BORDER-COLOR: #000066; margin:0;' alt='" + alt + "'>"); /* vertical-align:middle;*/ 
	document.write (" class='Icona' alt='" + ReplaceSingleQuoteJS(alt) + "'>"); /* vertical-align:middle;*/ 
	if (js!="") document.write ("</a>");
}

//--- SezioneTabella(testo, table, img, js, alt): [SS, UG, FP, AF 16 June 2003]
function SezioneTabella(testo, table, img, js, alt)
{
	if ((table == true) || (table == "true")) document.write ("<table width='97%' align='center' cellspacing='1' border='0'>");
	document.write ("<tr height='10px'><td></td></tr>");
	document.write ("<tr><td class='SezioneTabella'>"+testo+"</td>");
	document.write ("<td class='Campo'>");
	if ((img != undefined) && (img != "")) {
		if ((js != undefined) && (js != "")) {
			Icona(img, js, alt)
		}
		else {
			document.write (img);
		}
	}
	document.write ("</td>");	
	document.write ("<td class='Campo'>&nbsp;</td><td class='Campo'>&nbsp;</td></tr>");
	if ((table == true) || (table == "true")) document.write ("</table>");
}

//--- ArraySezioneTabella(testo, table, img, js, alt): [SS, UG, FP, AF 16 June 2003]
function ArraySezioneTabella(testo, table, img, js, alt)
{
	if ((table == true) || (table == "true")) document.write ("<table width='97%' align='center' cellspacing='1' border='0'>");
	document.write ("<tr valign='middle' height='10px'><td></td>");
	document.write ("<tr valign='middle'><td width='25%' bgcolor='#000066' class='SezioneTabella'>"+testo+"</td>");
	document.write ("<td align='left'>&nbsp;");
	var i, iMax;
	if (img.constructor == Array) {
		for(i=0; i<img.length; i++) {
				if ((img[i] != undefined) && (img[i] != "")) Icona(img[i], js[i], alt[i])	
				document.write ("&nbsp;");
			}			
	}
	else {
		if ((img != undefined) && (img != "")) Icona(img, js, alt);
	}	
	document.write ("</td>");	
	document.write ("<td>&nbsp;</td><td>&nbsp;</td></tr>");
	if ((table == true) || (table == "true")) document.write ("</table>");
}

function elaborazioneInCorso() {
	document.write ("<br><br><table align=\"center\"><tr><td><font size=\"4\">Elaborazione in corso ...</font></td></tr></table>");
}

function SvuotaHDN(objCod, objDescr, objHidden, isChangedCod)
{	
	if ((objDescr.value=="") && ((typeof(objCod)=="object") ? (objCod.value=="") : (true))) {
		objHidden.value="";
	}
	else { 
		if ((!isChangedCod) && (!(objDescr.value=="")) && ((typeof(objCod)=="object"))) {
			objCod.value="";
			objHidden.value="";
		}
		else {
			if (typeof(objCod)=="object") {
				if ((isChangedCod) && (!(objCod.value==""))) {
					objDescr.value="";
					objHidden.value="";
				}
			}
		}
	}
}

function ReplaceSingleQuoteJS(stringa) {
	return stringa.replace(/'/g, "&#39;");
}
//--- IsTelOk: controlla la correttezza di un numero di telefono/fax [CI 10 May 2004]
function IsTelOk(txtTelField)
{	
	if ((txtTelField.value != "") && !(IsTelValid(txtTelField.value))) 
	{
		alert("Il numero di telefono/fax inserito non è corretto.\n\nCorreggerlo, grazie.");
		txtTelField.focus();
		return false;
	}
}

function IsTelValid(telNumber)
{
	//@MMan (9731) Accentramento COL
	//Il telefono o fax dev'essere composto solo da numeri!
	//var RE;
	//var matchArray;
	//
	//telNumber += "";   // cast a stringa
	//RE = /\+?\d+([\s\/-]\d+(-\d+)?)?/;  // sequenza di un numero qualsiasi di cifre eventualmente precedute da "+",
	//									// seguite eventualmente da un'altra sequenza di un numero qualsiasi di cifre
	//									// precedute da uno tra: un qualsiasi spazio, "/" o "-" ed eventualmente seguite da "-"
	//									// ed almeno una cifra
	//matchArray = telNumber.match(RE);
	////--- Se il numero è diverso dalla sequenza estratta
	//if ((matchArray == null) || (telNumber != matchArray[0]))
	//{ 
	//	return false;
	//}
	////--- Else
	//return true;
	/////////////////////////////////////////////////////////////////////////////////////
	if (isNaN(telNumber.replace("+","++").replace("-","--"))){
		return false;
	}
	return true;
	//Fine @MMan (9731)
}

function IsMailValid(email)
{
	var aPos, dotPos, lastPos;
 	aPos=email.indexOf("@"); 
 	dotPos=email.lastIndexOf(".");
 	lastPos=email.length-1;
 	if (aPos<1 || (dotPos-aPos)<2 || (lastPos-dotPos)>4 || (lastPos-dotPos)<2) 
 	{
  		return false;
 	}
 	return true;
}
//@mb(1566)
function ReplaceEcomm(stringa) {
	return stringa.replace(/&/g, "%26"); 
}

//@Boris (6260)
function MyPopUp(windowName, height, width)
{
	var customWindow
	
	customWindow = window.open(windowName, "", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, height="+height+", width="+width);
	
	if (customWindow.screen)
	{
		customWindow.window.moveTo((screen.availWidth/2)-(width/2),(screen.availHeight/2)-(height/2));
		customWindow.focus();
	}
}
//Fine @Boris (6260)

function FinestraDefinita(link, height, width)	//@fp (16958)	//creata per essere associata ai bottoni
{
    var widthFinestra = width;
    var heightFinestra = height;
    return ("var finestra; finestra = window.open (\"" + link + "\", \"dettagli\", \"scrollbars=yes, width=" + widthFinestra + ", height=" + heightFinestra + "\"); if (finestra.screen) { finestra.window.moveTo(0,0);  finestra.focus(); }");
}
