/* SWF Object */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
/* Fine SWF Object */

/* Funzione di addizione/rimozione generica eventi */
function addEvent(o, n, h) {
	// alert(o);
	if (o.attachEvent){
		// alert("attachEvent");
		o.attachEvent("on" + n, h);
	} else {
		// alert("addEventListener " + n + h);
		o.addEventListener(n, h, false);
	}
}
function removeEvent(o, n, h) {
	// alert(o);
	if (o.attachEvent){
		// alert("attachEvent");
		o.detachEvent("on" + n, h); 
	} else {
		// alert("addEventListener " + n + h);
		o.removeEventListener(n, h, false);
	}
}

/* Identifica se si accede con un dispositivo mobile */
function isMobile()
{
	var isMobileTest = false;
	var navAgent = navigator.userAgent.toLowerCase();
	if (navAgent.match(/iphone/i) || navAgent.match(/symbian/i) || navAgent.match(/android/i)|| navAgent.match(/bada/i))
	{
		isMobileTest = true;
	}
	return isMobileTest;
}

/* FIX PNG su IE 5.5 e 6 */
function pngFix ()
{
	   for(var i=0; i<document.images.length; i++)
	   {
	      var img = document.images[i]
	      var imgName = img.src.toUpperCase()
	      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	      {
	         var imgID = (img.id) ? "id='" + img.id + "' " : ""
	         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
	         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
	         var imgStyle = "display:inline-block;" + img.style.cssText 
	         if (img.align == "left") imgStyle = "float:left;" + imgStyle
	         if (img.align == "right") imgStyle = "float:right;" + imgStyle
	         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
	         var strNewHTML = "<span " + imgID + imgClass + imgTitle
	         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	         + "(src=\'" + img.src + "\', sizingMethod='crop');\"></span>" 
	         img.outerHTML = strNewHTML
	         i = i-1
	      }
	   }
}

/* Funzioni condivise */
/* Toglie tutti gli embed temporaneamente*/
function deFlashize ()
{
	allswf = document.getElementsByTagName('EMBED');
	for (i=0; i<allswf.length; i++)
	{
		allswf[i].style.visibility = 'hidden';
	}
}

/* Toglie tutti gli embed temporaneamente*/
function reFlashize ()
{
	allswf = document.getElementsByTagName('EMBED');
	for (i=0; i<allswf.length; i++)
	{
		allswf[i].style.visibility = 'visible';
	}
}

function isSwfLayerable ()
{
	if (navigator.platform.substr(0,3) == "Lin") return false;
	if (navigator.appVersion.indexOf("Version/2")>=0 && navigator.appVersion.indexOf("Safari")>=0) return false; 
	return true;

}
/* Fine funzioni condivisibili*/


/*** Gestione dei cookies in login ***/
function setLoginCookie (value)
{
	//setta lo stato con expiry date di 1 anno (fino alla fine dell'anno successivo)
	var dataOggi = new Date();
	document.cookie = "openedLogin="+ value + "; expires= Thu, 31-Dec-"+ dataOggi.getFullYear()+1 +" 23:59:59 GMT";
}

function checkLoginCookie ()
{
	//Setta la durata del cookie in giorni, se non è una macchina unix based
	if (!(navigator.appVersion.indexOf("X11") != -1))
	{
		var isCookieToSet = true;
		if (document.cookie.length > 0) 
		{
			var allCookies = document.cookie.split(";")
			for (i=0;i<allCookies.length;i++)
			{
				if (allCookies[i].split("=")[0].replace(" ","") == "openedLogin")
				{
					if (allCookies[i].split("=")[1].replace(" ","") == "true")
					{
						switchLogin ();
					}
					isCookieToSet = false;
				}
			}
		}
		
		if (isCookieToSet) setLoginCookie ("false");
	}
}

/***** JS NUOVA LOGIN *****/

function checkUserAndPwd(user,ut1,pwd,admin)
{
	var check = true;

	if (user.id == 'idCl')
	{
		if ((user.value.length == 0)
				|| (user.value == "User ID"))
			check = false;
	}
	else
	{
		if ( (user.value.length == 0) ||(user.value == "Codice cliente")
				|| ((!admin.checked) && (ut1.value.length == 0) || (ut1.value == "Codice utente")))
			check = false;
	}
	
	check = check && !( (pwd.value.length == 0) || (pwd.value == "Password"))
	
	return check;
}
/***** |FINE| JS NUOVA LOGIN *****/

// --------- Framework per overlayer e alert ------------//
// Rileva il massimo z-index in tutto il documento corrente
function getNextHighestZindex()
{
	var highestIndex = 0;
	var currentIndex = 0;
	var elArray = Array();
	if (navigator.userAgent.indexOf("MSIE 5.5") > -1)
	{
		elArray = document.all;
	}
	else
	{
		elArray = document.getElementsByTagName('*');
	}

	for(var i=0; i < elArray.length; i++){
		if(window.getComputedStyle){
			currentIndex = parseFloat(document.defaultView.getComputedStyle(elArray[i],null).getPropertyValue('z-index'));
			if(!isNaN(currentIndex) && currentIndex >= highestIndex){highestIndex = currentIndex;}
		}
		if (elArray[i].currentStyle){
			//stile dell'elemento
			currentIndex = parseFloat(elArray[i].currentStyle['zIndex']);
			if(!isNaN(currentIndex) && currentIndex >= highestIndex){highestIndex = currentIndex;}
		}
		if (elArray[i].style.zIndex){
			//stile dell'elemento
			currentIndex = parseFloat(elArray[i].style.zIndex);
			if(!isNaN(currentIndex) && currentIndex >= highestIndex){highestIndex = currentIndex;}
		}
	}
	return(highestIndex+1);
}

//identifica la meta' orizzontale della pagina
function getPageWidth ()
{
	if (navigator.appName != "Microsoft Internet Explorer")
	{
		return document.body.clientWidth;
	} 
	else 
	{
		if(navigator.userAgent.indexOf("MSIE 5.5") > -1)
		{
			return document.body.offsetWidth;
		}
		else
		{
			return document.documentElement.clientWidth;
		}
	}
}

function getPageHeight ()
{
	if (navigator.appName != "Microsoft Internet Explorer")
	{
		return window.innerHeight;
	} 
	else 
	{
		if (navigator.userAgent.indexOf("MSIE 5.5") > -1)
		{
			return document.body.offsetHeight;
		}
		else
		{
			return document.documentElement.clientHeight;
		}

	}
}

//scrolling amount
function getScrollY() {
	if(navigator.appName != "Microsoft Internet Explorer"){
		return window.pageYOffset;
	}
	else
	{
		if (navigator.userAgent.indexOf("MSIE 5.5") > -1)
		{
			return document.body.scrollTop;
		}
		else
		{
			return document.documentElement.scrollTop;
		}
	}
}

//oscura tutto
function obscurateAll (opacitylevel)
{
	var layerpop = document.createElement('DIV');
	layerpop.id='layerpop';
	document.body.appendChild(layerpop);
	if (document.getElementById('overlayerLight')) 
		{ 
			document.getElementById('layerpop').className = "overlayerchiaro"; 
		}
	//imposta l'oscuratore layerpop al massimo dei livelli
	document.getElementById('layerpop').style.zIndex = getNextHighestZindex();
	//imposta l'altezza di layerpop a tutto schermo e appende le funzioni di scrolling e resizing all'oscuratore
	if(navigator.appName != "Microsoft Internet Explorer")
	{ 
		document.getElementById('layerpop').style.height = window.height + 'px'; 
		document.getElementById('layerpop').style.marginTop = getScrollY() + 'px';
	} 
	else 
	{ 
		document.getElementById('layerpop').style.height = getPageHeight() + 'px';  
		document.getElementById('layerpop').style.marginTop = getScrollY() + 'px';
	} 
	obscuratescroll = new Function ('document.getElementById(\'layerpop\').style.marginTop = getScrollY() + \'px\';');
	obscurateresize = new Function ('document.getElementById(\'layerpop\').style.height = getPageHeight() + \'px\';');
	if (window.attachEvent)
	{
		window.attachEvent("onresize", obscurateresize);
		window.attachEvent("onscroll", obscuratescroll);
	}
	else
	{
		window.addEventListener("scroll",obscuratescroll, false);
		window.addEventListener("DOMMouseScroll", obscuratescroll, false);
		window.addEventListener("resize", obscurateresize, false);
	}		
	if (opacitylevel)
	{
		layerpop.style.opacity = opacitylevel/10;
		layerpop.style.filter = 'alpha(opacity=' + opacitylevel * 10 + ')';
	}
}

function unobscurateAll ()
{
	if (window.attachEvent)
	{
		window.detachEvent("onresize",obscurateresize);
		window.detachEvent("onscroll", obscuratescroll);
	}
	else
	{
		window.removeEventListener("scroll", obscuratescroll, false);
		window.removeEventListener("DOMMouseScroll", obscuratescroll, false);
		window.removeEventListener("resize",obscurateresize, false);
	}		
	document.body.removeChild(document.getElementById('layerpop'));
}

//funzione che rende invisibili le tendine tranne quelle contenute nel div che risulta essere attivo (e nei suoi figli)
function arrangeSelect (idElement)
{
	if (idElement)
	{
		var x = document.getElementsByTagName("select").length;	
		x = document.getElementsByTagName("select");
		for (i = x.length; i; x[--i].style.visibility='hidden');
		var y = document.getElementById(idElement).getElementsByTagName('select');
		for (i = y.length; i; x[--i].style.visibility='visible');
	}
	else
	{
		x = document.getElementsByTagName("select");
		for (i = x.length; i; x[--i].style.visibility='visible');
	}
}


//funzione che apre un popup con overlayer
//mode = 'fixed' overlayer con margin-top fisso da css
//mode = 'floating' overlayer sempre centrato nella pagina
function openPopOverLayer (idElement, mode, opacitylevel)
{
	if (!isSwfLayerable ())
	{
		deFlashize();
	}
	
	if (opacitylevel) {obscurateAll(opacitylevel)}
	else {obscurateAll()}
	
	document.body.insertBefore(document.getElementById(idElement), document.body.getElementsByTagName('div')[0]);
	document.getElementById(idElement).style.display='block';
	
	
	//allocazione funzioni scrolling e resizing
	popfixedalertresize = new Function ('document.getElementById(\''+ idElement + '\').style.marginLeft = Math.round((getPageWidth() - document.getElementById(\''+ idElement + '\').offsetWidth)/2) + \'px\';');
	popalertscroll = new Function ('document.getElementById(\''+ idElement + '\').style.marginTop = getScrollY() + Math.round((getPageHeight() - document.getElementById(\''+ idElement + '\').offsetHeight)/2) + \'px\';');
	popalertresize = new Function ('document.getElementById(\''+ idElement + '\').style.marginLeft = Math.round((getPageWidth() - document.getElementById(\''+ idElement + '\').offsetWidth)/2) + \'px\';document.getElementById(\''+ idElement + '\').style.marginTop = getScrollY() + Math.round((getPageHeight() - document.getElementById(\''+ idElement + '\').offsetHeight)/2) + \'px\';');
	
	//controlla se deve fissare la X o renderla dinamica
	if (mode == 'fixed')
	{
		document.getElementById(idElement).style.marginLeft = Math.round((getPageWidth() - document.getElementById(idElement).offsetWidth)/2) + 'px';
		//riallinea l'oggetto orizzontalmente sul resize
		if (window.attachEvent)
		{
			window.attachEvent("onresize", popfixedalertresize);
		}
		else
		{
			window.addEventListener("resize", popfixedalertresize, false);
		}
	}
	else
	{
		if(document.getElementById(idElement).offsetHeight < getPageHeight ())
		{
			document.getElementById(idElement).style.marginLeft = Math.round((getPageWidth() - document.getElementById(idElement).offsetWidth)/2) + 'px';
			document.getElementById(idElement).style.marginTop = getScrollY() + Math.round((getPageHeight() - document.getElementById(idElement).offsetHeight)/2) + 'px';
			//riallinea l'oggetto sia verticalmente che orizzontalmente
			if (window.attachEvent)
			{
				window.attachEvent("onscroll", popalertscroll);
				window.attachEvent("onresize", popalertresize);
			}
			else
			{
				window.addEventListener("scroll", popalertscroll, false);
				window.addEventListener("resize", popalertresize , false);
			}
		}
		else
		{
			document.getElementById(idElement).style.marginLeft = Math.round((getPageWidth() - document.getElementById(idElement).offsetWidth)/2) + 'px';
			if (getScrollY() + getPageHeight() - document.getElementById(idElement).offsetHeight < 0)
			{
				document.getElementById(idElement).style.marginTop = '0px';
			}
			else
			{
				document.getElementById(idElement).style.marginTop = getScrollY() + getPageHeight() - document.getElementById(idElement).offsetHeight  + 'px';
			}
		}
	}
	arrangeSelect(idElement);
	document.getElementById(idElement).style.zIndex = getNextHighestZindex();
}

//chiude l'overlayer + l'oscuratore
function closePopOverLayer (idElement)
{
	if (window.attachEvent)
		{
			if (popfixedalertresize) window.detachEvent("onresize", popfixedalertresize);
			if (popalertscroll) window.detachEvent("onscroll", popalertscroll);
			if (popalertresize) window.detachEvent("onresize", popalertresize);
		}
		else
		{
			if (popfixedalertresize) window.removeEventListener("resize", popfixedalertresize, false);
			if (popalertscroll) window.removeEventListener("scroll", popalertscroll, false);
			if (popalertresize) window.removeEventListener("resize", popalertresize , false);
		}

	document.getElementById(idElement).style.display='none';
	arrangeSelect();
	unobscurateAll ();
	if (!isSwfLayerable ())
	{
		reFlashize();
	}
}

//apre una popup fissa da css o style nella pagina
//elemento ancora opzionale e serve per agganciare il layer ad un altro elemento di qualsiasi natura (i parametri TOP e LEFT sono configurabili nello stile  per posizionare l'elemento rispetto a questo)
function openFixedAlert (idElement, anchorElement)
{
	arrangeSelect (idElement);
	document.body.insertBefore( document.getElementById(idElement), document.body.getElementsByTagName('div')[0] );
	
	anchoralertresize = new Function ('document.getElementById(\''+ idElement + '\').style.marginTop = anchorElement.offsetTop + \'px\';document.getElementById(\''+ idElement + '\').style.marginLeft = anchorElement.offsetLeft + \'px\';');
	fixedalertresize =  new Function ('document.getElementById(\''+ idElement + '\').style.marginLeft = Math.round((getPageWidth() - document.getElementById(\''+ idElement + '\').offsetWidth)/2) + \'px\';');
	
	if (anchorElement)
	{
		document.getElementById(idElement).style.marginTop = anchorElement.offsetTop + 'px';
		document.getElementById(idElement).style.marginLeft = anchorElement.offsetLeft + 'px';
		//ancora in resize della finestra
		if (window.attachEvent)
		{
			window.attachEvent("onresize", anchoralertresize);
		}
		else
		{
			window.addEventListener("resize", anchoralertresize, false);
		}
	}
	else
	{
		document.getElementById(idElement).style.marginLeft = Math.round((getPageWidth() - document.getElementById(idElement).offsetWidth)/2) + 'px';
		if (window.attachEvent)
		{
			window.attachEvent("onresize", fixedalertresize);
		}
		else
		{
			window.addEventListener("resize", fixedalertresize, false);
		}
	}
	document.getElementById(idElement).style.display = 'block';
	document.getElementById(idElement).style.zIndex = getNextHighestZindex();
}

//apre una popup sempre centrata nella pagina
function openAlert (idElement)
{
	arrangeSelect (idElement);
	//appende il layer direttamente al body
	document.body.insertBefore(document.getElementById(idElement), document.body.getElementsByTagName('div')[0]);
	document.getElementById(idElement).style.display = 'block';
	document.getElementById(idElement).style.zIndex = getNextHighestZindex();
	document.getElementById(idElement).style.top = '0px';
	document.getElementById(idElement).style.left = '0px';
	document.getElementById(idElement).style.marginLeft = Math.round ((getPageWidth() - document.getElementById(idElement).offsetWidth )/2) + 'px'; 
	
	if (document.getElementById(idElement).offsetHeight < getPageHeight ())
	{
		document.getElementById(idElement).style.marginTop = getScrollY() + Math.round((getPageHeight() - document.getElementById(idElement).offsetHeight)/2) + 'px';
		
		alertscroll = new Function('document.getElementById(\''+ idElement + '\').style.marginTop = getScrollY() + Math.round((getPageHeight() - document.getElementById(\''+ idElement + '\').offsetHeight)/2) + \'px\';');
		alertresize = new Function('document.getElementById(\''+ idElement + '\').style.marginLeft = Math.round ( (getPageWidth() - document.getElementById(\''+ idElement + '\').offsetWidth )/2) + \'px\'; document.getElementById(\''+ idElement + '\').style.marginTop = getScrollY() + Math.round((getPageHeight() - document.getElementById(\''+ idElement + '\').offsetHeight)/2) + \'px\';');
		
		if (window.attachEvent)
		{
			window.attachEvent("onresize", alertresize);
			window.attachEvent("onscroll", alertscroll);
		}
		else
		{
			window.addEventListener("resize", alertresize, false);
			window.addEventListener("scroll", alertscroll, false);
		}
	}
	else
	{
			if (getScrollY() + getPageHeight() - document.getElementById(idElement).offsetHeight < 0)
			{
				document.getElementById(idElement).style.marginTop = '0px';
			}
			else
			{
				document.getElementById(idElement).style.marginTop = getScrollY() + getPageHeight() - document.getElementById(idElement).offsetHeight  + 'px';
			}
	}
	
}

//chiude un alert qualsiasi (occorre indicarlo se esiste un overlayer o un padre altrimenti si puo' omettere e saranno riabilitate tutte le select nella pagina)
function closeAlert (idElement,idFather)
{
	document.getElementById(idElement).style.display = 'none';
	
	//rimuove tutti gli eventi associati agli alert
	if (window.attachEvent)
	{
		if (typeof(alertresize) != 'undefined' ) window.detachEvent("onresize", alertresize);
		if (typeof(alertscroll) != 'undefined' ) window.detachEvent("onscroll", alertscroll);
		if (typeof(anchoralertresize) != 'undefined' ) window.detachEvent("onresize", anchoralertresize);
		if (typeof(fixedalertresize) != 'undefined' ) window.detachEvent("onresize", fixedalertresize);
	}
	else
	{
		if (typeof(alertresize) != 'undefined' ) window.removeEventListener("resize", alertresize, false);
		if (typeof(alertscroll) != 'undefined' ) window.removeEventListener("scroll", alertscroll, false);
		if (typeof(anchoralertresize) != 'undefined' ) window.removeEventListener("resize", anchoralertresize, false);
		if (typeof(fixedalertresize) != 'undefined' ) window.removeEventListener("resize", fixedalertresize, false);
	}
	if (idFather)
	{
		arrangeSelect (idFather);
	}
	else
	{
		arrangeSelect ();
	}
}

//chiude tutti gli alert aperti
function closeAllAlert()
{
	allDivs = document.getElementsByTagName('DIV');
	for (i=0; i<allDivs.length; i++)
	{
		if (allDivs[i].className.indexOf("layeralert")>-1)
		{
			document.getElementById(allDivs[i].id).style.display = 'none';
		}
	}
}

function focusPrint(divId)
{
	//catch di tutti gli elementi della pagina
	var wholedivs = document.getElementsByTagName('DIV');
	//appende a tutti gli elementi la classe "noprint"
	for (i=0; i<wholedivs.length; i++)
	{
		if (wholedivs[i].className)
		{
			wholedivs[i].className = wholedivs[i].className + ' noprint';
		}
		else
		{
			wholedivs[i].className = 'noprint';
		}
	}
	//toglie anche la classe di "non stampa" da id e "sottoelementi"
	document.getElementById(divId).className = document.getElementById(divId).className.replace('noprint','');
	var subdivs = document.getElementById(divId).getElementsByTagName('DIV');
	for (i=0; i<subdivs.length; i++)
	{
		if (subdivs[i].className)	
		{
			subdivs[i].className = subdivs[i].className.replace('noprint','');
		}
	}
}

function unFocusPrint()
{
	var wholedivs = document.getElementsByTagName('DIV');
	for (i=0; i<wholedivs.length; i++)
	{
		if (wholedivs[i].className)
		{
			wholedivs[i].className = wholedivs[i].className.replace('noprint','');
		}
	}
}
/* Fine Framework Overlayer e Alert */

/* Nuova funzione apertura login */
function switchLogin()
{
	loginDiv = document.getElementById("toplogin").parentNode.parentNode;
	var formLogin = document.getElementById("toplogin");
	var radioContainer = formLogin.getElementsByTagName('fieldset')[1];
	var radioContainerDiv = radioContainer.getElementsByTagName('div')[0];
	var radioClient = radioContainerDiv.getElementsByTagName('input');
	var radioContainerProfilo = formLogin.getElementsByTagName('fieldset')[2];
	var radioContainerDivProfilo = radioContainerProfilo.getElementsByTagName('div')[0];
	var radioConsultare = radioContainerDivProfilo.getElementsByTagName('input')[1];
	var radioConsultareDisp =radioContainerDivProfilo.getElementsByTagName('input')[0];
	var labelConsultare = radioContainerDivProfilo.getElementsByTagName('label')[1];
	if (loginDiv.className == "headerLogin") 
		{
			if (!isSwfLayerable ()) deFlashize();
			loginDiv.className = "headerLogin opened";
			setLoginCookie ("true");
			document.getElementById('idCl').focus();
			
			/* disabilitazione option consultare per business */
			if(window.attachEvent) {radioClient[0].attachEvent ('onclick', function(){disabilitaRadio(false)}); radioClient[1].attachEvent ('onclick', function(){disabilitaRadio(true)});}
			else {radioClient[0].addEventListener ('click', function(){disabilitaRadio(false)},false); radioClient[1].addEventListener ('click', function(){disabilitaRadio(true)},false);}
		} 
	else 
		{ 
			if (!isSwfLayerable ()) reFlashize();
			loginDiv.className = "headerLogin";
			setLoginCookie ("false");
		}
	function disabilitaRadio(state)
			{
				if(state==true)
				{
					radioConsultare.disabled=true;
					labelConsultare.className='disabled';
					radioConsultareDisp.checked =true;
					
				}
				else 
				{
					radioConsultare.removeAttribute('disabled');
					labelConsultare.className='';
				}
			
			}
	
}

/* riposizionamento box condividi */

if ((navigator.userAgent.indexOf("MSIE 7.0") != -1) || ((document.documentMode && document.documentMode !='8') ))
	{	
		var addthis_config = 
			{
			ui_offset_top: -230,
			ui_offset_left: -180,
			ui_click: true
			
			}
	}
else if (navigator.userAgent.indexOf("MSIE 6.0") != -1) 
	{
		var addthis_config = 
		{
			ui_offset_top: -240,
			ui_offset_left: -190,
			ui_click: true
		}
	}
else {
	var addthis_config = 
	{
		ui_offset_top: -210,
		ui_offset_left: -180,
		ui_click: true
	}
}

		
/* Funzioni Facebook "Mi piace" */
function setFBLike ()
{
	var iframeBox = document.getElementById("fbLike");
	var pageUrl = "https://www.webank.it/webankpub/wb/home.do?tabId=nav_pub_wb_home_nw%26amp;OBS_KEY=nav_pub_wb_home_nw";
	iframeBox.innerHTML = "<iframe src=\"https://www.facebook.com/plugins/like.php?href="+ pageUrl +"&locale=en_US&layout=button_count&show_faces=false&width=100&action=like&font=tahoma&colorscheme=light&height=21\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:100px; height:21px;\" allowTransparency=\"true\"></iframe>";
} 

function loadFBLike()
{
	addEvent(window,"load", setFBLike)
}

/* Funzioni loading home visual */
function loadHomeVisualSwf()
{
	// XML Locale 
	// xmlMenu = "/swf/xml/hp_menu.xml";
	// XML Dinamico
	xmlMenu = "/webankpub/wb/jsp/hp_menu_xml.jsp";
	
	//ottiene la variabile dall'esterno
	if (hp_visual) 
		{
			switch (hp_visual)
			{
				case 'deposito': visualIndex = 0; break;
				case 'trading': visualIndex = 1; break;
				case 'mutui': visualIndex = 2; break;
				case 'investimenti': visualIndex = 3; break;
				default : visualIndex = 0;
			}
		}
	else
		{
			visualIndex = 0;
		}
	
	//VISUAL 4 TAB
	//var hpv = new  SWFObject("/swf/hp_visual_contenitore.swf", "home_visual", "855", "320", "8", "");
	
	//VISUAL "MONO"
	var hpv = new  SWFObject("/swf/hp_visual_fullpromo.swf", "home_visual", "855", "320", "8", "");
	
	hpv.addParam("quality", "high");		
	hpv.addParam("wmode", "transparent");
	hpv.addParam("menu", "false");
	hpv.addParam("Flashvars", "servstamp=" + parseInt((srvTs/1000)) + "&numContenuto=" + visualIndex + "&fileXML=" + xmlMenu);
	if (!isMobile())
	{
		hpv.write("homevisualflash");
	}
	//Se non funziona l'SWF Object...
	if (document.getElementById("hp_visualspace"))
	{
		
		/* ************************** BLOCCO NO TAB DA MAPPARE CORRETTAMENTE *********************/
		hp_visualspace_HTML = "<div class=\"hp_visualspacebox\"><img src=\"/img/img_pr_hp_fullpromo.gif\" usemap=\"#deposito_map\"><map name=\"deposito_map\"><area shape=\"rect\" coords=\"549,183,682,219\" href=\"/webankpub/wb/schedaProdottoLarge.do?tabId=nav_pub_wb_conti_nw&OBS_KEY=pro_wbn_caratteristiche_condizioni&KEY4=pro4_nuova_promo&cid=bn-eccezionale-cw-dt\" alt=\"Scopri di pi&ugrave;\" title=\"Scopri di pi&ugrave;\" target=\"_self\"/><area shape=\"rect\" coords=\"768,240,833,252\" href=\"/doc/Regolamento_Due_cose_eccezionali.pdf\" alt=\"Regolamento\" title=\"Regolamento\" target=\"_blank\"/><area shape=\"rect\" coords=\"491,255,565,267\" href=\"/webankpub/aol/wbPDFFoglioInformativo.do?BV_UseBVCookie=Yes&cod=1.02.0\" alt=\"Fogli informativi\" title=\"Fogli informativi\" target=\"_blank\"/></map></div>";
		document.getElementById("hp_visualspace").innerHTML = hp_visualspace_HTML;
		
		/* ************************** FINE BLOCCO NO TAB *********************/	
		
		// ************************** BLOCCO 4 TAB *************************
		/* Riempie lo spazio dei visual */
		/*
		//contenitore DEPOSITO
		hp_visualspace_HTML = "<div class=\"hp_visualspacebox\"><img src=\"/img/img_pr_home_deposito.jpg\" usemap=\"#deposito_map\"><map name=\"deposito_map\"><area shape=\"rect\" alt=\"Scopri di pi&ugrave;\" title=\"\" coords=\"358,175,510,200\" href=\"/webankpub/wb/schedaProdotto.do?tabId=nav_pub_wb_conti_nw&OBS_KEY=pro_wbn_caratteristiche_condizioni&KEY4=pro4_conto_webank&OBS_REF=hp_Link1\" target=\"_self\" /></map></div>";
		//contenitore TRADING
		hp_visualspace_HTML = hp_visualspace_HTML + "<div style=\"display:none;\" class=\"hp_visualspacebox\"><img src=\"/img/img_pr_home_trading.jpg\" usemap=\"#trading_map\"><map name=\"trading_map\"><area shape=\"rect\" alt=\"Scopri di pi&ugrave;\" title=\"\" coords=\"200,200,350,170\" href=\"schedaServizio.do?tabId=nav_pub_wb_footer_nw&OBS_KEY=pro_wbn_news&KEY4=pro4_bolli_bloccati\" target=\"_self\" /></map></div>";
		//contenitore MUTUI
		hp_visualspace_HTML = hp_visualspace_HTML + "<div style=\"display:none;\" class=\"hp_visualspacebox\"><img src=\"/img/img_pr_home_mutui.jpg\" usemap=\"#mutui_map\"><map name=\"mutui_map\"><area shape=\"rect\" alt=\"Scopri di pi&ugrave;\" coords=\"155,178,300,201\" href=\"/webankpub/wb/fpProdotti.do?tabId=nav_pub_wb_finanziamenti_nw&OBS_KEY=pro_wbn_mutui_nw1\" target=\"_self\" /><area shape=\"rect\" alt=\"Calcola la rata\" coords=\"324,179,510,202\" href=\"/webankpub/wb/schedaSimulatore.do?tabId=nav_pub_wb_finanziamenti_nw&OBS_KEY=pro_wbn_mutui_nw1&KEY4=pro4_calcola_rata&OBS_REF=hp_Finanziamenti\" target=\"_self\" /></map></div>";
		//contenitore INVESTIMENTI
		hp_visualspace_HTML = hp_visualspace_HTML + "<div style=\"display:none;\" class=\"hp_visualspacebox\"><img src=\"/img/img_pr_home_investimenti.jpg\" usemap=\"#investimenti_map\"><map name=\"investimenti_map\"><area shape=\"rect\" alt=\"Scopri di pi&ugrave;\" coords=\"255,182,410,208\" href=\"/webankpub/wb/fpProdotti.do?tabId=nav_pub_wb_investimenti_nw&OBS_KEY=pro_wbn_investment_solution\" target=\"_self\"></map></div>";
		//assegnazione HTML
		document.getElementById("hp_visualspace").innerHTML = hp_visualspace_HTML;
		
		// Riempie lo spazio della console 
		var hp_visualconsole_HTML = "<a href=\"javascript:;\" title=\"Deposito\" class=\"on\" onclick=\"switchVisual(this);\"><span>Deposito</span></a><a href=\"javascript:;\" title=\"Trading\" onclick=\"switchVisual(this);\"><span>Trading</span></a><a href=\"javascript:;\" title=\"Mutui\" onclick=\"switchVisual(this);\"><span>Mutui</span></a><a href=\"javascript:;\" title=\"Investimenti\" onclick=\"switchVisual(this);\"><span>Investimenti</span></a>";
		document.getElementById("hp_visualconsole").innerHTML = hp_visualconsole_HTML;
		if (visualIndex != 0)
		{
			switchVisual(document.getElementById("hp_visualconsole").getElementsByTagName("A")[visualIndex]);
		}
		*/
		// ************************** FINE BLOCCO 4 TAB *************************
		
		/* Inserisce il pulsante tutti i prodotti col relativo contenitore*/
		allProdsButton = document.createElement("A");
		allProdsButton.className = "allprods";
		allProdsButton.href = "javascript:;"
		allProdsButton.onclick = function() {eval("switchAllprods(this)")};
		document.getElementById("homevisual").insertBefore(allProdsButton, document.getElementById("homevisualflash"));
		/* Inserisce il contenitore per il menu senza ancora popolarlo */
		allProdsMenu = document.createElement("DIV");
		allProdsMenu.id = "hp_allprodsmenu";
		allProdsMenu.innerHTML = "<img src=\"/wscmn/img/ico2inf_loadingpub.gif\" class=\"loading\">";
		document.getElementById("homevisual").insertBefore(allProdsMenu, document.getElementById("homevisualflash"));
	}
}

/* Riempie il menu tutti i prodotti */
function hpAllprodsInit ()
{
	xmlMenuData = getXMLRoot (xmlMenu);
	menuColonne = xmlMenuData.getElementsByTagName("colonna");
	allProdsMenu_HTML = "";
	//Inizializza le colonne del menu
	for (x=0; x < menuColonne.length; x++)
	{
		if (x==0) {allProdsMenu_HTML = allProdsMenu_HTML + "<div class=\"allProdsMenuColumn\" style=\"background-image: none;\">"}
		else {allProdsMenu_HTML = allProdsMenu_HTML + "<div class=\"allProdsMenuColumn\">"}
		allProdsMenu_HTML = allProdsMenu_HTML + "<h3>" + menuColonne[x].getElementsByTagName("titolo")[0].firstChild.nodeValue + "</h3>";
		allProdsMenu_HTML = allProdsMenu_HTML + "<ul>";
		menuColonnaLabel = menuColonne[x].getElementsByTagName("label");
		menuColonnaPath = menuColonne[x].getElementsByTagName("path");
		menuColonnaTarget = menuColonne[x].getElementsByTagName("target");
		for (i=0; i < menuColonnaLabel.length; i++)
			{
				allProdsMenu_HTML =  allProdsMenu_HTML + "<li><a href=\""+ menuColonnaPath[i].firstChild.nodeValue +"\" target=\"" + menuColonnaTarget[i].firstChild.nodeValue + "\">" + menuColonnaLabel[i].firstChild.nodeValue + "</a></li>";
			}
		allProdsMenu_HTML = allProdsMenu_HTML + "</ul>";
		
		//controlla se c'è il "Primo piano"
		pp = menuColonne[x].getElementsByTagName("boxPromo")[0];
		if (pp)
		{
			//Crea il contenitore e lo popola con i contenuti
			allProdsMenu_HTML = allProdsMenu_HTML + "<div class=\"pp\">";
			allProdsMenu_HTML = allProdsMenu_HTML + "<h4>" + pp.getElementsByTagName("titoloBox")[0].firstChild.nodeValue + "</h4>";
			menuPPLabel = pp.getElementsByTagName("labelBox");
			menuPPPath = pp.getElementsByTagName("pathBox");
			menuPPTarget = pp.getElementsByTagName("targetBox");
			allProdsMenu_HTML = allProdsMenu_HTML + "<ul>";
			for (y=0; (y < menuPPLabel.length && y<2); y++)
			{
				allProdsMenu_HTML =  allProdsMenu_HTML + "<li><a href=\""+ menuPPPath[y].firstChild.nodeValue +"\" target=\"" + menuPPTarget[y].firstChild.nodeValue + "\">" + menuPPLabel[y].firstChild.nodeValue + "</a></li>";
			}
			allProdsMenu_HTML = allProdsMenu_HTML + "</ul>";
			allProdsMenu_HTML = allProdsMenu_HTML + "</div>";
		}
		allProdsMenu_HTML = allProdsMenu_HTML + "</div>";
	}
	
	//Aggancia il menù dei servizi
	allProdsMenu_HTML = allProdsMenu_HTML + "<div class=\"allProdsServizi\">";
	allProdsMenu_HTML = allProdsMenu_HTML + "<h3>I servizi al tuo servizio</h3>";
	//Carica i nodi dei servizi
	menuServizi = xmlMenuData.getElementsByTagName("servizi")[0];
	menuServiziLabel= menuServizi.getElementsByTagName("label");
	menuServiziPath = menuServizi.getElementsByTagName("path");
	menuServiziTarget = menuServizi.getElementsByTagName("target");
	allProdsMenu_HTML = allProdsMenu_HTML + "<ul>";
	for (x=0; x < menuServiziLabel.length; x++)
	{
		allProdsMenu_HTML =  allProdsMenu_HTML + "<li><a href=\""+ menuServiziPath[x].firstChild.nodeValue +"\" target=\"" + menuServiziTarget[x].firstChild.nodeValue + "\">" + menuServiziLabel[x].firstChild.nodeValue + "</a></li>";
	}
	allProdsMenu_HTML = allProdsMenu_HTML + "</ul>";
	allProdsMenu_HTML = allProdsMenu_HTML + "</div>";
	allProdsMenu.innerHTML = allProdsMenu_HTML;
}

/* Tutti i prodotti sostitutivo */
function switchAllprods(buttonTutti)
{
	var hasLP = true; 
	if (document.getElementById("homevisualflash"))
	{
		var hpVisualFlash = document.getElementById("homevisualflash");
		
	}
	else
	{
		var hpVisualFlash = document.getElementById("homeTotalVisualPromo");
		hasLP = false; 
	}
	
	if (buttonTutti.className == "allprods")
	{
		//Apre l'elenco di tutti i prodotti
		buttonTutti.className = "allprods opened";
		allProdsMenu.style.display = "block";
		//Nasconde gli altri contenitori
		hpVisualFlash.style.display = "none";
		if (hasLP) hpHideLeftPromo();
		//Se necessario, inizializza il contenitore
		if (allProdsMenu.getElementsByTagName("img")[0])
		{
			hpAllprodsInit();
		}
	}
	else
	{
		//Chiude l'elenco di tutti i prodotti
		buttonTutti.className = "allprods";
		allProdsMenu.style.display = "none";
		hpVisualFlash.style.display = "block";
		if (hasLP) hpShowLeftPromo();
	}
}

/* Funzione sostitutivo iPad*/
function switchVisual (abut)
{
	var allhpdiv = document.getElementById('hp_visualspace').getElementsByTagName("DIV");
	var allhpa = document.getElementById('hp_visualconsole').getElementsByTagName("A");
	for (i=0; i<allhpa.length; i++)
	{
		if (allhpa[i] == abut)
		{
			allhpa[i].className = "on";
			allhpdiv[i].style.display = "block";
		}
		else
		{
			allhpa[i].className = "";
			allhpdiv[i].style.display = "none";
		}
	}
}

/* condividi nel footer*/
function openShareTool(ico,larg) //numero icone e dimensione parametri passati
{
	var toolCnt = document.getElementById("condividiID");
	var toolbtn = toolCnt.getElementsByTagName("a");
	for(i=0; i<toolbtn.length; i++) 
		{
			if(toolbtn[i].className == "condividibtn") {
				var tools = toolbtn[i].parentNode.getElementsByTagName("div")[0];
				var imgLarg = tools.getElementsByTagName("img")[0]
				if(tools.style.display == "none") 
				{
					tools.style.display="block";
					tools.getElementsByTagName("div")[0].style.width=((ico*larg) + (4*(ico-1)) + 12 + 'px'); //moltiplica il numero icone per la dimensione di ognuna , agiunge il padding e il margine
				}
				else{
					tools.style.display="none";
				}
			}
		}
	}
	
function loadHomeVisual()
{
	addEvent(window,"load",loadHomeVisualSwf);
}


/* Funzione acquisizione "root" XML */
function getXMLRoot(xmlPath)
{
	if (window.XMLHttpRequest)
		 {
		 // Browser "nuovi" che supportano XHTTPRequest
		 var xmlhttp = new XMLHttpRequest();
		 }
	else
		 {
		 // Browser vecchi
		 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		 }
	xmlhttp.open ("GET", xmlPath, false);
	xmlhttp.send();
	xmlDocument = xmlhttp.responseXML;
	//Indice del primo nodo, sui vari Browser
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
	{
		firstIndex = 1;
	}
	else
	{
		firstIndex = 0;
	}
	return xmlDocument.childNodes[firstIndex]; 
}
/* Fine acquisizione di una "root" XML*/

/* Funzioni cellette home page */
function celletteHpSwitch(cindex)
{
	clearTimeout(celletteEvent);
	celletteA[celletteIndex].className = "";
	celletteDiv[celletteIndex].style.display = "none";
	if (cindex >= 0)
	{	
		celletteIndex = cindex;
	}
	else
	{
		celletteIndex = celletteIndex + 1;
		if (celletteIndex >= celletteA.length) celletteIndex = 0;		
	}
	celletteA[celletteIndex].className = "selected";
	celletteDiv[celletteIndex].style.display = "block";
	celletteEvent = setTimeout(function(){celletteHpSwitch()}, 6000);
}

function celletteHpInit()
{
	//Acquisizione delle cellette via XML
	var xmlCellette = getXMLRoot(xmlPath);
	var celletteLink = xmlCellette.getElementsByTagName("link");
	var celletteAlt = xmlCellette.getElementsByTagName("alt");
	var celletteImage = xmlCellette.getElementsByTagName("image");
	var celletteTarget = xmlCellette.getElementsByTagName("target");
	displaycelletta = "";
	var homecellettecont_HTML = "";
	for (x=0; x < celletteLink.length; x++)
	{
		homecellettecont_HTML = homecellettecont_HTML + "<div "+ displaycelletta + "><a href=\""+ celletteLink[x].firstChild.nodeValue +"\" target=\"" + celletteTarget[x].firstChild.nodeValue +"\"><img src=\""+ celletteImage[x].firstChild.nodeValue +"\" alt=\""+ celletteAlt[x].firstChild.nodeValue + "\"></a></div>";
		displaycelletta = " style=\"display:none\"";
	}
	document.getElementById("homecellettecont").innerHTML = homecellettecont_HTML;
	var homecelletteswitch_HTML = "<span>Primo piano</span>";
	//popola automaticamente il pannello di switching 
	celletteDiv = document.getElementById("homecellettecont").getElementsByTagName("DIV");
	celletteIndex = 0;
	for (x=0; x<celletteDiv.length; x++)
	{
		homecelletteswitch_HTML = homecelletteswitch_HTML + "<a href=\"javascript:;\" onclick=\"celletteHpSwitch("+ x + ");\"></a>";
	}
	document.getElementById("homecelletteswitch").innerHTML = homecelletteswitch_HTML;
	
	celletteA = document.getElementById("homecelletteswitch").getElementsByTagName("A");
	celletteA[0].className = "selected"; 
	celletteEvent = setTimeout(function() {celletteHpSwitch()},6000);
}

function celletteHp()
{
	var cellette = new  SWFObject("/swf/hp_cellette.swf", "home_cellette", "242", "139", "8", "");
	xmlPath = "/swf/xml/hp_cellette.xml";
	cellette.addParam("quality", "high");		
	cellette.addParam("wmode", "transparent");
	cellette.addParam("menu", "false");
	cellette.addParam("FlashVars", "fileXML=" + xmlPath);
	if (!isMobile())
	{
		cellette.write("homecellette");
	}
	//sostitutivo
	if (document.getElementById("homecelletteswitch") || isMobile())
	{
		addEvent(window,"load",celletteHpInit);
	}
}

/* Fine funzioni cellette home page */
// Inizializza la barra dei Social Network
// Attribuisce i link (se non sono ancora inizializzati) 
function initSocialBar()					
{					
	if(document.getElementById("condividiTool"))
	{
		// Trova url della pagina
		var pageUrl = document.location.href.split("&").join("%26");
		// Attribuisce i link ai social network
		document.getElementById("cond_fb").href = "http://www.facebook.com/sharer.php?u=" + pageUrl;
		document.getElementById("cond_digg").href = "http://digg.com/submit?url=" + pageUrl;
		document.getElementById("cond_del").href = "http://delicious.com/post?url=" + pageUrl;
		document.getElementById("cond_tw").href = "http://twitter.com/share?url=" + pageUrl;
		document.getElementById("cond_ok").href = "http://oknotizie.alice.it/post?url=" + pageUrl;
		document.getElementById("cond_mail").href = "mailto: ?Subject=Ti segnalo questa pagina di Webank&Body=" + pageUrl;
	}	
}

//Show-hide promo left
//Nasconde la promo (CONTO WEBANK) quando il menù viene aperto.
function hpHideLeftPromo()
{
	var hpLP = document.getElementById("leftpromo");
	if (hpLP) hpLP.className = "invisiblelogo";
}
function hpShowLeftPromo()
{
	var hpLP = document.getElementById("leftpromo");
	if (hpLP) hpLP.className = "";
}


/* *** CALCOLO DEL TEMPO PASSATO IN FORMATO TESTUALE *** */
function timeElapsedTw(timeString)
{
	var timeElapsedText = "";
	//converte il tempo ricevuto da stringa in data, uniformandone il formato
	//dataParts = timeString.split(" ")
	//var dataReceived = new Date(dataParts[1] + " " + parseInt(dataParts[2])+ ", " + dataParts[5] + " " + dataParts[3]);
	dataReceived = new Date(timeString);
	var dataNow = new Date();
	//minuti passati dall'ultimo aggiornamento
	var dataMinuti =  Math.round((dataNow.getTime() - dataReceived.getTime())/(1000 * 60));
	if (dataMinuti < 60)
		{
			if (dataMinuti <= 1)
			{
				timeElapsedText = "1 minuto fa";
			}
			else
			{
				timeElapsedText = dataMinuti + " minuti fa";
			}
		}
	else
		{
			var dataOre = Math.round(dataMinuti/60);
			if (dataOre < 24)
			{
				if (dataOre == 1)
				{
					timeElapsedText = "1 ora fa";
				}
				else
				{
					timeElapsedText = dataOre + " ore fa";
				}
			}
			else
			{
				if (Math.round(dataOre/24) == 1)
				{
					timeElapsedText = "1 giorno fa";
				}
				else
				{
					timeElapsedText = Math.round(dataOre/24) + " giorni fa";
				}
			}
		}
	return timeElapsedText;
}

/* TAGLIA UN TESTO METTENDO "..." */
// taglia un testo con un certo limite
function textCut (testo,limit)
{
	if (testo.length > limit) {testo = testo.substring(0,limit) + "&hellip;"}
	return testo;
}


/* **** BOX SOCIAL IN HOME (TWITTER + SOCIAL + CMS ) **** */

// Tweetta il testo mettendo A, e altro
function textTweet(twText)
{
	//Se il testo è troppo lungo lo taglia
	twText = textCut(twText, 60);
	twWordArray = twText.split(" ");
	//Mette i tag per i link e i profili
	for (i=0; i<twWordArray.length; i++)
	{
		if (twWordArray[i].indexOf("@") == 0 && !(twWordArray[i].indexOf("&hellip;")>=0))
		{
			twWordArray[i] = "<a href=\"http://twitter.com/" + twWordArray[i].replace("@","") + "\" target=\"_blank\" title=\"Vai al profilo di "+twWordArray[i].replace("@","")+"\">" + twWordArray[i] + "</a>"
		}
		if (twWordArray[i].indexOf("http:") == 0 && !(twWordArray[i].indexOf("&hellip;")>=0))
		{
			twWordArray[i] = "<a href=\"" + twWordArray[i] + "\" target=\"_blank\" title=\"Vai a " + twWordArray[i] + "\">" + twWordArray[i] + "</a>"
		}
	}
	twText = twWordArray.join(" ");
	return twText;
}

// switch col pulsantino
function switchSocialbox (containernum)
{
	for (i=0; i<boxSocialcontents.length; i++)
	{
		boxSocialcontents[i].hide();
		hpSocialboxConsoleBtn[i].className = "socialboxSwitch";
	}
	boxSocialcontents[containernum].appear();
	hpSocialboxConsoleBtn[containernum].className = "socialboxSwitch on";
}


// inizializza la console del social box
function initSocialBoxSwitch ()
{
	//Popolamento console (come variabile globale)
	boxSocialcontents = $$(".socialcontent");
	var boxSocialcontents_HTML = "";
	for(i=0; i<boxSocialcontents.length; i++)
	{
		boxSocialcontents_HTML = boxSocialcontents_HTML + "<a href=\"javascript:;\" onclick=\"switchSocialbox("+ i + ")\" style=\"display:none\" class=\"socialboxSwitch\"></a>";
	}
	hpSocialboxConsole.innerHTML = boxSocialcontents_HTML;
	//Effetto comparsa della toolbox (il primo viene acceso tramite la classe)
	hpSocialboxConsoleBtn = $$(".socialboxSwitch");
	for (i=0; i<hpSocialboxConsoleBtn.length; i++)
	{
		if (i==0) 
		{
			hpSocialboxConsoleBtn[i].className = "socialboxSwitch on";
			boxSocialcontents[i].appear();
		}
		hpSocialboxConsoleBtn[i].appear({duration:0.3});
	}
	
		
}

//Estrae i testi dei tweet avvalendosi di altre funzioni per scorporare i vari dati
function initSocialBoxTweets(tweets)
{
	//Se non è troppo tardi
	if (!isSocialboxStarted)
	{
		//Se la risposta non è malforme.
		if (tweets.results[0])
		{
			socialboxTwitter = socialBoxPrepare ("soc_boxTwitter");
			/* Estrae i dati di Twitter */
			var twUsername = tweets.results[0].from_user;
			var twText = tweets.results[0].text;
			var twTime = tweets.results[0].created_at;
			//filla il box Twitter con tutti i dati ricevuti e quelli di default
			socialboxTwitter.getElementsByTagName('A')[0].href = twitterProfile;
			socialboxTwitter.getElementsByTagName('A')[0].target = "_blank";
			socialboxTwitter.getElementsByTagName('span')[0].innerHTML = "<a href=\"http://twitter.com/" + twUsername + "\" target=\"_blank\">" + textCut(twUsername,15) + "</a>";
			socialboxTwitter.getElementsByTagName('span')[1].innerHTML = timeElapsedTw(twTime);
			socialboxTwitter.getElementsByTagName('span')[2].innerHTML = textTweet(twText);
			//Mette il nodo per primo, quando e se arriva per tempo
			socialboxTwitter.parentNode.insertBefore(socialboxTwitter, socialboxPodcast);
		}
		fireSocialBox();
	}
}

//Inizializza tutti gli elementi del box "pervenuti"
function fireSocialBox()
{
	if (!isSocialboxStarted)
	{
		isSocialboxStarted = true;
		//Rimuove il loading
		$("soc_loading").fade();
		//Dopo il popolamento attiva lo switch, caricando tutti gli oggetti da ruotare
		initSocialBoxSwitch ();
		if (boxSocialcontents.length > 1 ) 
		{
			startSocialRotator ();
		}
	}
}

function initSocialBoxPodcast(xmlPodcast)
{
	socialboxPodcast = socialBoxPrepare ("soc_boxPodcast");
	//filla il box Podcast con tutti i dati ricevuti e quelli di default
	var podcast = xmlPodcast.getElementsByTagName("podcast")[0];
	socialboxPodcast.getElementsByTagName('A')[0].href = podcastPage;
	socialboxPodcast.getElementsByTagName('A')[0].target = "_self";
	// Ev. titolo Radio Webank
	socialboxPodcast.getElementsByTagName('span')[0].innerHTML = "Radio Webank";
	// socialboxPodcast.getElementsByTagName('span')[0].innerHTML = "Puntata n." + podcast.getElementsByTagName("puntata")[0].firstChild.nodeValue;;
	socialboxPodcast.getElementsByTagName('span')[1].innerHTML = podcast.getElementsByTagName("data")[0].firstChild.nodeValue;
	socialboxPodcast.getElementsByTagName('span')[2].innerHTML = textCut(podcast.getElementsByTagName("titolo")[0].firstChild.nodeValue, 60);
}

function initSocialCmsbox(xmlCms)
{
	var cmsdata = xmlCms.getElementsByTagName("banner")[0];
	//Se il nodo esiste, lo appende
	if (cmsdata)
	{
		var boxCms = document.createElement("div");
		boxCms.id = "soc_boxCms";
		boxCms.className = "socialcontent";
		boxCms.style.display = "none"; 
		if (cmsdata.getElementsByTagName("html")[0].firstChild.nodeValue.length > 0)
		{
			boxCms.innerHTML = cmsdata.getElementsByTagName("html")[0].firstChild.nodeValue;
		}
		else
		{
			boxCms.innerHTML = "<a href=\"" + cmsdata.getElementsByTagName("link")[0].firstChild.nodeValue + "\" title=\"" + cmsdata.getElementsByTagName("alt")[0].firstChild.nodeValue + "\" target=\"" + cmsdata.getElementsByTagName("target")[0].firstChild.nodeValue + "\"><img src=\"" + cmsdata.getElementsByTagName("imgpath")[0].firstChild.nodeValue + "\" alt=\"" + cmsdata.getElementsByTagName("alt")[0].firstChild.nodeValue + "\"></a>"
		}
		hpSocialbox.appendChild (boxCms);
	}	
}

function startSocialRotator ()
{
	//Tempo di permanenza dei visual in millisecondi
	rotationTime = 6000;
	socialRotator = setInterval(function()
	{
		var nextindex = 0;
		//becca il visibile
		for(x=0; x<boxSocialcontents.length; x++)
		{
			if (boxSocialcontents[x].style.display != "none")
			{
				nextindex = x + 1;
				if (nextindex>=boxSocialcontents.length) nextindex=0;
			}
		}
		switchSocialbox (nextindex);
	}
	,rotationTime);
	//stoppa la rotazione al mouse over
	Event.observe (hpSocialbox, 'mouseover', function() {clearInterval(socialRotator)}); 
	
	//riavvia la rotazione al mouse out
	Event.observe(hpSocialbox, 'mouseout', startSocialRotator); 
}

function socialBoxPrepare (socialID)
{
	var socialBoxDiv = document.createElement('div');
	var socialboxBaseHTML = "<a href=\"#\" class=\"viewAll\" title=\"Vedi tutti\">Vedi tutti</a><div><span class=\"boxTitle\">&nbsp;</span><span class=\"boxTime\">&nbsp;</span><span class=\"boxText\">&nbsp;</span></div>";
	socialBoxDiv.id = socialID;
	socialBoxDiv.className = "socialcontent";
	socialBoxDiv.style.display = "none";
	socialBoxDiv.innerHTML = socialboxBaseHTML;
	hpSocialbox.appendChild (socialBoxDiv);
	return socialBoxDiv;
}

function initSocialBox()
{
	hpSocialbox = $("hpsocialboxcontainer");
	
	if (hpSocialbox)
	{
		//Prepara la "console" coi bottoncini colorati
		hpSocialboxConsole = document.createElement('div');
		hpSocialboxConsole.id = "soc_console";
		hpSocialboxConsole.className = "socialconsole";
		hpSocialbox.appendChild (hpSocialboxConsole);
		
		//icona Loading (viene tolta non appena scaricato il json di Twitter);
		hpSocialLoading = document.createElement('img');
		hpSocialLoading.id = "soc_loading";
		hpSocialLoading.src = "/img/socloading.gif";
		hpSocialbox.appendChild (hpSocialLoading);
		
		/* TWITTER (E' anche l'evento che scatena tutti gli altri)*/
		twitterProfile = "http://www.twitter.com/webank";
		var script = document.createElement('script'); 
		script.type = "text/javascript"; 
		// Interrogazione a twitter che fa il callback alla funzione initSocialBoxTweets
		script.src = "https://search.twitter.com/search.json?q=from:webank&rpp=1&callback=initSocialBoxTweets&" + Math.random() ; 
		try
		{
			document.getElementsByTagName('head')[0].appendChild(script);
		}
		catch (socialError){}
		
		/* PODCAST E CMS BOX */
		podcastPage =  "/webankpub/wb/archivioPodcast.do?tabId=nav_pub_wb_newsroom_nw&OBS_KEY=pro_wbn_newsroom&KEY4=pro4_radio_webank";
		//Becca l'XML coi dati del di Podcast e Content e se lo elabora
		//var xmlSocialBox = "/swf/xml/hp_socialbox.xml";
		var xmlSocialBox = "/webankpub/wb/ajax/socialTicker.jsp"
		var xmlSocialBoxData = getXMLRoot(xmlSocialBox);
		//inizializza il Podcast
		initSocialBoxPodcast(xmlSocialBoxData);
		//Inizializza anche il box CMS (dentro la funzione controlla se presente il nodo oppure no)
		initSocialCmsbox(xmlSocialBoxData);
		
		//Se entro 10 secondi la rotazione non viene attivata, la attiva ugualmente (se necessario)
		isSocialboxStarted = false;
		setTimeout (fireSocialBox,10000);
	}
}
/* **** FINE BOX SOCIAL IN HOME **** */

//Promo home full
function loadHomeFull()
{
	addEvent(window,"load",loadHomeFullpromo);
}

function loadHomeFullpromo()
{
	// XML Locale 
	//xmlMenu = "/swf/xml/hp_menu.xml";
	// XML Dinamico
	xmlMenu = "/webankpub/wb/jsp/hp_menu_xml.jsp";
	var hpfp = new  SWFObject("/swf/hp_visual_contenitore_promo.swf", "home_promo", "855", "509", "8", "");
	hpfp.addParam("quality", "high");		
	hpfp.addParam("wmode", "transparent");
	hpfp.addParam("menu", "false");
	hpfp.addParam("Flashvars", "servstamp=" + parseInt((srvTs/1000)) + "&fileXML=" + xmlMenu);
	if (!(isMobile()))
	{
		hpfp.write("homeTotalVisualPromo");
	}
	
	var htv = document.getElementById("homeTotalVisual");
	if(htv.getElementsByTagName("embed").length <= 0 && htv.getElementsByTagName("object").length <= 0)
	{
		/* Inserisce il pulsante tutti i prodotti col relativo contenitore*/
		allProdsButton = document.createElement("A");
		allProdsButton.className = "allprods";
		allProdsButton.href = "javascript:;"
		allProdsButton.onclick = function() {eval("switchAllprods(this)")};
		htv.insertBefore(allProdsButton, document.getElementById("homeTotalVisualPromo"));
		/* Inserisce il contenitore per il menu senza ancora popolarlo */
		allProdsMenu = document.createElement("DIV");
		allProdsMenu.id = "hp_allprodsmenu";
		allProdsMenu.innerHTML = "<img src=\"/wscmn/img/ico2inf_loadingpub.gif\" class=\"loading\">";
		htv.insertBefore(allProdsMenu, document.getElementById("homeTotalVisualPromo"));
		document.getElementById("homeTotalVisualPromo").innerHTML = "<img src=\"/img/img_pr_hp_full.jpg\" usemap=\"#hpfmap\"><map id=\"hpfmap\" name=\"hpfmap\"><area shape=\"rect\" coords=\"498,365,757,426\" href=\"/webankpub/wb/schedaProdottoLarge.do?tabId=nav_pub_wb_conti_nw&OBS_KEY=pro_wbn_caratteristiche_condizioni&KEY4=pro4_nuova_promo&cid=bn-eccezionale-cw-dt\" alt=\"Scopri i vantaggi\" title=\"Scopri i vantaggi\" /><area shape=\"rect\" coords=\"393,447,451,456\" href=\"/doc/Regolamento_Due_cose_eccezionali.pdf\" alt=\"Regolamento\" title=\"Regolamento\" target=\"_blank\"/><area shape=\"rect\" coords=\"551,446,618,455\" href=\"/webankpub/aol/wbPDFFoglioInformativo.do?BV_UseBVCookie=Yes&cod=1.02.0\" alt=\"Fogli informativi\" title=\"Fogli informativi\" target=\"_blank\"/></map>";
	}
}


/* JS UNOBTRUSIVE AZIONI HOME */
//document.observe("dom:loaded", function() {
addEvent(window,"load",function() {
 
	// NUOVA LOGIN
	checkLoginCookie();
	
	//Inibire prima del rilascio: box social
	initSocialBox();
	
	//Barra social a fondo pagina
	initSocialBar();
	
});


