
var szUsrNvg=navigator.userAgent.toLowerCase();
var _isIE=szUsrNvg.indexOf('msie')!=-1;
var _isIE5=szUsrNvg.indexOf('msie 5.')!=-1;
var _isIE6=szUsrNvg.indexOf('msie 6.')!=-1;
var _isIE7=szUsrNvg.indexOf('msie 7.')!=-1;
var _isIE8=szUsrNvg.indexOf('msie 8.')!=-1;

var _isOpera=szUsrNvg.indexOf('opera')!=-1;
var _isKonqueror=szUsrNvg.indexOf('konqueror')!=-1;

var _isGecko=szUsrNvg.indexOf('gecko')!=-1;//firefox,camino,safari,chrome
var _isFirefox,_isCamino,_isSafari,_isChrome;
_isFirefox=_isCamino=_isSafari=isChrome=false;
if(_isGecko){
	if(szUsrNvg.indexOf('firefox')!=-1){
		if(szUsrNvg.indexOf('camino')!=-1) _isCamino=true;
		else _isFirefox=true;
	}
	if(szUsrNvg.indexOf('safari')!=-1){
		if(szUsrNvg.indexOf('chrome')!=-1) _isChrome=true;
		else _isSafari=true;
	}
}


var szDomainList="|aero|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|shop|tel|travel|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|g|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw|";
function _gel(sz){
	return document.getElementById(sz);
}
function _cel(sz){
	return document.createElement(sz);
}
function _rel(obj){
	if(!obj) return;
	if(!obj.parentNode) return;
	obj.parentNode.removeChild(obj);
}
function isBool(o){
	return 'boolean'===typeof o;
}
function sMSG(szIt,szEn){
	this.it=szIt;
	this.en=szEn;
}
function alerta(sz){
	sz="<div class=\"dAlrt\"><img src=\""+szImgCmsPath+"alert.png\" alt=\""+gestMSG("alrt")+"\" title=\""+gestMSG("alrt")+"\" class=\"imgAlrt\" /><div class=\"msgAlrt\"><div class=\"msgAlrtA\">"+gestMSG("alrt")+"</div><div class=\"msgAlrtB\">"+sz+"</div><div class=\"msgAlrtBtt\"><a href=\"javascript:clAlrt();\" class=\"bttAlrtV\">OK</a></div></div></div>";
	window.top.opAlrt(sz);
}
function confirm(sz,fn,args,b){
	window.top.cnfrmFn=fn;
	window.top.cnfrmArgs=args;
	window.top.cnfrmB=b;
	sz="<div class=\"dAlrt\"><img src=\""+szImgCmsPath+"alert.png\" alt=\""+gestMSG("alrt")+"\" title=\""+gestMSG("alrt")+"\" class=\"imgAlrt\" /><div class=\"msgAlrt\"><div class=\"msgAlrtA\">"+gestMSG("alrt")+"</div><div class=\"msgAlrtB\">"+sz+"</div><div class=\"msgAlrtBtt\"><a href=\"javascript:clCnfrm(false);\" class=\"bttAlrtV\">"+gestMSG("annCncl")+"</a><a href=\"javascript:clCnfrm(true);\" class=\"bttAlrtR\">OK</a></div></div></div>";
	window.top.opAlrt(sz);
}
function clCnfrm(b){
	clAlrt();
	if(window.top.cnfrmB) cnfrmFn(window.top.cnfrmArgs,b);
	else if(b) cnfrmFn(window.top.cnfrmArgs);
}
function clAlrt(){
	clOsc();
	document.body.removeChild(_gel("alert"));
}
function opAlrt(sz){
	opOsc(function(){});
	var obj=_cel("div");
	obj.id="alert";
	obj.innerHTML=sz;
	document.body.appendChild(obj);
	cntrObj(obj,obj.offsetWidth,obj.offsetHeight);
}
arMSG=new Array();
arMSG["boh"]= new sMSG("","");
arMSG["img"]=new sMSG("Immagine","Image");
arMSG["OC"]=new sMSG("Apri/chiudi","Open/close");
arMSG["chgImg"]=new sMSG("Cambia immagine","Change image");
arMSG["delImg"]=new sMSG("Cancella immagine","Delete image");
arMSG["url"]=new sMSG("Indirizzo web","Web address");
arMSG["aFoto"]= new sMSG("Aggiungi foto","Add photo");
arMSG["fErr"]= new sMSG("Compilare il form correttamente","Fill the form correctly");
arMSG["fMail"]= new sMSG("Inserire un campo di tipo Email","Add one Email-type field");
arMSG["close"]= new sMSG("Chiudi","Close");
arMSG["nmSez"]= new sMSG("Sezione","Section");
arMSG["nmCat"]= new sMSG("Categoria","Category");
arMSG["dRec"]= new sMSG("Sei sicuro di voler eliminare questo record?","Do you really want to delete this record?");
arMSG["dSez"]= new sMSG("Sei sicuro di voler eliminare questa sezione?","Do you really want to delete this section?");
arMSG["loElim"]= new sMSG("Elimina","Remove");
arMSG["loRipr"]= new sMSG("Ripristina","Restore");
arMSG["loAdd"]= new sMSG("Aggiungi modulo","Add module");
arMSG["loMm"]= new sMSG("Inserire il modulo menu","Add menu module");
arMSG["loNoCnfg"]= new sMSG("Sezione non ancora configurata","Section not configured yet");
arMSG["mMenu"]= new sMSG("Menu","Menu");
arMSG["mMLst"]= new sMSG("Newsletter","Newsletter");
arMSG["mBann"]= new sMSG("Banner","Banner");
arMSG["mRic"]= new sMSG("Ricerca nel sito","Search site");
arMSG["mRim"]= new sMSG("Ricerca immobili","Real estate search");
arMSG["mNews"]= new sMSG("News","News");
arMSG["mMtop"]= new sMSG("Menu alto","Top menu");
arMSG["mMbtm"]= new sMSG("Menu basso","Bottom menu");
arMSG["mLang"]=new sMSG("Modulo lingue","Languages module");
arMSG["mGmap"]=new sMSG("Modulo Google maps","Google maps module");
arMSG["mPriv"]=new sMSG("Modulo privacy","Privacy module");
arMSG["mSond"]=new sMSG("Modulo sondaggio","Poll module");
arMSG["mCat"]=new sMSG("Modulo categorie","Categories module");
arMSG["mCmt"]=new sMSG("Modulo commenti","Comments module");
arMSG["mBpth"]=new sMSG("Modulo percorso","Bread path module");
arMSG["dFlash"]=new sMSG("Cancella filmato","Delete movie");
arMSG["cFlash"]=new sMSG("Cambia filmato","Change movie");
arMSG["flash"]=new sMSG("Filmato Flash","Flash movie");
arMSG["dim"]=new sMSG("Dimensioni","Dimensions");
arMSG["tBann"]= new sMSG("Tipo di banner","Banner type");
arMSG["ins"]=new sMSG("Inserisci","Insert");
arMSG["onw"]=new sMSG("L'indirizzo verra' aperto in una nuova finestra","Address will be opened in a new window");
arMSG["aRisp"]=new sMSG("Aggiungi risposta","Add answer");
arMSG["risp"]=new sMSG("Risposta","Answer");
arMSG["dom"]=new sMSG("Domanda","Question");
arMSG["annCncl"]=new sMSG("Annulla","Cancel");
arMSG["grphClr"]=new sMSG("Colore del grafico","Graph color");

arMSG["aSez"]= new sMSG("Aggiungi sezione","Add section");
arMSG["aCat"]= new sMSG("Aggiungi categoria","Add category");
arMSG["aBan"]= new sMSG("Aggiungi banner","Add banner");
arMSG["aCmp"]= new sMSG("Aggiungi campo","Add input field");
arMSG["szNm"]= new sMSG("Nome sezione","Section name");
arMSG["szDoc"]=new sMSG("Tipo sezione","Section type");
arMSG["save"]= new sMSG("Salva","Save");
arMSG["2lang"]=new sMSG("Seconda lingua","2nd language");
arMSG["sel"]=new sMSG(" --- Seleziona --- "," --- Select --- ");
arMSG["noAct"]=new sMSG("Operazione non permessa","Action not permitted");
arMSG["setAllNoSz"]= new sMSG("Imposta tutte le sezioni NON ANCORA CONFIGURATE come la homepage","Set all NOT YET CONFIGURED sections like homepage");
arMSG["setAllSz"]= new sMSG("Imposta TUTTE LE SEZIONI come la homepage","Set ALL SECTIONS like homepage");
arMSG["szNotConf"]= new sMSG("Sezione non configurata","Section not configured");
arMSG["insBan"]=new sMSG("Scegliere un'immagine","Choose an image");
arMSG["insLnk"]=new sMSG("Inserire il collegamento","Insert a link");
arMSG["catPrnt"]=new sMSG("Categoria padre","Parent category");
arMSG["catOrdr"]=new sMSG("Ordine","Order");
arMSG["sicuro"]=new sMSG("Sei sicuro dell'eliminazione?","Are you sure?");
//arMSG["nmCat"]=new sMSG("Nome categoria","Category name");
//arMSG["nmSez"]=new sMSG("Nome sezione","Section name");
arMSG["sezObblI"]=new sMSG("La sezione ","");
arMSG["sezObblF"]=new sMSG(" e' obbligatoria"," is mandatory");
arMSG["home"]=new sMSG("La sezione homepage non &egrave; stata definita","Homepage section hasnot been defined");
arMSG["alrt"]=new sMSG("Attenzione!","Alert!");
arMSG["sggBrws"]=new sMSG("Suggeriamo di utilizzare<br />il browser <a href=\"http://www.mozilla.org/firefox/\" target=\"_blank\" >Mozilla Firefox</a><br />o <a href=\"http://www.google.com/chrome/\" target=\"_blank\" >Google Chrome</a>","We suggest the use<br />of <a href=\"http://www.mozilla.org/firefox/\" target=\"_blank\" >Mozilla Firefox</a><br />or <a href=\"http://www.google.com/chrome/\" target=\"_blank\" >Google Chrome</a> browser");
arMSG["noBrws"]=new sMSG("Si consiglia di utilizzare un altro browser.<br />Quello in uso potrebbe causare malfunzionamenti del programma.","Your browser is obsolete.");
arMSG["altBrws"]=new sMSG("Se preferisci puoi usare: ","You can also use: ");

arMSG["noCat"]=new sMSG("Nessuna categoria","No category");
arMSG["noCntLnk"]=new sMSG("Nessun contenuto per questa sezione e categoria","No contenti in this section and category");

arMSG["cmpTxt"]=new sMSG("testo","text");
arMSG["cmpArea"]=new sMSG("area di testo","text area");
arMSG["cmpNm"]=new sMSG("Nome campo","Input field name");
arMSG["cmpTipo"]=new sMSG("Tipo del campo","Input field type");
arMSG["cmpObb"]=new sMSG("Campo obbligatorio","Compulsory field");
arMSG["insCmp"]=new sMSG("Inserire almeno un campo","Insert one field at least");

arMSG["docArt"]=new sMSG("Articoli","Articles");
arMSG["docCont"]=new sMSG("Contatti","Contacts");
arMSG["docFgall"]=new sMSG("Galleria foto","Photo gallery");
arMSG["docHome"]=new sMSG("Homepage","Homepage");
arMSG["docLnk"]=new sMSG("Links","Links");
arMSG["docVideo"]=new sMSG("Galleria video","Video gallery");
arMSG["docEvnt"]=new sMSG("Eventi","Events");
arMSG["docProd"]=new sMSG("Prodotti","Products");
arMSG["docImm"]=new sMSG("Immobili","Real estates");
arMSG["docMod"]=new sMSG("Modulo","Form");

arMSG["gstCntCC"]=new sMSG("Impaginazione contenuti colonna centrale","Central column content layout");
arMSG["cntLnkClk"]=new sMSG("Seleziona il contenuto:","Select content:");
arMSG["aCntLnk"]=new sMSG("Aggiungi contenuto","Add content");

arMSG["cmtLst"]=new sMSG("Elenco commenti al contenuto:","Content's comment list:");
arMSG["vwCmt"]=new sMSG("Visualizza commenti","Show comment");
arMSG["noCmt"]=new sMSG("Nessun commento","No comments");
arMSG["dlCmt"]=new sMSG("Commento eliminato","Comment removed");
arMSG["dlNoCmt"]=new sMSG("Attenzione! Commento NON eliminato","Attention! Comment NOT removed");
arMSG["dCmt"]=new sMSG("Vuoi eliminare il commento?","Are you sure to delete this comment?");

arMSG["aFoto"]=new sMSG("Aggiungi foto","Add photo");
arMSG["aFile"]=new sMSG("Aggiungi file","Add file");
arMSG["aTube"]=new sMSG("Aggiungi filmato","Add clip");
arMSG["aCmp"]=new sMSG("Aggiungi campo","Add field");
arMSG["aRis"]=new sMSG("Accesso riservato","Restricted access");

arMSG["artImgD"]=new sMSG("Descrizione immagine","Image description");

arMSG["noRes"]=new sMSG("La ricerca non ha prodotto risultati","No results");

arMSG["elOpz"]=new sMSG("Elenco opzioni","Options list");
arMSG["opt"]=new sMSG("Opzione","Option");
arMSG["aOpt"]=new sMSG("Aggiungi opzione","Add option");

arMSG["chgDoc"]=new sMSG("Cambiando il tipo di sezione verranno cancellati tutti i dati della sezione.\nContinuare?","Changing section type will be deleted all inserted data.\nContinue?");
arMSG["docNoCat"]=new sMSG("Questo tipo di documento non puo' avere sottocategorie","This document type cannot have categories");

//HELP
arMSG["cnf_sw"]=new sMSG("In questa sezione configurare le impostazioni generali del software.<br /><ul><li>Modifica della password di accesso;</li><li>Impostazione delle visualizzazioni delle date, delle valute e della lingua del gestionale;</li><li>Scelta della prima (e seconda lingua, opzionale) del sito;</li><li>Modello di impaginazione (solo se non sono gi&agrave; state impostate delle sezioni;</li><li>Modello di aspetto grafico.</li></ul>","Not available");
arMSG["cnf_web"]=new sMSG("In questa sezione vengono richieste informazioni sul sito.<br /><ul><li>Dominio;</li><li>Nome;</li><li>Breve descrizione dei contenuti del sito;</li><li>Parole chiave (elenco di parole separate da virgole).</li></ul>Tutte queste informazioni hanno grande utilit&agrave; per l'indicizzazione sui motori di ricerca, compilare con cura.","Not available");
arMSG["cnf_sz"]=new sMSG("Impostare qui quelle che saranno le sezioni (aree) del sito.<br /><br />Per ogni sezione indicare:<ul><li>Nome;</li><li>Presenza della sezioni nei men&ugrave; disponibili;</li><li>Il tipo, a seconda del suo contenuto;</li><li>Ordine di comparsa nei men&ugrave;.</li></ul>","Not available");
arMSG["cnf_cat"]=new sMSG("Impostare qui, per ogni sezione del sito, le eventuali sottosezioni.<br /><br />Per ogni categoria (sottosezione) indicare:<ul><li>Nome;</li><li>Categoria padre, se la categoria fa parte di un'altra gi&agrave; definita;</li><li>Ordine di comparsa nei men&ugrave;.</li></ul>","Not available");
arMSG["cnf_lo"]=new sMSG("Impaginazione delle sezioni del sito.<br /><br />Per ogni sezione potete scegliere se:<ul><li>Visualizzare o nascondere le aree di impaginazione;</li><li>Aggiungere o eliminare moduli di contenuti;</li><li>Scegliere quali colonne visualizzare e la loro larghezza.</li></ul>","Not available");
arMSG["cnf_lo_as"]=new sMSG("Impostazioni grafiche generali del sito.","Not available");
arMSG["cnf_lo_cat"]=new sMSG("Impostazioni grafiche delle categorie del sito.","Not available");
arMSG["cnf_lo_hf"]=new sMSG("Impostazioni grafiche e contenuti della testata e del pi&egrave; di pagina del sito.","Not available");
arMSG["cnf_lo_mm"]=new sMSG("Impostazioni grafiche dei men&ugrave; del sito.","Not available");
arMSG["cnf_lo_cc"]=new sMSG("Impostazioni grafiche delle colonne del sito.","Not available");
arMSG["cnf_lo_cc"]=new sMSG("Impostazioni grafiche delle colonne del sito.","Not available");
arMSG["cnf_lo_fn"]=new sMSG("Impostazioni grafiche e contenuto dell'area delle note di fondo del sito.","Not available");
arMSG["cnf_lo_mod"]=new sMSG("Impostazioni grafiche dei moduli del sito e dei loro titoli.","Not available");
arMSG["cnf_lo_cmp"]=new sMSG("Impostazioni grafiche dei campi dei moduli. Queste modifiche influiranno sul modulo della sezione tipo \"contatti\", sul modulo newsletter e sul modulo ricerca nel sito.","Not available");
arMSG["cnf_lo_nwl"]=new sMSG("Impostazioni grafiche di tutte le E-mail inviate attraverso il sito.","Not available");
arMSG["cnf_lo_oth"]=new sMSG("Impostazioni grafiche degli elementi di servizio del sito.","Not available");
arMSG["cnf_lo_bpth"]=new sMSG("Impostazioni grafiche del menu orizontale di navigazione tra le sezioni.","Not available");
arMSG["cnf_lo_lst"]=new sMSG("Impostazioni grafiche delle liste di contenuti.","Not available");
arMSG["cnf_lo_imm"]=new sMSG("Impostazioni grafiche del modulo immobili.","Not available");
arMSG["cnt_cntt"]=new sMSG("Impostazioni della sezione tipo \"contatti\".<br /><ul><li>Attraverso voce \"Google Maps\" &egrave; possibile inserire nel sito una mappa creata con l'apposito strumento di Google.<br />Se non si &egrave; specificata la colonna di inserimento attraverso il \"modulo Google Maps\" nella pagina \"Impaginazione\" verr&agrave; posizionata nella colonna principale; &egrave; possibile creare un modulo per la richiesta di informazioni<br />Per ogni campo indicare il nome, il tipo e se &egrave; obbligatoria la sua compilazione;</li><li>Alla voce \"Messaggio dopo l'invio del modulo\" indicare il messaggio che verr&agrave; visualizzato dopo che un utente ha inviato il modulo di richiesta informazioni;</li><li>Alla voce \"Testo email\" indicare il messaggio che verr&agrave; inviato nella E-mail all'utente che ha inviato il modulo di richiesta informazioni.</li></ul>","Not available");




var lang,cmsLang,cmsDec,cmsDate;

function gestMSG(index){
	if(!arMSG[index].it) alert(index);
	return (cmsLang==0) ? arMSG[index].it : arMSG[index].en;
}
var arMenu=new Array();
arMenu.push(new Array(6,new Array("Alto","Top")));
arMenu.push(new Array(1,new Array("Principale","Main")));
arMenu.push(new Array(7,new Array("Basso","Bottom")));
function sDoc(idSez,szNm,szCode,iVarianti,bCategorie,bObbl,iNMax,iNUsd,szTab){
	this.idSez=idSez;//idTipoDoc
	this.szNm=szNm;
	this.szCode=szCode;
	this.iVarianti=iVarianti;
	this.bCategorie=bCategorie;
	this.bObbl=bObbl;
	this.iNMax=iNMax;
	this.iNUsd=iNUsd;
	this.szTab=szTab;
}
//idTipoDoc, nomeDoc, codDoc, numVarianti, haCategorie?,obbligatorio,numMax,used,accRes
var arTDoc=new Array();
arTDoc.push(new sDoc("1",gestMSG("docArt"),"art",3,1,0,99,0,'tblArticoli',1));
arTDoc.push(new sDoc("2",gestMSG("docFgall"),"ftg",2,1,0,99,0,'tblFgall',1));
arTDoc.push(new sDoc("3",gestMSG("docLnk"),"lnk",2,1,0,99,0,'tblLink',1));
arTDoc.push(new sDoc("4",gestMSG("docCont"),"ctt",1,0,0,1,0,'tblContatti',0));
arTDoc.push(new sDoc("5",gestMSG("docHome"),"prs",1,0,1,1,0,'tblHome',0));
arTDoc.push(new sDoc("6","Banner","bnn",0,0,0,0,0,'tblBanner',0));
arTDoc.push(new sDoc("7","Mailing list","mlt",0,0,0,0,0,'tblMlist',0));
arTDoc.push(new sDoc("8","Newsletter","nwl",0,0,0,0,0,'tblNewsletter',0));
arTDoc.push(new sDoc("9","Config","cnf",0,0,0,0,0,false,0));
arTDoc.push(new sDoc("10","News","nws",0,0,0,0,'tblNews',0));
arTDoc.push(new sDoc("11","Aspetto Newsletter","nl",0,0,0,0,'tblNwl',0));
arTDoc.push(new sDoc("12",gestMSG("docVideo"),"vdo",1,1,0,99,0,'tblVideo',1));
arTDoc.push(new sDoc("13",gestMSG("docEvnt"),"evn",1,1,0,99,0,'tblEvents',1));
arTDoc.push(new sDoc("14",gestMSG("docProd"),"prd",1,1,0,99,0,'tblProdotti',1));
arTDoc.push(new sDoc("15",gestMSG("docImm"),"imm",1,1,0,99,0,'tblImm',1));
arTDoc.push(new sDoc("16",gestMSG("docMod"),"mdl",1,0,0,99,0,'tblMod',1));

function arGetKey(ar,indexNm,szValue){
	for(var i=0;i<ar.length;i++){ if(ar[i][indexNm]==szValue) return i;}
	return false;
}
/*
function arGetKey2(ar,indexNm1,indexNm2,szValue1,szValue2){
	for(var i=0;i<ar.length;i++){ if(ar[i][indexNm1]==szValue1 && ar[i][indexNm2]==szValue2) return i;}
	return false;
}
*/
function arRemElem(ar,szValue){
	for(var i=0;i<ar.length;i++) if(ar[i]==szValue){ar.splice(i,1);break;}
}
function ppString(ar,szSep){
	if(!szSep) szSep="|";
	return szSep+ar.join(szSep)+szSep;	
}
function ppArr(sz,szSep){
	if(sz=="") return new Array();
	if(!szSep) szSep="|";
	var iSL=szSep.length;
	var sz=sz.slice(iSL,-iSL);
	return sz.split(szSep);
}
//trim function - rimuove gli spazi bianchi all'inizio e alla fine di una stringa
function trimAll(szStr){
	return szStr.replace(/^\s+|\s+$/g,'');
}
function ppSrch(szPp,szSearch){
	if(szPp.indexOf("|"+szSearch+"|")==-1) return false;
	return true;
}
function objRollOver(obj){
	if(!obj) return;
	if(obj.className.indexOf("Hvr")==-1) obj.className+="Hvr"; else obj.className=obj.className.slice(0,-3);
}
function imgRollOver(obj){
	if(!obj) return;
	var id=obj.id;
	if(obj.src.indexOf(id+"Hvr")==-1) obj.src=obj.src.replace(id,id+"Hvr"); else obj.src=obj.src.replace(id+"Hvr",id);
}

function dtPrnt(dtTRd){
	if(dtTRd!="0000-00-00" && dtTRd!=""){
		var ar=dtTRd.split("-");
		return (!cmsLang)?ar[2]+"/"+ar[1]+"/"+ar[0]:ar[0]+"/"+ar[1]+"/"+ar[1];
	}else return false;
}


function objPos(obj){
	if(!obj) return;
	var x=0;
	var y=0;
	while(obj.offsetParent){
		x+=obj.offsetLeft;
		y+=obj.offsetTop;
		obj=obj.offsetParent;
	}
	return new Array(x,y);
}
function objPosPage(obj,newObjW,newObjH){
	var areaDisp=areaDoc();
	var areaScroll=scrollDoc();
	var objPosiz=objPos(obj);
	var newObjPosX=objPosiz[0]+obj.offsetWidth+2;
	var newObjPosY=objPosiz[1];
	if(newObjW>areaDisp[0]+areaScroll[0]-newObjPosX) newObjPosX=objPosiz[0]-newObjW-2;
	if(newObjH>areaDisp[1]+areaScroll[1]-newObjPosY) newObjPosY=newObjPosY-(newObjH-((areaDisp[1]+areaScroll[1])-newObjPosY));
	if(newObjW>areaDisp[0]-areaScroll[0]-objPosiz[0]) newObjPosX=newObjPosX-(newObjW-((areaDisp[0]+areaScroll[0])-newObjPosX));
	return new Array(newObjPosX,newObjPosY);
}
function objHasChild(obj,regEx,szChildNm){
	for(var i=0;i<obj.childNodes.length;i++) if(regEx.test(obj.childNodes[i].id)){ return true; break;}
	return false;
}
/*
function rmvChildNodes(idObj){
	var obj=_gel(idObj);
	while(obj.childNodes.length>0) obj.removeChild(obj.firstChild);
}
*/
function rmvChildNodes(idObj){
	var obj=_gel(idObj);
	if(!obj) return;
	while(obj.childNodes.length>0) obj.removeChild(obj.firstChild);
	stCmbSel(obj);
}

function objNxt(obj){
	var obj=obj.nextSibling;
	if(!obj) return false;
	if(obj.nodeType!=1) objNxt(obj);
	else return obj;
}

function objPrv(obj){
	var obj=obj.previousSibling;
	if(!obj) return false;
	if(obj.nodeType!=1) objPrv(obj);
	else return obj;
}
function popolaCmb(objCmb,arOpt,optSel,bSel){
	if(bSel){
		var objOpt=_cel('option');
		objOpt.text=gestMSG("sel");
		objOpt.value="";
		try{ objCmb.add(objOpt,null);} // standards compliant
		catch(ex){ objCmb.add(objOpt);} // IE only
	}
	for(var i=0;i<arOpt.length;i++){
		var objOpt=_cel('option');
		//objOpt.text=(!scndLang)?arOpt[i][1]:arOpt[i][2];
		objOpt.text=arOpt[i][1];
		objOpt.value=arOpt[i][0];
		if(parseInt(arOpt[i][0])==optSel) objOpt.selected="selected";
		try{ objCmb.add(objOpt,null);} // standards compliant
		catch(ex){ objCmb.add(objOpt);} // IE only
	}
	stCmbSel(objCmb);
	return objCmb;
}
function ripopolaCmb(idObj,arOpt,optSel,bSel){
	var objCmb=_gel(idObj);
	if(!objCmb) return;
	rmvChildNodes(idObj);
	return popolaCmb(objCmb,arOpt,optSel,bSel);
}
function creaCmb(idPrnt,idObj,arOpt,optSel,bSel,szFunc){
	var objPrnt=_gel(idPrnt);
	if(!objPrnt) return;
	var objSpan=_cel("span");
	objSpan.id="slct_"+idObj;
	objSpan.className="slct";
	objPrnt.appendChild(objSpan);
	var objSpanT=_cel("div");
	objSpanT.className="slctTxt";
	objSpanT.id="slctTxt_"+idObj;
	objSpan.appendChild(objSpanT);
	var objCmb=_cel("select");
	objCmb.name=objCmb.id=idObj;
	objCmb.className="inpCmb";
	if(szFunc) addEvent(objCmb,'change',szFunc,false);
	objPrnt.appendChild(objCmb);
	return popolaCmb(objCmb,arOpt,optSel,bSel);
}
function disCmb(idCmb){
	_gel(idCmb).disabled=true;
	_gel("slct_"+idCmb).className="slctDis";	
}
function enCmb(idCmb){
	_gel(idCmb).disabled=false;
	_gel("slct_"+idCmb).className="slct";	
}
function arCmbNm(ar,vl,i1,i2){
	if(!i1) i1=0;
	if(!i2) i2=1;
	for(i=0;i<ar.length;i++) if(ar[i][i1]==vl){ return ar[i][i2]; break;}
}
function ltrim(sz){
	return sz.replace(/^\s{1,}/,"");
}
/*
function stCmbSel(obj){
	if(!obj.id) obj=getElem(obj);
	if(!obj) return;
	if(obj.selectedIndex>=0) _gel("slct_"+obj.id).innerHTML=ltrim(obj.options[obj.selectedIndex].text);
}
*/
function stCmbSel(obj){
	if(!obj.id) obj=getElem(obj);
	if(!obj) return;
	if(obj.selectedIndex>=0){
		_gel("slctTxt_"+obj.id).innerHTML=ltrim(obj.options[obj.selectedIndex].text);
		inputOk(obj);
	}else _gel("slctTxt_"+obj.id).innerHTML="";
}
function crChk(idPrnt,idObj,bSel,szFunc){
	var objPrnt=_gel(idPrnt);
	if(!objPrnt) return;
	var objSpan=_cel("span");
	objSpan.id="chckbx_"+idObj;
	objSpan.className="chckbx";
	objPrnt.appendChild(objSpan);
	var objCmb=_cel("input");
	objCmb.type="checkbox";
	objCmb.name=objCmb.id=idObj;
	objCmb.className="dIC";
	if(szFunc) addEvent(objCmb,'change',szFunc,false);
	objPrnt.appendChild(objCmb);
}

function stChkSel(obj,b){
	chgBChg();
	if(b) obj.checked=(obj.checked)?false:true;
	var obj=_gel("chck_"+obj.id);
	if(obj.className.indexOf("Sel")==-1) obj.className+="Sel"; else obj.className=obj.className.slice(0,-3);
}
function stRdoSel(obj){
	chgBChg();
	var szId=obj.id.slice(0,-1);
	var objFrm=_gel("f");
	for(var i=0;i<objFrm.length;i++){
		if(objFrm.elements[i].id.indexOf(szId)>-1){
			for(var j=0;j<10;j++){
				var objRdo=_gel("rdo_"+szId+j);
				if(objRdo) if(objRdo.className.indexOf("Sel")!=-1) objRdo.className=objRdo.className.slice(0,-3);
			}
		}
	}
	var obj=_gel("rdo_"+obj.id);
	if(obj.className.indexOf("Sel")==-1) obj.className+="Sel"; else obj.className=obj.className.slice(0,-3);
}

function areaDoc(){
	return ar=new Array(document.documentElement.clientWidth,document.documentElement.clientHeight);
}
function scrollDoc(){
	return ar=new Array(document.documentElement.scrollLeft,document.documentElement.scrollTop);
}
var expdate = new Date(); expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 

function setCookie(name,value){
	var argv=setCookie.arguments;
	var argc=setCookie.arguments.length;
	var nHours=(2<argc) ? parseInt(argv[2]):null;
	var path=(3<argc) ? argv[3]:null;
	var domain=(4<argc) ? argv[4]:null;
	var secure=(5<argc) ? argv[5]:false;
	var today=new Date();
	expires=new Date(today.getTime()+3600000*nHours);
	document.cookie=name+"="+escape(value)+
	((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
	((path==null) ? "" : ("; path="+path))+
	((domain==null) ? "" : ("; domain="+domain))+
	((secure==true) ? "; secure" : "");
}

function getCookieVal(offset){
   var endstr=document.cookie.indexOf(";",offset);
   if(endstr==-1) endstr=document.cookie.length;
   return unescape(document.cookie.substring(offset,endstr));
}
function getCookie(name){
	var arg=name+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while(i<clen){
		var j=i+alen;
		if(document.cookie.substring(i,j)==arg) return getCookieVal(j);
		i=document.cookie.indexOf(" ",i)+1;
		if(i==0)break; 
	}
	return null;
}






function noPropag(e){
	e=e?e:window.event;
	if(e.stopPropagation) e.stopPropagation();
	if(e.preventDefault) e.preventDefault();
	e.cancelBubble=true;
}
function addEvent(obj,e,fn,useCapture){
	if(obj.addEventListener){
		obj.addEventListener(e,fn,useCapture);
		return true;
	}else if(obj.attachEvent)	return obj.attachEvent("on"+e,fn);
	else alert("evento non attaccato");
}
function rmvEvent(obj,e,fn,useCapture){
	if(obj.removeEventListener){
		obj.removeEventListener(e,fn,useCapture);
		return true;
	}else if(obj.detachEvent)	return obj.detachEvent("on"+e,fn);
	else alert("evento non staccato");
}
function getElem(e){
	var obj;
	//if(!e) var e=window.event;
	e=e?e:window.event;
	if(e.target) obj=e.target;
	else if(e.srcElement) obj=e.srcElement;
	if(obj.nodeType==3) obj=obj.parentNode;
	return obj;
}
function gtStl(obj,szStl){
	if(!obj||!szStl) return;
	var szVl=false;
	if(obj.currentStyle) szVl=obj.currentStyle[szStl];
	else if(window.getComputedStyle) szVl=document.defaultView.getComputedStyle(obj,null).getPropertyValue(szStl);
	return szVl;
}



var arResized=new Array();
function gestResize(obj,wF,hF,fn){
	if(!ppSrch(ppString(arResized),obj.id)){
		arResized.push(obj.id);
		new divResize(obj,wF,hF,fn);
	}
}

function divResize(obj,wF,hF,fn){
	this.obj=obj;
	this.wI=parseInt(obj.offsetWidth);
	this.hI=parseInt(obj.offsetHeight);
	this.wF=wF;
	this.hF=hF;
	this.xDir=this.wF-this.wI;
	this.yDir=this.hF-this.hI;
	this.fn=fn;
	var thi=this;
	this.funcResize=function(){
		if(thi.xDir==0 && thi.yDir==0){ arRemElem(arResized,thi.obj.id); return;}
		if(thi.hF!=null){   
			var jmp=(thi.hF-thi.hI)/4;
			thi.hI+=jmp;
			thi.obj.style.height=thi.hI+"px";
			if((thi.yDir>0&&thi.hI>=thi.hF-1)||(thi.yDir<0&&thi.hI<=thi.hF+1)){
				thi.obj.style.height=thi.hF+"px";
				thi.hF=null;
			}
		}
		if(thi.wF!=null){
			var jmp=(thi.wF-thi.wI)/4;
			thi.wI+=jmp;
			thi.obj.style.width=thi.wI+"px";
			if((thi.xDir>0&&thi.wI>=thi.wF-1)||(thi.xDir<0&&thi.wI<=thi.wF+1)){
				thi.obj.style.width=thi.wF+"px";
				thi.wF=null;
			}
		}
		if(thi.wF!=null || thi.hF!=null) setTimeout(thi.funcResize,41); 
		else{
			if(fn) fn();
			arRemElem(arResized,thi.obj.id);
		}
	};
	this.funcResize();
}


var xmlHttp=null;
function ajaxCall(ppArgs,func){
	//if(isAjax()==null) return;
	isAjax();
	/*
	ppArgs
	3idUser3szTab321cmp1vlcmp121cmp1vlcmp121cmp1vlcmp123
	*/
	var url="php/ajax.php?_ppArgs="+ppArgs+"&_nc="+Math.random();
	xmlHttp.onreadystatechange=func;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function ajaxAr(rspTxt){
	var arRec=new Array();
	//alert(rspTxt+"___");
	var ar2=ppArr(rspTxt,"\2");
	for(var i=0;i<ar2.length;i++) arRec[i]=ppArr(ar2[i],"\1");
	return arRec;
}

function isAjax(){//GetXmlHttpObject
	try{xmlHttp=new XMLHttpRequest();}
	catch(e){
  		try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
		catch(e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
	}
	if(xmlHttp==null) return false;//no ajax
	return true;
}
function vlSv(valore){
	if(!valore) return 0;
	valore=valore.toString();
	if(valore.length-valore.indexOf(",")==3){
		valore=valore.replace(/\./g,"");
		valore=valore.replace(/\,/g,".");
	}
	var val=new Number(valore);
	return parseFloat(val.toFixed(2));
}
function vlPrnt(valore){
	if(!valore) return "";
	valore=parseFloat(valore);
	valore=valore.toFixed(2);
	var ar=valore.split(".");
	var arCifre=ar[0].split("").reverse();
	var sz="";
	for(var i=0;i<arCifre.length;i++){
		if(i%3==0 && i!=0) sz=(!cmsDec) ? "."+sz : ","+sz;
		sz=arCifre[i].toString()+sz;
	}
	var sep=(!cmsDec)?",":".";
	if(parseFloat(sz)==0 && parseFloat(ar[1])==0) return "";
	return sz+sep+ar[1];
}
function setOnLoad(func){
	addEvent(window,"load",func,false);
}
var arFaded=new Array();
function gestFaded(obj,time,iDir,fn){
	if(!ppSrch(ppString(arFaded),obj.id)){
		arFaded.push(obj.id);
		new objFade(obj,time,iDir,fn);
	}
}
function objFade(obj,time,iDir,fn){
	this.obj=obj;
	this.time=time;
	this.iAlpha=(iDir<0)?100:0;
	this.iTime=35;
	this.iDir=100/(time/this.iTime);
	if(this.iDir<1) this.iDir=1;
	if(iDir<0) this.iDir*=-1;
	obj.style.visibility="visible";
	//alert("inizio: "+iAlpha+"___"+iDir);
	var thi=this;
	stAlph(this.obj,this.iAlpha);
	this.fader=function(){
		thi.iAlpha+=thi.iDir; 
		if(thi.iAlpha<0) thi.iAlpha=0;
		if(thi.iAlpha>100) thi.iAlpha=100;
		stAlph(thi.obj,thi.iAlpha);
		if((thi.iAlpha>0&&thi.iDir<0)||(thi.iAlpha<100&&thi.iDir>0)) setTimeout(thi.fader,thi.iTime);
		else{
			//alert("finito: "+thi.iAlpha+"___"+thi.iDir);
			if(thi.iAlpha==0) obj.style.visibility="hidden";
			if(fn) fn(thi.obj);
			arRemElem(arFaded,thi.obj.id);
		}
	};
	this.fader();
}
function stAlph(obj,iAlpha){
	if(_isIE) obj.style.filter="alpha(opacity="+iAlpha+")";
	else obj.style.opacity=iAlpha/100;
}
/*
function opOsc(func){
	var objOscura=_cel("div");
	objOscura.id="divOscura";
	objOscura.className="dOsc";
	addEvent(objOscura,'click',func,false);
	var h=(document.documentElement.clientHeight>document.body.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight;
	objOscura.style.height=h+"px";
	document.body.appendChild(objOscura);
	if(!_isIE){
		stAlph(objOscura,0);
		new objFade(objOscura,100,100);
	}	
}
function clOsc(){
	if(_gel("divOscura")) document.body.removeChild(_gel("divOscura"));
}
function cntrObj(obj,objW,objH){
	var arD=areaDoc();
	var arS=scrollDoc();
	obj.style.left=Math.floor(parseInt(arD[0]/2-objW/2))+"px";
	var iTop=(arD[1]-objH)/2+arS[1];
	obj.style.top=Math.floor(parseInt(iTop))+"px";
}
*/
function opOsc(func){
	if(_gel("divOscura")) return;
	var objOscura=_cel("div");
	objOscura.id="divOscura";
	objOscura.className="dOsc";
	addEvent(objOscura,'click',func,false);
	var h=(document.documentElement.clientHeight>document.body.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight;
	objOscura.style.height=h+"px";
	document.body.appendChild(objOscura);
	if(!_isIE){
		stAlph(objOscura,0);
		new objFade(objOscura,100,100);
	}	
}
function clOsc(){
	if(_gel("divOscura")) document.body.removeChild(_gel("divOscura"));
}
function clDtFrm(iKey){
	var iKey=(!iKey&&iKey!=0)?arOpener.length-1:iKey;
	var id=arOpener[iKey];
	if(_gel("if_"+id)) document.body.removeChild(_gel("if_"+id));
	arOpener.splice(iKey,1);
	if(arOpener.length==0) clOsc();
	//if(_gel("insideFrame")) document.body.removeChild(_gel("insideFrame"));
}
function cntrObj(obj,objW,objH){
	var arD=areaDoc();
	var arS=scrollDoc();
	obj.style.left=Math.floor(parseInt(arD[0]/2-objW/2))+"px";
	var iTop=(arD[1]-objH)/2+arS[1];
	obj.style.top=Math.floor(parseInt(iTop))+"px";
}
var objOpener;
var arOpener=new Array();
function crDtFrm(obj,url,__sins){
	arOpener.push(obj.id);
	objOpener=obj;
	var objFrame=_cel("iframe");
	//objFrame.id="insideFrame";
	objFrame.name=objFrame.id="if_"+obj.id;
	objFrame.className="insideFrame";
	url+="?__sobj="+objOpener.id+"&_nc="+(Math.random());
	if(__sins) url+="&__sins="+__sins+"&_a=new";
	objFrame.src=url;
	var ar=areaDoc();
	ar[0]=(80*ar[0]/100);
	ar[1]=(80*ar[1]/100);
	objFrame.style.width=ar[0]+"px";
	objFrame.style.height=ar[1]+"px";
	document.body.appendChild(objFrame);
	cntrObj(objFrame,ar[0],ar[1]);
}
function opDtFrm(obj,url,__sins){
	window.top.opOsc(window.top.rmDtFrm);
	window.top.crDtFrm(obj,url,__sins);
}
function rmDtFrm(){
	clDtFrm();
}
function closeDivInside(jxArgs){
	ajaxCall(jxArgs,function(){
		if(xmlHttp.readyState==4){
			if(xmlHttp.responseText=="NO") return false;
			var arRec=ajRsp(xmlHttp.responseText);
			var objFrm=window.top.frames["cmsCnt"];
			objFrm.ripopolaCmb(arRec[2],arRec[0],arRec[0][arRec[0].length-1][0],true);
			xmlHttp=null;
			window.top.rmDtFrm();
		}	
	});
}
function ajRsp(pp){
	var ar=new Array();
	var arRes=new Array();
	var ar4=ppArr(pp,"\4");
	var ar7=ppArr(ar4[0],"\7\7\6\7\6\7\7");
	for(var i=0;i<ar7.length;i++){
		var ar6=ppArr(ar7[i],"\6\6\7\6\7\6\6");
		arRes.push(ar6);
	}
	ar[0]=arRes;
	ar[1]=ar4[1];
	ar[2]=ar4[2];
	return ar;
}





function isUrl(szUrl){
	var regExpression=new RegExp("^((http[s]?|ftp)\:\/\/)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?\/?([a-zA-Z0-9\-\._\?\,\'\/\\\+&amp;%\$#\=~])*$");
	var arStr=szUrl.split(".");
	return (regExpression.test(szUrl) && ppSrch(szDomainList,arStr.pop()));
}
function isEmail(szMail){
	var regExpression=/^(([^<>()[\]\\.,\\?;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
	var arStr=szMail.split(".");
	return (regExpression.test(szMail) && ppSrch(szDomainList,arStr.pop()));
}
