
	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;
				}
			}
		}
	}

	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')) {
	          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;
		//	if ((hostName == 'st-eni.eni.it') || (hostName == 'st-eni.eni.com')) 
		//		window.location.href = destination;
		//	else
				window.location.href = "https://"+hostName+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') {
		  	if ((hostName == 'www.eni.it') || (hostName == 'www.eni.com'))
				var destination =  'https://fastlogon.eni.it/Redirector/redirector.aspx?TARGET2=https://www.eni.com/public/redirect.html';
			else if ((hostName == 'st-eni.eni.it') || (hostName == 'st-eni.eni.com'))
				var destination =  'https://st-fastlogon.eni.it/Redirector/redirector.aspx?TARGET2=http://st-eni.eni.com/it_IT/components/redirect.html';
					
			if (destination!=null) {
				// Genera il Cookie di atterraggio
	
	      			if ((hostName == 'www.eni.it') || (hostName == 'www.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;
	
				window.location.href = destination;
			}
	
		}
	}
	
	function goTo(url)
	{
 		if (url) location.href = url;

	}; 
