﻿// JScript File
// inizio funzioni editBox ---------------------------------------------------------------
var testoRTF = "";
function calcIFrame( sField ) {
    var s = (document.all)? 'document.frames("' + sField + '").document;': 'document.getElementById("' + sField + '").contentDocument;'; 
    return( eval( s ));
}
function initEditBox(sField) {
    iFrameDoc = calcIFrame( sField );
    iFrameDoc.open();
    if (!document.all) {
        iFrameDoc.write("<HTML><!DOCTYPE html PUBLIC '-/"+"/W3C/"+"/DTD XHTML 1.0 Transitional/"+"/EN' 'http:/"+"/www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><HEAD><LINK href='stili/iframePage.css' type=text/css rel=stylesheet></HEAD><BODY><table class='contenuto'><tr><td colspan='3'><div class='bContent'>" + document.getElementById(sField.substring(5,9)).value + "</div></td></tr></table></BODY></HTML>");
    }else {
        iFrameDoc.write("<HTML><!DOCTYPE html PUBLIC '-/"+"/W3C/"+"/DTD XHTML 1.0 Transitional/"+"/EN' 'http:/"+"/www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><HEAD><LINK href='stili/iframePage.css' type=text/css rel=stylesheet></HEAD><BODY><table class='contenuto'><tr><td colspan='3'><div class='bContent'>" + document.getElementById(sField.substring(5,9)).value + "</div></td></tr></table></BODY></HTML>");
        //iFrameDoc.write("<HTML><!DOCTYPE html PUBLIC '-/"+"/W3C/"+"/DTD XHTML 1.0 Transitional/"+"/EN' 'http:/"+"/www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><HEAD><LINK href='SitoStile/publicPage.css' type=text/css rel=stylesheet></HEAD><BODY class='iframebody'>" + document.getElementById(sField.substring(5,9)).value + "</BODY></HTML>");
    }
    iFrameDoc.close();
    iFrameDoc.bHtmlMode = false;
    iFrameDoc.designMode = "On";
    if (!document.all) {
        document.getElementById("taglia"+sField).style.visibility = "hidden";
        document.getElementById("copia"+sField).style.visibility = "hidden";
        document.getElementById("incolla"+sField).style.visibility = "hidden";
        document.getElementById("taglia"+sField).style.display = "none";
        document.getElementById("copia"+sField).style.display = "none";
        document.getElementById("incolla"+sField).style.display = "none";
    }
}

function previewFile(controlName){
    control=getDivObj(controlName);
    var ext =  control.value;
    ext = ext.substring(ext.lastIndexOf(".")+1);
    if (".jpg.jpeg.gif.png.bmp".indexOf(ext)>-1){
        document.getElementById("anteprima").src = control.value;        
    }else if(".avi.doc.dot.exe.htm2.htm.html.mdb.mid.mp3.mpg.msg.pdf.pps.ppt.ps.rtf.swf.txt.wmv.xls.zip".indexOf(ext)>-1){
        document.getElementById("anteprima").src = "img/" + ext + ".gif";        
    }else{
        document.getElementById("anteprima").src = "img/file.gif";        
    }     
//    document.getElementById("C1").value = control.value;        
}

function uploadfile(controlName){ 
    var ausilio = String(this.location);
    sField = ausilio.substring(ausilio.lastIndexOf("?")+1); 
    control=getDivObj(controlName);
    if(window.opener){
        window.opener.inserisci(sField,"<img src='" + control.value + "' alt='immagine' />");
    }
    window.close();
}

function getEditboxValue(sField){
    iFrameDoc = calcIFrame( "frame" + sField );
    riquadro = iFrameDoc.body;
    testo = riquadro.innerHTML;
    // elimina i riferimenti a se' stesso nelle url
     testo = cleanInternalReferences( testo );      
     document.getElementById(sField).value = testo; 
    //myForm(sField).value=testo; 
}

function currWebPath() {
    var s = document.location.href;
    for( i=s.length-1; i > 0; i-- ) {
       if( s.charAt(i)=='/' ) return s.substring(0, i+1); 
    } 
   return "??"; 
}

function cleanInternalReferences( s ) {
    t = 'src="'+currWebPath();
    regex= new RegExp(t, "g" ); 
    s=s.replace(regex, 'src="');
    t = 'href="'+currWebPath();
    regex= new RegExp(t, "g" ); 
    s=s.replace(regex, 'href="');
    return s;    
}

function setEditboxValue(sField){
}

function validateMode( sField ) {
    iFrameDoc = calcIFrame( sField );
    if (!iFrameDoc.bHtmlMode) return true;
    alert("Deselezionare \"HTML\" per utilizzare le barre degli strumenti");
    setFocus( sField );
    return false;
}
function setFocus( sField ) {

} 
function setColor( sField, sColor ) {
    formatC( "frame" + sField, 'forecolor', sColor);    
    btColorSelect('btFontParframe' + sField, sColor);
    visibilita('FontParframe' + sField);
}
function setSfondo( sField, sColor ) {
    formatC( "frame" + sField, 'backcolor', sColor);
    btColorSelect('btSfondoParframe' + sField, sColor);
    visibilita('SfondoParframe' + sField);
} 
function formatC(sField, what,opt) {
    if (!validateMode( sField )) return;
    if (what=="backcolor" && !document.all) what="hilitecolor";
    iFrameDoc = calcIFrame( sField );
    iFrameDoc.execCommand(what,false,opt);
    setFocus( sField );
}
function btColorSelect(controlName,colore){
    if(controlName=="") {
        var appControl = getDivObj("btName");
        controlName = appControl.value ; 
    }
    control=getDivObj(controlName);
    control.style.backgroundColor=colore;        
}
function inBTFormat(control) {
    control.style.backgroundColor="#ffffff";
}
function outBTFormat(control) {
    control.style.backgroundColor="#cccccc";
}
function getDivObj(id) {
    if (document.all) { return document.all[id]; } 
    else {	return document.getElementById(id);	}
}
function visibilita(controlName){
    control = getDivObj(controlName);
    if ( control.style.visibility == "visible" ) {
        control.style.visibility =  "hidden";
        control.style.display = "none";
    }else{            
        control.style.visibility = "visible";
        control.style.display = "block";
    }  
}
function setModeDisplay(sField, newMode) {
    var testo;
    var iFrameDoc = calcIFrame( sField );

    if ( iFrameDoc.bHtmlMode != newMode ) {
        iFrameDoc.bHtmlMode  = newMode;
        riquadro = iFrameDoc.body;
        if (iFrameDoc.bHtmlMode) {
            testo = riquadro.innerHTML;
            if (document.all){ 
                riquadro.innerText = cleanInternalReferences(testo);
            }else{
                riquadro.textContent = cleanInternalReferences(testo);
            }
            document.getElementById("vedi1").style.borderColor = "#cccccc"; 
            document.getElementById("vedi2").style.borderColor = "#ffffff";   
        } else {
            testo = (document.all)? riquadro.innerText:riquadro.textContent;
            riquadro.innerHTML = cleanInternalReferences(testo);
            document.getElementById("vedi1").style.borderColor = "#ffffff";
            document.getElementById("vedi2").style.borderColor = "#cccccc";    
        }        
    }
    setFocus( sField );
}
function generaTabella(id){
    var ausilio = String(this.location);
    sField = ausilio.substring(ausilio.lastIndexOf("?")+1); 
    var tabella = "<table class=\"editBoxTable\"><tr>";
    if(id==1)tabella += "<td></td><td></td><td></td><td></td>";
    if(id==2)tabella += "<th></th><td colspan=\"3\"></td>";
    if(id==3)tabella += "<td colspan=\"4\"></td>";
    if(id==4)tabella += "<th></th><td colspan=\"2\"></td><th></th>";
    tabella += "</tr></table>";
    if(window.opener){
        window.opener.inserisci(sField,tabella);
    }
    window.close();     
}
//function generaTabella(){
//    var ausilio = String(this.location);
//    sField = ausilio.substring(ausilio.lastIndexOf("?")+1); 
//    var cols = document.getElementById("sizeCols").value;
//    var rows = document.getElementById("sizeRows").value;
//    var titolo = document.getElementById("titolo").value;
//    var tot =  eval(cols) +  eval(rows);
//    var tabella = "<table class=\"editBoxTable\">";
//    if(titolo!=""){
//        tabella += "<tr><th colspan=" + cols + ">" + titolo + "</th></tr>";
//    }
//    for(i=1;i<=rows;i++){
//        tabella += "<tr>";
//        for(a=1;a<=cols;a++){
//            tabella += "<td>&nbsp;</td>";           
//        }       
//        tabella += "</tr>";
//    }
//    tabella += "</table>";
//    if(window.opener){
//        window.opener.inserisci(sField,tabella);
//    }
//    window.close();         
//}
function inserisci(sField, tabella) {//funzione da approfondire
    var iFrameDoc = calcIFrame(sField);
    riquadro = iFrameDoc.body;
    riquadro.innerHTML += tabella;    
} 
function tabStyle(){
    control=getDivObj("btBordoTab");
    var bordo= control.style.backgroundColor; 
    control=getDivObj("btSfondoTab");
    var sfondo= control.style.backgroundColor; 
    control=getDivObj("btSfondoTit");
    var sfondoTitolo= control.style.backgroundColor; 

    if(window.opener){
        styleTab  ="style='border-collapse: collapse; border: 1px solid " + bordo + "; background: " + sfondo + ";'" ;
        styleTh  ="style='margin: 5px; border: 1px solid " + bordo + "; background: " + sfondoTitolo + ";'"
        styleTd  ="style='margin: 5px; border: 1px solid " + bordo + "; background: " + sfondo + ";'"
    }  
}
function btNameVal(valore){ 
    control = getDivObj("btName");
    control.value = valore;  
}

//function inserisciLink(){
//    var ausilio = String(this.location);
//    sField = ausilio.substring(ausilio.lastIndexOf("?")+1);
//    alert(sField);
//    var url = document.getElementById("url").value;
//    alert(url);
//    if(window.opener){
//        alert("prima");
//        window.opener.formatC( sField, 'CreateLink',url)
//        window.opener.inserisci( sField, url)
//        alert("due");
//    }
//    window.close();         
//}
//function calcIFrameNew( sField ) {
//    var s = (document.all)? 'document.frames("' + sField + '").document;': 'document.getElementById("' + sField + '").contentDocument;'; 
//    return( eval( s ));
//}
function inserisciLink(sField){
    var link = document.getElementById("url").value;
    link = link.toLowerCase();
    if(window.opener){
        window.opener.formatC(sField, "createlink" ,link);
        window.close();
    } 
}         

function AttivaFrame(iFrameID){
  if (document.getElementById(iFrameID).contentDocument){  
	  //Mozilla
    return document.getElementById(iFrameID).contentDocument;
  } else {
	  //Internet Explorer
    return document.frames[iFrameID].document;
   }
 }
// fine funzioni editBox---------------------------------------

//funzioni popup ricerca
function setSelectedValue(valori) {
    if(window.opener){
        var arr = valori.split(",");
        var lista = document.getElementsByTagName("input");
        for (var i = 0; i < lista.length; i++) { 
            if ((lista[i].nodeType == 1)){
                if (lista[i].getAttribute("type") == "checkbox"){
                    for (var j = 1; j < arr.length; j++) { 
                        var app = lista[i].value.split(String.fromCharCode(1));
                        if (app[0] == arr[j].replace("'","")){
                            lista[i].checked = true;
                        }
                    }
                }else if (lista[i].getAttribute("type") == "radio"){
                    for (var j = 1; j < arr.length; j++) { 
                        var app = lista[i].value.split(String.fromCharCode(1));
                        if (app[0] == arr[j].replace("'","")){
                            lista[i].checked = true;
                        }
                    }
                }
            }
        }
    }
}
function getSelectedValue(sField) {
    if(window.opener){
        var valori = document.getElementById("hidden").value;
        if(valori == ""){
            valori = window.opener.document.getElementById(sField).value;
        }        
        var arr = valori.split(String.fromCharCode(1));
        var lista = document.getElementsByTagName("input");
        for (var i = 0; i < lista.length; i++) { 
            if ((lista[i].nodeType == 1)){
                if (lista[i].getAttribute("type") == "checkbox"){
                    for (var j = 0; j < arr.length; j++) { 
                        var app = lista[i].value.split(String.fromCharCode(1));
                        if (app[0] == arr[j]){
                            lista[i].checked = true;
                        }
                    }
                }else if (lista[i].getAttribute("type") == "radio"){
                    for (var j = 0; j < arr.length; j++) { 
                        var app = lista[i].value.split(String.fromCharCode(1));
                        if (app[0] == arr[j]){
                            lista[i].checked = true;
                        }
                    }
                }
            }
        }
    }
}
function getSearchValue(sField ) {
    var sValue = "";
    var sLabel = "";
    var lista = document.getElementsByTagName("input");
    for (var i = 0; i < lista.length; i++) { 
        if ((lista[i].getAttribute("type")=="checkbox")&&(lista[i].checked == true)){
            var app = lista[i].value.split(String.fromCharCode(1));
            sValue += String.fromCharCode(1) + app[0];
            sLabel += "<li>" + app[1] + "</li>";                
        }else if ((lista[i].getAttribute("type") == "radio")&&(lista[i].checked == true)){
            var app = lista[i].value.split(String.fromCharCode(1));
            sValue = String.fromCharCode(1) + app[0];
            sLabel = "<li>" + app[1] + "</li>";                
        }       
    }
    if(window.opener){
        window.opener.writeSearchValue(sField, sValue, sLabel);
    }
    window.close(); 
}
function writeSearchValue(sField, sValue, sLabel) {
    var lista = document.getElementById("srcReturn"+sField);
    lista.innerHTML = sLabel;
    document.getElementById(sField).value = sValue;
}
//fine funzioni popup ricerca


// funzioni di cookies
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function incrementa(sField) {//funzione da approfondire
    var element = getDivObj(sField);
    var num = eval(element.innerHTML);
    element.innerHTML = num + 1;    
}

function openImage( sId, sNome ) {
    var w = window.open( "_image.aspx?id="+sId, "image", "dependent=yes,width=600,height=400,scrollbars=yes" );
}

function openDoc( sId, sNome ) {
    var w = window.open( "_image.aspx?id="+sId, "image", "dependent=yes,width=600,height=400,scrollbars=yes" );
}

//inizio funzioni calendario
  function modData( vTime, idDiv, nameText ) {
    var objDiv = getDivObj(idDiv);
    var objText = getObj4InputType("text", nameText)
    var d = new Date( vTime );
    var nGiorno, nMese, sAnno, sGiorno, sMese, sData;
    sAnno = "" +d.getFullYear();
    nMese = d.getMonth()+1;
    sMese = "0"+nMese;
    nGiorno = d.getDate();
    sGiorno = "0"+nGiorno;
    var ora = objText.value.substr(10);
    sData = sGiorno.substr(sGiorno.length-2 )+"/"+sMese.substr(sMese.length-2)+"/"+sAnno+ora;
    objText.value = sData;
    objDiv.innerHTML="";
    visibilita(idDiv);
  } 
   function visuaMeseRiquadro( idDiv, nMese, nAnno, dDay, nameText ) {
    // trova il primo lunedi' prima dell'inizio del mese: parte dal mese/anno richiesto e va indietro fino al primo lunedi'
    var objDiv = getDivObj(idDiv);
    var sMese = [ "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre" ][nMese-1]+" "+nAnno;
    var dLunedi = new Date(nAnno, nMese-1, 1 );
    var sLinkPrec, sLinkNext, x, y, s;
    for( ;dLunedi.getDay() != 1; dLunedi = new Date( dLunedi.getTime() - (1000 * 60 * 60 * 24) ));
    sLinkPrec = "visuaMeseRiquadro(\"" + objDiv.id +"\"," + (nMese==1? 12: (nMese-1)) +","+(nMese==1? nAnno-1: nAnno)+", new Date(" + dDay.getTime() +"), \""+nameText+"\")";
    sLinkNext = "visuaMeseRiquadro(\"" + objDiv.id +"\"," + (nMese==12? 1: nMese+1) +","+(nMese==12? nAnno+1: nAnno)+", new Date(" + dDay.getTime() +"),\""+nameText+"\")";
   // visualizza la tabella del mese
    var s = "<span class='dateHead'><a href='javascript:" + sLinkPrec + "'><img src='stili/meseIndietro.gif' border=0></a>" + sMese;
    s += "<a href='javascript:" + sLinkNext + "'><img src='stili/meseAvanti.gif' border=0></a></span>";
    s += "<span class='dateHead'><div>l</div><div>m</div><div>m</div><div>g</div><div>v</div><div>s</div><div>d</div></span>";
    var dGiorno = dLunedi;
     for ( y=0; y<6; y++) {
      s += "<span class='dateDay'>";
      for( x=0; x<7; x++) {
        if(dGiorno.getTime()==dDay.getTime()){
            s += "<div><a href='javascript:modData(" + dGiorno.getTime()+",\"" +objDiv.id+"\",\""+nameText+"\");'";
            s +=" class='dateSelected'>";
        }else if(dGiorno.getMonth()==(nMese-1)){
            s += "<div"+(x>=5? " class='weekend'>": ">")+"<a href='javascript:modData(" + dGiorno.getTime()+",\"" +objDiv.id+"\",\""+nameText+"\");'";
            s +=" class='mese'>";
        }else{
            s += "<div><a href='javascript:modData(" + dGiorno.getTime()+",\"" +objDiv.id+"\",\""+nameText+"\");'";
            s +=" class='nomese'>";
        }
        s += dGiorno.getDate() + "</a></div>";
        dGiorno.setDate( parseInt(dGiorno.getDate()) + 1);
      }
      s += "</span>";
      if( dGiorno.getMonth() !=nMese-1 ) break;
    }
    //inserisci("frameC2", s); 
    objDiv.innerHTML =  s; 
  }
  function visuaMese(idDiv, nameText ) {
    // divide in giorno, mese, anno
    visibilita(idDiv);
    var objDiv = getDivObj(idDiv);
    var objText = getObj4InputType("text", nameText)
    var arr, nGiorno, nMese, nAnno, dIn;
    if( objDiv.style.visibility == "visible" ) {
      // normalizza la data testuale passata in objText
      dIn = objText.value+"00/00/0000";
      nGiorno = parseInt( dIn.substr(0,2),10);
      nMese = parseInt( dIn.substr(3,2),10);
      nAnno=parseInt( dIn.substr(6,4),10);//+2000
      if( isNaN(nGiorno) || isNaN(nMese) || isNaN(nAnno) || nGiorno < 1 || nGiorno > 31 || nMese < 1 || nMese > 12 ) {
        // data errata, pone uguale al giorno corrente
        var dOggi = new Date();
        nMese = dOggi.getMonth()+1;
        nAnno = dOggi.getFullYear();
        nGiorno = dOggi.getDate();
      }
      visuaMeseRiquadro( idDiv, nMese, nAnno, new Date( nAnno, nMese-1, nGiorno), nameText );
    } else {
        objDiv.innerHTML = "";
    }        
  }
 function closeDiv(idDiv){
    objDiv=getDivObj(idDiv);
    if ( objDiv.style.visibility == "visible" ) {
        objDiv.innerHTML = "";
        objDiv.style.visibility = "hidden";
        objDiv.style.display = "none";
    } 
 } 
 function getObj4InputType(objType,objName){
        var lista = document.getElementsByTagName("input");
        for (var i = 0; i < lista.length; i++) { 
            if ((lista[i].nodeType == 1)){
                if ((lista[i].getAttribute("type") == objType)&&(lista[i].getAttribute("name") == objName)){
                    return lista[i]
                }
            }
        } 
 }
//fine funzioni calendario
function openMenuDiv( divId ) {{
if( false ) {{
    // se non e' presente nello stack, chiudi tutto...
    for( i=0; i<menuStack.length; i++) {{
        if( menuStack[i]==divId) return; // non fare nulla, e' gia' aperto...
    }}
    for( i=1; i<menuStack.length; i++) {{
        visibilita( menuStack[i] );
    }}
}}
    menuStack[menuStack.length]=divId;
    visibilita( divId );
}}
function closeMenuDiv( divId ) {{
    // solo se veramente e' fuori dal div...
    var obj=getDivObj(divId); 
    var bDentro = (window.event.clientX >= findPosX(divId) && window.event.clientY >= findPosY(divId) && 
        window.event.clientX <=findPosX(divId)+obj.offsetWidth && window.event.clientY <= findPosY(divId) + obj.offsetHeight);
    if ( bDentro ) return;

    if( divId==menuStack[menuStack.length-1]) {{
        menuStack.length=menuStack.length-1;
        obj(divId).style.display="none";
        visibilita( divId );
    }}
}}

  function findPosX(divId)  {{
    var obj=getDivObj(divId); 
    var curleft = 0;
    if(obj.offsetParent)
        while(1) {{
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }}
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }}

  function findPosY(divId)  {{
    var obj=getDivObj(divId); 
    var curtop = 0;
    if(obj.offsetParent)
        while(1) {{
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }}
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }}

function autoIframe(frameId){
  try{
    frame = document.getElementById(frameId);
    innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
    objToResize = (frame.style) ? frame.style : frame;
    objToResize.height = innerDoc.body.scrollHeight +10;
  }
  catch(err){
    window.status = err.message;
  }
}
//###########################################
function setViewPage( item , color, page ){
    var obj
    obj = getDivObj( item );
    if (obj!=null) obj.style.backgroundColor = color;
    obj = getDivObj(page);
    if (obj!=null) obj.style.fontWeight = "bold";
}
function flipMenuImage(id,on){
    var obj=getDivObj("menu"+id);
    if (on == true){
    obj.style.backgroundImage = "url(SitoStile/"+id+".gif)";
    }else{
    obj.style.backgroundImage = "url(SitoStile/0.gif)";
    }
}
//###########################################
function disableForm(valore) {
     var fldset 
    fldset = document.getElementsByTagName("fieldset");
    for (var k = 0; k < fldset.length; k++) { 
        if ((fldset[k].getAttribute("id") != "Posizione")&&(fldset[k].getAttribute("id") != "headerCV")&&(fldset[k].getAttribute("id") != "ConsensoPrivacyFS")){
            if(fldset[k].getAttribute("id") == "datiDomicilio"){
                enableInput(fldset[k], "input" ,true);
                enableInput(fldset[k], "textarea" ,true);
                enableInput(fldset[k], "select" ,true);
//                fldset[k].style.backgroundColor = "#ECECEC";
            }else{
                enableInput(fldset[k], "input" ,valore);
                enableInput(fldset[k], "textarea" ,valore);
                enableInput(fldset[k], "select" ,valore);
//                fldset[k].style.backgroundColor = (valore ? "#ECECEC" : "#FFFFFF");
            }  
            
        }
    }
 }
 function enableInput(obj, tipo ,valore){
    var lista 
    lista = obj.getElementsByTagName(tipo);
    for (var i = 0; i < lista.length; i++) { 
        lista[i].disabled = valore;
        lista[i].style.backgroundColor = (valore ? "#ECECEC" : "#FFFFFF");    
    }
 } 
 function PrivacyClick(checkValue) {
	fForm = document.forms["mainForm"];
	if (checkValue) {
		disableForm(false);
	} else {
		if (confirm("Non dando l'autorizzazione al trattamento dei dati personali non sara' possibile procedere con l'invio del CV.\n Si e' sicuri di non accettare?"))
			disableForm(true);
		else {
			fForm.elements["ConsensoPrivacy"][1].checked = false;
			disableForm(true);
		}
		fForm.reset();
	}
}
 function enableDomicilio(id){
    var fldset
    var obj = getDivObj(id);
    var valore = (obj.checked? false: true);
    fldset = getDivObj("datiDomicilio");
    enableInput(fldset, "input" ,valore);
    enableInput(fldset, "textarea" ,valore);
    enableInput(fldset, "select" ,valore);                
    //fldset.style.backgroundColor = (valore ? "#ECECEC" : "#FFFFFF");
}
 
function SelectedStato(id){
   var row
   var obj = getDivObj("C"+id);
   var i = id;
   if (obj.selectedIndex==1){
       loadRegione(id);
       i++;
       row = getDivObj("rigaform"+i);
       row.style.visibility = "visible";
       row.style.display = "table-row";
       i++;
       row = getDivObj("rigaform"+i);
       row.style.visibility = "visible";
       row.style.display = "table-row";
       i++;
       row = getDivObj("rigaform"+i);
       row.style.visibility = "visible";
       row.style.display = "table-row";
       i++;
       row = getDivObj("rigaform"+i);
       row.style.visibility = "hidden";
       row.style.display = "none";
       obj = getDivObj("C"+i);
       obj.text = "";
       i++;
       row = getDivObj("rigaform"+i);
       row.style.visibility = "visible";
       row.style.display = "table-row";
          
   } else{
       i++;
       row = getDivObj("rigaform"+i);
       row.style.visibility = "hidden";
       row.style.display = "none";
       obj = getDivObj("C"+i);
       obj.selectedIndex = 0;
       i++;
       row = getDivObj("rigaform"+i);
       row.style.visibility = "hidden";
       row.style.display = "none";
       obj = getDivObj("C"+i);
       obj.selectedIndex = 0;
       i++;
       row = getDivObj("rigaform"+i);
       row.style.visibility = "hidden";
       row.style.display = "none";
       obj = getDivObj("C"+i);
       obj.selectedIndex = 0;
       i++;
       row = getDivObj("rigaform"+i);
       row.style.visibility = "visible";
       row.style.display = "table-row";
       i++;
       row = getDivObj("rigaform"+i);
       row.style.visibility = "hidden";
       row.style.display = "none";
       obj = getDivObj("C"+i);
       obj.value = "";
       
   }   
}
function myOuterHTML(elm, html) {
    var elmNew = document.createElement("div");
    elmNew.innerHTML = html;
    for(var elmContent = elmNew.firstChild;
    	elmNew.firstChild.nextSibling;
    	elmContent = elmNew.firstChild) {
    	
    	elm.parentNode.insertBefore(elmContent, elm);
    }
    	                	
    elm.parentNode.replaceChild(elmContent, elm);    
}

function loadRegione(id){
   var i = parseInt(id);
   i++;
   AjaxRequest.get(
    {
      'url':"getRegione.aspx"
      ,'onSuccess':function(req){loadMyCombo("C" + i,req.responseText);}
      }     
  );     
}
function loadProvince(id){
   var obj = getDivObj("C"+id);
   var i = parseInt(id);
   i++;
   AjaxRequest.get(
    {
      'url':"getProvince.aspx?id="+obj.options[obj.selectedIndex].value
      ,'onSuccess':function(req){loadMyCombo("C" + i,req.responseText);}
      }     
  );     
}
function loadCitta(id){
   var obj = getDivObj("C"+id);
   var i = parseInt(id);
   i++;
   AjaxRequest.get(
    {
      'url':"getCitta.aspx?id="+obj.options[obj.selectedIndex].value
      ,'onSuccess':function(req){loadMyCombo("C" + i,req.responseText);}
      }     
  );     
}
function loadMyCombo(idSelect, testo) {

    var select = getDivObj(idSelect); 
    var arr =  testo.split("|");
    select.innerHTML = "";
    for (var i = 0; i < arr.length; i++){
	    var lista = arr[i].split(":");
	    insertOptionBefore(select, i, lista[1], lista[0]);
	}      
}
function insertOptionBefore(elSel, index, testo, val)
{
   if (elSel.selectedIndex >= 0) {}
    var elOptNew = document.createElement('option');
    elOptNew.text = testo;
    elOptNew.value = val;
    var elOptOld = elSel.options[elSel.options.length];  
    try {
      elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE
    }
    catch(ex) {
      elSel.add(elOptNew, elSel.selectedIndex); // IE only
    }
  
}
function submitMyRequest(id, azione)
{
    var hdd = getDivObj("valore"); 
    hdd.value = id;
    document.forms['mainForm'].action = azione;
    document.forms['mainForm'].submit();
}

