//String.prototype.contains = function(it) { 
//	return this.indexOf(it) != -1; 
//};
	
//alert(""+!(top.location.href.contains("publish-wcm")));
//alert("parent.document : "+parent.document);
//if(!(top.location.href.contains("publish-wcm"))){
//	if(top.location.href != self.location.href) {
	//	alert("top.location.href = "+top.location.href);
	//	alert("self.location.href = "+self.location.href);
//		alert("top.location.href = "+top.location.href);
//		alert("top.location = "+top.location);
//		top.location.href = self.location.href;
//	}
//}

function cleartext(){
	document.form.firstName.value="";
	}

	
function webTrends(divId){
	var obj = (document.getElementById(divId))? document.getElementById(divId):null;
	if(obj){
		var links = obj.getElementsByTagName('a');
		for(i=0;i<links.length;i++){labels.push(links.item(i).innerHTML);}
		var contentGroup = (labels[2])? labels[2]:null;
		var subGroups = (labels[labels.length-1])? labels[labels.length-1]:null;
		if(contentGroup && subGroups){
			var meta_cgn = document.createElement('meta');
			meta_cgn.setAttribute('name', 'WT.cg_n');
			meta_cgn.setAttribute('content', contentGroup);
			headElement.appendChild(meta_cgn);
			var meta_cgs = document.createElement('meta');
			meta_cgs.setAttribute('name', 'WT.cg_s'); 
			meta_cgs.setAttribute('content', subGroups);
			headElement.appendChild(meta_cgs);
		}
	}else{
		var path = document.location.pathname;
		var pathArray = new Array();
		pathArray = path.split('/');
		var contentGroup = pathArray[2];
		if(document.getElementById('navigazione')){
			var imgs = document.getElementById('navigazione').getElementsByTagName('img');
		}
		if(imgs){
			for(i=0;i<imgs.length;i++){
				var alt1 = imgs.item(i).alt.toString();
				if(alt1.substr(1).indexOf(contentGroup.substr(1).substr(0,3))!=-1){
					var meta_cgn = document.createElement('meta');
					meta_cgn.setAttribute('name', 'WT.cg_n');
					meta_cgn.setAttribute('content', imgs.item(i).alt);
					headElement.appendChild(meta_cgn);
				}
			}
		}
	}
}

function webTrendsReturn(divId,opt){
	var obj = (document.getElementById(divId))? document.getElementById(divId):null;
	if(obj){
		var links = obj.getElementsByTagName('a');
		for(i=0;i<links.length;i++){labels.push(links.item(i).innerHTML);}
		var contentGroup = (labels[2])? labels[2]:null;
		var subGroups = (labels[labels.length-1])? labels[labels.length-1]:null;
		if(contentGroup && opt){
			return contentGroup
		}else if(subGroups && !opt){
			return subGroups
		}
	}
}

function allDivs(div1,opt){
	var strClassName = new Array();
	var strClassId = new Array();
	if (div1){
	for (j=0;j<div1.length;j++){
		strClassName[j] = div1.item(j).className;
		strClassId[j] = div1.item(j).id;
	}
	if(opt){return strClassName;
  }else{return strClassId;}
  }
}

function allUls(uls){
	var ulClassName = new Array();
	for (n=0;n<uls.length;n++){
		ulClassName[n] = uls.item(n).className;
	}
	return ulClassName;
}

function wtForBoxs(){
	for(i=0;i<div1.length;i++){
		if(div1.item(i).id == 'temi' || div1.item(i).className == 'lancio'){	
			var hrefs = div1.item(i).getElementsByTagName('a');
			var h2s = div1.item(i).getElementsByTagName('h2');
			if(!hrefs[2] && hrefs[0].innerHTML.indexOf('Web')!=-1){ // For Webranking box
				for(y=0;y<hrefs.length;y++){
					hrefs.item(y).href += '?leftbox=webranking_awards_2008';
				}y=0;
			}else if(!hrefs[2] && hrefs[0].innerHTML.indexOf('Consu')!=-1){
				for(y=0;y<hrefs.length;y++){
					hrefs.item(y).href += '?leftbox=asso_cons&cons=hp';
				}y=0;
			}else if(hrefs[0].innerHTML.indexOf('Documentazione')!=-1 || hrefs[0].innerHTML.indexOf('Publications')!=-1){
				hrefs[0].href += '&leftbox=documentazione&doc_from=hpeni_left';
			}else if(h2s[0].innerHTML.indexOf('Temi')!=-1 || h2s[0].innerHTML.indexOf('Themes')!=-1){
				for(y=0;y<hrefs.length;y++){
					hrefs.item(y).href += '?leftbox=temi_interesse&temi=hp';
				}y=0;
			}else if(h2s[0].innerHTML.indexOf('Altri Siti')!=-1){
				for(y=0;y<hrefs.length;y++){
					if(hrefs.item(y).innerHTML.indexOf('Eni Award')!=-1 ||
					   hrefs.item(y).innerHTML.indexOf('Eni Foundation')!=-1){
							hrefs.item(y).href += '?leftbox=altri_siti';
					}
				}y=0;
			}else if(h2s[0].innerHTML.indexOf('Tools')!=-1){
				for(y=0;y<hrefs.length;y++){
					if(hrefs.item(y).innerHTML.indexOf('Submit CV')!=0){
						if(hrefs.item(y).href.indexOf('?')!=-1){hrefs.item(y).href += '&leftbox=tools'
						}else{hrefs.item(y).href += '?leftbox=tools';}
					}
				}y=0;
			}
		}
	}
}

preObj = false;
preObjBar = false;
first = true;
var intervalO = '';
var intervalC = '';
var objheight = '';
var delay = 4;
if(navigator.appName.substr(0,2) == 'Mi'){delay = 8;}

function keepMoving(objBar,id){
	objBar.style.backgroundImage = 'url(/en_IT/static/images/open.gif)';
	var obj = (document.getElementById(id))? document.getElementById(id):null;
	if(obj == null){alert("l'oggetto è nullo");}else{releaseMoving(objBar,obj);}
}
//alert('10.');
function releaseMoving(objBar,obj){
	if(preObj != obj && preObjBar != objBar){
		if(preObj && preObjBar){
			window.clearInterval(intervalO);
			var nowH = preObj.style.height;
			preObjBar.style.backgroundImage = 'url(/en_IT/static/images/open.gif)';
			intervalC = window.setInterval('closeTooltip(\"'+ preObj.id +'\",\"'+ objheight +'\",\"'+ nowH +'\")', 1);
		}
		obj.style.display = 'block';
		objheight = obj.style.height;
		if(first){
			obj.style.height = '0px';
			intervalO = window.setInterval('openTooltip(\"'+ obj.id +'\",\"'+ objheight +'\")', 1);
		}else{obj.style.height = '352px';} 
		objBar.style.backgroundImage = 'url(/en_IT/static/images/close.gif)';
		preObjBar = objBar;
		preObj = obj;
		first = true;
	}else{
		window.clearInterval(intervalO);
		objBar.style.backgroundImage = 'url(/en_IT/static/images/open.gif)';
		var nowH = obj.style.height;
		intervalC = window.setInterval('closeTooltip(\"'+ obj.id +'\",\"'+ objheight +'\",\"'+ nowH +'\")', 1);
		preObjBar = false;
		preObj = false;
	}
}

function openTooltip(openid,height){
	removeParam();
	var obj = (document.getElementById(openid))? document.getElementById(openid):false;
	if(obj){
		if(parseFloat(obj.style.height) < parseFloat(height)){
			obj.style.height=(parseFloat(obj.style.height)+delay)+'px';
		}else{window.clearInterval(intervalO); impostParam();}
	}
}

function closeTooltip(openid,height,nowH){
	removeParam();
	var obj = (document.getElementById(openid))? document.getElementById(openid):false;
	if(obj){
		if(parseFloat(obj.style.height) > 0){
			obj.style.height=(parseFloat(obj.style.height)-delay)+'px';
		}else{
			var correctH = (parseFloat(height) > parseFloat(nowH))? height:nowH;
			obj.style.display = 'none';
			obj.style.height = correctH;
			window.clearInterval(intervalC); impostParam();
		}
	}
}

function removeParam(){
	for(r=0;r<idArray.length;r++){
		if(navigator.appName.substr(0,2) == 'Mi'){
		var collectionA = document.getElementById(idArray[r]).parentNode.childNodes[0].attributes;
		}else{var collectionA = document.getElementById(idArray[r]).parentNode.childNodes[1].attributes;}
		for(n=0;n<collectionA.length;n++){
			if(collectionA[n].nodeName.toLowerCase() == 'onclick'){
			collectionA[n].nodeValue='';}
		}
	}
}

function impostParam(){
	for(i=0;i<idArray.length;i++){
		var id = "'" + idArray[i] + "'";
		if(navigator.appName.substr(0,2) == 'Mi'){ // Internet Explorer
			var parentN = document.getElementById(idArray[i]).parentNode.childNodes[0];
			if(idArray[i] == 'glossBody'){parentN.onclick = function(){keepMoving(this,'glossBody');}}
			if(idArray[i] == 'rssBody'){parentN.onclick = function(){keepMoving(this,'rssBody');}}
			if(idArray[i] == 'alertBody'){parentN.onclick = function(){keepMoving(this,'alertBody');}}
			if(idArray[i] == 'helpBody'){parentN.onclick = function(){keepMoving(this,'helpBody');}}
			if(idArray[i] == 'calendarioBody'){parentN.onclick = function(){keepMoving(this,'calendarioBody');}}
		}else{ // Others 
			var collectionB = document.getElementById(idArray[i]).parentNode.childNodes[1].attributes;
			for(m=0;m<collectionB.length;m++){
				if(collectionB[m].nodeName.toLowerCase() == 'onclick'){
					collectionB[m].nodeValue='keepMoving(this,'+id+')';
				}
			}
		}
	}
}

function operaRescue(bn){
	if(navigator.appName == 'Opera'){	// && (http1 == 'home' || https1 == 'home')){

		var styleForComunicati = '';
		styleForComunicati += '<style>';
			styleForComunicati +='div#comunicatistampa{width:372px;height:70px;}';
			styleForComunicati +='div#comunicatistampa h2{padding-left:10px}';
			styleForComunicati +='div#comunicatistampa li{margin:0px 10px 0px 10px;}';
			styleForComunicati +='div#comunicatistampa_bg{ background-color:#FFFFFF;}';
			styleForComunicati +='div#lanciHomeGroup{width:384px;}';
			//styleForComunicati +='div#footer{margin:-1280px 0px 0px 20px;}';
			styleForComunicati +='div#frasi{width:auto;margin-top:30px;}';
		styleForComunicati += '</style>';
		document.getElementsByTagName('head')[0].innerHTML += styleForComunicati;

		var loginHeight = document.getElementById('login').offsetHeight;
		var navPosition = position(document.getElementById('nav'));
		var col_dx = document.getElementById('coldxOpera');
		col_dx.style.position = 'absolute';
		col_dx.style.left = navPosition[0] + navPosition[1] + 'px';
		col_dx.style.top =  navPosition[2] + 'px';//loginHeight + 'px';
		var bignewPosition = position(document.getElementById('bignew'));
		var bignewULPosition = position(document.getElementById('bignew').getElementsByTagName('h1')[0]);
		var breakinHeight = 0;
		if(bn){
			var breakin_obj = document.getElementById('breaking-news');
			var breakinHeight = document.getElementById('breaking-news-it').offsetHeight;
			breakin_obj.style.position = 'absolute';
			breakin_obj.style.left = bignewULPosition[0] + 'px';
			breakin_obj.style.top =  bignewPosition[2] + bignewPosition[3] + 'px';//loginHeight + 8 + 'px';
		}
		var comunicati_obj = document.getElementById('comunicatistampa');
		var comunicatiHeight = comunicati_obj.offsetHeight + 15;
		var lanci_obj = document.getElementById('lanciHomeGroup');		
		lanci_obj.style.position = 'absolute';
		lanci_obj.style.left = bignewULPosition[0] + 'px';
		lanci_obj.style.top = bignewPosition[2] + bignewPosition[3] + breakinHeight + comunicatiHeight + 'px';//loginHeight + 'px';
		comunicati_obj.style.position = 'absolute';
		comunicati_obj.style.left = bignewULPosition[0] + 'px';
		comunicati_obj.style.top =  bignewPosition[2] + bignewPosition[3] + breakinHeight + 5 + 'px';//+ loginHeight 
		var lanciHeight = 0;
		var num_div_lanci = document.getElementById('lanciHomeGroup').getElementsByTagName('div').length;
		for(i=0;i<num_div_lanci;i++){			
			//alert("numero"+i+"altezza ="+document.getElementById('lanciHomeGroup').getElementsByTagName('div')[i].offsetHeight);
			lanciHeight = lanciHeight + document.getElementById('lanciHomeGroup').getElementsByTagName('div')[i].offsetHeight;
			//alert("altezza totale ="+ lanciHeight );
			}
		lanciHeight = lanciHeight + 5;
		var footer_obj = document.getElementById('footer');		
		footer_obj.style.position = 'absolute';
		//footer_obj.style.left = bignewULPosition[0] + 'px';
		footer_obj.style.top = bignewPosition[2] + bignewPosition[3] + breakinHeight + comunicatiHeight + lanciHeight+ 'px';//loginHeight + 'px';
	}
}

function position(obj) {
	var width = height = 0;
	width = obj.offsetWidth;
	height = obj.offsetHeight;
	
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	//alert('ritorno le variabili curleft='+curleft+', curtop='+curtop+', mw='+mw+', mh='+mw+'');
	return [curleft,width,curtop,height];
}

/*if(navigator.appName == 'Opera' && (http1 == 'home' || https1 == 'home')){
	operaCss = document.createElement('link');
	operaCss.href = '/it_IT/static/css/opera_rescue.css';
	operaCss.rel = 'stylesheet';
	operaCss.type = 'text/css';
	operaCss.id = 'opera';
	//var css = '<link href="'+originalCss+'" rel="stylesheet" type="text/css" id="3a">';
	if(!document.getElementById('opera')){
		document.getElementsByTagName('head')[0].insertAdjacentElement('beforeEnd',operaCss);
		//document.getElementById('head').addChild(css);
	}
}*/

function screenAdjust(){
	if(screen.width == '1280'){
		var bodyStyle = document.getElementsByTagName('body')[0].style;
		var divZero = document.getElementsByTagName('div')[0];
		var divFrst = divZero.getElementsByTagName('div')[0];
		var divScnd = divFrst.getElementsByTagName('div')[0];
		var divTrdt = divScnd.getElementsByTagName('div')[0];
		bodyStyle.paddingLeft = '40px';
		divZero.style.marginLeft = '-40px';
		divZero.style.width = screen.width + 'px';
		divTrdt.style.width = screen.width + 'px';
	}
}


function goTo(url)
{
	if (url) location.href = url;

};
/*
function openMenuSx(){		
	var uls = document.getElementsByTagName('ul');
	for(u=0;u<uls.length;u++){
		if(uls.item(u).className == 'menu_sx'){
			var closeThisUls = uls.item(u).getElementsByTagName('ul');
			var changeClass = uls.item(u).getElementsByTagName('li');
			//alert('ho ottenuto la lista dei li ' + changeClass);
			for(n=0;n<closeThisUls.length;n++){
				closeThisUls.item(n).style.display = 'none';
			}
			for(b=0;b<changeClass.length;b++){
				//alert('la classe del li è ' + changeClass.item(b).className + 'ed il suo contenuto è ' + changeClass.item(b).innerHTML);
				changeClass.item(b).className = '';
			}
		}
	}
	var queryString = parent.location.search.substr(1);
	
	var variabili = new Array();
	var menu2 = '';
	var menu3 = '';
	if(queryString != ''){
		////alert('la query string non è vuota');
		variabili = queryString.split("&");
		////alert('splitto la query string in un array che diventa --> '+variabili+'');
		for(i=0;i<variabili.length;i++){
			if(variabili[i].indexOf("menu2") == 0){
				////alert('ho trovato menu2');
				menu2 = variabili[i].substr(variabili[i].indexOf("=")+1);
				////alert('menu2 = '+menu2+'');
			}
			if(variabili[i].indexOf("menu3") == 0){
				////alert('ho trovato menu3');
				menu3 = variabili[i].substr(variabili[i].indexOf("=")+1);
				////alert('menu3 = '+menu3+'');
			}
		}
	}
	////alert('sono arrivato qui !');
	if(menu2 != '' || menu3 != ''){
		////alert(menu2 + '  ' + menu3 + 'diversi da vuoto');
		if (document.getElementById(menu2)){
			document.getElementById(menu2).className = 'active';
		}			
		if (document.getElementById(menu2+'Ul')){
			document.getElementById(menu2+'Ul').style.display = '';
		}
		if (document.getElementById(menu2+'Li')){
			document.getElementById(menu2+'Li').className = 'active_only';
		}
		if (document.getElementById(menu3)){
			document.getElementById(menu3).className = 'active';
		}
		if (document.getElementById(menu3+'Ul')){
			document.getElementById(menu3+'Ul').style.display = '';
		}
		if (document.getElementById(menu3+'Li')){
			document.getElementById(menu3+'Li').className = 'active_only';
		}		
	}else{
		////alert("1. la query string è vuota provo a caricare la path");
		
		var url = parent.location.pathname;// se è tutto in pagina sostituire "parent" con "window"
		var queryString = parent.location.search.substr(1);
		
		var urlArray = new Array();
		urlArray = url.split('/');
		for (i=0;i<urlArray.length;i++){
			if (document.getElementById(urlArray[i])){
				document.getElementById(urlArray[i]).className = 'active';
			}
			if (document.getElementById(urlArray[i]+'Ul')){	
				document.getElementById(urlArray[i]+'Ul').style.display = '';
			}
			if (document.getElementById(urlArray[i]+'Li')){
				document.getElementById(urlArray[i]+'Li').className = 'active_only';
			}
		}
	}
}*/
// VECCHIO JS PER MENUSX 
function openNewMenuSx(){		
	if ((document.getElementById('sondaggio'))!=null){
            document.getElementById('sondaggio').getElementsByTagName('a')[0].setAttribute('target', '_blank');
	}

	var uls = document.getElementsByTagName('ul');
	for(u=0;u<uls.length;u++){
		if(uls.item(u).className == 'menu_sx'){
			//var closeThisLIs = uls.item(u).getElementsByTagName('li');
			var changeClass = uls.item(u).getElementsByTagName('li');
			for(b=0;b<changeClass.length;b++){
				//alert('la classe del li è ' + changeClass.item(b).className + 'ed il suo contenuto è ' + changeClass.item(b).innerHTML);
				if(changeClass.item(b).id.substr(0,2) != 'xs'){
					// changeClass.item(b).className = '';
				}else{changeClass.item(b).style.display = 'none';  }
			}
		}
	}
	var queryString = parent.location.search.substr(1);
	var url = parent.location.pathname;// se è tutto in pagina sostituire "parent" con "self"
	if((url.indexOf("load_external_contents")!=-1)||(url.indexOf("myenilight_external_contents")!=-1)){
			queryString = parent.main.location.search.substr(1);
	}
	var variabili = new Array();
	var menu2 = ''; var menu3 = ''; var menu4 = '';
	if(queryString != ''){
		////alert('la query string non è vuota');
		variabili = queryString.split("&");
		////alert('splitto la query string in un array che diventa --> '+variabili+'');
		for(i=0;i<variabili.length;i++){
			if(variabili[i].indexOf("menu20") == 0){
				////alert('ho trovato menu2');
				menu2 = variabili[i].substr(variabili[i].indexOf("=")+1);
				////alert('menu2 = '+menu2+'');
			}
			if(variabili[i].indexOf("menu30") == 0){
				////alert('ho trovato menu3');
				menu3 = variabili[i].substr(variabili[i].indexOf("=")+1);
				////alert('menu3 = '+menu3+'');
			}
			if(variabili[i].indexOf("menu40") == 0){
				////alert('ho trovato menu3');
				menu4 = variabili[i].substr(variabili[i].indexOf("=")+1);
				////alert('menu3 = '+menu3+'');
			}
		}
	}
	////alert('sono arrivato qui !');
	if(menu2 != '' || menu3 != '' || menu4 != ''){
		////alert(menu2 + '  ' + menu3 + 'diversi da vuoto');
		if (document.getElementById(menu2)){
			document.getElementById(menu2).className = 'active_only';
		}			
		if (document.getElementById('xs'+menu2+'Ul')){
			document.getElementById('xs'+menu2+'Ul').style.display = '';
		}
		if (document.getElementById(menu2+'Li')){
			document.getElementById(menu2+'Li').className = 'active_only';
		}
		if (document.getElementById(menu3)){
			document.getElementById(menu3).className = 'active_only';
		}
		if (document.getElementById('xs'+menu3+'Ul')){
			document.getElementById('xs'+menu3+'Ul').style.display = '';
		}
		if (document.getElementById(menu3+'Li')){
			document.getElementById(menu3+'Li').className = 'active_only';
		}		
		if (document.getElementById(menu4)){
			document.getElementById(menu4).className = 'active_only';
		}
		if (document.getElementById('xs'+menu4+'Ul')){
			document.getElementById('xs'+menu4+'Ul').style.display = '';
		}
		if (document.getElementById(menu4+'Li')){
			document.getElementById(menu4+'Li').className = 'active_only';
		}
	}else{
		////alert("1. la query string è vuota provo a caricare la path");
		var url = parent.location.pathname;// se è tutto in pagina sostituire "parent" con "self"
		var queryString = parent.location.search.substr(1);
		if((url.indexOf("load_external_contents")!=-1)||(url.indexOf("myenilight_external_contents")!=-1)){
			url = parent.main.location.pathname;
			queryString = parent.main.location.search.substr(1);
		}
		
		var urlArray = new Array();
		urlArray = url.split('/');
		for (i=0;i<urlArray.length;i++){
		   if(i==3)
		   {
			
			if (document.getElementById('xs'+urlArray[i]+'Ul')){
				document.getElementById(urlArray[i]).className = 'menu segue active_menu';
				document.getElementById('xs'+urlArray[i]+'Ul').style.display = '';
			}else{ 
			    
				     	  					 if(document.getElementById(urlArray[i])!=null){ 
											     prov=document.getElementById(urlArray[i]);
							                     aconte=prov.innerHTML;
											 if((urlArray[i]!='comunicati-stampa')&&(urlArray[i]!='note-stampa')){
				      	                         document.getElementById(urlArray[i]).className = 'active menu';
				      	                         
						                         var acontestart=aconte.indexOf(">")+1;
							                     var	acontestop=aconte.indexOf("</");
							                     var	label = aconte.substring(acontestart,acontestop);
								                  prov.innerHTML=label;
				                  		    }   else{
									     			 document.getElementById(urlArray[i]).className = 'menulista';
												 }
								
						}		
				
				}
			if (document.getElementById(urlArray[i]+'Li')){
				document.getElementById(urlArray[i]+'Li').className = 'menu segue active_menu';
			}
		   }
		   if(i==4)
		   {
			  if (document.getElementById('xs'+urlArray[i]+'Ul')){	
	            document.getElementById(urlArray[i]).className='segue_2 active_menu_2'; 	  
				document.getElementById('xs'+urlArray[i]+'Ul').style.display = '';
				
			     } else{
					 if(document.getElementById(urlArray[i])!=null){
						 if((urlArray[i-1]=='presentazioni')){
							 document.getElementById(urlArray[i]).className = 'menulista';
						  }
						  else{
			   
				            document.getElementById(urlArray[i]).className = 'active menu2';
				              provse=document.getElementById(urlArray[i]);
							acontese=provse.innerHTML;
						    var acontestartse=acontese.indexOf(">")+1;
							var	acontestopse=acontese.indexOf("</");
							var	labelse = acontese.substring(acontestartse,acontestopse);
							 provse.innerHTML=labelse;
						  }
					 }
				
		    }
			}
			
		 if(i==5)
		   {
			  if (document.getElementById(urlArray[i])){	
	            document.getElementById(urlArray[i]).className='active'; 	  
				//document.getElementById('xs'+urlArray[i]+'Ul').style.display = '';
				
				 provter=document.getElementById(urlArray[i]);
				
				          	aconteter=provter.innerHTML;
						  
						    var acontestartter=aconteter.indexOf(">")+1;
							var	acontestopter=aconteter.indexOf("</");
							var	labelter = aconteter.substring(acontestartter,acontestopter);
								
								
								
				                provter.innerHTML=labelter;
			}   
			}
				
			
		}
		
	}
	  
	 
	
}

//
function openMenuDx(id,id2){
	if (id != ''){
		document.getElementById(id).className = 'active';
	}
	if (document.getElementById(id+'Ul')){
		document.getElementById(id+'Ul').style.display = '';
	}
	if (id2 != ''){
		document.getElementById(id2).className = 'active';
	}
	if (document.getElementById(id2+'Ul')){
		document.getElementById(id2+'Ul').style.display = '';
	}
}
// VECCHIO JS PER MENUSX 
function brad(){
	var ul = document.getElementsByTagName('ul');



	for (j=0;j<ul.length;j++){
		if (ul.item(j).className == 'menu_sx'){
			var li = ul.item(j).getElementsByTagName('li');
			for (i=0;i<li.length;i++){
				if (li.item(i).className == 'menu segue active_menu'||li.item(i).className == 'segue_2 active_menu_2'||li.item(i).className == 'menulista'){
					var a = li.item(i).getElementsByTagName('a');
					document.write('&nbsp;&gt;&nbsp; <a href="'+a.item(0)+'">'+a.item(0).innerHTML+'</a>');
				}
				if(li.item(i).className=='active'){
						
						document.write('&nbsp;&gt;&nbsp; '+aconteter+'');
						} 
				if(li.item(i).className=='active menu'){
				        document.write('&nbsp;&gt;&nbsp; '+aconte+'');
				
				}
				if(li.item(i).className=='active menu2'){
				        document.write('&nbsp;&gt;&nbsp; '+acontese+'');
				
				}
				
			}
		}
	}
}
var breadCrumb = "" ;

function brad2(){
	var ul = document.getElementsByTagName('ul');

  var omniture="";

  var omnituretemp="";
	for (j=0;j<ul.length;j++){
		if (ul.item(j).className == 'menu_sx'){
			var li = ul.item(j).getElementsByTagName('li');
			for (i=0;i<li.length;i++){
				if (li.item(i).className == 'active' || li.item(i).className == 'active_only'){
					var a = li.item(i).getElementsByTagName('a');
				  omnituretemp = omnituretemp + " | "+ a.item(0).innerHTML;

				}
			}
			omniture=omniture+omnituretemp;
			breadCrumb = omniture;
	
		}
	}
	return omniture;
	
}

function HideDIV(d) { 
	if (document.getElementById(d)) {
		document.getElementById(d).style.display = "none"; 
	}
}
function DisplayDIV(d) { 
	if (document.getElementById(d)) {
		document.getElementById(d).style.display = "block"; 
	}
}	

function resizeFont(type){
	var originalCss = '/it_IT/static/css/'+type+'.css';
	css = document.createElement('link');
	css.href = originalCss;
	css.rel = 'stylesheet';
	css.type = 'text/css';
	css.id = '3a';
	//var css = '<link href="'+originalCss+'" rel="stylesheet" type="text/css" id="3a">';
	if(!document.getElementById('3a')){
		document.getElementsByTagName('head')[0].insertAdjacentElement('beforeEnd',css);
		//document.getElementById('head').addChild(css);
	}else{
		var a3 = document.getElementById('3a');
		a3.href = originalCss;
	}
	setCookieRF(type);
}

function goToCondivi() {
   var w = 500;
   var h = 450;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
   var stile = "top=" + t + ", left=" + l + ", width=" + w + ", height=" + h + ",locations=yes, directories=no, status=no, menubar=yes, toolbar=no, scrollbars=yes, resizable=yes, "; 


   window.open("/portal/tools/processCondividi.do?url="+location.href,"","stile");
 
 }
 
 <!--window.open("/portal/tools/processCondividi.do?url="+location.href,"",stile); -->
function goToContatti() {
	var url2 = location.pathname;
  var urlArray2 = new Array();
  urlArray2 = url2.split('/');
  var locale= urlArray2[0];  	
	window.open("/portal/tools/processContatti.do?locale="+locale,"");
 } 
 
 function gotoCountry (countrySelect,locale) {
 	var prefix = '';
 	var countryOptions, currentValue;
 	
 	countryOptions = countrySelect.options;
 	currentValue = countryOptions[countrySelect.selectedIndex].value;
 	if (currentValue=='') {
 		return;
 	}

	prefix = '/it_IT/azienda/eni-nel-mondo/eni_mondo_open.page';
 	
 	lolocation.href=prefix+'?locale=it_IT&country='+currentValue;
	<!-- 	location.href=prefix+'?locale=it_IT&country='+currentValue;-->
 }
	
	
// carica la finestra per aggiungere il sito nei preferiti 
function bookmark()
{
	var ua=navigator.userAgent.toLowerCase();
	var isKonq=(ua.indexOf('konqueror')!=-1);
	var isSafari=(ua.indexOf('webkit')!=-1);
	var isMac=(ua.indexOf('mac')!=-1);
	var buttonStr=isMac?'Command/Cmd':'CTRL';
	
	if(window.external && (!document.createTextNode ||
	  (typeof(window.external.AddFavorite)=='unknown'))) {
		window.external.AddFavorite(location.href,document.title); // IE
	} else if(window.sidebar){ // firefox
		//alert('ok');
		//alert(location.href + ' ' + document.title);
		window.sidebar.addPanel(document.title, location.href,"");
	} else if(isKonq) {
	  //alert('Per aggiungere questa pagina come nuovo segnalibro premere CTRL + B');
	  // //alert('You need to press CTRL + B to bookmark our site');
	} else if(window.opera) {
	  //void(0); // non fai niente (Opera 7+)
	  alert('Per aggiungere questa pagina nei preferiti premere '+buttonStr+' + D');
	} else if(window.home || isSafari) { // Firefox, Netscape, Safari, iCab
	  alert('Per aggiungere questa pagina nei preferiti premere '+buttonStr+' + D');
	  ////alert('You need to press '+buttonStr+' + D to bookmark our site');
	} else if(!window.print || isMac) { // IE5/Mac e Safari 1.0
	  //alert('Per aggiungere questa pagina nei preferiti premere Command/Cmd + D');  
	  ////alert('You need to press Command/Cmd + D to bookmark our site');    
	}
} 
//Stampa Nuova
//funzione per la stampa della pagina con header e corpo centrale col_centro
function print_preview () {
	
	//var disp_setting="toolbar=no,location=no,directories=no,menubar=yes"; 
	var divs = document.getElementsByTagName('div');

	for(i=0;i<divs.length;i++){

		if(divs.item(i).className == 'col_centro'){

			var itemCol_centro = divs.item(i);

			i = divs.length;

		}

	}
	var htmlBody = itemCol_centro.innerHTML;
	var updateDiv = '';
	if(document.getElementById('update')){
		var updateDiv = document.getElementById('update').innerHTML;
	}
	//alert(htmlBody);
	var boxStampa = '<div id="printf" align="right" style="visibility:visible;"><img src="/it_IT/static/images/print.gif" border="0"/><a href="#" style="" onClick="window.print()">Print Page</a>&#160;&#160;<img src="/it_IT/static/images/close_print.gif" border="0"/><a href="#" style="" onClick="window.close()">Close Window</a></div>';

	//var htmlBody = document.getElementById('container').innerHTML;
	var docprint=window.open("","","");
	docprint.document.open();
	docprint.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" href="/it_IT/static/css/sIFR-print.css"/></head><body>'+boxStampa+'<div id="container"><div id="contenuti"><div class="col_centro">'+htmlBody+'</div></div></div><div id="update">'+updateDiv+'</div></body></html>');
	//docprint.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" href="/it_IT/static/css/sIFR-print.css"/></head><body>');
	//docprint.document.write(htmlBody);
	//docprint.document.write('</body></html>');
	//docprint.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="/it_IT/static/css/print.css"/><link rel="stylesheet" href="/it_IT/static/css/sIFR-print.css"/></head><body>prova per la stampa</body></html>');
	docprint.document.close();
	//docprint.focus();
	//docprint.window.print();
}	

//Fine Stampa Nuova
//funzione per la stampa della pagina con header e corpo centrale col_centro
function print_preview_old () {
	
	//var disp_setting="toolbar=no,location=no,directories=no,menubar=yes"; 
	var divs = document.getElementsByTagName('div');
	for(i=0;i<divs.length;i++){
		if(divs.item(i).className == 'col_centro'){
			var itemConteiner = divs.item(i);
			i = divs.length;
		}
	}
	var headHTML = document.getElementsByTagName('head')[0].innerHTML;
	var htmlBody = itemConteiner.innerHTML;
	var boxStampa = '<div id="printf"><img src="/it_IT/static/images/print.gif" alt="stampa" border="0"/>&nbsp;';
	if(document.all){
		boxStampa += '<a href="javascript:window.print();" accesskey="p">Stampa</a></div>';
	}else{boxStampa += '<a href="javascript:location.reload();" accesskey="p">Stampa</a></div>';}
	var docprint = window.open('','','');
	docprint.focus();
	docprint.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n');
	docprint.document.write('<html xmlns="http://www.w3.org/1999/xhtml">\n');
	docprint.document.write('<head>\n');
	docprint.document.write('<link type="text/css" href="/it_IT/static/css/print.css" rel="stylesheet" media="print">');
	docprint.document.write(headHTML);
	docprint.document.write('<style>div#bookmark{display:none;visibility:hidden;}</style>');
	docprint.document.write('</head>\n');
	docprint.document.write('<body>\n');
	docprint.document.write('<div id="container"><div class="col_centro">\n');
	docprint.document.write(boxStampa);
	if(!document.all){docprint.document.write('<script language="javascript">window.print();</script>\n');}
	docprint.document.write(htmlBody);
	docprint.document.write('</html>');
	//window.setTimeout("docprint.print()", 2000);
	if(document.all){//for IE
		docprint.location.reload(true);
	}
	//docprint.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="/it_IT/static/css/print.css"/><link rel="stylesheet" href="/it_IT/static/css/sIFR-print.css"/></head><body>prova per la stampa</body></html>');
	//docprint.document.close();
}	

// --------------------------------------------------------------------------------------
// INIZIO CODICE JS FORNITO DA COMES
// --------------------------------------------------------------------------------------

var ua = navigator.userAgent
var ps = navigator.productSub 
var dom = (document.getElementById)? 1:0
var ie4 = (document.all&&!dom)? 1:0
var ie5 = (document.all&&dom)? 1:0
var nn4 =(navigator.appName.toLowerCase() == "netscape" && parseInt(navigator.appVersion) == 4)
var nn6 = (dom&&!ie5)? 1:0
var sNav = (nn4||nn6||ie4||ie5)? 1:0
var cssFilters = ((ua.indexOf("MSIE 5.5")>=0||ua.indexOf("MSIE 6")>=0)&&ua.indexOf("Opera")<0)? 1:0
var Style=[],Text=[],Count=0,sbw=0,move=0,hs="",mx,my,scl,sct,ww,wh,obj,sl,st,ih,iw,vl,hl,sv,evlh,evlw,tbody
var HideTip = "eval(obj+sv+hl+';'+obj+sl+'=0;'+obj+st+'=-800')"
var doc_root = ((ie5&&ua.indexOf("Opera")<0||ie4)&&document.compatMode=="CSS1Compat")? "document.documentElement":"document.body"
var PX = (nn6)? "px" :"" 

if(sNav) {
	window.onresize = ReloadTip
	document.onmousemove = MoveTip
	if(nn4) document.captureEvents(Event.MOUSEMOVE) 
}	
if(nn4||nn6) {
	mx = "e.pageX"
	my = "e.pageY"
	scl = "window.pageXOffset"
	sct = "window.pageYOffset"	
	if(nn4) {
		obj = "document.TipLayer."
		sl = "left"
		st = "top"
		ih = "clip.height"
		iw = "clip.width"
		vl = "'show'"
		hl = "'hide'"
		sv = "visibility="
	}
	else obj = "document.getElementById('TipLayer')."
} 
if(ie4||ie5) {
	obj = "TipLayer."
	mx = "event.x"
	my = "event.y"
	scl = "eval(doc_root).scrollLeft"
	sct = "eval(doc_root).scrollTop"
	if(ie5) {
		mx = mx+"+"+scl 
		my = my+"+"+sct
	}
}
if(ie4||dom){
	sl = "style.left"
	st = "style.top"
	ih = "offsetHeight"
	iw = "offsetWidth"
	vl = "'visible'"
	hl = "'hidden'"
	sv = "style.visibility="
}
if(ie4||ie5||ps>=20020823) {
	ww = "eval(doc_root).clientWidth"
	wh = "eval(doc_root).clientHeight"
}	 
else { 
	ww = "window.innerWidth"
	wh = "window.innerHeight"
	evlh = eval(wh)
	evlw = eval(ww)
	sbw=15
}	
/*
function applyCssFilter(){
	if(cssFilters&&FiltersEnabled) { 
		var dx = " progid:DXImageTransform.Microsoft."
		TipLayer.style.filter = "revealTrans()"+dx+"Fade(Overlap=1.00 enabled=0)"+dx+"Inset(enabled=0)"+dx+"Iris(irisstyle=PLUS,motion=in enabled=0)"+dx+"Iris(irisstyle=PLUS,motion=out enabled=0)"+dx+"Iris(irisstyle=DIAMOND,motion=in enabled=0)"+dx+"Iris(irisstyle=DIAMOND,motion=out enabled=0)"+dx+"Iris(irisstyle=CROSS,motion=in enabled=0)"+dx+"Iris(irisstyle=CROSS,motion=out enabled=0)"+dx+"Iris(irisstyle=STAR,motion=in enabled=0)"+dx+"Iris(irisstyle=STAR,motion=out enabled=0)"+dx+"RadialWipe(wipestyle=CLOCK enabled=0)"+dx+"RadialWipe(wipestyle=WEDGE enabled=0)"+dx+"RadialWipe(wipestyle=RADIAL enabled=0)"+dx+"Pixelate(MaxSquare=35,enabled=0)"+dx+"Slide(slidestyle=HIDE,Bands=25 enabled=0)"+dx+"Slide(slidestyle=PUSH,Bands=25 enabled=0)"+dx+"Slide(slidestyle=SWAP,Bands=25 enabled=0)"+dx+"Spiral(GridSizeX=16,GridSizeY=16 enabled=0)"+dx+"Stretch(stretchstyle=HIDE enabled=0)"+dx+"Stretch(stretchstyle=PUSH enabled=0)"+dx+"Stretch(stretchstyle=SPIN enabled=0)"+dx+"Wheel(spokes=16 enabled=0)"+dx+"GradientWipe(GradientSize=1.00,wipestyle=0,motion=forward enabled=0)"+dx+"GradientWipe(GradientSize=1.00,wipestyle=0,motion=reverse enabled=0)"+dx+"GradientWipe(GradientSize=1.00,wipestyle=1,motion=forward enabled=0)"+dx+"GradientWipe(GradientSize=1.00,wipestyle=1,motion=reverse enabled=0)"+dx+"Zigzag(GridSizeX=8,GridSizeY=8 enabled=0)"+dx+"Alpha(enabled=0)"+dx+"Dropshadow(OffX=3,OffY=3,Positive=true,enabled=0)"+dx+"Shadow(strength=3,direction=135,enabled=0)"
	}
}
*/
function stm(t,s) {
  if(sNav) {
  	if(t.length<2||s.length<25) {
		var ErrorNotice = "DHTML TIP MESSAGE VERSION 1.2 ERROR NOTICE.\n"
		if(t.length<2&&s.length<25) alert(ErrorNotice+"It looks like you removed an entry or more from the Style Array and Text Array of this tip.\nTheir should be 25 entries in every Style Array even though empty and 2 in every Text Array. You defined only "+s.length+" entries in the Style Array and "+t.length+" entry in the Text Array. This tip won't be viewed to avoid errors")
		else if(t.length<2) alert(ErrorNotice+"It looks like you removed an entry or more from the Text Array of this tip.\nTheir should be 2 entries in every Text Array. You defined only "+t.length+" entry. This tip won't be viewed to avoid errors.")
		else if(s.length<25) alert(ErrorNotice+"It looks like you removed an entry or more from the Style Array of this tip.\nTheir should be 25 entries in every Style Array even though empty. You defined only "+s.length+" entries. This tip won't be viewed to avoid errors.")
 	}
  	else {
		var ab = "" ;var ap = ""
		var titCol = (s[0])? "COLOR='"+s[0]+"'" : ""
		var txtCol = (s[1])? "COLOR='"+s[1]+"'" : ""
		var titBgCol = (s[2])? "BGCOLOR='"+s[2]+"'" : ""
		var txtBgCol = (s[3])? "BGCOLOR='"+s[3]+"'" : ""
		var titBgImg = (s[4])? "BACKGROUND='"+s[4]+"'" : ""	
		var txtBgImg = (s[5])? "BACKGROUND='"+s[5]+"'" : ""
		var titTxtAli = (s[6] && s[6].toLowerCase()!="left")? "ALIGN='"+s[6]+"'" : ""
		var txtTxtAli = (s[7] && s[7].toLowerCase()!="left")? "ALIGN='"+s[7]+"'" : ""   
		var add_height = (s[15])? "HEIGHT='"+s[15]+"'" : ""
		if(!s[8])  s[8] = "Verdana,Arial,Helvetica"
		if(!s[9])  s[9] = "Verdana,Arial,Helvetica"					
		if(!s[12]) s[12] = 1
		if(!s[13]) s[13] = 1
		if(!s[14]) s[14] = 200
		if(!s[16]) s[16] = 0
		if(!s[17]) s[17] = 0
		if(!s[18]) s[18] = 10
		if(!s[19]) s[19] = 10
		hs = s[11].toLowerCase() 
		if(ps==20001108){
		if(s[2]) ab="STYLE='border:"+s[16]+"px solid"+" "+s[2]+"'"
		ap="STYLE='padding:"+s[17]+"px "+s[17]+"px "+s[17]+"px "+s[17]+"px'"}
		var closeLink=(hs=="sticky")? "<TD ALIGN='right'><FONT SIZE='"+s[12]+"' FACE='"+s[8]+"'><A HREF='javascript:void(0)' ONCLICK='stickyhide()' STYLE='text-decoration:none;color:"+s[0]+"'><B>Close</B></A></FONT></TD>":""
		var title=(t[0]||hs=="sticky")? "<TABLE WIDTH='100%' BORDER='0' CELLPADDING='0' CELLSPACING='0'><TR><TD "+titTxtAli+"><FONT SIZE='"+s[12]+"' FACE='"+s[8]+"' "+titCol+"><B>"+t[0]+"</B></FONT></TD>"+closeLink+"</TR></TABLE>" : ""
		var txt="<TABLE "+titBgImg+" "+ab+" WIDTH='"+s[14]+"' BORDER='0' CELLPADDING='"+s[16]+"' CELLSPACING='0' "+titBgCol+" ><TR><TD>"+title+"<TABLE WIDTH='100%' "+add_height+" BORDER='0' CELLPADDING='"+s[17]+"' CELLSPACING='0' "+txtBgCol+" "+txtBgImg+"><TR><TD "+txtTxtAli+" "+ap+" VALIGN='top'><FONT SIZE='"+s[13]+"' FACE='"+s[9]+"' "+txtCol +">"+t[1]+"</FONT></TD></TR></TABLE></TD></TR></TABLE>"
		if(nn4) {
			with(eval(obj+"document")) {
				open()
				write(txt)
				close()
			}
		}
		else eval(obj+"innerHTML=txt")
		tbody = {
			Pos:s[10].toLowerCase(), 
			Xpos:s[18],
			Ypos:s[19], 
			Transition:s[20],
			Duration:s[21], 
			Alpha:s[22],
			ShadowType:s[23].toLowerCase(),
			ShadowColor:s[24],
			Width:parseInt(eval(obj+iw)+3+sbw)
		}
		if(ie4) { 
			TipLayer.style.width = s[14]
	 		tbody.Width = s[14]
		}
		Count=0	
		move=1
 	 }
  }
}

function MoveTip(e) {
	if(move) {
		var X,Y,MouseX = eval(mx),MouseY = eval(my); tbody.Height = parseInt(eval(obj+ih)+3)
		tbody.wiw = parseInt(eval(ww+"+"+scl)); tbody.wih = parseInt(eval(wh+"+"+sct))
		switch(tbody.Pos) {
			case "left" : X=MouseX-tbody.Width-tbody.Xpos; Y=MouseY+tbody.Ypos; break
			case "center": X=MouseX-(tbody.Width/2); Y=MouseY+tbody.Ypos; break
			case "float": X=tbody.Xpos+eval(scl); Y=tbody.Ypos+eval(sct); break	
			case "fixed": X=tbody.Xpos; Y=tbody.Ypos; break		
			default: X=MouseX+tbody.Xpos; Y=MouseY+tbody.Ypos
		}

		if(tbody.wiw<tbody.Width+X) X = tbody.wiw-tbody.Width
		if(tbody.wih<tbody.Height+Y+sbw) {
			if(tbody.Pos=="float"||tbody.Pos=="fixed") Y = tbody.wih-tbody.Height-sbw
			else Y = MouseY-tbody.Height
		}


		if(X<0) X=0 
		eval(obj+sl+"=X+PX;"+obj+st+"=Y+PX")
		ViewTip()
	}
}

function ViewTip() {
  	Count++
	if(Count == 1) {
		if(cssFilters&&FiltersEnabled) {	
			for(Index=28; Index<31; Index++) { TipLayer.filters[Index].enabled = 0 }
			for(s=0; s<28; s++) { if(TipLayer.filters[s].status == 2) TipLayer.filters[s].stop() }
			if(tbody.Transition == 51) tbody.Transition = parseInt(Math.random()*50)
			var applyTrans = (tbody.Transition>-1&&tbody.Transition<24&&tbody.Duration>0)? 1:0
			var advFilters = (tbody.Transition>23&&tbody.Transition<51&&tbody.Duration>0)? 1:0
			var which = (applyTrans)?0:(advFilters)? tbody.Transition-23:0 
			if(tbody.Alpha>0&&tbody.Alpha<100) {
	  			TipLayer.filters[28].enabled = 1
	  			TipLayer.filters[28].opacity = tbody.Alpha
			}
			if(tbody.ShadowColor&&tbody.ShadowType == "simple") {
	  			TipLayer.filters[29].enabled = 1
	  			TipLayer.filters[29].color = tbody.ShadowColor
			}
			else if(tbody.ShadowColor&&tbody.ShadowType == "complex") {
	  			TipLayer.filters[30].enabled = 1
	  			TipLayer.filters[30].color = tbody.ShadowColor
			}
			if(applyTrans||advFilters) {
				eval(obj+sv+hl)
	  			if(applyTrans) TipLayer.filters[0].transition = tbody.Transition
	  			TipLayer.filters[which].duration = tbody.Duration 
	  			TipLayer.filters[which].apply()
			}
		}
 		eval(obj+sv+vl)
		if(cssFilters&&FiltersEnabled&&(applyTrans||advFilters)) TipLayer.filters[which].play()
		if(hs == "sticky") move=0
  	}
}

function stickyhide() {
	eval(HideTip)
}

function ReloadTip() {
	 if(nn4&&(evlw!=eval(ww)||evlh!=eval(wh))) location.reload()
	 else if(hs == "sticky") eval(HideTip)
}

function htm() {
	if(sNav) {
		if(hs!="keep") {
			move=0; 
			if(hs!="sticky") eval(HideTip)
		}	
	} 
}

        function tendina (ident, num){
        var elem;         
       if(document.getElementById) 
        { var elem = document.getElementById(num);
        } else if (document.all)
        { var elem = document.all[num]; 
        } 
 if (window.XMLHttpRequest) {
        if (document.getElementById(ident).style.display=='none') {
        document.getElementById(ident).style.display='block';
elem.className = "freccia_open";  
                } else { 
                document.getElementById(ident).style.display='none'; 
elem.className = "freccia"; 
                }        
        } else {
        if (document.getElementById(ident).style.display=='none') {
  document.getElementById(ident).style.display='block';
elem.className = "freccia_open"; 
         } else {
         document.getElementById(ident).style.display='none';
elem.className = "freccia"; 
         };
        };
 }


// --------------------------------------------------------------------------------------
// FINE CODICE JS FORNITO DA COMES
// --------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------
// INIZIO CODICE PER alert STAMPA PAGINA
// --------------------------------------------------------------------------------------

var IE = document.all?true:false //creo una variabile la quale è valorizzata a true se il broswer è IE o false se è un altro

var xCoords = 0
var yCoords = 0
var x = '';

function over(obj,idDiv){
	//alert('sono entrato');
	if (!IE) document.captureEvents(Event.MOUSEMOVE) //NETSCAPE(MOZILLA FIREFOX) catturo l'evento movimento del mouse;
	document.onmousemove = getMouseCoords;
	//alert('prendo le coordinate');
	//alert('xCoords = ' + xCoords + 'px; yCoords = ' + yCoords + 'px'); 
	document.getElementById(idDiv).style.visibility = 'visible';
	//alert('visualizzo il div --> ' + document.getElementById(idDiv));
	 if (xCoords < 0 || yCoords < 0){
		document.getElementById('alert').style.display = 'none';
	} else { //altrimenti via all'integrazione con il box
		document.getElementById('alert').style.left = xCoords + 'px';
		document.getElementById('alert').style.top = yCoords - 100 + 'px';
		//document.getElementById('alert').innerHTML = 'xCoords = ' + xCoords + '<br />yCoords = ' + yCoords;
	}
	window.clearTimeout(x);
	x = window.setTimeout("out()", 3000);

	return true
}

function out(){
	//alert('ci sono i 3 secondi sono scaduti');
	document.getElementById('alert').style.visibility = 'hidden';
}

function getMouseCoords(e) {
	if (IE) { // prendo la posizione del mouse se il broswer è IE
		xCoords = event.clientX + document.documentElement.scrollLeft;
		yCoords = event.clientY + document.documentElement.scrollTop;
	} else {   // prendo la posizione del mouse se il broswer è MF
		xCoords = e.pageX
		yCoords = e.pageY
	}  
	// possibili valori negativi in Nescape 4
}

// --------------------------------------------------------------------------------------
// FINE CODICE PER alert STAMPA PAGINA
// --------------------------------------------------------------------------------------

	// Variabili globali per l'inclusione Ajax
	var ajaxRequest = false;
	var globalDivObject = null;

	// ------------------------------------------------------------------------------------
	// ajaxInclude ()
	// Funzioni per l'inclusione Ajax
	// ------------------------------------------------------------------------------------
	function ajaxInclude (url,divId) {
		
    // window.alert ("ajaxInclude() - Start "+url);
		
		if (divId==null || divId=='') {
			globalDivObject = null;
			ajaxError ("Div Id Not Defined");
			return;
		}

		globalDivObject = document.getElementById(divId);
		
		if (url==null || url=='') {
			ajaxError ('URL not defined');
			return;
		}
		    
		if(window.XMLHttpRequest && !(window.ActiveXObject)) {
			try {
				ajaxRequest = new XMLHttpRequest();
			} catch(e) {
				ajaxRequest = false;
			}
		} else if(window.ActiveXObject) {
			try {
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				try {
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e) {
					ajaxRequest = false;
				}
			}
		}
	
		if(ajaxRequest) {
			ajaxRequest.onreadystatechange = new Function ("processInclude();");
			ajaxRequest.open("GET", url, true);
			ajaxRequest.send(null);
		} else {
			ajaxError ("Ajax not supported");
		}

		//window.alert ("ajaxInclude() - End");
	}

	
	// ------------------------------------------------------------------------------------
	// processInclude ()
	// Gestisce la risposta Ajax per l'inclusione
	// ------------------------------------------------------------------------------------
	function processInclude() {
		
		if ( ajaxRequest==null ) return;

		if (ajaxRequest.readyState == 4) {
			if (ajaxRequest.status == 200) {
				var response = ajaxRequest.responseText;
				globalDivObject.innerHTML = response;				
			} else {
				ajaxError ("Error retrieving Content (Code "+ajaxRequest.status+")");
			}
		}
	}
	
	// ------------------------------------------------------------------------------------
	// ajaxError ()
	// ------------------------------------------------------------------------------------
	function ajaxError (message) {
		
		if (globalDivObject==null) {
			message = "AJAX ERROR\n"+message;
			window.alert (message);
		} else{
			message = "<strong>AJAX ERROR<br/>"+message+"</strong>";
			globalDivObject.innerHTML = message;
		}
	}
	

function setCookieHP(checked,which){
	var expire = new Date();
	expire.setTime(expire.getTime() + (60*60*24*31*1000));
	if(checked == true){
		document.cookie = 'nome' + '='+which+'' + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
	}else{eraseCooKie(which,expire);}
}

function  eraseCooKie(which,oldEx){
	var expire = new Date();
	expire.setTime(expire.getTime() - (1000*60*60*24));
	document.cookie= 'nome' + '='+which+'' + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
	document.cookie= 'nome' + '=tab1' + ((oldEx == null) ? "" : ("; expires=" + oldEx.toGMTString()));
}

var wtArray = new Array();

wtArray[1] = '/it_IT/hp_dx_clienti_predefinita.html';
wtArray[2] = '/it_IT/hp_dx_media_predefinita.html';
wtArray[3] = '/it_IT/hp_dx_investor_predefinita.html';
wtArray[4] = '/it_IT/hp_dx_lavora_predefinita.html';
var cb = true;

function getCookieHP(){
	if (document.cookie.length > 0) {
		var source = new Array();
		source = document.cookie.split('=');
		var img1t = (document.getElementById("imgtab1"))? document.getElementById("imgtab1"):null;
		//alert(source);
		for(i=0;i<source.length;i++){
			//alert(source[i]);
			if(source[i].indexOf('tab') == 0){
				nTab = source[i].substr(3,1);
				var tWtId = source[i].substr(0,4) + 'wt';
				var wtDiv = (document.getElementById(tWtId))? document.getElementById(tWtId):null;
				var imgWt ='<img alt="" border="0" name="DCSIMG" width="1" height="1" ';
				imgWt+='src="http://sdc.eni.it/dcs67gfdv000000ggn52ira0x_5q6n/dcs.gif?dcssip=www.eni.it&amp;dcsuri='+wtArray[nTab]+'">';
				if(wtDiv){wtDiv.innerHTML = imgWt;wtDiv.style.display = '';}
				//alert(nTab);
				var idImg = 'img' + source[i].substr(0,4);
				//alert(idImg);
				var objImg = document.getElementById(idImg);
				//alert(document.getElementById(idImg));
				//alert(tabc);
				if(objImg){
					m_over(nTab,objImg);
				}cb = false;break
			}else if(img1t){img1t.src="/it_IT/static/images/menu/tab1selected.jpg";}
		}
	}
	if(cb){
		var wtDiv = (document.getElementById('tab1wt'))? document.getElementById('tab1wt'):null;
		var imgWt ='<img alt="" border="0" name="DCSIMG" width="1" height="1" ';
		imgWt +='src="http://sdc.eni.it/dcs67gfdv000000ggn52ira0x_5q6n/dcs.gif?dcssip=www.eni.it&amp;dcsuri='+wtArray[1]+'">';
		if(wtDiv){wtDiv.innerHTML = imgWt;wtDiv.style.display = '';}
	}
}

	// ------------------------------------------------------------------------------------
	// goLogin ()
	// Gestione della login da Home Page
	// ------------------------------------------------------------------------------------
	function goLogin(mode,selection_area) {
		
		// Ricava il nome del sito
		var hostName = location.href;
		hostName = hostName.substring(hostName.indexOf('//')+2);
		hostName = hostName.substring(0,hostName.indexOf('/'));

		// Ricava la locale del sito		
		var locale = location.href;
		locale = locale.substring(locale.indexOf('//')+2);
		locale = locale.substring(locale.indexOf('/')+1);
		locale = locale.substring(0,locale.indexOf('/'));
		
		if (mode) {
			
			//controllo la tipologia di login selezionata per cercare il link di tipo password
			var selectedType = selection_area.options[selection_area.selectedIndex].innerHTML;			
			
			// Nel caso di login di tipo password riscrivo la url altrimenti prendo il valore dalla option
			if (selectedType == 'Password') {
						if (hostName == 'ensv11wr.eni.it:21090') {
							var destination = 'https://st-cbasic.eni.it/up-cns/LoginUp-Consumer.jsp?TARGET2=https://ensv11wr.eni.it:21443/public/redirect.html';
						}
					  else if ((hostName == 'st-eni.eni.it') || (hostName == 'st-eni.eni.com')) {
					  	var destination = 'https://st-cbasic.eni.it/up-cns/LoginUp-Consumer.jsp?TARGET2=https://st-eni.eni.com/public/redirect.html';
					  }
					  else {
					  	var destination = 'https://cbasic.eni.it/up-cns/LoginUp-Consumer.jsp?TARGET2=https://www.eni.com/public/redirect.html';
					  	//var destination = 'https://basic.eni.it/up-password/LoginUp-Password.jsp?TARGET2=https://www.eni.it/public/redirect.html';
					  }
			}
			
			// Ricava dalla combo l'URL di destinazione
			else {
				if (selectedType == 'Dipendenti') {
			     	var destination =  'https://fastlogon.eni.it/Redirector/redirector.aspx?TARGET2=https://www.eni.com/public/redirect.html';
				   }
				else if (selectedType == 'Securid') {	   
				    var destination =  'https://rsa.eni.it/up-rsa/LoginUp-Rsa.jsp?TARGET2=https://www.eni.com/public/redirect.html';
				   } 
			   
			  else {	
			  		if (selectedType == 'Certificate') {		   
				       var destination =  'https://cert.eni.it/up-cert/LoginUp-Cert.jsp?TARGET2=https://www.eni.com/public/redirect.html';
			      } 				
			      else {var destination = selection_area.options[selection_area.selectedIndex].value; }
			    }
			
		   }
		}
		else {
			// L'URL di destinazione viene passata come parametro
			var destination = selection_area;
		}
		
		if (destination!=null) {
			// Genera il Cookie di atterraggio

      	if ((hostName == 'www.eni.it') || (hostName == 'www.eni.com')  || (hostName == 'eni.com')) {
	          var targetAppl = 'https://www.auth.eni.it/'+locale+'/reserved/home-shadow.page';
						}
					  else if ((hostName == 'st-eni.eni.it') || (hostName == 'st-eni.eni.com')) {
					  	var targetAppl = 'https://st-auth.eni.it/'+locale+'/reserved/home-shadow.page';
					  }


			
			var cookieValue = "targetappl="+targetAppl+";path=/"; 
			document.cookie= cookieValue;
		
			parent.location.href = destination;
		}
	}
	
	//login dipendenti
	function goLoginDipendenti(mode,selection_area) {
		
		// Ricava il nome del sito
		var hostName = location.href;
		hostName = hostName.substring(hostName.indexOf('//')+2);
		hostName = hostName.substring(0,hostName.indexOf('/'));

		// Ricava la locale del sito		
		var locale = location.href;
		locale = locale.substring(locale.indexOf('//')+2);
		locale = locale.substring(locale.indexOf('/')+1);
		locale = locale.substring(0,locale.indexOf('/'));
		
		if (document.URL.indexOf('login-it_IT.shtml')!= -1)
			locale = 'it_IT';	
		
		if (document.URL.indexOf('login-en_IT.shtml')!= -1)
			locale = 'en_IT';	
		
	  
	  	if (mode == 'Dipendenti') {
			var destination =  'https://fastlogon.eni.it/Redirector/redirector.aspx?TARGET2=https://www.eni.com/public/redirect.html';
		}
				
		if (destination!=null) {
			// Genera il Cookie di atterraggio

		      	if ((hostName == 'www.eni.it') || (hostName == 'www.eni.com')  || (hostName == 'eni.com')) {
			          var targetAppl = 'https://www.auth.eni.it/'+locale+'/reserved/home-shadow.page';
			}
			else if ((hostName == 'st-eni.eni.it') || (hostName == 'st-eni.eni.com')) {
				var targetAppl = 'https://st-auth.eni.it/'+locale+'/reserved/home-shadow.page';
			}

	
				
			var cookieValue = "targetappl="+targetAppl+";path=/"; 
			document.cookie= cookieValue;
	
			parent.location.href = destination;
		}
	
	}
	
	
	
	
	
	
// Gestione link alla home page: nel caso in cui il protocollo sia HTTPS, 
// i link devono puntare alla home.page e non alla home.html  	
// parametro locale passato direttamente come parametro per gestire anche il cambio lingua
function gotoHomePage(locale,id) {
	var obj = document.getElementById(id);
	if (locale == null || locale == 'undefined' || locale == 'null'){locale ='it_IT';}
	// Ricava il protocollo
	var protocolName = location.href;
	protocolName = protocolName.substring(0,5);
	if (protocolName == 'https') {
		var destination = '/'+locale+'/home.page';
	}else{
		var destination = '/'+locale+'/home.html';
	}
	obj.href = destination;
}

function toSubmit(idM,idY){
	var valueM = document.getElementById(idM).value;
	var valueY = document.getElementById(idY).value;
	if(valueM != '' && valueY == ''){
		alert("ATTENZIONE: Se scegli il mese devi selezionare anche l'anno");
		return false;
	}else{
		document.archivio_form.submit();
	}
}

function setCookieRF(type){
	if(type != ''){
		document.cookie = 'rf-to' + '='+type+'' + '; path=/';
	}
}

function getCookieRF(){
	if (document.cookie.length > 0) {
		var source = new Array();
		source = document.cookie.split(';');
		//alert(source[0]);
		for(i=0;i<source.length;i++){
			if(source[i].indexOf('rf') == 0){
				//alert('ok');
				var rfto = source[i].substr(source[i].indexOf("=")+1);
				//alert(rfto);
				resizeFont(rfto);
			}else if(source[i].charAt(0) == ' ' && source[i].indexOf(' rf') == 0){
				var rfto = source[i].substr(source[i].indexOf("=")+1);
				//alert(rfto);
				resizeFont(rfto);
			}
		}
	}	
}

function changeIMG(that){
	if(that.className == 'exp'){
		that.src = '/it_IT/static/images/minimized.gif';
		that.className = 'min';
	}else{changeClass(that);}
}

function changeClass(that){
	that.className = 'exp';
	that.src = '/it_IT/static/images/expanded.gif';
}

	// ------------------------------------------------------------------------------------
	// Aggiunta js per pagina contatti
	// ------------------------------------------------------------------------------------
function spAccordionByObj(){
	var nElements = 0;
	var accordionElement = Array();
	var animAccordionElement = Array();
	
	this.setElementsCount = setElementsCount;
	this.accordionElement = accordionElement;
	this.switchElement = switchElement;
	this.createElement = createElement;
	this.attachAnimationOpenCloseToElement = attachAnimationOpenCloseToElement;
	

	function switchElement(i){
		//alert(animAccordionElement[i].getObjVisible());
		var okSwitch = true;
		for(var j=0;j<nElements;j++){
			if(animAccordionElement[j].getMoving()){
				okSwitch = false;
			}
		}
		if(okSwitch){
			if(animAccordionElement[i].getObjVisible()){
				animAccordionElement[i].hide();
				//accordionElement[i].setImageToClose();
			}else{
				for(var j=0;j<nElements;j++){
					if(animAccordionElement[j].getObjVisible()){
						animAccordionElement[j].hide();
						//accordionElement[j].setImageToClose();
					}
				}
				animAccordionElement[i].show();
				//accordionElement[i].setImageToOpen();
			}
		}
	}
	function setElementsCount(val){
		nElements = val;
	}
	function createElement(i){
		//alert("fatto");
		accordionElement[i] = new spAccordionElement();
	}
	function attachAnimationOpenCloseToElement(i){
		animAccordionElement[i] = new animationOpenClose();
		animAccordionElement[i].setTargetObj(accordionElement[i].getDivBody());
		//alert("fatto");
	}
	

	function spAccordionElement(){
		var m_divMain = null;
		var m_divTitleBar = null;
		var m_divBody = null;
		var m_openImage = null;
		var m_closeImage = null;
	
		this.divMain = divMain;
		this.divTitleBar = divTitleBar;
		this.divBody = divBody;
		this.getDivBody = getDivBody;
		this.setOpenImage = setOpenImage;
		this.setCloseImage = setCloseImage;
		this.setImageToClose = setImageToClose;
		this.setImageToOpen = setImageToOpen;
				
		function divMain(val){
			m_divMain = val;
		}
		function divTitleBar(val){
			m_divTitleBar = val;
		}
		function divBody(val){
			m_divBody = val;
		}
		function getDivBody(){
			return m_divBody;
		}
		function setOpenImage(val){
			m_openImage = val;
		}
		function setCloseImage(val){
			m_closeImage = val;
		}
		function setImageToClose(){
			m_divTitleBar.style.backgroundImage = m_closeImage;
		}
		function setImageToOpen(){
			m_divTitleBar.style.backgroundImage = m_openImage;
		}
		


	
	}
	
	function animationOpenClose(){
	
		var height = 0;
		var targetHeight = 0;
		var maxHeight = 0;
		var cutSpeed = 15;
		var objVisible = false;
		var moving = false;
		var targetObj = null;
	
		this.setTargetObj = setTargetObj;
		this.show = show;
		this.hide = hide;
		
		this.getObjVisible = getObjVisible;
		this.getMoving = getMoving;
	
		function setTargetObj(val)
		{
			targetObj = val;
			//alert(val.className);
		}
		function getObjVisible(){
			return objVisible;
		}
		function getMoving(){
			return moving;
		}

		
		function show(){
			if(!objVisible){
				targetObj.style.display='block';
				if (maxHeight == 0){
					maxHeight = parseInt(targetObj.offsetHeight);
				}
				height = 0;
				targetObj.style.height = '0px'
				targetHeight = maxHeight;
				objVisible = true;
				moving = true;
				cutInDiv();
			}
		}
		
		function cutInDiv(){
			height += cutSpeed;
			if(height>targetHeight){
				height=targetHeight;
			}
			targetObj.style.height = height+"px";
			if(height<targetHeight){
				setTimeout(cutInDiv,20);
			}else{
				targetObj.style.height = '';
				moving = false;
			}
		}
		
		
		function hide(){
			height = parseInt(targetObj.offsetHeight)
			maxHeight = height;
			targetHeight=0;
			cutOutDiv();
		}
		
		function cutOutDiv(){
			height -= cutSpeed;
			if(height<targetHeight){
				height=targetHeight;
			}
			targetObj.style.height = height+"px";;
			if(height>targetHeight){
				setTimeout(cutOutDiv,20);
			}else{
				//divObj.style.display="none";
				objVisible = false;
				moving = false;
			}
		}
		
		
	
	}



}

//--------------------------------------------------------
var accordionMappaBox = new spAccordionByObj();	
var nextElementCount = 0;

function isKnownElement(obj){
	var isK = 0;
	for(var j=0;j<nextElementCount;j++){
		if(obj == accordionMappaBox.accordionElement[j].getDivBody()){
			isK = j+1;
		}
	}
	return isK;
}

function clickMappa(objLink){
	divMappaObj = 0;
	var o = objLink;
	while(o.className!='box_landing_in'){
		o=o.parentNode;
	}
	for(var j=0;j<o.childNodes.length;j++){
		if(o.childNodes[j].className=="mappa"){
			divMappaObj = o.childNodes[j];
		}
	}
		
	var elem = isKnownElement(divMappaObj);
	if(elem==0){
		//alert(nextElementCount);
		accordionMappaBox.createElement(nextElementCount);
		accordionMappaBox.accordionElement[nextElementCount].divBody(divMappaObj);
		accordionMappaBox.attachAnimationOpenCloseToElement(nextElementCount);
		nextElementCount++;
		accordionMappaBox.setElementsCount(nextElementCount);
		elem = nextElementCount;
	}
	//alert(elem);
	accordionMappaBox.switchElement(elem-1);
}

// silvana foto gallery
var hs = {

// Apply your own settings here, or override them in the html file.  
graphicsDir : '/attachments/images/highslide/graphics/',
restoreCursor : 'zoomout.cur', // necessary for preload
expandSteps : 10, // number of steps in zoom. Each step lasts for duration/step milliseconds.
expandDuration : 250, // milliseconds
restoreSteps : 10,
restoreDuration : 250,
marginLeft : 15,
marginRight : 15,
marginTop : 15,
marginBottom : 15,
zIndexCounter : 2001, // adjust to other absolutely positioned elements

restoreTitle : "Clicca per chiudere l'mmagine, clicca e trascina per spostare. Usare tasti direzionali per successivo e precedente.",
loadingText : 'Loading...',
loadingTitle : 'Clicca to cancel',
loadingOpacity : 0.75,
focusTitle : 'Clicca per portare in primo piano',
allowMultipleInstances: true,
numberOfImagesToPreload : 5,
captionSlideSpeed : 1, // set to 0 to disable slide in effect
padToMinWidth : false, // pad the popup width to make room for wide caption
outlineWhileAnimating : 2, // 0 = never, 1 = always, 2 = HTML only 
outlineStartOffset : 3, // ends at 10
fullExpandTitle : 'Espandi alla dimensione reale',
fullExpandPosition : 'bottom right',
fullExpandOpacity : 1,
showCredits : false, // you can set this to false if you want
creditsText : '',
creditsHref : '',
creditsTitle : '',
enableKeyListener : true,


// These settings can also be overridden inline for each image
captionId : null,
spaceForCaption : 30, // leaves space below images with captions
slideshowGroup : null, // defines groups for next/previous links and keystrokes
minWidth: 200,
minHeight: 200,
allowSizeReduction: true, // allow the image to reduce to fit client size. If false, this overrides minWidth and minHeight
outlineType : 'drop-shadow', // set null to disable outlines
wrapperClassName : 'highslide-wrapper', // for enhanced css-control

// END OF YOUR SETTINGS


// declare internal properties
preloadTheseImages : [],
continuePreloading: true,
expanders : [],
overrides : [
	'allowSizeReduction',
	'outlineType',
	'outlineWhileAnimating',
	'spaceForCaption',
	'captionId',
	'captionText',
	'captionEval',
	
	'wrapperClassName',
	'minWidth',
	'minHeight',
	'slideshowGroup',
	'easing',
	'easingClose',
	'fadeInOut'
],
overlays : [],
faders : [],

pendingOutlines : {},
clones : {},
ie : (document.all && !window.opera),
safari : /Safari/.test(navigator.userAgent),
geckoMac : /Macintosh.+rv:1\.[0-8].+Gecko/.test(navigator.userAgent),

$ : function (id) {
	return document.getElementById(id);
},

push : function (arr, val) {
	arr[arr.length] = val;
},

createElement : function (tag, attribs, styles, parent, nopad) {
	var el = document.createElement(tag);
	if (attribs) hs.setAttribs(el, attribs);
	if (nopad) hs.setStyles(el, {padding: 0, border: 'none', margin: 0});
	if (styles) hs.setStyles(el, styles);
	if (parent) parent.appendChild(el);	
	return el;
},

setAttribs : function (el, attribs) {
	for (var x in attribs) el[x] = attribs[x];
},

setStyles : function (el, styles) {
	for (var x in styles) {
		try { 
			if (hs.ie && x == 'opacity') 
				el.style.filter = (styles[x] == 1) ? '' : 'alpha(opacity='+ (styles[x] * 100) +')';
			else el.style[x] = styles[x]; 
		}
		catch (e) {}
	}
},

ieVersion : function () {
	var arr = navigator.appVersion.split("MSIE");
	return arr[1] ? parseFloat(arr[1]) : null;
},

getPageSize : function () {
	var iebody = document.compatMode && document.compatMode != "BackCompat" 
		? document.documentElement : document.body;
	
	var width = hs.ie ? iebody.clientWidth : 
			(document.documentElement.clientWidth || self.innerWidth),
		height = hs.ie ? iebody.clientHeight : self.innerHeight;
	
	return {
		width: width,
		height: height,		
		scrollLeft: hs.ie ? iebody.scrollLeft : pageXOffset,
		scrollTop: hs.ie ? iebody.scrollTop : pageYOffset
	}
},

position : function(el)	{ 
	var p = { x: el.offsetLeft, y: el.offsetTop };
	while (el.offsetParent)	{
		el = el.offsetParent;
		p.x += el.offsetLeft;
		p.y += el.offsetTop;
		if (el != document.body && el != document.documentElement) {
			p.x -= el.scrollLeft;
			p.y -= el.scrollTop;
		}
	}
	return p;
},

expand : function(a, params, custom) {
	if (a.getParams) return params;
	
	try {
		new hs.Expander(a, params, custom);
		return false;		
	} catch (e) { return true; }
},

focusTopmost : function() {
	var topZ = 0, topmostKey = -1;
	for (var i = 0; i < hs.expanders.length; i++) {
		if (hs.expanders[i]) {
			if (hs.expanders[i].wrapper.style.zIndex && hs.expanders[i].wrapper.style.zIndex > topZ) {
				topZ = hs.expanders[i].wrapper.style.zIndex;
				
				topmostKey = i;
			}
		}
	}
	if (topmostKey == -1) hs.focusKey = -1;
	else hs.expanders[topmostKey].focus();
},

getAdjacentAnchor : function(key, op) {
	var aAr = document.getElementsByTagName('A'), hsAr = {}, activeI = -1, j = 0;
	for (var i = 0; i < aAr.length; i++) {
		if (hs.isHsAnchor(aAr[i]) && ((hs.expanders[key].slideshowGroup 
				== hs.getParam(aAr[i], 'slideshowGroup')))) {
			hsAr[j] = aAr[i];
			if (hs.expanders[key] && aAr[i] == hs.expanders[key].a) {
				activeI = j;
			}
			j++;
		}
	}
	return hsAr[activeI + op] || null;
},

getParam : function (a, param) {
	a.getParams = a.onclick;
	var p = a.getParams ? a.getParams() : null;
	a.getParams = null;
	
	return (p && typeof p[param] != 'undefined') ? p[param] : 
		(typeof hs[param] != 'undefined' ? hs[param] : null);
},

getSrc : function (a) {
	var src = hs.getParam(a, 'src');
	if (src) return src;
	return a.href;
},

getNode : function (id) {
	var node = hs.$(id), clone = hs.clones[id], a = {};
	if (!node && !clone) return null;
	if (!clone) {
		clone = node.cloneNode(true);
		clone.id = '';
		hs.clones[id] = clone;
		return node;
	} else {
		return clone.cloneNode(true);
	}
},

purge : function(d) {
	if (!hs.ie) return;
	var a = d.attributes, i, l, n;
	if (a) {
		l = a.length;
		for (var i = 0; i < l; i += 1) {
			n = a[i].name;
			if (typeof d[n] === 'function') {
				d[n] = null;
			}
		}
	}
	a = d.childNodes;
	if (a) {
		l = a.length;
		for (var i = 0; i < l; i += 1) {
			hs.purge(d.childNodes[i]);
		}
	}
},

previousOrNext : function (el, op) {
	var exp = hs.last = hs.getExpander(el);
	try {
		var adj = hs.upcoming =  hs.getAdjacentAnchor(exp.key, op);
		adj.onclick(); 		
	} catch (e){}
	try { exp.close(); } catch (e) {}	
	return false;
},

previous : function (el) {
	return hs.previousOrNext(el, -1);
},

next : function (el) {
	return hs.previousOrNext(el, 1);	
},

keyHandler : function(e) {
	if (!e) e = window.event;
	if (!e.target) e.target = e.srcElement; // ie
	if (e.target.form) return true; // form element has focus
	
	var op = null;
	switch (e.keyCode) {
		case 32: // Space
		case 34: // Page Down
		case 39: // Arrow right
		case 40: // Arrow down
			op = 1;
			break;
		case 8:  // Backspace
		case 33: // Page Up
		case 37: // Arrow left
		case 38: // Arrow up
			op = -1;
			break;
		case 27: // Escape
		case 13: // Enter
			op = 0;
	}
	if (op !== null) {
		hs.removeEventListener(document, 'keydown', hs.keyHandler);
		if (!hs.enableKeyListener) return true;
		
		if (e.preventDefault) e.preventDefault();
    	else e.returnValue = false;
		if (op == 0) {
			try { hs.getExpander().close(); } catch (e) {}
			return false;
		} else {
			return hs.previousOrNext(hs.focusKey, op);
		}
	}
	return true;
},


registerOverlay : function (overlay) {
	hs.push(hs.overlays, overlay);
},

getWrapperKey : function (element) {
	var el, re = /^highslide-wrapper-([0-9]+)$/;
	// 1. look in open expanders
	el = element;
	while (el.parentNode)	{
		if (el.id && re.test(el.id)) return el.id.replace(re, "$1");
		el = el.parentNode;
	}
	// 2. look in thumbnail
	el = element;
	while (el.parentNode)	{
		if (el.tagName && hs.isHsAnchor(el)) {
			for (var key = 0; key < hs.expanders.length; key++) {
				var exp = hs.expanders[key];
				if (exp && exp.a == el) return key;
			}
		}
		el = el.parentNode;
	}
	return null; 
},

getExpander : function (el) {
	if (typeof el == 'undefined') return hs.expanders[hs.focusKey] || null;
	if (typeof el == 'number') return hs.expanders[el] || null;
	if (typeof el == 'string') el = hs.$(el);
	return hs.expanders[hs.getWrapperKey(el)] || null;
},

isHsAnchor : function (a) {
	return (a.onclick && a.onclick.toString().replace(/\s/g, ' ').match(/hs.(htmlE|e)xpand/));
},

cleanUp : function () {
	for (var i = 0; i < hs.expanders.length; i++)
		if (hs.expanders[i] && hs.expanders[i].isExpanded) hs.focusTopmost();
},

mouseClickHandler : function(e) 
{	
	if (!e) e = window.event;
	if (e.button > 1) return true;
	if (!e.target) e.target = e.srcElement;
	
	var el = e.target;
	while (el.parentNode
		&& !(/highslide-(image|move|html|resize)/.test(el.className)))
	{
		el = el.parentNode;
	}
	var exp = hs.getExpander(el);
	if (exp && (exp.isClosing || !exp.isExpanded)) return true;
		
	if (exp && e.type == 'mousedown') {
		if (e.target.form) return true;
		var match = el.className.match(/highslide-(image|move|resize)/);
		if (match) {
			hs.dragArgs = { exp: exp , type: match[1], left: exp.x.min, width: exp.x.span, top: exp.y.min, 
				height: exp.y.span, clickX: e.clientX, clickY: e.clientY };
			
			//if (hs.dragArgs.type == 'image') exp.content.style.cursor = 'move';
			
			hs.addEventListener(document, 'mousemove', hs.dragHandler);
			if (e.preventDefault) e.preventDefault(); // FF
			
			if (/highslide-(image|html)-blur/.test(exp.content.className)) {
				exp.focus();
				hs.hasFocused = true;
			}
			return false;
		}
	} else if (e.type == 'mouseup') {
		
		hs.removeEventListener(document, 'mousemove', hs.dragHandler);
		
		if (hs.dragArgs) {
			if (hs.dragArgs.type == 'image')
				hs.dragArgs.exp.content.style.cursor = hs.styleRestoreCursor;
			var hasDragged = hs.dragArgs.hasDragged;
			
			if (!hasDragged &&!hs.hasFocused && !/(move|resize)/.test(hs.dragArgs.type)) {
				exp.close();
			} 
			else if (hasDragged || (!hasDragged && hs.hasHtmlexpanders)) {
				hs.dragArgs.exp.redoShowHide();
			}
			
			hs.hasFocused = false;
			hs.dragArgs = null;
		
		} else if (/highslide-image-blur/.test(el.className)) {
			el.style.cursor = hs.styleRestoreCursor;		
		}
	}
	return false;
},

dragHandler : function(e)
{
	if (!hs.dragArgs) return true;
	if (!e) e = window.event;
	var a = hs.dragArgs, exp = a.exp;
	
	a.dX = e.clientX - a.clickX;
	a.dY = e.clientY - a.clickY;	
	
	var distance = Math.sqrt(Math.pow(a.dX, 2) + Math.pow(a.dY, 2));
	a.hasDragged = (a.type != 'image' && distance > 0)
		|| (distance > (hs.dragSensitivity || 5));
	
	if (a.hasDragged) {
		 exp.move(a);
	}
	return false;
},

addEventListener : function (el, event, func) {
	try {
		el.addEventListener(event, func, false);
	} catch (e) {
		try {
			el.detachEvent('on'+ event, func);
			el.attachEvent('on'+ event, func);
		} catch (e) {
			el['on'+ event] = func;
		}
	} 
},

removeEventListener : function (el, event, func) {
	try {
		el.removeEventListener(event, func, false);
	} catch (e) {
		try {
			el.detachEvent('on'+ event, func);
		} catch (e) {
			el['on'+ event] = null;
		}
	}
},

preloadFullImage : function (i) {
	if (hs.continuePreloading && hs.preloadTheseImages[i] && hs.preloadTheseImages[i] != 'undefined') {
		var img = document.createElement('img');
		img.onload = function() { hs.preloadFullImage(i + 1); };
		img.src = hs.preloadTheseImages[i];
	}
},
preloadImages : function (number) {
	if (number && typeof number != 'object') hs.numberOfImagesToPreload = number;
	var a, re, j = 0;
	
	var aTags = document.getElementsByTagName('A');
	for (var i = 0; i < aTags.length; i++) {
		a = aTags[i];
		re = hs.isHsAnchor(a);
		if (re && re[0] == 'hs.expand') {
			if (j < hs.numberOfImagesToPreload) {
				hs.preloadTheseImages[j] = hs.getSrc(a); 
				j++;
			}
		}
	}
	
	// preload outlines
	new hs.Outline(hs.outlineType, function () { hs.preloadFullImage(0)} );
	
	
	// preload cursor
	var cur = hs.createElement('img', { src: hs.graphicsDir + hs.restoreCursor });
},


genContainer : function () {
	if (!hs.container) {
		hs.container = hs.createElement('div', 
			null, 
			{ position: 'absolute', left: 0, top: 0, width: '100%', zIndex: hs.zIndexCounter }, 
			document.body,
			true
		);
		hs.loading = hs.createElement('a',
			{
				className: 'highslide-loading',
				title: hs.loadingTitle,
				innerHTML: hs.loadingText,
				href: 'javascript:void(0)'
			},
			{
				position: 'absolute',
				opacity: hs.loadingOpacity,
				left: '-9999px',
				zIndex: 1
			}, hs.container
		);
		
		// http://www.robertpenner.com/easing/ 
		Math.linearTween = function (t, b, c, d) {
			return c*t/d + b;
		};
		Math.easeInQuad = function (t, b, c, d) {
			return c*(t/=d)*t + b;
		};
	}
},

fade : function (el, o, oFinal, dur, i, dir) {
	if (typeof i == 'undefined') { // new fader
		if (typeof dur != 'number') dur = 250;
		if (dur < 25) { // instant
			hs.setStyles( el, {
				opacity: oFinal,
				visibility: (o < oFinal ? 'visible': 'hidden')
			});
			return;
		}
		i = hs.faders.length;
		dir = oFinal > o ? 1 : -1;
		var step = (25 / (dur - dur % 25)) * Math.abs(o - oFinal);
	}
	o = parseFloat(o);
	el.style.visibility = (o <= 0) ? 'hidden' : 'visible';
	if (o < 0 || (dir == 1 && o > oFinal)) return;
	if (el.fading && el.fading.i != i) { // reverse
		clearTimeout(hs.faders[el.fading.i]);
		o = el.fading.o;
	}
	el.fading = {i: i, o: o, step: (step || el.fading.step)};
	el.style.visibility = (o <= 0) ? 'hidden' : 'visible';
	hs.setStyles(el, { opacity: o });
	hs.faders[i] = setTimeout(function() {
		hs.fade(el, o + el.fading.step * dir, oFinal, null, i, dir);
	}, 25);
},

close : function(el) {
	try { hs.getExpander(el).close(); } catch (e) {}
	return false;
}
}; // end hs object


//-----------------------------------------------------------------------------
hs.Outline =  function (outlineType, onLoad) {
	this.onLoad = onLoad;
	this.outlineType = outlineType;
	var v = hs.ieVersion(), tr;
	
	this.hasAlphaImageLoader = hs.ie && v >= 5.5 && v < 7;
	if (!outlineType) {
		if (onLoad) onLoad();
		return;
	}
	
	hs.genContainer();
	this.table = hs.createElement(
		'table', { cellSpacing: 0 },
		{
			visibility: 'hidden',
			position: 'absolute',
			borderCollapse: 'collapse'
		},
		hs.container,
		true
	);
	this.tbody = hs.createElement('tbody', null, null, this.table, 1);
	
	this.td = [];
	for (var i = 0; i <= 8; i++) {
		if (i % 3 == 0) tr = hs.createElement('tr', null, { height: 'auto' }, this.tbody, true);
		this.td[i] = hs.createElement('td', null, null, tr, true);
		var style = i != 4 ? { lineHeight: 0, fontSize: 0} : { position : 'relative' };
		hs.setStyles(this.td[i], style);
	}
	this.td[4].className = outlineType;
	
	this.preloadGraphic(); 
};

hs.Outline.prototype = {
preloadGraphic : function () {	
	var src = hs.graphicsDir + (hs.outlinesDir || "outlines/")+ this.outlineType +".png";
				
	var appendTo = hs.safari ? hs.container : null;
	this.graphic = hs.createElement('img', null, { position: 'absolute', left: '-9999px', 
		top: '-9999px' }, appendTo, true); // for onload trigger
	
	var pThis = this;
	this.graphic.onload = function() { pThis.onGraphicLoad(); };
	
	this.graphic.src = src;
},

onGraphicLoad : function () {
	var o = this.offset = this.graphic.width / 4,
		pos = [[0,0],[0,-4],[-2,0],[0,-8],0,[-2,-8],[0,-2],[0,-6],[-2,-2]],
		dim = { height: (2*o) +'px', width: (2*o) +'px' };
		
	for (var i = 0; i <= 8; i++) {
		if (pos[i]) {
			if (this.hasAlphaImageLoader) {
				var w = (i == 1 || i == 7) ? '100%' : this.graphic.width +'px';
				var div = hs.createElement('div', null, { width: '100%', height: '100%', position: 'relative', overflow: 'hidden'}, this.td[i], true);
				hs.createElement ('div', null, { 
						filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale, src='"+ this.graphic.src + "')", 
						position: 'absolute',
						width: w, 
						height: this.graphic.height +'px',
						left: (pos[i][0]*o)+'px',
						top: (pos[i][1]*o)+'px'
					}, 
				div,
				true);
			} else {
				hs.setStyles(this.td[i], { background: 'url('+ this.graphic.src +') '+ (pos[i][0]*o)+'px '+(pos[i][1]*o)+'px'});
			}
			
			if (window.opera && (i == 3 || i ==5)) 
				hs.createElement('div', null, dim, this.td[i], true);
			
			hs.setStyles (this.td[i], dim);
		}
	}
	
	hs.pendingOutlines[this.outlineType] = this;
	if (this.onLoad) this.onLoad();
},
	
setPosition : function (exp, x, y, w, h, vis) {
	if (vis) this.table.style.visibility = (h >= 4 * this.offset) 
		? 'visible' : 'hidden';
	this.table.style.left = (x - this.offset) +'px';
	this.table.style.top = (y - this.offset) +'px';
	this.table.style.width = (w + 2 * (exp.offsetBorderW + this.offset)) +'px';
	w += 2 * (exp.offsetBorderW - this.offset);
	h += + 2 * (exp.offsetBorderH - this.offset);
	this.td[4].style.width = w >= 0 ? w +'px' : 0;
	this.td[4].style.height = h >= 0 ? h +'px' : 0;
	if (this.hasAlphaImageLoader) this.td[3].style.height 
		= this.td[5].style.height = this.td[4].style.height;
},
	
destroy : function(hide) {
	if (hide) this.table.style.visibility = 'hidden';
	else {
		hs.purge(this.table);
		try { this.table.parentNode.removeChild(this.table); } catch (e) {}
	}
}
};

//-----------------------------------------------------------------------------
// The expander object
hs.Expander = function(a, params, custom, contentType) {
	this.a = a;
	this.custom = custom;
	this.contentType = contentType || 'image';
	this.isImage = !this.isHtml;
	
	hs.continuePreloading = false;
	hs.genContainer();
	var key = this.key = hs.expanders.length;
	
	// override inline parameters
	for (var i = 0; i < hs.overrides.length; i++) {
		var name = hs.overrides[i];
		this[name] = params && typeof params[name] != 'undefined' ?
			params[name] : hs[name];
	}
	
	// get thumb
	var el = this.thumb = ((params && params.thumbnailId) ? hs.$(params.thumbnailId) : null) 
		|| a.getElementsByTagName('img')[0] || a;
	this.thumbsUserSetId = el.id || a.id;
	
	// check if already open
	for (var i = 0; i < hs.expanders.length; i++) {
		if (hs.expanders[i] && hs.expanders[i].a == a) {
			hs.expanders[i].focus();
			return false;
		}		
	}	
	// cancel other
	for (var i = 0; i < hs.expanders.length; i++) {
		if (hs.expanders[i] && hs.expanders[i].thumb != el && !hs.expanders[i].onLoadStarted) {
			hs.expanders[i].cancelLoading();
		}
	}
	hs.expanders[this.key] = this;
	if (!hs.allowMultipleInstances) {
		if (hs.expanders[key-1]) hs.expanders[key-1].close();
		if (typeof hs.focusKey != 'undefined' && hs.expanders[hs.focusKey])
			hs.expanders[hs.focusKey].close();
	}
	this.overlays = [];

	var pos = hs.position(el);
	
	// store properties of thumbnail
	this.thumbWidth = el.width ? el.width : el.offsetWidth;		
	this.thumbHeight = el.height ? el.height : el.offsetHeight;
	this.thumbLeft = pos.x;
	this.thumbTop = pos.y;
	this.thumbOffsetBorderW = (this.thumb.offsetWidth - this.thumbWidth) / 2;
	this.thumbOffsetBorderH = (this.thumb.offsetHeight - this.thumbHeight) / 2;
	
	// instanciate the wrapper
	this.wrapper = hs.createElement(
		'div',
		{
			id: 'highslide-wrapper-'+ this.key,
			className: this.wrapperClassName
		},
		{
			visibility: 'hidden',
			position: 'absolute',
			zIndex: hs.zIndexCounter++
		}, null, true );
	
	this.wrapper.onmouseover = function (e) { 
		try { hs.expanders[key].wrapperMouseHandler(e); } catch (e) {} 
	};
	this.wrapper.onmouseout = function (e) { 
		try { hs.expanders[key].wrapperMouseHandler(e); } catch (e) {}
	};
	if (this.contentType == 'image' && this.outlineWhileAnimating == 2)
		this.outlineWhileAnimating = 0;
	// get the outline
	if (hs.pendingOutlines[this.outlineType]) {
		this.connectOutline();
		this[this.contentType +'Create']();
	} else if (!this.outlineType) {
		this[this.contentType +'Create']();
	} else {
		this.displayLoading();
		var exp = this;
		new hs.Outline(this.outlineType, 
			function () { 
				exp.connectOutline();
				exp[exp.contentType +'Create']();
			} 
		);
	}
	return true;
};

hs.Expander.prototype = {

connectOutline : function(x, y) {	
	var w = hs.pendingOutlines[this.outlineType];
	this.objOutline = w;
	w.table.style.zIndex = this.wrapper.style.zIndex;
	hs.pendingOutlines[this.outlineType] = null;
},

displayLoading : function() {
	if (this.onLoadStarted || this.loading) return;
		
	this.originalCursor = this.a.style.cursor;
	this.a.style.cursor = 'wait';
	
	this.loading = hs.loading;
	var exp = this;
	this.loading.onclick = function() {
		exp.cancelLoading();
	};
	this.loading.style.top = (this.thumbTop 
		+ (this.thumbHeight - this.loading.offsetHeight) / 2) +'px';
	var exp = this, left = (this.thumbLeft + this.thumbOffsetBorderW 
		+ (this.thumbWidth - this.loading.offsetWidth) / 2) +'px';
	setTimeout(function () { if (exp.loading) exp.loading.style.left = left }, 100); 
},

imageCreate : function() {
	var exp = this;
	
	var img = document.createElement('img');
    this.content = img;
    img.onload = function () {
    	if (hs.expanders[exp.key]) exp.contentLoaded(); 
	};
    if (hs.blockRightClick) img.oncontextmenu = function() { return false; };
    img.className = 'highslide-image';
    img.style.visibility = 'hidden'; // prevent flickering in IE
    img.style.display = 'block';
	img.style.position = 'absolute';
	img.style.maxWidth = 'none';
    img.style.zIndex = 3;
    img.title = hs.restoreTitle;
    if (hs.safari) hs.container.appendChild(img);
    if (hs.ie && hs.flushImgSize) img.src = null;
	img.src = hs.getSrc(this.a);
	
	this.displayLoading();
},

contentLoaded : function() {
	try {	
		if (!this.content) return;
		if (this.onLoadStarted) return; // old Gecko loop
		else this.onLoadStarted = true;
		
			   
		if (this.loading) {
			this.loading.style.left = '-9999px';
			this.loading = null;
			this.a.style.cursor = this.originalCursor || '';
		}
		this.marginBottom = hs.marginBottom;	
			this.newWidth = this.content.width;
			this.newHeight = this.content.height;
			this.fullExpandWidth = this.newWidth;
			this.fullExpandHeight = this.newHeight;
			
			this.content.style.width = this.thumbWidth +'px';
			this.content.style.height = this.thumbHeight +'px';
			this.getCaption();	
		
		
		this.wrapper.appendChild(this.content);
		this.content.style.position = 'relative'; // Saf
		if (this.caption) this.wrapper.appendChild(this.caption);
		this.wrapper.style.left = this.thumbLeft +'px';
		this.wrapper.style.top = this.thumbTop +'px';
		hs.container.appendChild(this.wrapper);
		
		// correct for borders
		this.offsetBorderW = (this.content.offsetWidth - this.thumbWidth) / 2;
		this.offsetBorderH = (this.content.offsetHeight - this.thumbHeight) / 2;
		var modMarginRight = hs.marginRight + 2 * this.offsetBorderW;
		this.marginBottom += 2 * this.offsetBorderH;
		
		var ratio = this.newWidth / this.newHeight;
		var minWidth = this.allowSizeReduction 
			? this.minWidth : this.newWidth;
		var minHeight = this.allowSizeReduction 
			? this.minHeight : this.newHeight;
		
		var justify = { x: 'auto', y: 'auto' };
		
		var page = hs.getPageSize();
		// justify
		this.x = { 
			min: parseInt(this.thumbLeft) - this.offsetBorderW + this.thumbOffsetBorderW,
			span: this.newWidth,
			minSpan: (this.newWidth < minWidth && !hs.padToMinWidth) 
				? this.newWidth : minWidth,
			marginMin: hs.marginLeft, 
			marginMax: modMarginRight,
			scroll: page.scrollLeft,
			clientSpan: page.width,
			thumbSpan: this.thumbWidth
		};
		var oldRight = this.x.min + parseInt(this.thumbWidth);
		this.x = this.justify(this.x);
		this.y = { 
			min: parseInt(this.thumbTop) - this.offsetBorderH + this.thumbOffsetBorderH,
			span: this.newHeight,
			minSpan: this.newHeight < minHeight ? this.newHeight : minHeight,
			marginMin: hs.marginTop, 
			marginMax: this.marginBottom, 
			scroll: page.scrollTop,
			clientSpan: page.height,
			thumbSpan: this.thumbHeight
		};
		var oldBottom = this.y.min + parseInt(this.thumbHeight);
		this.y = this.justify(this.y);
		
			this.correctRatio(ratio);
		

		var x = this.x;
		var y = this.y;
		
		this.show();
	} catch (e) {
		parent.location.href = hs.getSrc(this.a);
	}
},

justify : function (p) {
	
	var tgt, dim = p == this.x ? 'x' : 'y';
	
	
		var hasMovedMin = false;
		
		var allowReduce = true;
		
		// calculate p.min
		p.min = Math.round(p.min - ((p.span - p.thumbSpan) / 2)); // auto
		
		if (p.min < p.scroll + p.marginMin) {
			p.min = p.scroll + p.marginMin;
			hasMovedMin = true;		
		}
	
		
		if (p.span < p.minSpan) {
			p.span = p.minSpan;
			allowReduce = false;			
		}
		
		// calculate right/newWidth
		if (p.min + p.span > p.scroll + p.clientSpan - p.marginMax) {
			if (hasMovedMin && allowReduce) {
				
				p.span = p.clientSpan - p.marginMin - p.marginMax; // can't expand more
				
			} else if (p.span < p.clientSpan - p.marginMin - p.marginMax) { // move newTop up
				p.min = p.scroll + p.clientSpan - p.span - p.marginMin - p.marginMax;
			} else { // image larger than client
				p.min = p.scroll + p.marginMin;
				
				if (allowReduce) p.span = p.clientSpan - p.marginMin - p.marginMax;
				
			}
			
		}
		
		if (p.span < p.minSpan) {
			p.span = p.minSpan;
			allowReduce = false;
		}
		
	
		
	if (p.min < p.marginMin) {
		tmpMin = p.min;
		p.min = p.marginMin; 
		
		if (allowReduce) p.span = p.span - (p.min - tmpMin);
		
	}
	return p;
},

correctRatio : function(ratio) {
	var x = this.x;
	var y = this.y;
	var changed = false;
	if (x.span / y.span > ratio) { // width greater
		var tmpWidth = x.span;
		x.span = y.span * ratio;
		if (x.span < x.minSpan) { // below minWidth
			if (hs.padToMinWidth) x.imgSpan = x.span;			
			x.span = x.minSpan;
			if (!x.imgSpan)
			y.span = x.span / ratio;
		}
		changed = true;
	
	} else if (x.span / y.span < ratio) { // height greater
		var tmpHeight = y.span;
		y.span = x.span / ratio;
		changed = true;
	}
	
	if (changed) {
		x.min = parseInt(this.thumbLeft) - this.offsetBorderW + this.thumbOffsetBorderW;
		x.minSpan = x.span;
		this.x = this.justify(x);
		
		y.min = parseInt(this.thumbTop) - this.offsetBorderH + this.thumbOffsetBorderH;
		y.minSpan = y.span;
		this.y = this.justify(y);
	}
},

show : function () {
	
	// Selectbox bug
	var imgPos = {x: this.x.min - 20, y: this.y.min - 20, w: this.x.span + 40, 
		h: this.y.span + 40
		 + this.spaceForCaption};
	hs.hideSelects = (hs.ie && hs.ieVersion() < 7);
	if (hs.hideSelects) this.showHideElements('SELECT', 'hidden', imgPos);
	// Iframes bug
	hs.hideIframes = ((window.opera && navigator.appVersion < 9) || navigator.vendor == 'KDE' 
		|| (hs.ie && hs.ieVersion() < 5.5));
	if (hs.hideIframes) this.showHideElements('IFRAME', 'hidden', imgPos);
	// Scrollbars bug
	if (hs.geckoMac) this.showHideElements('*', 'hidden', imgPos); 
	
	
	if (this.x.imgSpan) this.content.style.margin = '0 auto';
	
	// Apply size change		
	this.changeSize(
		1,
		{ 
			x: this.thumbLeft + this.thumbOffsetBorderW - this.offsetBorderW,
			y: this.thumbTop + this.thumbOffsetBorderH - this.offsetBorderH,
			w: this.thumbWidth,
			h: this.thumbHeight,
			imgW: this.thumbWidth,
			o: hs.outlineStartOffset
		},
		{
			x: this.x.min,
			y: this.y.min,
			w: this.x.span,
			h: this.y.span,
			imgW: this.x.imgSpan,
			o: this.objOutline ? this.objOutline.offset : 0
		},
		hs.expandDuration,
		hs.expandSteps
	);
},

changeSize : function(up, from, to, dur, steps) {
	
	if (up && this.objOutline && !this.outlineWhileAnimating) 
		this.objOutline.setPosition(this, this.x.min, this.y.min, this.x.span, this.y.span);
	
	else if (!up && this.objOutline) {
		if (this.outlineWhileAnimating) this.objOutline.setPosition(this, from.x, from.y, from.w, from.h);
		else this.objOutline.destroy();
	}	
			
	if (!up) { // remove children
		var n = this.wrapper.childNodes.length;
		for (var i = n - 1; i >= 0 ; i--) {
			var child = this.wrapper.childNodes[i];
			if (child != this.content) {
				hs.purge(child);
				this.wrapper.removeChild(child);
			}
		}
	}
		
	if (this.fadeInOut) {
		from.op = up ? 0 : 1;
		to.op = up;
	}
	var t,
	exp = this,
	easing = Math[this.easing] || Math.easeInQuad;
	if (!up) easing = Math[this.easingClose] || easing;
	
	for (var i = 1; i <= steps; i++) {
		t = Math.round(i * (dur / steps));
		
		(function(){
			var pI = i, size = {};
			
			for (var x in from) 
				size[x] = easing(t, from[x], to[x] - from[x], dur);
						
			setTimeout ( function() {
				if (up && pI == 1) {
					exp.content.style.visibility = 'visible';
					exp.a.className += ' highslide-active-anchor';
				}
				exp.setSize(size);
			}, t);				
		})();		
	}
	
	if (up) { 
			
		setTimeout(function() {
			if (exp.objOutline) exp.objOutline.table.style.visibility = "visible";
		}, t);
		setTimeout(function() {
			if (exp.caption) exp.writeCaption();
			exp.afterExpand();
		}, t + 50);
	}
	else setTimeout(function() { exp.afterClose(); }, t);
		
},

setSize : function (to) {
	try {
			this.wrapper.style.width = (to.w + 2*this.offsetBorderW) +'px';
			this.content.style.width =
				((to.imgW && !isNaN(to.imgW)) ? to.imgW : to.w) +'px';
			if (hs.safari) this.content.style.maxWidth = this.content.style.width;
			this.content.style.height = to.h +'px';
		
		if (to.op) hs.setStyles(this.wrapper, { opacity: to.op });
				
		
		if (this.objOutline && this.outlineWhileAnimating) {
			var o = this.objOutline.offset - to.o;
			this.objOutline.setPosition(this, to.x + o, to.y + o, to.w - 2 * o, to.h - 2 * o, 1);
		}
				
		hs.setStyles ( this.wrapper,
			{
				'visibility': 'visible',
				'left': to.x +'px',
				'top': to.y +'px'
			}
		);
		
	} catch (e) { parent.location.href = hs.getSrc(this.a);	}
},

afterExpand : function() {
	this.isExpanded = true;	
	this.focus();
	
	this.createOverlays();
	if (hs.showCredits) this.writeCredits();
	if (this.isImage && this.fullExpandWidth > this.x.span) this.createFullExpand();
	if (!this.caption) this.prepareNextOutline();
},


prepareNextOutline : function() {
	var key = this.key;
	var outlineType = this.outlineType;
	new hs.Outline(outlineType, 
		function () { try { hs.expanders[key].preloadNext(); } catch (e) {} });
},


preloadNext : function() {
	var next = hs.getAdjacentAnchor(this.key, 1);	
	if (next.onclick.toString().match(/hs\.expand/)) 
		var img = hs.createElement('img', { src: hs.getSrc(next) });
},

cancelLoading : function() {	
	hs.expanders[this.key] = null;
	this.a.style.cursor = this.originalCursor;	
	if (this.loading) hs.loading.style.left = '-9999px';
},

writeCredits : function () {
	var credits = hs.createElement('a',
		{
			href: hs.creditsHref,
			className: 'highslide-credits',
			innerHTML: hs.creditsText,
			title: hs.creditsTitle
		}
	);
	this.createOverlay({ overlayId: credits, position: 'top left'});
},

getCaption : function() {
	if (!this.captionId && this.thumbsUserSetId)  
		this.captionId = 'caption-for-'+ this.thumbsUserSetId;
	if (this.captionId) this.caption = hs.getNode(this.captionId);
	if (!this.caption && !this.captionText && this.captionEval) try {
		this.captionText = eval(this.captionEval);
	} catch (e) {}
	if (!this.caption && this.captionText) this.caption = hs.createElement('div', 
			{ className: 'highslide-caption', innerHTML: this.captionText } );
	
	if (!this.caption) {
		var next = this.a.nextSibling;
		while (next && !hs.isHsAnchor(next)) {
			if (/highslide-caption/.test(next.className || null)) {
				this.caption = next.cloneNode(1);
				break;
			}
			next = next.nextSibling;
		}
	}
	if (this.caption) {
		this.marginBottom += this.spaceForCaption;		
	}
	
},

writeCaption : function() {
	try {
		hs.setStyles(this.wrapper, { width: this.wrapper.offsetWidth +'px', 
			height: this.wrapper.offsetHeight +'px' } );	
		hs.setStyles(this.caption, { visibility: 'hidden', marginTop: hs.safari ? 0 : '-'+ this.y.span +'px'});
		this.caption.className += ' highslide-display-block';
		
		var height, exp = this;
		if (hs.ie && (hs.ieVersion() < 6 || document.compatMode == 'BackCompat')) {
			height = this.caption.offsetHeight;
		} else {
			var temp = hs.createElement('div', {innerHTML: this.caption.innerHTML}, 
				null, null, true); // to get height
			this.caption.innerHTML = '';
			this.caption.appendChild(temp);	
			height = this.caption.childNodes[0].offsetHeight;
			this.caption.innerHTML = this.caption.childNodes[0].innerHTML;
		}
		hs.setStyles(this.caption, { overflow: 'hidden', height: 0, zIndex: 2, marginTop: 0 });
		this.wrapper.style.height = 'auto';
		
		if (hs.captionSlideSpeed) {
			var step = (Math.round(height/50) || 1) * hs.captionSlideSpeed;
		} else {
			this.placeCaption(height, 1);
			return;
		}
		for (var h = height % step, t = 0; h <= height; h += step, t += 10) {
			(function(){
				var pH = h, end = (h == height) ? 1 : 0;
				setTimeout( function() {
					exp.placeCaption(pH, end);
				}, t);
			})();
		}
	} catch (e) {}	
},

placeCaption : function(height, end) {
	if (!this.caption) return;
	this.caption.style.height = height +'px';
	this.caption.style.visibility = 'visible';
	this.y.span = this.wrapper.offsetHeight - 2 * this.offsetBorderH;
	
	
	var o = this.objOutline;
	if (o) {
		o.td[4].style.height = (this.wrapper.offsetHeight - 2 * this.objOutline.offset) +'px';
		if (o.hasAlphaImageLoader) o.td[3].style.height = o.td[5].style.height = o.td[4].style.height;
	}
	if (end) this.prepareNextOutline();
},


showHideElements : function (tagName, visibility, imgPos) {
	var els = document.getElementsByTagName(tagName);
	var prop = tagName == '*' ? 'overflow' : 'visibility';
	for (var i = 0; i < els.length; i++) {
		if (prop == 'visibility' || (document.defaultView.getComputedStyle(
				els[i], "").getPropertyValue('overflow') == 'auto'
				|| els[i].getAttribute('hidden-by') != null)) {
			var hiddenBy = els[i].getAttribute('hidden-by');
			if (visibility == 'visible' && hiddenBy) {
				hiddenBy = hiddenBy.replace('['+ this.key +']', '');
				els[i].setAttribute('hidden-by', hiddenBy);
				if (!hiddenBy) els[i].style[prop] = els[i].origProp;
			} else if (visibility == 'hidden') { // hide if behind
				var elPos = hs.position(els[i]);
				elPos.w = els[i].offsetWidth;
				elPos.h = els[i].offsetHeight;
			
				
					var clearsX = (elPos.x + elPos.w < imgPos.x || elPos.x > imgPos.x + imgPos.w);
					var clearsY = (elPos.y + elPos.h < imgPos.y || elPos.y > imgPos.y + imgPos.h);
				var wrapperKey = hs.getWrapperKey(els[i]);
				if (!clearsX && !clearsY && wrapperKey != this.key) { // element falls behind image
					if (!hiddenBy) {
						els[i].setAttribute('hidden-by', '['+ this.key +']');
						els[i].origProp = els[i].style[prop];
						els[i].style[prop] = 'hidden';
					} else if (!hiddenBy.match('['+ this.key +']')) {
						els[i].setAttribute('hidden-by', hiddenBy + '['+ this.key +']');
					}
				} else if (hiddenBy == '['+ this.key +']' || hs.focusKey == wrapperKey) { // on move
					els[i].setAttribute('hidden-by', '');
					els[i].style[prop] = els[i].origProp || '';
				} else if (hiddenBy && hiddenBy.match('['+ this.key +']')) {
					els[i].setAttribute('hidden-by', hiddenBy.replace('['+ this.key +']', ''));
				}
						
			}
		}
	}
},

focus : function() {
	this.wrapper.style.zIndex = hs.zIndexCounter++;
	// blur others
	for (var i = 0; i < hs.expanders.length; i++) {
		if (hs.expanders[i] && i == hs.focusKey) {
			var blurExp = hs.expanders[i];
			blurExp.content.className += ' highslide-'+ blurExp.contentType +'-blur';
			
			if (blurExp.caption) {
				blurExp.caption.className += ' highslide-caption-blur';
			}
			
				blurExp.content.style.cursor = hs.ie ? 'hand' : 'pointer';
				blurExp.content.title = hs.focusTitle;
		}
	}
	
	// focus this
	if (this.objOutline) this.objOutline.table.style.zIndex 
		= this.wrapper.style.zIndex;
	
	this.content.className = 'highslide-'+ this.contentType;
	
	if (this.caption) {
		this.caption.className = this.caption.className.replace(' highslide-caption-blur', '');
	}
	
		this.content.title = hs.restoreTitle;
		
		hs.styleRestoreCursor = window.opera ? 'pointer' : 'url('+ hs.graphicsDir + hs.restoreCursor +'), pointer';
		if (hs.ie && hs.ieVersion() < 6) hs.styleRestoreCursor = 'hand';
		this.content.style.cursor = hs.styleRestoreCursor;
		
	hs.focusKey = this.key;	
	hs.addEventListener(document, 'keydown', hs.keyHandler);	
},

move : function (e) {
	this.x.min = e.left + e.dX;
	this.y.min = e.top + e.dY;
	
	if (e.type == 'image') this.content.style.cursor = 'move';
	hs.setStyles(this.wrapper, { left: this.x.min +'px', top: this.y.min +'px' });
	
	if (this.objOutline)
		this.objOutline.setPosition(this, this.x.min, this.y.min, this.x.span, this.y.span);
	
},

close : function() {
	if (this.isClosing || !this.isExpanded) return;
	this.isClosing = true;
	
	hs.removeEventListener(document, 'keydown', hs.keyHandler);
	
	try {
		
		this.content.style.cursor = 'default';
		
		this.changeSize(
			0,
			{
				x: this.x.min,
				y: this.y.min,
				w: this.x.span,
				h: parseInt(this.content.style.height),
				imgW: this.x.imgSpan,
				o: this.objOutline ? this.objOutline.offset : 0
			},
			{
				x: this.thumbLeft - this.offsetBorderW + this.thumbOffsetBorderW,
				y: this.thumbTop - this.offsetBorderH + this.thumbOffsetBorderH,
				w: this.thumbWidth,
				h: this.thumbHeight,
				imgW: this.thumbWidth,
				o: hs.outlineStartOffset
			},
			hs.restoreDuration,
			hs.restoreSteps
		);
		
	} catch (e) { this.afterClose(); } 
},

createOverlay : function (o) {
	var el = o.overlayId;
	if (typeof el == 'string') el = hs.getNode(el);
	if (!el || typeof el == 'string') return;
	
	
	var overlay = hs.createElement(
		'div',
		null,
		{
			'left' : 0,
			'top' : 0,
			'position' : 'absolute',
			'zIndex' : 3,
			'visibility' : 'hidden'
		},
		this.wrapper,
		true
	);
	if (o.opacity) hs.setStyles(el, { opacity: o.opacity });
	el.style.styleFloat = 'none';
	el.className += ' highslide-display-block';
	overlay.appendChild(el);	
	
	overlay.hsPos = o.position;
	this.positionOverlay(overlay);	
	
	if (o.hideOnMouseOut) overlay.setAttribute('hideOnMouseOut', true);
	if (!o.opacity) o.opacity = 1;
	overlay.setAttribute('opacity', o.opacity);
	hs.fade(overlay, 0, o.opacity);
	
	hs.push(this.overlays, overlay);
},

positionOverlay : function(overlay) {
	var left = this.offsetBorderW;
	var dLeft = this.x.span - overlay.offsetWidth;
	var top = this.offsetBorderH;
	var dTop = parseInt(this.content.style.height) - overlay.offsetHeight;
	
	var p = overlay.hsPos || 'center center';
	if (/^bottom/.test(p)) top += dTop;
	if (/^center/.test(p)) top += dTop / 2;
	if (/right$/.test(p)) left += dLeft;
	if (/center$/.test(p)) left += dLeft / 2;
	overlay.style.left = left +'px';
	overlay.style.top = top +'px';
},

createOverlays : function() {
	for (var i = 0; i < hs.overlays.length; i++) {
		var o = hs.overlays[i], tId = o.thumbnailId, sg = o.slideshowGroup;
		if ((!tId && !sg) || tId == this.thumbsUserSetId
				|| sg === this.slideshowGroup) {
			this.createOverlay(o);
		}
	}
},


createFullExpand : function () {
	var a = hs.createElement(
		'a',
		{
			href: 'javascript:hs.expanders['+ this.key +'].doFullExpand();',
			title: hs.fullExpandTitle,
			className: 'highslide-full-expand'
		}
	);
	
	this.fullExpandLabel = a;
	this.createOverlay({ overlayId: a, position: hs.fullExpandPosition, 
		hideOnMouseOut: true, opacity: hs.fullExpandOpacity });
},

doFullExpand : function () {
	try {	
		hs.purge(this.fullExpandLabel);
		this.fullExpandLabel.parentNode.removeChild(this.fullExpandLabel);
		this.focus();
		
		this.x.min = parseInt(this.wrapper.style.left) - (this.fullExpandWidth - this.content.width) / 2;
		if (this.x.min < hs.marginLeft) this.x.min = hs.marginLeft;		
		this.wrapper.style.left = this.x.min +'px';
		
		hs.setStyles(this.content, { width: this.fullExpandWidth +'px', 
			height: this.fullExpandHeight +'px'});
		
		this.x.span = this.fullExpandWidth;
		this.wrapper.style.width = (this.x.span + 2*this.offsetBorderW) +'px';
		
		this.y.span = this.wrapper.offsetHeight - 2 * this.offsetBorderH;
		
		if (this.objOutline)
			this.objOutline.setPosition(this, this.x.min, this.y.min, this.x.span, this.y.span);
		
		for (var i = 0; i < this.overlays.length; i++)
			this.positionOverlay(this.overlays[i]);
		
		this.redoShowHide();
		
		
	
	} catch (e) {
		parent.location.href = this.content.src;
	}
},


// on end move and resize
redoShowHide : function() {
	var imgPos = {
		x: parseInt(this.wrapper.style.left) - 20, 
		y: parseInt(this.wrapper.style.top) - 20, 
		w: this.content.offsetWidth + 40, 
		h: this.content.offsetHeight + 40 
			+ this.spaceForCaption
	};
	if (hs.hideSelects) this.showHideElements('SELECT', 'hidden', imgPos);
	if (hs.hideIframes) this.showHideElements('IFRAME', 'hidden', imgPos);
	if (hs.geckoMac) this.showHideElements('*', 'hidden', imgPos);

},

wrapperMouseHandler : function (e) {
	if (!e) e = window.event;
	var over = /mouseover/i.test(e.type); 
	if (!e.target) e.target = e.srcElement; // ie
	if (hs.ie) e.relatedTarget = 
		over ? e.fromElement : e.toElement; // ie
	if (hs.getExpander(e.relatedTarget) == this || hs.dragArgs) return;
	for (var i = 0; i < this.overlays.length; i++) {
		var o = this.overlays[i];
		if (o.getAttribute('hideOnMouseOut')) {
			var from = over ? 0 : o.getAttribute('opacity'),
				to = over ? o.getAttribute('opacity') : 0;			
			hs.fade(o, from, to);
		}
	}
},

afterClose : function () {
	this.a.className = this.a.className.replace('highslide-active-anchor', '');
	
	if (hs.hideSelects) this.showHideElements('SELECT', 'visible');
	if (hs.hideIframes) this.showHideElements('IFRAME', 'visible');
	if (hs.geckoMac) this.showHideElements('*', 'visible');
		if (this.objOutline && this.outlineWhileAnimating) this.objOutline.destroy();
		hs.purge(this.wrapper);
		if (hs.ie && hs.ieVersion() < 5.5) this.wrapper.innerHTML = ''; // crash
		else this.wrapper.parentNode.removeChild(this.wrapper);
	hs.expanders[this.key] = null;		
	hs.cleanUp();
}
};
// history
var HsExpander = hs.Expander;

// set handlers
hs.addEventListener(document, 'mousedown', hs.mouseClickHandler);
hs.addEventListener(document, 'mouseup', hs.mouseClickHandler);
hs.addEventListener(window, 'load', hs.preloadImages);

// tab_paese

var Spry;
if (!Spry) Spry = {};
if (!Spry.Widget) Spry.Widget = {};

Spry.Widget.TabbedPanels = function(element, opts)
{
	this.element = this.getElement(element);
	this.defaultTab = 0; // Show the first panel by default.
	this.bindings = [];
	this.tabSelectedClass = "TabbedPanelsTabSelected";
	this.tabHoverClass = "TabbedPanelsTabHover";
	this.tabFocusedClass = "TabbedPanelsTabFocused";
	this.panelVisibleClass = "TabbedPanelsContentVisible";
	this.focusElement = null;
	this.hasFocus = false;
	this.currentTabIndex = 0;
	this.enableKeyboardNavigation = true;

	Spry.Widget.TabbedPanels.setOptions(this, opts);

	// If the defaultTab is expressed as a number/index, convert
	// it to an element.

	if (typeof (this.defaultTab) == "number")
	{
		if (this.defaultTab < 0)
			this.defaultTab = 0;
		else
		{
			var count = this.getTabbedPanelCount();
			if (this.defaultTab >= count)
				this.defaultTab = (count > 1) ? (count - 1) : 0;
		}

		this.defaultTab = this.getTabs()[this.defaultTab];
	}

	// The defaultTab property is supposed to be the tab element for the tab content
	// to show by default. The caller is allowed to pass in the element itself or the
	// element's id, so we need to convert the current value to an element if necessary.

	if (this.defaultTab)
		this.defaultTab = this.getElement(this.defaultTab);

	this.attachBehaviors();
};

Spry.Widget.TabbedPanels.prototype.getElement = function(ele)
{
	if (ele && typeof ele == "string")
		return document.getElementById(ele);
	return ele;
}

Spry.Widget.TabbedPanels.prototype.getElementChildren = function(element)
{
	var children = [];
	var child = element.firstChild;
	while (child)
	{
		if (child.nodeType == 1 /* Node.ELEMENT_NODE */)
			children.push(child);
		child = child.nextSibling;
	}
	return children;
};

Spry.Widget.TabbedPanels.prototype.addClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) != -1))
		return;
	ele.className += (ele.className ? " " : "") + className;
};

Spry.Widget.TabbedPanels.prototype.removeClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) == -1))
		return;
	ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
};

Spry.Widget.TabbedPanels.setOptions = function(obj, optionsObj, ignoreUndefinedProps)
{
	if (!optionsObj)
		return;
	for (var optionName in optionsObj)
	{
		if (ignoreUndefinedProps && optionsObj[optionName] == undefined)
			continue;
		obj[optionName] = optionsObj[optionName];
	}
};

Spry.Widget.TabbedPanels.prototype.getTabGroup = function()
{
	if (this.element)
	{
		var children = this.getElementChildren(this.element);
		if (children.length)
			return children[0];
	}
	return null;
};

Spry.Widget.TabbedPanels.prototype.getTabs = function()
{
	var tabs = [];
	var tg = this.getTabGroup();
	if (tg)
		tabs = this.getElementChildren(tg);
	return tabs;
};

Spry.Widget.TabbedPanels.prototype.getContentPanelGroup = function()
{
	if (this.element)
	{
		var children = this.getElementChildren(this.element);
		if (children.length > 1)
			return children[1];
	}
	return null;
};

Spry.Widget.TabbedPanels.prototype.getContentPanels = function()
{
	var panels = [];
	var pg = this.getContentPanelGroup();
	if (pg)
		panels = this.getElementChildren(pg);
	return panels;
};

Spry.Widget.TabbedPanels.prototype.getIndex = function(ele, arr)
{
	ele = this.getElement(ele);
	if (ele && arr && arr.length)
	{
		for (var i = 0; i < arr.length; i++)
		{
			if (ele == arr[i])
				return i;
		}
	}
	return -1;
};

Spry.Widget.TabbedPanels.prototype.getTabIndex = function(ele)
{
	var i = this.getIndex(ele, this.getTabs());
	if (i < 0)
		i = this.getIndex(ele, this.getContentPanels());
	return i;
};

Spry.Widget.TabbedPanels.prototype.getCurrentTabIndex = function()
{
	return this.currentTabIndex;
};

Spry.Widget.TabbedPanels.prototype.getTabbedPanelCount = function(ele)
{
	return Math.min(this.getTabs().length, this.getContentPanels().length);
};

Spry.Widget.TabbedPanels.addEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.addEventListener)
			element.addEventListener(eventType, handler, capture);
		else if (element.attachEvent)
			element.attachEvent("on" + eventType, handler);
	}
	catch (e) {}
};

Spry.Widget.TabbedPanels.prototype.onTabClick = function(e, tab)
{
	this.showPanel(tab);
};

Spry.Widget.TabbedPanels.prototype.onTabMouseOver = function(e, tab)
{
	this.addClassName(tab, this.tabHoverClass);
};

Spry.Widget.TabbedPanels.prototype.onTabMouseOut = function(e, tab)
{
	this.removeClassName(tab, this.tabHoverClass);
};

Spry.Widget.TabbedPanels.prototype.onTabFocus = function(e, tab)
{
	this.hasFocus = true;
	this.addClassName(this.element, this.tabFocusedClass);
};

Spry.Widget.TabbedPanels.prototype.onTabBlur = function(e, tab)
{
	this.hasFocus = false;
	this.removeClassName(this.element, this.tabFocusedClass);
};

Spry.Widget.TabbedPanels.ENTER_KEY = 13;
Spry.Widget.TabbedPanels.SPACE_KEY = 32;

Spry.Widget.TabbedPanels.prototype.onTabKeyDown = function(e, tab)
{
	var key = e.keyCode;
	if (!this.hasFocus || (key != Spry.Widget.TabbedPanels.ENTER_KEY && key != Spry.Widget.TabbedPanels.SPACE_KEY))
		return true;

	this.showPanel(tab);

	if (e.stopPropagation)
		e.stopPropagation();
	if (e.preventDefault)
		e.preventDefault();

	return false;
};

Spry.Widget.TabbedPanels.prototype.preorderTraversal = function(root, func)
{
	var stopTraversal = false;
	if (root)
	{
		stopTraversal = func(root);
		if (root.hasChildNodes())
		{
			var child = root.firstChild;
			while (!stopTraversal && child)
			{
				stopTraversal = this.preorderTraversal(child, func);
				try { child = child.nextSibling; } catch (e) { child = null; }
			}
		}
	}
	return stopTraversal;
};

Spry.Widget.TabbedPanels.prototype.addPanelEventListeners = function(tab, panel)
{
	var self = this;
	Spry.Widget.TabbedPanels.addEventListener(tab, "click", function(e) { return self.onTabClick(e, tab); }, false);
	Spry.Widget.TabbedPanels.addEventListener(tab, "mouseover", function(e) { return self.onTabMouseOver(e, tab); }, false);
	Spry.Widget.TabbedPanels.addEventListener(tab, "mouseout", function(e) { return self.onTabMouseOut(e, tab); }, false);

	if (this.enableKeyboardNavigation)
	{
		// XXX: IE doesn't allow the setting of tabindex dynamically. This means we can't
		// rely on adding the tabindex attribute if it is missing to enable keyboard navigation
		// by default.

		// Find the first element within the tab container that has a tabindex or the first
		// anchor tag.
		
		var tabIndexEle = null;
		var tabAnchorEle = null;

		this.preorderTraversal(tab, function(node) {
			if (node.nodeType == 1 /* NODE.ELEMENT_NODE */)
			{
				var tabIndexAttr = tab.attributes.getNamedItem("tabindex");
				if (tabIndexAttr)
				{
					tabIndexEle = node;
					return true;
				}
				if (!tabAnchorEle && node.nodeName.toLowerCase() == "a")
					tabAnchorEle = node;
			}
			return false;
		});

		if (tabIndexEle)
			this.focusElement = tabIndexEle;
		else if (tabAnchorEle)
			this.focusElement = tabAnchorEle;

		if (this.focusElement)
		{
			Spry.Widget.TabbedPanels.addEventListener(this.focusElement, "focus", function(e) { return self.onTabFocus(e, tab); }, false);
			Spry.Widget.TabbedPanels.addEventListener(this.focusElement, "blur", function(e) { return self.onTabBlur(e, tab); }, false);
			Spry.Widget.TabbedPanels.addEventListener(this.focusElement, "keydown", function(e) { return self.onTabKeyDown(e, tab); }, false);
		}
	}
};

Spry.Widget.TabbedPanels.prototype.showPanel = function(elementOrIndex)
{
	var tpIndex = -1;
	
	if (typeof elementOrIndex == "number")
		tpIndex = elementOrIndex;
	else // Must be the element for the tab or content panel.
		tpIndex = this.getTabIndex(elementOrIndex);
	
	if (!tpIndex < 0 || tpIndex >= this.getTabbedPanelCount())
		return;

	var tabs = this.getTabs();
	var panels = this.getContentPanels();

	var numTabbedPanels = Math.max(tabs.length, panels.length);

	for (var i = 0; i < numTabbedPanels; i++)
	{
		if (i != tpIndex)
		{
			if (tabs[i])
				this.removeClassName(tabs[i], this.tabSelectedClass);
			if (panels[i])
			{
				this.removeClassName(panels[i], this.panelVisibleClass);
				panels[i].style.display = "none";
			}
		}
	}

	this.addClassName(tabs[tpIndex], this.tabSelectedClass);
	this.addClassName(panels[tpIndex], this.panelVisibleClass);
	panels[tpIndex].style.display = "block";

	this.currentTabIndex = tpIndex;
};

Spry.Widget.TabbedPanels.prototype.attachBehaviors = function(element)
{
	var tabs = this.getTabs();
	var panels = this.getContentPanels();
	var panelCount = this.getTabbedPanelCount();

	for (var i = 0; i < panelCount; i++)
		this.addPanelEventListeners(tabs[i], panels[i]);

	this.showPanel(this.defaultTab);
};

//fine js tab_paese


//funzione per disabilitare la tastiera


function onKeyPressBlockNumbers(e)
{
	var key = window.event ? e.keyCode : e.which;
	var keychar = String.fromCharCode(key);
	reg = /\d/;
	return !reg.test(keychar);
}

//-->

// 10/02/2009 Elena
// Aaggiunta funzione per gestire apertura dei tab tramite parametro in querystring

function checkTabAperto() 
{
	var queryString = parent.location.search.substr(1);
	
  var variabili = queryString.split("&");
  
  for(i=0;i<variabili.length;i++){
			if(variabili[i].indexOf("tabAperto") == 0){
				var tabAperto = parseInt(variabili[i].substr(variabili[i].indexOf("=")+1));
			}
		}
  
  if (tabAperto && TabbedPanels1) {TabbedPanels1.showPanel(tabAperto);}
	
}


var html1 = document.getElementsByTagName('html')[0];

html1.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
html1.setAttribute('xml:lang', 'it');
html1.setAttribute('lang', 'it');


			function change_result(resultform) {	
						
					selecteditem = resultform.number_results.selectedIndex ;
					varnumber = resultform.number_results.options[ selecteditem ].value;
				  urlStirnga= location.href;
					//return varnumber;
					if (varnumber.length != 0){
					 location.href = urlStirnga  + '&result'+ varnumber;
					}
			}
			
			
// 04/02/2001 Luca
// aggiunte funzioni per gestione paginatura archivio-media

function submitResults(valueR)
{
	var urlStr=location.href;
	var keyword ='';
	var month ='';
	var year ='';
	var country ='';
	var results = '&results='+valueR+'';

	if (urlStr.indexOf("?") > 0)
	{
		var linkPage = urlStr.substr(0,urlStr.indexOf("?"));
	}	
	else
	{
		var linkPage = location.href;
	}
	
    if (urlStr.indexOf("?") > 0) 
	{
		var parametri=urlStr.split("?")[1];
		var parametriArray=parametri.split('&');
		for (i=0;i<parametriArray.length;i++)
		{
			if (parametriArray[i].indexOf("keyword=") >-1 )
				{
				keyword='&'+parametriArray[i];
			}
			if (parametriArray[i].indexOf("month=") >-1 )
				{
				month='&'+parametriArray[i];
			}
			if (parametriArray[i].indexOf("year=") >-1 )
				{
				year='&'+parametriArray[i];
			}
			if (parametriArray[i].indexOf("country=") >-1 )
				{
				country='&'+parametriArray[i];
			}
		}	
	}
	
	location.href = linkPage+'?'+keyword+month+year+country+results;
}

function returnValueOfSelect(obj)
{
	var selIndex = obj.selectedIndex;
	var optionValue = obj.options[selIndex].value;
	return optionValue;
}

function getSelected ()
{
	var urlStr=location.href;
	var results;

	if (urlStr.indexOf("?") > 0)
	{
		var parametri=urlStr.split("?")[1];
		var parametriArray=parametri.split('&');	
		for (i=0;i<parametriArray.length;i++)
		{
			if (parametriArray[i].indexOf("results=") >-1 )
			{
				if(parametriArray[i].length > 8) 
				{
					results_sel=parametriArray[i].split('=')[1];
					document.getElementById(results_sel).setAttribute('selected','selected');
				}
			}
		}
	}
}

function azionisti() {

$("col_centro_dx").css("padding","0px");}


