/*************************************
 2009 - Stefano Rossi - Quarella S.p.A
 *************************************/

window.onload = on_load;
window.onunload = on_unload;
window.onbeforeunload = on_before_unload;
window.onresize = on_resize;

document.onclick = on_click;
document.onkeypress = on_keypress;

if (pageLangName == "" || pageLangName == "index") {chkIntro = 1;}
var chkProf = 0; if (fMid(pageFullName, 2, 3) == "@") {chkProf = 1;}

var chkSlide = 1;
if (1 == 0
	|| chkIntro == 1
	|| chkProf == 1
	|| pageBaseName == "dise"
    || fLeft(pageBaseName, 2) == "vd"
	|| pageBaseName == "sp01"
	|| pageName == "vide1"
	|| fLeft(pageLangName, 1) == "_"
	) {chkSlide = 0;}
var chkBlink = 0;
if (pageName != "foot" && (pageName == "home1" || pageName == "novi1")) {chkBlink = 1;}

var dirPrf = "prf"; var pathPrf = pathTop + dirPrf + "/";
var dirImg = "img"; var pathImg = pathTop + dirImg + "/";
var pathColMD = "colo_md/";
var pathColHD = "colo_hd/";
var msgPath = "=>" + pageURL + "<=>" + pageDom + "<=>" + pageFullName + "<=>" + pageLangName + "<=>" + pageName + "<=>" + pageBaseName + "<=>" + pageLang + "<=";
//msgBox(msgPath);
//msgBox(pageDom + "<=>" + pathRoot + "<=>" + pathTop + "<=>" + autPwd + "<=>" + chkAut);

var accePage = "acce1";

var errPwd = "XXXXXXXX";
var arrAcc = new Array();
var iAcc = -1;
arrAcc[++iAcc] = "|acc1";
arrAcc[++iAcc] = "colm";
arrAcc[++iAcc] = "colq";
arrAcc[++iAcc] = "cole";
arrAcc[++iAcc] = "colc";
arrAcc[++iAcc] = "gprg";

if (chkAut == 1) {
	setPage();
}

var arrVar = new Array(); var iVar = -1;
iVar++; arrVar[iVar] = new Array(); arrVar[iVar][0] = "coar"; arrVar[iVar][1] = 0; arrVar[iVar][2] = 0; arrVar[iVar][3] = 0;

var arrRes = new Array();

function setPage() {

	//msgBox(self.document.styleSheets[0].cssRules.length);	

	bHH = 768;                      // altezza base di riferimento
	if (1     ==    1) {cH = 0.81;} // coefficiente estensione verticale relativo a bHH
	if (appId == "CH") {cH = 0.89;} // coefficiente estensione verticale relativo a bHH
	qWH = 4/3;                      // proporzioni pagina
	bF  = 9;                        // font-size di base (in px)
	cW  = 1;                        // coefficiente estensione orizzontale
	mW  = 0;                        // estensione minima margini laterali (in px)

	getScreen();

	tW = 300; tH = 100; // dimensioni titolo
	cFtr = 0.0475;      // coefficiente estensione verticale footer
	hTbs = hF * 2;      // altezza menu di testata

	if      (sHH <=  600) {titH =  50;}
	else if (sHH <=  864) {titH =  75;}
	else if (sHH <= 1050) {titH = 100;}
	else                  {titH = 125;}
	titW = parseInt(tW / tH * titH);
	pbH  = pH - titH;                //pageBody height
	hFtr = parseInt(pbH * cFtr);     //footer height
	xFtr = hFtr + "px";
	pbH  = pbH - hFtr - hTbs;

	var logoImg = "img/logo_" + titH + ".gif";
	var bkgPfx = "url(img/bkg_" + titH;

	vdW = 400; vdH = 335; vdPath = "vid/" + pageBaseName + "_" + pageLang + ".";
	if (pageBaseName == "sp01") {vdPath = "vid/spot_euros_" + pageLang + ".avi";}
	if (pageBaseName == "vdq0") {vdPath = "http://www.youtube.com/v/XyLK5LKFuIc?hl=it&fs=1"; vdW = 640; vdH = 480;}
	if (pageBaseName == "vdpr") {
		vdW = 640; vdH = 480;
		vdPath = "eh4Uph2lKBA";
		if (pageLang == "it") {vdPath = "118JXXgDxSE";}
		if (pageLang == "es") {vdPath = "9AbAf0XAXnU";}
		vdPath = "http://www.youtube.com/v/" + vdPath + "?hl=it&fs=1";
	}

	var iRule, idRule, xH, yH, xW, xT, xL;	//msgBox(iiRule);
	for (var iRule = 0; iRule < iiRule; iRule++) {
		idRule = theRules[iRule].selectorText.toLowerCase();
		// if (iRule >= 39 && iRule <= 40) {msgBox(iRule + "<=>" + idRule + "<=");}
		//---------------------
		if (idRule == "body") {
		//---------------------
			theRules[iRule].style.fontSize = xF;
		}
		//------------------------------
		if (idRule == "div.container") {
		//------------------------------
			theRules[iRule].style.top = mrgY + "px";
			theRules[iRule].style.left = mrgX + "px";
			theRules[iRule].style.width = pW + "px";
			xH = pH + "px"; theRules[iRule].style.minHeight = xH; theRules[iRule].style.maxHeight = xH;
			theRules[iRule].style.visibility = "visible";
		}
		//--------------------------
		if (idRule == "div.title") {
		//--------------------------
			theRules[iRule].style.height = titH + "px";
			if (chkIntro == 0) theRules[iRule].style.background = "url(" + logoImg + ") top left no-repeat";
		}
		//------------------------------
		if (idRule == "div.title_img") {
		//------------------------------
			theRules[iRule].style.left = parseInt(((pW - titW) / 2) * 1.1) + "px";
			theRules[iRule].style.width = titW + "px";
			theRules[iRule].style.height = titH + "px";
		}
		//----------------------------------
		if (idRule == "div.title_img img") {
		//----------------------------------
		}
		//-------------------------
		if (idRule == "div.bkg2") {
		//-------------------------
			if (chkIntro == 0) theRules[iRule].style.background = bkgPfx + ".jpg) bottom right no-repeat";
		}
		//------------------------
		if (idRule == "img.bkg") {
		//------------------------
			theRules[iRule].style.filter = "alpha(opacity=75)";
		}
		//-------------------------
		if (idRule == "div.tabs") {
		//-------------------------
			xH = hTbs + "px"; theRules[iRule].style.height = xH;
		}
		//---------------------------------
		if (idRule == "div.quicklinks a img") {
		//---------------------------------
			xH = parseInt((hTbs - 22) / 2); if (xH < 0) {xH = 0;}  //msgBox(hTbs + "<=>" + xH);
			xH = xH + "px"; theRules[iRule].style.marginTop = xH;
		}
		//-----------------------------
		if (idRule == "div.pagebody") {
		//-----------------------------
			xH = pbH + "px"; theRules[iRule].style.height = xH;
		}
		//-------------------------------
		if (idRule == "div.pagecenter") {
		//-------------------------------
			if (chkIntro == 0 && (1 == 0
			   || pageBaseName == "azie"
			   || pageBaseName == "nain"
			   || pageBaseName == "coar"
			   || pageBaseName == "novi"
			   || pageBaseName == "colm"
			   || pageBaseName == "colq"
			   || pageBaseName == "colc"
			   || pageBaseName == "cole"
			   || pageBaseName == "cicl"
			   || pageBaseName == "prbl"
			   || pageBaseName == "prla"
			   || pageBaseName == "prma"
			   || pageBaseName == "carm"
			   || pageBaseName == "appl"
			   || pageBaseName == "fier"
			   || pageBaseName == "rice"
			   || pageBaseName == "usmp"
			   || pageBaseName == "usmn"
			   || pageBaseName == "usmc"
			   || fLeft(pageBaseName, 2) == "dc"
			   )) {
			   theRules[iRule].style.background = bkgPfx + "_opa.jpg) bottom right no-repeat";
			   //msgBox(sHH + "<>" + titH + "<>" + bkgPfx);
		   }
		}
		//--------------------------
		if (idRule == "div.msgjs") {
		//--------------------------
			theRules[iRule].style.visibility = "hidden";
		}
		//------------------------------
		if (idRule == "div.indexleft") {
		//------------------------------
			inW = pW * parseInt(theRules[iRule].style.width) / 100; // index width
			vdL = inW + pW * (0.05); // video left margin
			//msgBox(inW + "<=>" + vdL);
		}
		if (1 == 0
		//------------------------
		|| idRule == "iframe#vdpr"
		|| idRule == "iframe#sp01"
		|| idRule == "iframe#vdq0"
		//------------------------
		   ) {
			//vdW = parseInt(theRules[iRule].style.width); vdH = parseInt(theRules[iRule].style.height);
			theRules[iRule].style.width = vdW + "px";
			theRules[iRule].style.height = vdH + "px";
			xT = parseInt(((pbH - vdH) / 2) * 0.7); if (xT < 0) {xT = 0;} theRules[iRule].style.top = xT + "px";
			xL = parseInt((pW - vdW) / 2) - vdL; if (xL < 0) {xL = 0;} theRules[iRule].style.left = xL + "px";
		}
		//-------------------------------------
		if (idRule == "div.flag ul li a img") {
		//-------------------------------------
			theRules[iRule].style.filter = "alpha(opacity=50)";
		}
		if (1 == 0
		//------------------------------------------------
		|| idRule == "div.flag ul li a:hover img"
		|| idRule == "div.flag ul li a.active img"
		|| idRule == "div.intro_band div.flag ul li a img"
		//------------------------------------------------
		   ) {
			theRules[iRule].style.filter = "alpha(opacity=100)";
		}
		//------------------------------
		if (idRule == "div.home_news") {
		//------------------------------
			theRules[iRule].style.filter = "alpha(opacity=80)";
		}
		//-----------------------------------------
		if (idRule == "div.gall_colo_lnk2 div a") {
		//-----------------------------------------
			theRules[iRule].style.filter = "alpha(opacity=50)";
		}
		//---------------------------------------------
		if (idRule == "div.gall_colo_lnk2 div a#sel") {
		//---------------------------------------------
			theRules[iRule].style.filter = "alpha(opacity=100)";
		}
		if (1 == 0
		//-------------------------------------
		|| idRule == "div.gall_colo_marmo a"
		|| idRule == "div.gall_colo_quarzo a"
		|| idRule == "div.gall_colo_evo a"
		|| idRule == "div.gall_colo_chenille a"
		//-------------------------------------
		   ) {
			theRules[iRule].style.filter = "alpha(opacity=60)";
		}
		if (1 == 0
		//-------------------------------------------
		|| idRule == "div.gall_colo_marmo a:hover"
		|| idRule == "div.gall_colo_quarzo a:hover"
		|| idRule == "div.gall_colo_evo a:hover"
		|| idRule == "div.gall_colo_chenille a:hover"
		//-------------------------------------------
		   ) {
			theRules[iRule].style.filter = "alpha(opacity=100)";
		}
		//-------------------------------------
		if (idRule == "div.gall_colo_thumbs") {
		//-------------------------------------
			var xR = 2; xW = theRules[iRule].style.width; xW = fLeft(xW, xW.length - 1);
			if (appId == "IE") {
				xW = xW - xR; xW = xW + "%";
				theRules[iRule].style.width = xW;
				theRules[iRule].style.paddingRight = xR + "%";
			} 
		}
		//---------------------------------------------
		if (idRule == "div.gall_colo_thumbs ul li a") {
		//---------------------------------------------
			theRules[iRule].style.cursor = "hand";
		}
		//-----------------------------------
		if (idRule == "div.sche_lnk a img") {
		//-----------------------------------
			theRules[iRule].style.filter = "alpha(opacity=75)";
		}
		//-----------------------------------------
		if (idRule == "div.sche_lnk a:hover img") {
		//-----------------------------------------
			theRules[iRule].style.filter = "alpha(opacity=100)";
		}
		//------------------------------
		if (idRule == "div.img_slide") {
		//------------------------------
			theRules[iRule].style.filter = "alpha(opacity=0)";
		}
		//---------------------------------
		if (idRule == "div.img_even img") {
		//---------------------------------
			theRules[iRule].style.filter = "alpha(opacity=90)";
		}
		//-------------------------
		if (idRule == "div.maps") {
		//-------------------------
			theRules[iRule].style.filter = "alpha(opacity=70)";
		}
		//---------------------------------
		if (idRule == "div.quicklinks a") {
		//---------------------------------
			theRules[iRule].style.filter = "alpha(opacity=75)";
		}
		//---------------------------------------
		if (idRule == "div.quicklinks a:hover") {
		//---------------------------------------
			theRules[iRule].style.filter = "alpha(opacity=99)";
			theRules[iRule].style.cursor = "hand";
		}
		//---------------------------------------
		if (idRule == "div.dise_col_ele ul li") {
		//---------------------------------------
			if (appId == "FF") {
				theRules[iRule].style.width = "94.5%";
				theRules[iRule].style.paddingRight = "5.5%";
			}
		}
		if (1 == 0
		//-------------------------------------------
		|| idRule == "div.dise_col_mob ul li a:hover"
		|| idRule == "div.dise_col_ele ul li a:hover"
		//-------------------------------------------
		   ) {
			theRules[iRule].style.cursor = "hand";
		}
		//-----------------------------
		if (idRule == "div.dise_img") {
		//-----------------------------
			theRules[iRule].style.visibility = "visible";
		}
		//------------------------------------
		if (idRule == "div.htmlcheck a img") {
		//------------------------------------
			theRules[iRule].style.filter = "alpha(opacity=75)";
		}
		//------------------------------------------
		if (idRule == "div.htmlcheck a:hover img") {
		//------------------------------------------
			theRules[iRule].style.filter = "alpha(opacity=100)";
		}
		//----------------------------
		if (idRule == "iframe.foot") {
		//----------------------------
			theRules[iRule].style.minHeight = xFtr;
			theRules[iRule].style.maxHeight = xFtr;
		}
	}

	titOpacityMin = 0;
	titOpacityMax = 100;
	titOpacityInc = 10;
	titImages     = 5;
	titImagesPfx  = pathTop + "img/title_";
	titImagesSfx  = "_" + titH + ".gif";
	titTimerFrq   = 100;
	titPauseSec   = 5;
	titTimerMax   = 1000 / titTimerFrq * titPauseSec;
	slideImgs     = new Array();
	titSlideOpa   = titOpacityMax;
	titSlideIdx   = -1;
	titSlideImg   = fRandom(titImages, -1);
	titSlideTimer = 0;

	blinkColors   = new Array();
	bColors = -1;
	bColors++; blinkColors[bColors] = "#ffdd99";
	bColors++; blinkColors[bColors] = "#eecc88";
	bColors++; blinkColors[bColors] = "#ddbb77";
	bColors++; blinkColors[bColors] = "#ccaa66";
	bColors++; blinkColors[bColors] = "#bb9955";
	bColors++; blinkColors[bColors] = "#aa8844";
	bColors++; blinkColors[bColors] = "#997733";
	bColors++; blinkColors[bColors] = "#886622";
	bColors++; blinkColors[bColors] = "#775511";
	bColors++; blinkColors[bColors] = "#664400";
	bColors++; blinkColors[bColors] = "#000000";
	bColor = 0;
	iColor = 1;
	//msgBox("OK");

}

function on_keypress(e) {
	evInf(e);
	if (kCode == 13) {on_click(e);}
}

function on_before_unload(e) {
	//
}

function on_unload(e) {
	return;
	var el;	try {el = document.getElementById("gall_prog");} catch(e) {}
	if (el != null) {
		galPosRW(galInf("imgDir", ""), galPos, "w");
	}
}

function on_load() {

	if (chkAut == 0) {
		var eJS = document.getElementById("msgJS").style.visibility = "hidden";
		var eNA = document.getElementById("msgNA").style.visibility = "visible";
		return;
	}

	var el;

	if (1 == 1 && chkProf == 1) {
		var lnk;
		var cPage = cookieRead("callPage");
		var dPage = "" + cookieRead("destPage");
		if (cPage != "") {
			lnk = cPage; //Per eventuale ritorno a pagina precedente
			var xPage = fPageBaseName(cPage);
			var eProf = document.getElementById("prof");
			var ii = eProf.childNodes.length;
			if (ii > 0) {
				//Cicla nodi profilo
				for (var i = 0; i < ii; i++) {
					var iProf = eProf.childNodes[i]; var cProf = iProf.className;
					//Cicla matrice arrAcc[iAcc]
					for (var nAcc = 0; nAcc <= iAcc; nAcc++) {
						var rAcc = arrAcc[nAcc];
						if (fLeft(rAcc, 1) == "|") {var xAcc = rAcc.substring(1);}
						//Trova nodo profilo
						if (xAcc == cProf && rAcc == xPage) {
							//Configura accesso
							var vProf = iProf.id;
							if (dPage != "") {
								lnk = pathTop + vProf + "/" + fPageFullName(dPage);
								nAcc = iAcc; i = ii - 1;
							}
						}
					}
				}
			}
		}
		window.location.href = lnk;
		return;
	}

	if (fLeft(pageLangName, 1) == "_") {
		var cRegi = cookieRead("callRegi"); //msgBox(fPageName(cRegi)); return;
		if (fPageName(cRegi) == "regi1") {
			var dPage = fPageLang(cRegi) + "_$" + fRight(pageLangName, 4) + pageExt;
			openPage(dPage);
		}
		else {
			openPage(cRegi);
		}
		return;
	}

	if (fLeft(pageBaseName, 1) == "$") {
		var cPage = cookieRead("callPage"); //msgBox(cPage);
		if (1 == 0 || fPageName(cPage) == "regi1") {
			document.getElementById("pass").style.visibility = "visible";
		}
		else {
			openPage(cPage);
		}
		return;
	}

	if ((fLeft(pageBaseName, 2) == "vd" || pageBaseName == "sp01") && pageBaseName != "vide") {
		el = document.getElementById(pageBaseName);
		el.src = pageLang + "_vide1.html";
		var WMP7, vdType; if (appId == "IE" ) {WMP7 = new ActiveXObject("WMPlayer.OCX");}
		vdType = ""; if (WMP7) {vdType = "WMP7";}
		if (pageBaseName == "vdq0" || pageBaseName == "vdpr") {vdType = "yt";}  //msgBox(vdType + "<=>" + vdPath);
		frames[0].document.write(objVid(vdType, vdPath, vdW, vdH));
	}

	try {el = document.getElementById("gall_prog");} catch(e) {}
	if (el != null) {
		var galP = cookieRead("galPar");
		if (galP != "undefined") {galPar += galP;}
		galPos = parseInt(galPosRW(galInf("imgDir", ""), "", "r"), 10);
		if (isNaN(galPos) || galPos == 0) {galPos = 1;}
		galLoadImg(galPos);
	}

	try {el = document.getElementById("prof");} catch(e) {}
	if (1 == 1
	    && pageBaseName != "regi" && pageBaseName != "cont" && pageBaseName != "gara"
		&& ((el != null && chkProf == 0 && autPwd != "") || (pageName == "gprg1" && pathTop == ""))
		) {
		getAccess(); //Reindirizzamento su pagina riservata
		return;
	}

	try {el = document.getElementById("gall_colo");} catch(e) {}
	if (el != null) {
		if (pathTop != "") {
			callLink = pgParR("callLink", pageBaseName, "1");
			if (callLink == "") {coloZoom("none", "load");}
			if (fLeft(callLink, 1) == "$") {coloZoom(callLink, "load");}
		}
	}

	if (pageName == "rice1") {
		parent.frames[indxFrame].location = pageLang + "_" + indxFrame + pageExt;
		var memRes = document.getElementById("memRes").value;
		if (memRes != "") {
			var arrRe0 = memRes.split("::");
			for (nRes = 0; nRes < arrRe0.length; nRes++) {
				var xRes = arrRe0[nRes];
				arrRes[nRes] = xRes.split(";;");
			}
			visRes();
		}
	}

	if (pageName == "dise1") {
		ico = document.getElementById("loadIcon");
		var arrImg = new Array(); var iImg = -1, iiImg, nImg;
		arrImg[++iImg] = new Array(); arrImg[iImg][0] = "bak"; arrImg[iImg][1] = "";
		arrImg[++iImg] = new Array(); arrImg[iImg][0] = "pav"; arrImg[iImg][1] = "Evo__Creta"; arrImg[iImg][2] = "Creta";
		arrImg[++iImg] = new Array(); arrImg[iImg][0] = "mob"; arrImg[iImg][1] = "Marron";
		arrImg[++iImg] = new Array(); arrImg[iImg][0] = "pia"; arrImg[iImg][1] = "Evo__Cenere";   arrImg[iImg][2] = "Cenere";
		var imgPat = pathImg + "dise/";
		var imgPfx = "dise_01";
		nnImg = -1;
		for (nImg = 0; nImg <= iImg; nImg++) {
			img = document.images[imgPfx + "_img_" + arrImg[nImg][0]];
			var imgSrc = imgPat + imgPfx + "_" + arrImg[nImg][0];
			if (arrImg[nImg][1] != "") {imgSrc += "_" + arrImg[nImg][1];}
			imgSrc += ".gif";
			img.onload = function() {
				nnImg++;
				if (nnImg == iImg) {
					ico.style.visibility = "hidden";
					document.getElementById("dise_01_img_sel").style.visibility = "visible";
				}
			};
			img.src = imgSrc;
			if (arrImg[nImg][2] != null) {document.getElementById("dise_img_sel_" + arrImg[nImg][0]).value = arrImg[nImg][2];}
		}
	}

	// Cicli continuativi

	if (pageBaseName == "coar") {
		tc = "coar"; ti = 100; window.setInterval(trans, ti);
	}

	if (chkSlide == 1) {
		window.setInterval(slide, titTimerFrq);
		if (chkBlink == 1) {window.setInterval(doBlink, 100);}
	}

}

function on_resize() {
	setPage();
}

function on_click(e) {

	evInf(e);

	var el;

	try {el = document.getElementById("gall_colo");} catch(e) {}
	if (el != null) {
		var rLink = trgParentId;
		if (fLeft(rLink, 1) == "$") {
			evPrevDef(e);
			//window.location.hash = rLink;
			pgParW("callLink", pageBaseName, rLink);
			if (pathTop == "") {
				getAccess();
			}
			else {
				coloZoom(rLink, "click");
				pgParW("callLink", pageBaseName, rLink);
			}
		}
		return;
	}

	if (trgParentId == "movSx" || trgParentId == "movDx") {
		if (trgParentId == "movDx") {galPos++;} else {galPos--;}
		galLoadImg(galPosNext(galPos));
	}

	if (fLeft(trgId, 2) == "G_") {
		galLoadImg(parseInt(trgId.substring(2, 4), 10));
	}

	if (fLeft(trgParentId, 5) == "dise_") {
		var eId = trgParentId;
		var eName = trgParentName;
		var xAre = fMid(eId, 8, 11);
		if (xAre == "mob" || xAre == "pia" || xAre == "pav") {
			ico.style.visibility = "visible";
			var xDis = fLeft(eId, 7);
			var xSrc = fMid(eId, 12); xSrc = fLeft(xSrc, xSrc.length - 4);
			img = document.images[xDis + "_img_" + xAre];
			var ySrc = pathImg + "dise/" + xDis + "_" + xAre + "_" + xSrc + ".gif";
			img.onload = function() {ico.style.visibility = "hidden";}
			img.src = ySrc;
			if (xAre == "pia" || xAre == "pav") {
				el = document.getElementById("dise_img_sel_" + xAre); el.value = eName.replace("<br>", " ");
			}
		}
	}

	//msgBox(trgParentClassN);
	if ((trgParentClassN == "formAcce" || trgParentClassN == "buttAcce") && (trgId == "conf" || (trgId == "code" && kCode == 13))) {
		evPrevDef(e);
		getCode();
		getProf();
		window.setTimeout("pwdErr()", 100);
	}

	if (trgParentClassN == "buttRegi") {
		if (trgId == "submit") {sendForm();}
		if (trgId == "reset")  {document.forms[0].reset();}
	}

    if (trgId == "searchFind" || (trgId == "searchInput" && kCode == 13)) {srcRes();}

}

function sendForm() {

	if (submitCount > 0) {return;}
	chkForm = 1;

	var eFrm = document.forms[0];
	var idFrm = eFrm.id; //msgBox(idFrm);
	var eFld, xFld, vFld, yFld, zFld, cFld = "#000000", vEr1 = "??????";

	//Field validation
	nnFld = eFrm.elements.length;
	for (var nFld = 0; nFld < nnFld; nFld++) {
		eFld = eFrm.elements[nFld];
		xFld = eFld.name;
		eLab = document.getElementById(xFld + "_lab");
		zFld = "#"; if (eLab) {zFld = eLab.lang;}
		vFld = "" + fTrim(eFld.value);
		eFld.style.color = cFld;
		//msgBox(xFld + "<->" + zFld + "<->" + vFld.length);
		     if (zFld == "null"  && vFld.length < 1)                  {                               markErrFld(eFld, vEr1);}
		     if (zFld == "null"  && vFld == "-")                      {                               markErrFld(eFld, vFld);}
		else if (zFld == "mail"  && checkMail(vFld)  == false)        {if (vFld == "") {vFld = vEr1;} markErrFld(eFld, vFld);}
		else if (zFld == "phone" && checkPhone(vFld) == false)        {if (vFld == "") {vFld = vEr1;} markErrFld(eFld, vFld);}
		else if (vFld == zFld)                                        {                               markErrFld(eFld, vEr1);}
		else if (vFld == vEr1)                                        {                               markErrFld(eFld, vEr1);}
	}

	//chkForm = 1; //Usata solo per test
	if (chkForm == 1) {
		if (idFrm == "formRegi") {eFrm.send_mail.value = eFrm.mail.value;}
		callPage = pageFullName;
		callRegi = pageFullName;
		cookieWrite("", 0);
		submitCount++;
		//msgBox(idFrm + "<=>" + eFrm.mail.value + "<=>" + eFrm.send_mail.value);
		//openPage("_1d81" + pageExt); // Simula pagina di conferma
		eFrm.submit();
	}

}

function getAccess() {
	callPage = pageURL;
	destPage = pageURL;
	//autPwd = errPwd; //simula codice errato.
	if (autPwd == "") {autPwd = errPwd;}
	cookieWrite("", 0);
	getProf();
	window.setTimeout("pwdErr()", 1000);
}

function getCode() {
	chkFrm = document.getElementById("formAcce");
	autPwd = chkFrm.code.value;
	cookieWrite("", 0);
}

function getProf() {
	var lnk = pathPrf + pageLang + "@" + fPageBaseName(callPage) + "@" + autPwd;
	var tester = new Image();
	tester.onload = function() {openPage(lnk + pageExt);}
	//msgBox(callPage + "<=>" + lnk + ".jpg");
	tester.src = lnk + ".jpg";
}

function pwdErr() {
	if (pageName != accePage) {openPage(pageLang + "_" + accePage + pageExt);}
}

function trans() {

	for (var nVar = 0; nVar <= iVar; nVar++) {
		if (arrVar[nVar][0] == tc) {
			var xVar = nVar;
			var xSld = arrVar[xVar][1];
			var xTmr = arrVar[xVar][2];
			var xOpa = arrVar[xVar][3];
		}
	}

	var arrSld = new Array(); var iiSld = -1; var iSld;

	if (tc == "coar") {
		var ssSld = 2000;
		arrSld[++iiSld] = new Array(); iSld = -1;
			arrSld[iiSld][++iSld] = "img_slide_0";
			arrSld[iiSld][++iSld] = "";
		arrSld[++iiSld] = new Array(); iSld = -1;
			arrSld[iiSld][++iSld] = "img_slide_1";
			arrSld[iiSld][++iSld] = "";
		arrSld[++iiSld] = new Array(); iSld = -1;
			arrSld[iiSld][++iSld] = "img_slide_2";
			arrSld[iiSld][++iSld] = "";
		arrSld[++iiSld] = new Array(); iSld = -1;
			arrSld[iiSld][++iSld] = "img_slide_3";
			arrSld[iiSld][++iSld] = "";
	}

	xTmr += ti;
	if (xTmr > ssSld) {

		var ySld; var iX; var iY; var eX; var eY;
		ySld = xSld + 1; if (ySld > iiSld) {ySld = 0;}
		xOpa += 10;
		if (xOpa <= 100) {
			iSld = 0;
			iX = arrSld[xSld][iSld];
			iY = arrSld[ySld][iSld];
			if (iX != "") {eX = document.getElementById(iX);}
			if (iY != "") {eY = document.getElementById(iY);}
			if (appId == "IE") {
				if (iX != "") {eX.style.filter = "alpha(opacity=" + (100 - xOpa) + ")";}
				if (iY != "") {eY.style.filter = "alpha(opacity=" + xOpa + ")";}
			}
			if (appId == "FF") {
				if (iX != "") {eX.style.MozOpacity = 1 - xOpa / 100;}
				if (iY != "") {eY.style.MozOpacity = xOpa / 100;}
			}
			else {
				if (iX != "") {eX.style.opacity = 1 - xOpa / 100;}
				if (iY != "") {eY.style.opacity = xOpa / 100;}
			}
		}
		else {
			xOpa = 0;
			xTmr = 0;
			if (++xSld > iiSld) {xSld = 0;}
		}

	}

	arrVar[xVar][1] = xSld;
	arrVar[xVar][2] = xTmr;
	arrVar[xVar][3] = xOpa;

}

function slide() {

	slideImgs[0] = titImagesPfx + fInt(0, 2, "0") + titImagesSfx;
	slideImgs[1] = titImagesPfx + fInt(titSlideImg, 2, "0") + titImagesSfx;

	if (chkNewPage == 1) {
		for (iImage = 0; iImage <= 1; iImage++) {
			document.getElementById("title_img_" + iImage).src = slideImgs[iImage];
		}
		slideOpacity(titSlideOpa);
		document.getElementById("title_img").style.visibility = "visible";
		chkNewPage = 0;
	}

	else {
		if (titSlideTimer >= titTimerMax) {titSlideTimer = 0;}
		if (titSlideTimer > 0) {titSlideTimer++;}
		if (titSlideTimer == 0) {
			if (titSlideOpa < titOpacityMin || titSlideOpa > titOpacityMax) {
				slideImgs[((titSlideIdx * -1) + 1) / 2] = titImagesPfx + fInt(titSlideImg, 2, "0") + titImagesSfx;
				// Determina prossima immagine
				titSlideImg += 1; if (titSlideImg > titImages) {titSlideImg = 1;}
				titSlideIndex = (titSlideIdx + 1) / 2; titSlideImage = titImagesPfx + fInt(titSlideImg, 2, "0") + titImagesSfx;
				document.getElementById("title_img_" + titSlideIndex).src = titSlideImage;
				slideImgs[titSlideIndex] = titSlideImage;
				titSlideIdx *= -1; titSlideTimer++;
			}
			if (titSlideOpa >= titOpacityMin && titSlideOpa <= titOpacityMax) {
				slideOpacity(titSlideOpa);
			}
			titSlideOpa += titSlideIdx * titOpacityInc;
		}
	}

}

function coloZoom(zId, zEv) {

	callPage = pageURL;	destPage = pageURL;

	var eTg = document.getElementById("gall_colo_zoom_tag"); eTg.style.visibility = "hidden";

	var im = zId, eId, nn, n;
	eId = document.getElementById("gall_colo_zoom_img");
	eId.style.backgroundImage = "url(" + pathImg + "loader_red.gif)";
	nn = eId.childNodes.length;
	for (n = 0; n < nn; n++) {
		eId.removeChild(eId.lastChild);
	}

	if (im != "none") {
		im = im.substring(1);
		var eImg = eId.appendChild(document.createElement("img")); eImg.src = pathColMD + im;
		var t0 = im; t0 = t0.substring(t0.indexOf("_") + 1);
		var tt = "", y;
		for (var n = 0; n <= t0.length - 5; n++) {
			x = t0.charCodeAt(n);
			y = 0; if (n > 0) {y = t0.charCodeAt(n - 1);}
			if (n > 0 && x >= 65 && x <= 90 && (y < 65 || y > 90)) {tt += " ";}
			tt += t0.substring(n, n + 1);
		}
		tt = tt.replace("_", "");
		eId = document.getElementById("gall_colo_zoom_tit");
		nn = eId.childNodes.length;
		for (n = 0; n < nn; n++) {
			eId.removeChild(eId.lastChild);
		}
		var eTit = eId.appendChild(document.createElement("h1")); eTit.innerHTML = tt;
	}

	else {
		eId.style.backgroundImage = "none";
	}

	coloMark(zEv);

}

function coloMark(zEv) {
	//msgBox(zEv);
	var eTi = document.getElementById("gall_colo_zoom_tit");
	var tiCo = ""; try {tiCo = eTi.firstChild.innerHTML;} catch(e) {} //msgBox(tiCo);
	if (tiCo != null && tiCo != "") {
		tiCo = tiCo.replace(/ /g, "");
		var eThumb = document.getElementById("gall_colo_thumbs").childNodes[fChild(0)];
		var arrLi = new Array; arrLi = eThumb.getElementsByTagName("LI");
		var nnLi = arrLi.length - 1;
		var eAn, eLi;
		for (var nLi = 0; nLi <= nnLi; nLi++) {
			eLi = arrLi[nLi];
			//var eAn = eLi.firstChild;
			eAn = ""; try {eAn = eLi.getElementsByTagName("A")[0]} catch(e) {}; //msgBox(eAn);
			if (eAn != null && eAn != "") {
				var sTi = eAn.id.substring(6, eAn.id.length - 4);
				if (sTi == tiCo) {
					//msgBox(eLi.firstChild.id);
					if (zEv == "load") {
						//window.location.hash = eId;
						arrLi[nnLi].getElementsByTagName("A")[0].focus();
						arrLi[nLi - 1].getElementsByTagName("A")[0].focus();
						eAn.focus();
					}
					eAn.blur();
					eAn.style.color = "#ee0000";
					eAn.style.margin = "0";
					eAn.style.border = "dashed 1px #ff0000";
					if (eLi.firstChild.id == "elim") {
						document.getElementById("gall_colo_zoom_tag").style.visibility = "visible";
					}
				}
				else {
					eAn.style.margin = "1px";
					eAn.style.border = "";
					eAn.style.color = "";
				}
			}
		}
	}
}

function srcRes() {
	var resMax = 99; var resExt = 200; arrRes.length = 0;
	var srcStr = document.getElementById("searchInput").value.toLowerCase();
	if (srcStr == "") {return;}
	var ii = frames[indxFrame].document.links.length;
	if (ii > 0) {
		var srcArr = srcStr.split(" ");
		var nnSrc = srcArr.length;
		if (nnSrc > 0) {
			nnSrc--;
			var arrDim = new Array();
			var arrSrc = new Array();
			var nSrc = 0;
			for (n = 0; n <= 1; n++) {
				for (iSrc = 0; iSrc <= nnSrc; iSrc++) {
					if (n == 0) {
						arrDim[iSrc] = -1;
						arrSrc[iSrc] = new Array();
					}
					else {
						for (iiSrc = nnSrc; iiSrc >= iSrc; iiSrc--) {
							tSrc = ""; var nEle = -1;
							for (iiiSrc = iSrc; iiiSrc <= iiSrc; iiiSrc++) {
								if (tSrc != "") {tSrc += " ";}
								tSrc += srcArr[iiiSrc];
								nEle++;
							}
							nSrc++;
							arrSrc[nEle][++arrDim[nEle]] = tSrc;
						}
					}
				}
			}
			var nRes = -1; var resTxt = "";
			for (n = nnSrc; n >= 0; n--) {
				for (nn = 0; nn <= arrDim[n]; nn++) {
					var xStr = arrSrc[n][nn];
					for (var i = 0; i < ii; i++) {
						var fndIdx = frames[indxFrame].document.links[i].id;
						var fndTit = frames[indxFrame].document.links[i].name;
						var fndDes = frames[indxFrame].document.links[i].innerHTML;
						var fndLnk = frames[indxFrame].document.links[i].href;
						var srcIdx = fndIdx.toLowerCase();
						var fndPos = srcIdx.indexOf(xStr);
						//msgBox(srcIdx + "<=>" + xStr + "<=>" + fndPos);
						var chkSrc = 0;
						if (fndPos < 0) {
							srcIdx = fndTit.toLowerCase();
							fndPos = srcIdx.indexOf(xStr);
							chkSrc = 1;
						}
						if (fndPos >= 0 && nRes <= resMax) {
							if (fndPos > 0 && chkSrc == 1) {fndPos = 0;}
							var lenIdx = fndIdx.length; var oflSx = 0; var oflDx = 0;
							var posSx = fndPos - resExt; if (posSx < 0) {oflSx = posSx * -1; posSx = 0;}
							var posDx = fndPos + xStr.length + resExt; if (posDx > lenIdx) {oflDx = posDx - lenIdx; posDx = lenIdx;}
							if (oflSx > 0 && posDx + oflSx <= lenIdx) {posDx += oflSx;}
							if (oflDx > 0 && posSx - oflDx >= 0) {posSx -= oflDx;}
							for (nChr = 1; nChr <= 2; nChr++) {
								if (nChr == 1) {var xChr = posSx; var iChr = -1; var yChr = 0;}
								if (nChr == 2) {var xChr = posDx; var iChr =  1; var yChr = lenIdx;}
								if (xChr > 0 && xChr < lenIdx) {
									tChr = fndIdx.substring(xChr, xChr + 1);
									if (tChr != " ") {
										do {
											xChr += iChr;
											tChr = fndIdx.substring(xChr, xChr + 1);
											if (tChr == " ") {
												if (iChr == -1) {posSx = xChr;}
												if (iChr ==  1) {posDx = xChr;}
												xChr = yChr;
											}
										}
										while (xChr != yChr);
									}
								}
							}
							var desRes = fTrim(fndIdx.substring(posSx, posDx));
							if (posSx > 0) {desRes = "..." + desRes;} if (posDx < lenIdx) {desRes += "...";}
							var chkRes = 1;
							if (nRes >= 0) {
								for (xRes = 0; xRes <= nRes; xRes++) {
									if (fndLnk == arrRes[xRes][1] && desRes == arrRes[xRes][2]) {
										chkRes = 0;
										xRes = nRes;
									}
								}
							}
							if (chkRes == 1) {
								nRes++;
								arrRes[nRes] = new Array();
								arrRes[nRes][0] = fndTit; arrRes[nRes][1] = fndLnk; arrRes[nRes][2] = desRes;
								if (resTxt != "") {resTxt += "::"} resTxt += fndTit + ";;" + fndLnk + ";;" + desRes;
							}
						}
					}
				}			
			}
		}
		var eTxt = document.getElementById("memRes"); eTxt.value = resTxt;
		visRes();
	}
}

function visRes () {

	var eDiv = document.getElementById("results");
	for (var nChl = 0; nChl <= eDiv.childNodes.length - 1; nChl++) {
		eDiv.removeChild(eDiv.lastChild);
	}
	var eUl = eDiv.appendChild(document.createElement("ul"));
	for (nRes = 0; nRes < arrRes.length; nRes++) {
		resTit = arrRes[nRes][0]; resLnk = arrRes[nRes][1]; resDes = arrRes[nRes][2];
		var eLi  = eUl.appendChild(document.createElement("li"));
		var eLnk = eLi.appendChild(document.createElement("a")); eLnk.innerHTML = resTit; eLnk.href = resLnk;
		if (resDes != resTit) {var eDes = eLi.appendChild(document.createElement("span")); eDes.innerHTML = resDes;}
	}
}

function galInf(gInf, pInf) {
	var rInf = "", eInf; if (gInf == "posAtt") {rInf = 1;}
	eInf = document.getElementById("gall_prog").childNodes[fChild(0)].id;
	//msgBox(document.getElementById("gall_prog").childNodes[5].id);
	//msgBox(fChild(0) + "<=>" + eInf);
	if (gInf == "posMax") {rInf = fLeft(eInf, 2); return rInf;}
	if (gInf == "imgDir") {rInf = eInf.substring(3); return rInf;}
	eInf = document.getElementById("gall_prog_pos");
	var iiInf = eInf.childNodes.length;
	//msgBox(iiInf);
	if (iiInf > 0) {
		var xInf; var yInf;
		for (iInf = fChild(0); iInf <= iiInf; iInf++) {
			try {xInf = eInf.childNodes[iInf].id;} catch (err) {xInf = ""}
			try {yInf = xInf.substring(2, 4);} catch (err) {yInf = ""}
			try {zInf = xInf.substring(5);} catch (err) {zInf = ""}
			if (gInf == "imgName" && yInf == pInf && zInf != "") {
				rInf = zInf;
			}
			if (gInf == "posAtt") {
				var xImg = document.getElementById("gall_prog_img").style.backgroundImage;
				var yImg = xImg.substring(xImg.lastIndexOf("/") + 1, xImg.length - 1);
				if (zInf == yImg) {rInf = yInf;}
			}
		}
	}
	return rInf;
}

function galLoadImg(imgPos) {
	galPos = imgPos;
	var imgDir = galInf("imgDir", 0);
	var imgName = galInf("imgName", galPos);
	var imgURL = "url('" + imgDir + "/" + imgName + "')";
	var eId = document.getElementById("gall_prog_img");
	eId.style.backgroundImage = imgURL;
	if (fLeft(pageBaseName, 2) == "gc") {
		document.getElementById("gall_prog").childNodes[fChild(2)].innerHTML = fFileBaseName(imgName);
	}
	galPosMark(fInt(galPos, 2, "0"), 2);
}

function galPosMark(posId, posSt) {

	var mrkAtt = "#900000";
	var mrkNul = "#000000";
	var posCo;

	for (var iLnk = 0; iLnk <= document.links.length; iLnk++) {
		var eLnk = document.links[iLnk]; var idLnk = "";
		try {idLnk = fLeft(eLnk.id, 4);}
		catch (err) {}
		if (fLeft(idLnk, 2) == "G_") {
			posCo = mrkNul;
			if (idLnk == "G_" + posId) {posCo = mrkAtt;}			
			eLnk.style.border = "solid 2px " + posCo;
		}
	}

}
