// -- ver 118a 
// --------------------------------INIZIALIZZAZIONI

var currentContentLink="";
var nomeFrecciaGoogle = 'myIMG';
var nomeFrecciaFlash = 'myIMG2';
var DEBUG = false;
var debugWh = null;
var visStack = new Array();
var collapse1;
var collapse2;
var collapse_banche;
var collapse_catalogo;
var pari = true;
var hs = new historyStack();
 
 
function loading(show) 
{
	if(show) 
	{	
		if($('caricamento')) 
		{ 
			if (langFix == 'ita') {
				$('caricamento').setHTML('<br/><br/><br/><br/><br/><br/><center><img src="'+portalURL+'/css/img_costruzione/loading.gif"</center>');
			} else {
				$('caricamento').setHTML('<br/><br/><br/><br/><br/><br/><center><img src="'+portalURL+'/css/img_costruzione/loading_'+langFix+'.gif"</center>');
			}
			$('caricamento').style.top = $('fxcenchan').getCoordinates().top; 
			$('caricamento').style.left = "0px"; 
			$('caricamento').style.width = document.body.offsetWidth;
			$('caricamento').style.height = document.body.offsetHeight; 
			$('caricamento').style.display="block"; 
			$('caricamento').style.opacity="0.7"; 
			$('caricamento').style.filter="alpha(opacity=70)";
			$('caricamento').style.MozOpacity="0.7"; 
			//var myFx = new Fx.Style('caricamento', 'opacity').start(1,0); //display a transition from transparent to opaque.
		}
	}
	else
	{
		
		if($('caricamento'))
		{
			(function(){$('caricamento').style.display="none"}).delay(300);
			
			//(function(){$('caricamento').remove()}).delay(500);
		}
	}
}

window.addEvent('load', 

function ()
{
	//loading(true);
	try
	{

		var accordion = new Accordion('h3.atStart', 'div.atStart', {
		opacity: false,
		
		onActive: function(toggler, element){
			toggler.setStyle('color', '#f57421');
		},
	 
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#f57421');
		}
	}, $('accordion'));

	//dropFlash('flash',508,81,'/flash_smart_finder/smart_finder.swf','','/flash_smart_finder/smart_finder.jpg',portalURL);
		
	collapse1=new animatedcollapse("aperto", 700, true, "block","horizontal");
	collapse2=new animatedcollapse("sotto", 700, true, "block","horizontal");
	
	$('nomibanche').style.visibility="";
	var altezzaTendina = '385';
	
	$('nomibanche').style.height=altezzaTendina+"px";
	collapse_banche=new animatedcollapse("nomibanche", 500, false, "contract","vertical");
	
	try {document.getElementById('spaziobanche').nextSibling.nextSibling.height = altezzaTendina} catch(exc) {};
	
	if($('myTabs')) new mootabs('myTabs');
	if($('myTabs2')) new mootabs2('myTabs2');
	
	var catalogoPagePath = '/'+langFix+'/home/pagine_richiamate/'+langFix+'_catalogo_prodotti.jsp';
	genericAjax('catalogoContainer', catalogoPagePath, function (){
					collapse_catalogo=new animatedcollapse("catalogo", 1000, false, "contract","vertical");
					gestisciVisibilita(); //nel caso di link da Google
					});
	
	//traceIframesrc('/'+langFix+'/home/'+langFix+'_home.jsp');
	
	
	
	}catch(e){outDebug( "[E]onLoad: "+e);}

}//fine onload
);

function genericAjax(objContainer,sUrl, callBack)
{
	
	if($(objContainer))
	{
		new Ajax(scriptURL+'/nop'+sUrl, {
			method: 'get',
			evalScripts : true,
			update : objContainer,
			onComplete : callBack
				}).request();
	}
}

function traceIframesrc(currUrl) 
{
	if($('footer_iframesrc'))
	{
		$('footer_iframesrc').src = portalURL + "/img_costruzione/1x1_trasp.gif" + "?=" + currUrl;
	}
}


function historyStack() 
{
	var hStack = new Array();
	function addUrl(currUrl,currType,currName)
	{
		switch (currType)
		{
			case 'schedaTab':
			{
				hStack.push({url:currUrl, uType:'schedaTab', uName:currName});
				break;
			}
			default: 
			{
				hStack.push({url:currUrl, uType:'culla', uName:currName});
			}
		}
		
		//traceIframesrc(currUrl);
		
		outDebug("---------  hStack.length: " + hStack.length);
		hStack.each(function(oObj){outDebug(oObj.url)});
		//outDebug("---------  langFix: " + langFix);
		outDebug("--------------------------------------------------------");
	}	
	function loadUrl()
	{
		outDebug("hStack.length: " + hStack.length);
		if (hStack.length >= 2)
		{
			var currHStack = hStack[hStack.length-2];
			outDebug("---------  currHStack: " +currHStack.uType+" - "+currHStack.url);
			switch (currHStack.uType)
			{
				case 'culla': 
				{
					inclusione(currHStack.url,"fxcenchan");
					break;
				}
				case 'schedaTab':
				{
					inclusioneST(currHStack.url, currHStack.uName);
					break;
				}
			}
			hStack.pop(); 		
		} 
	}
	function enableButton(dObj)
	{
		if ($('backButton')&&(hStack.length < 2))
		{
			$('backButton').style.display = "none";
		}	
	}	
	this.hStack = hStack;
	this.loadUrl = loadUrl;
	this.addUrl = addUrl;
	this.enableButton = enableButton;
} 



// --------------------------------INIZIALIZZAZIONI FINE

var visStackLastSize = 0;

function tmrControl()
{
	/*
	var nowTime = new Date().getTime();
	if(visStackLastSize != visStack.length)
	{
		visStackLastSize = visStack.length;
	}
	*/
	if(visStack.length > 0  )
	{
		outDebug("tmrGV->gestisciVisibilita");
		gestisciVisibilita();
	}
	//outDebug(visStack.length);

}
tmrControl.periodical(1000);




function outDebug(msg, flagClear)
{
	if(!DEBUG) return;
	//firebug
	try{
	console.log(msg);
} catch(E){}


/*
	try
	{
		if(debugWh == null)
		{
			debugWh = window.open("","debug","width=600,height=400,top=10,left=10");
			debugWh.document.write("<html><head><title>Debug Window</title></head><BODY>DebugWindow<br><textarea id='logT' style='width:100%;height:97%'></textarea></BODY></html>");
		}
	
	if(flagClear == true) debugWh.document.getElementById('logT').value = "";
	debugWh.document.getElementById('logT').value += "\r\n" + msg;
	}catch(e){}
*/

	//window.status =  msg +" ]]]"+ window.status;
}



function linkHelper(action, aObj)
{
	switch (action)
	{
		//user defined di esempio (l'azione ?showHref")
		case "showHref" :{
		//inserire codice da eseguire se chiamata "showHref"
		//--------------------------------------------------
		//--------------------------------------------------
		break;
    }
		case "act01" :{
		//inserire codice da eseguire se chiamata "action01"
		//--------------------------------------------------
		inclusione(aObj.href, 'fxcenchan');
		//-- historyStack
		hs.addUrl(aObj.href,'','');
		//--------------------------------------------------
		break;
		}
		case "act02" :{
		//inserire codice da eseguire se chiamata "action02"
		//--------------------------------------------------
		//-- gds addB: per accendere il tab relativo al link 
		//-- per le pagine di tipo [lfix]_[nometab].jsp
			try
			{
				var hrefTab = aObj.href;
				var nomeTab = (hrefTab.slice(hrefTab.lastIndexOf(langFix+"_")+4,hrefTab.indexOf(".jsp"))).replace(/_/g," ");;
				tabOn(nomeTab);

			}	catch(e){outDebug( "[E]act02: "+ e)}
		//-- gds addE

		inclusione(aObj.href, 'cullaProdotto');	
		
		
				
		
		//--------------------------------------------------
		break;
		}
		

		case "act03" :{
		//inserire codice da eseguire se chiamata "action03"
		//--------------------------------------------------
		//-- gds addB: per visualizzare ed accendere il tab nascosto 'Appuntamento' 
			try{
				for(var i=1;$("tab_"+i)!=null;i++)
				{
					if ($("tab_"+i)!='undefined')
					{
						$("tab_"+i).className = CLASSE_OFF;
						if ( ($("tab_"+i).innerHTML == 'Appuntamento')||($("tab_"+i).innerHTML == 'Termin') )
						{
							$("tab_"+i).style.display = "";
							$("tab_"+i).className = CLASSE_ON;
						}
					}
				}
			}	catch(e){outDebug( "[E]act03: "+ e)}
			
			inclusione(aObj.href+'?oggetto='+prodName, 'cullaProdotto');	
		//-- gds addE
		//--------------------------------------------------
		break;
		}
		

		case "act04" :{
		//inserire codice da eseguire se chiamata "action04"
		//--------------------------------------------------
		//-- gds addB: per accendere il tab relativo al link interno alla pagina
		//-- per le pagine di tipo [lfix]_scheda.jsp : e' necessario che il folder 
		//-- contenente la pagina abbia nome identico al tab da accendere
		//-- a meno di '_' 
			try
			{
				var hrefTab = aObj.href;
				var pathVet = hrefTab.split('/');
				var nomeTab = (pathVet[pathVet.length-2]).replace(/_/g," ");
				tabOn(nomeTab);
				
			}	catch(e){outDebug( "[E]act04: "+ e)}
		inclusione(aObj.href, 'cullaProdotto');	
		//-- gds addE
		//--------------------------------------------------
		break;
		}

		case "act05" :{
		//inserire codice da eseguire se chiamata "action05"
		//--------------------------------------------------
		//-- gds addB: 
		//-- link verso una scheda che deve caricare la culla includente
		//-- il tab relativo viene acceso da 'include_tabSchede'  
			try
			{
				var hrefTab = aObj.href;
				var pathVet = hrefTab.split('/');
				var cullaUrl = getPathOnly(getPathOnly(hrefTab))+"/"+langFix+"_"+pathVet[pathVet.length-3]+".jsp";
								
			}	catch(e){outDebug( "[E]act05: "+ e)}
		inclusione(cullaUrl+"?schedaUrl="+hrefTab, 'fxcenchan');
		//-- gds addE
		//--------------------------------------------------
		break;
		}

		
		
		default :{
		//inserire codice da eseguire se la action non era quelle gestite
		//attualmente prosegue la navigazione alla pagina indicata
		//--------------------------------------------------
		window.location.href = aObj.href;
		//--------------------------------------------------
		
		}
	}
}


function inclusioneF(sUrl, divName)
{
	inclusione(scriptURL+sUrl, divName);
	//-- historyStack
	hs.addUrl(scriptURL+sUrl,'','');
}


function inclusioneS(sUrl, divName)
{
	inclusione(scriptURL+sUrl, divName);	
}


function inclusione(sUrl, divName)
{
	try
	{
		if($(divName))
		{
			if(sUrl.indexOf(scriptURL) != -1)
			{
					var sPos = sUrl.indexOf(scriptURL)+scriptURL.length;
					sUrl = sUrl.substring(0,sPos)+"/nop"+sUrl.substring(sPos);
					//NO URLREWRITE:
					//sUrl = sUrl.substring(0,sPos)+sUrl.substring(sPos);
					
			}
			
			loading(true);
			currentContentLink=sUrl;
			var ajax = new Ajax(sUrl, {
			method: 'get',
			evalScripts : true,
			update : divName,
			onComplete : gestisciVisibilita
				});
			ajax.request();
		}

	}catch(e){outDebug( "[E]inclusione: "+e);}

}

function inclusioneST(tUrl,tName)
{
	try
	{
			loading(true);
			currentContentLink = tUrl;
			var pathVet = tUrl.split('/');
			var cullaUrl = getPathOnly(getPathOnly(tUrl))+"/"+langFix+"_"+pathVet[pathVet.length-3]+".jsp";
			//-- carica la culla con chiamata generica - carica la scheda con inclusioneF - accende il tab:
			genericAjax('fxcenchan',cullaUrl, function (){inclusioneS(tUrl, 'cullaProdotto');tabOn(tName);});

	} catch(e) {outDebug( "[E]inclusioneST: "+e);}
}


function isSlittaCoperta(contenuto, slitta)
{
	var oObj = $(contenuto).getElement('table').getCoordinates();
	var oSlitta = $(slitta).getCoordinates();
	return (oObj.height + oObj.top) > oSlitta.top;
	
}

/*-------------------------------------------------------------*/

function visualizzaFlash()
{
	$('flash').style.display = "block"; 
}

function barraGoogle(azione)
{
	try
	{
		if(azione == "apri")
		{
			collapse1.slidedown();
			$(nomeFrecciaGoogle).style.display = "none";
		}
		else // chiudi default
		{
			collapse1.slideup();
			$(nomeFrecciaGoogle).style.display = "block";
		}
	}catch(e){outDebug( "[E]barraGoogle: "+e);}
	
}

function barraSmartFinder(azione)
{
	try
	{
		if(azione == "apri")
		{
			if(typeof(collapse2)!='undefined')
				collapse2.slidedown();
			$(nomeFrecciaFlash).style.display = "none";
			window.setTimeout("visualizzaFlash()",600);
			$(nomeFrecciaFlash).style.display = "none";
			
		}
		else // chiudi default
		{
			if(typeof(collapse2)!='undefined')
				collapse2.slideup();
			$('flash').style.display = "none";
			$(nomeFrecciaFlash).style.display = "block";
			
		}
	}
	catch(e){outDebug( "[E]barraSmartFinder: "+e);}
}


function pausecomp(millis)
{
	var da = new Date();
	var curDate =null;
	do { curDate = new Date();}
	while (curDate - da < millis){;}
		
}

function gTracker(trackCode, trackUrl)
{
	if ( typeof(_gat)!='undefined')
	{
		try
		{
			var pageTracker = _gat._getTracker(trackCode);
			pageTracker._trackPageview(trackUrl);
			//-- unified tracker
			var pageUnifiedTracker = _gat._getTracker(bankUnifiedCode);
			pageUnifiedTracker._setDomainName("none");
			pageUnifiedTracker._setAllowLinker(true);
			pageUnifiedTracker._trackPageview(trackUrl);

			outDebug( "google analytics - trackUrl: "+trackUrl+" - trackCode: "+trackCode);
		
		}catch(e){
			outDebug( "[E]google analytics : "+ e)
		}
	}
}


function gestisciVisibilita()
{
	if(DEBUG)
		{
			outDebug( "gestisciVisibilita - start - :visStack: -----------------------------------");
			visStack.each(function(oObj){outDebug(oObj.action + " " + oObj.vis + "<->" + oObj.url + ":" + oObj.time)});
			outDebug( "--------------------------------------------------------");
		}
	
	var visibilityStatus = null;
	var visibilityStatusCurr = null;
	var tabClicked = "";
	try
	{
		if(visStack.length > 0)
		{ 
			visibilityStatus =  visStack.getLast();
			visibilityStatusCurr = visibilityStatus;
		}	else {
			visibilityStatus = {vis:"",url:"",time: 0};
			visibilityStatusCurr = visibilityStatus;
		}
		
		if(visibilityStatus.vis.indexOf("tab_") == 0)
		{
			tabClicked=visibilityStatus.vis;
			visibilityStatus.vis = "tab";
		}
		
		if((visibilityStatus.url).indexOf('/tool/'+langFix+'_scheda') != -1)
		{
			visibilityStatus.vis = "langFix"+"_appuntamento";
		}
		
		if(isSlittaCoperta('fxcenchan', 'chiuso')) 
		{	
			barraGoogle('chiudi');
		}
		else
		{
			barraGoogle('apri');
		}
			
		if(isSlittaCoperta('fxcenchan', 'chiuso2')) 
		{	
			barraSmartFinder('chiudi');		
		}
		else
		{
			barraSmartFinder('apri');			
		}
	}catch(e){outDebug( "[E]gestisciVisibilita[slitte]: "+ e)}
	
	
	switch (visibilityStatus.vis)
	{
		case (langFix+"_scheda") :{
			try{
				if($('catalogoContainer'))  $('catalogoContainer').style.display = "block";
				if($('barra')) 							$('barra').style.display = "block";
				if($('barraHome')) 					$('barraHome').style.display = "block";
				if($('RSSicon')) 					  $('RSSicon').style.display = "none";
				if($('accordion')) 					$('accordion').style.display = "none";
				if($('tuttelenews')) 				$('tuttelenews').style.display = "none";
				if($('boxopzionale_sx'))	 	$('boxopzionale_sx').style.display = "none";
				if($('correlati')) 					$('correlati').style.display = "none";
					
				if(collapse_catalogo == null)
					collapse_catalogo=new animatedcollapse("catalogo", 1000, false, "contract","vertical");
				
				if(visibilityStatus.pageTitle) window.title = visibilityStatus.pageTitle;
			  
			  var correlatiPagePath = '/correlati/'+langFix+'_correlati.jsp';			  
				outDebug("[getCorrelati] - correlatiPath - 0: " + getPathOnly(visibilityStatus.url) + correlatiPagePath);
				if ( (typeof(pageIncludedPath)!='undefined') && ((pageIncludedPath)!='') )
				{
					//-- correlati da chiamata diretta
					var pathVet = pageIncludedPath.split('/');
					var parentPath = '/'+(pathVet.slice(2,pathVet.length-1)).join("/"); 
					outDebug("[getCorrelati] - pageIncludedPath: " + pageIncludedPath);
					outDebug("[getCorrelati] - correlatiPath - 1: " + parentPath + correlatiPagePath);
					genericAjax('correlati',parentPath+correlatiPagePath,function(){$('correlati').style.display = "block"; pageIncludedPath ='';});

					//-- prima addUrl da chiamata diretta
					if (hs.hStack.length==0) 
					{ 
						var cullaPath = '/'+(pathVet.slice(2,pathVet.length)).join("/");
						//alert(visibilityStatus.url+" - "+pageIncludedPath+" - "+parentPath+" - "+cullaPath);
						hs.addUrl(scriptURL + cullaPath,'',''); 
					}
				} 
				else 
				{
					outDebug("[getCorrelati] - correlatiPath - 2: " + getPathOnly(visibilityStatus.url) + correlatiPagePath);
					genericAjax('correlati',getPathOnly(visibilityStatus.url)+correlatiPagePath,function(){$('correlati').style.display = "block";});
				}
			
				//-- google-analytics
				gTracker(bankCode, visibilityStatus.url);
				
			}
		  catch(e){outDebug( "[E]gestisciVisibilita[scheda]: "+ e)}
		  
			break;
		}
		
		
		case "tab":{
		try{
			for(var i=1;$("tab_"+i)!=null;i++)
			{
				$("tab_"+i).className = CLASSE_OFF;
			}
			$(tabClicked).className = CLASSE_ON;			
		}
		catch(e){outDebug( "[E]gestisciVisibilita[tab]: "+ e)}
		
		break;
		}
		
		case (langFix+"_appuntamento"):{
		try{
			if($('catalogoContainer'))  $('catalogoContainer').style.display = "block";
			if($('barra')) 						  $('barra').style.display = "block";  
			if($('barraHome')) 					$('barraHome').style.display = "block";
			if($('RSSicon')) 					  $('RSSicon').style.display = "none";
			if($('accordion')) 					$('accordion').style.display = "none";
			if($('tuttelenews')) 				$('tuttelenews').style.display = "none";
			if($('correlati')) 					$('correlati').style.display = "none";
			if($('boxopzionale_sx')) 		$('boxopzionale_sx').style.display = "none";
			
		}
		catch(e){outDebug( "[E]gestisciVisibilita[_appuntamento]: "+ e)}
		
		break;
		}
		
		case "centrale" :{
		try{
			if($('catalogoContainer'))  $('catalogoContainer').style.display = "block";
			if($('barra')) 							$('barra').style.display = "block";  
			if($('barraHome')) 					$('barraHome').style.display = "none";
			if($('RSSicon')) 					  $('RSSicon').style.display = "block";
			if($('accordion')) 					$('accordion').style.display = "block";
			if($('tuttelenews')) 				$('tuttelenews').style.display = "block";
			if($('correlati')) 					$('correlati').style.display = "none";
			if($('boxopzionale_sx'))  	$('boxopzionale_sx').style.display = "none";

			//-- google-analytics 
			gTracker(bankCode, visibilityStatus.url);
			
			var centralePagePath = '/'+langFix+'/home/centrale/'+langFix+'_centrale.jsp';
			if (hs.hStack.length==0) hs.addUrl(scriptURL+centralePagePath,'','');	
		
		}
		catch(e){outDebug( "[E]gestisciVisibilita[_centrale]: "+ e)}
	
		break;
		}


		case (langFix+"_dettagli_news") :{
		try{
			if($('catalogoContainer'))  $('catalogoContainer').style.display = "block";
			if($('barra')) 							$('barra').style.display = "block";
			if($('barraHome')) 					$('barraHome').style.display = "block";
			if($('RSSicon')) 					  $('RSSicon').style.display = "none";
			//-- google-analytics 
			gTracker(bankCode, visibilityStatus.url);
		}
		catch(e){outDebug( "[E]gestisciVisibilita[_dettagli_news]: "+ e)}

		break;
		}
		
		
		case (langFix+"_archivio_news") :{
		try{
			if($('catalogoContainer'))  $('catalogoContainer').style.display = "block";
			if($('barra')) 							$('barra').style.display = "block";
			if($('barraHome')) 					$('barraHome').style.display = "block";
			if($('RSSicon')) 					  $('RSSicon').style.display = "none";
			//-- google-analytics 
			gTracker(bankCode, visibilityStatus.url);
		}
		catch(e){outDebug( "[E]gestisciVisibilita[_archivio_news]: "+ e)}

		break;
		}

		
		default :
		{
			break;
		}
	}
	
	
	
	
	outDebug("[pre-POP] - "+visStack.length+"- CURR: -"+visibilityStatusCurr.vis);
	//visStack.pop();
	
	for(var i=0;i<visStack.length;i++)
	{
		outDebug(">>"+visStack[i].vis);
		if ((visStack[i].vis == visibilityStatusCurr.vis)&&(visStack[i].time == visibilityStatusCurr.time)) 
		{	
			outDebug("><"+visStack[i].vis);
			visStack.remove(visStack[i]);
		}
	}

	if(DEBUG)
		{
			outDebug( "gestisciVisibilita - end - :visStack: -----------------------------------");
			visStack.each(function(oObj){outDebug(oObj.action + " " + oObj.vis + "<->" + oObj.url + ":" + oObj.time)});
			outDebug( "--------------------------------------------------------");
		}


	outDebug("[post-POP] - "+visStack.length);
	if(visStack.length == 0) loading(false);


	
}

function getPathOnly(url)
{
	return url.substring(0,url.lastIndexOf("/"));
}

//------------------- gestione FLASH ----------------------------

var detectableWithVB = false;
var pluginFound = false;
function canDetectPlugins() 
{
  if( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) ) 
  {
		return true;
  } 
  else 
  {
		return false;
  }
}
function detectFlash(redirectURL, redirectIfFound) 
{
	pluginFound = detectPlugin('Shockwave','Flash'); 
  // if not found, try to detect with VisualBasic
  if(!pluginFound && detectableWithVB) 
  {
		pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
  }
  return pluginFound;
}
function detectPlugin() 
{
  // allow for multiple checks in a single pass
  var daPlugins = detectPlugin.arguments;
  // consider pluginFound to be false until proven true
  var pluginFound = false;
  // if plugins array is there and not fake
  if (navigator.plugins && navigator.plugins.length > 0) 
  {
		var pluginsArrayLength = navigator.plugins.length;
		// for each plugin...
		for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) 
		{
	    // loop through all desired names and check each against the current plugin name
	    var numFound = 0;
	    for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) 
	    {
				// if desired plugin name is found in either plugin name or description
				if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || 
				    (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) 
				{
	    		// this name was found
	    		numFound++;
				}   
    	}
	    // now that we have checked all the required names against this one plugin,
	    // if the number we found matches the total number provided then we were successful
	    if(numFound == daPlugins.length) 
	    {
				pluginFound = true;
				// if we've found the plugin, we can stop looking through at the rest of the plugins
				break;
    	}
		}
  }
  return pluginFound;
} // detectPlugin
// Here we write out the VBScript block for MSIE Windows
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) 
{
    document.writeln('<script language="VBscript">');
    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');
    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');
    document.writeln('</scr' + 'ipt>');
}


function createFlash(movie_width,movie_height,flash_pathname)
{
  var timeId = new Date().getTime();
  var bgcolor = (document.bgColor != null) ? document.bgColor : "#ffffff";
  return '<div style="text-align: center; z-index:-1;"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="//active.macromedia.com/flash5/cabs/swflash.cab#version=5,0,0,0" ID="'+timeId+'" WIDTH="'+ movie_width +'" HEIGHT="'+ movie_height+'"> <PARAM NAME=movie VALUE="'+ flash_pathname +'"> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=transparent> <PARAM NAME=bgcolor VALUE="' + bgcolor + '"><EMBED  src="'+ flash_pathname+'" quality=high bgcolor="' + bgcolor + '"  WIDTH="'+ movie_width +'" HEIGHT="'+ movie_height +'" TYPE="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" name="'+timeId+'" wmode="transparent"> </EMBED></OBJECT></div>';
}


function dropFlash(containerId,w,h,swfPathName,targetLink,gifPathname,portalURL)
{
	if(detectFlash())
	{
		if(containerId == "")
			document.write(createFlash(w,h,portalURL+swfPathName));
		else
			$(containerId).setHTML(createFlash(w,h,portalURL+swfPathName));
	}
	else
	{
		if((targetLink != null) && (!targetLink == ""))
		{
			document.writeln('<a href="'+portalURL+targetLink+'"><img src="'+portalURL+gifPathname+'" border="0" WIDTH="'+w+'" HEIGHT="'+h+'"></a><br>');
		}
		else 
		{
			document.writeln('<img src="'+portalURL+gifPathname+'" border="0" WIDTH="'+w+'" HEIGHT="'+h+'"><br>');
		}
	}		
}
//------------------- gestione TABS ----------------------------

var CLASSE_OFF = "pulsante_spento";
var CLASSE_ON = "pulsante_acceso";

function tabClick(tabObj,indexOn,pageUrl, props)
{
	if(tabObj.id == "tab_1")
	{
		inclusioneS("/"+pageUrl, "fxcenchan");	
	}
	else
	{
		//alert((tabObj.innerHTML).toLowerCase());
		visStack.push({action:'call', vis:tabObj.id, url:pageUrl, time: new Date().getTime()});
		inclusioneS("/"+pageUrl, "cullaProdotto");
		var nomeTab = (tabObj.innerHTML).toLowerCase();
		hs.addUrl("/"+pageUrl,'schedaTab',nomeTab);
	}
}

function tabOn(nomeTab)
{
	for(var i=1;$("tab_"+i)!=null;i++)
	{
		if ($("tab_"+i)!='undefined')
		{
			$("tab_"+i).className = CLASSE_OFF;
			if (($("tab_"+i).innerHTML).toLowerCase() == nomeTab.toLowerCase())
			{
				$("tab_"+i).style.display = "";
				$("tab_"+i).className = CLASSE_ON;
			}
		}
	}
}

//------------------- dettaglio NOTIZIA ----------------------------


function showNew(aNewObj,pageUrl,cntId)
{
	//visStack.push({action:'call', vis:aNewObj.id, url:pageUrl, time: new Date().getTime()});
	inclusioneF("/"+pageUrl+"?id="+cntId, "fxcenchan");	
}
