// JavaScript Document

function isIE(){
	if(document.all){
	    return true;
	}else{
	    return false;
	}
}

/*start auguri 20/12/2010*/
$(document).ready(function() {
	$('.tab_background').click(function() {
    $('#visore3').addClass('visore3_tot');
		 });
          });

/*end auguri 20/12/2010*/

/*if(isIE()){
	$(function() {
		
		var zIndexNumber = 2000;
		$('div').each(function() {
			$(this).css('zIndex', zIndexNumber);
			zIndexNumber -= 10;
		});
		
		$("#top")[0].style.zIndex = 2000;
		$("#nav")[0].style.zIndex = 2010;
		//$("#nav2")[0].style.zIndex = 2020;
		//$("#nav3")[0].style.zIndex = 2030;
				
	//	$("#cont_dx")[0].style.marginLeft = "2px";
	//	$("#cont_dx")[0].style.marginBottom = "10px";
	});
}*/

/*png fix*/

/* modifica 13/05/2011 - se apro la home con un cellulare redirigo sul sito mobile */
function initialize(){
	if((navigator.userAgent.match(/iPhone/i)) ||
	   (navigator.userAgent.match(/Android/i)) ||
	   (navigator.userAgent.match(/Nokia/i)) ||
	   (navigator.userAgent.match(/SymbianOS/i)) ||
	   (navigator.userAgent.match(/BlackBerry/i)) ||
	   (navigator.userAgent.match(/Windows CE/i)) ||
	   (navigator.userAgent.match(/Opera Mobi/i)) ||
	   (navigator.userAgent.match(/Opera Mini/i))
	  )

	{
	
		if(leggiCookie('eni_mobile_yes') == ''){
			
		//	alert('Prima Volta');	
	
			if (confirm("Vuoi essere rediretto al sito mobile?")) {
				scriviCookie('eni_mobile_yes','si',100000000);
				location.href = 'http://'+hostPrefix+'.eni.mobi';
			} else {
				scriviCookie('eni_mobile_yes','no',100000000);
				location.href = 'http://'+hostPrefix+'.eni.com';
			};
	
		} else if(leggiCookie('eni_mobile_yes') == 'si'){
	
		//	alert('Scelto Mobile');	
	
		//	location.href = 'http://open.reply.it/eni';
			location.href = 'http://'+hostPrefix+'.eni.mobi';
	
		} 
		/*Ale 06_06_2011
		else if(leggiCookie('eni_mobile_yes') == 'no'){
	
		//	alert('Scelto Web');	
	
			 location.href = 'http://www.eni.com';
	
		}
		*/
	}

}

function leggiCookie(nomeCookie)
{
  if (document.cookie.length > 0)
  {
    var inizio = document.cookie.indexOf(nomeCookie + "=");
    if (inizio != -1)
    {
      inizio = inizio + nomeCookie.length + 1;
      var fine = document.cookie.indexOf(";",inizio);
      if (fine == -1) fine = document.cookie.length;
      return unescape(document.cookie.substring(inizio,fine));
    }else{
       return "";
    }
  }
  return "";
}

function scriviCookie(nomeCookie,valoreCookie,durataCookie)
{
  var scadenza = new Date();
  var adesso = new Date();
  scadenza.setTime(adesso.getTime() + (parseInt(durataCookie) * 60000));
  document.cookie = nomeCookie + '=' + escape(valoreCookie) + '; expires=' + scadenza.toGMTString() + '; path=/';
}


// Ricava il nome del sito
var hostName = location.href;
hostName = hostName.substring(hostName.indexOf('//')+2);
hostName = hostName.substring(0,hostName.indexOf('/'));


/*06_06_2011 - Ale Go-Live mobile*/
var hostPrefix = 'www';
if (hostName == 'st-eni.eni.com') {
	hostPrefix = 'st-eni';
} 
//if (hostName == 'www.eni.com') { 
	/* 07_06_2011 - modifica Genga: se da mobile clicco su navigazione classica non deve essere richiesta la initialize */
	if (document.location.href.substring(document.location.href.lastIndexOf("?")+1) != 'navigazione_classica=yes')
		initialize();
	/* 07_06_2011 - modifica Genga */
//} 
/*End 06_06_2011 - Ale Go-Live mobile*/

/* modifica 13/05/2011 */

/*modifica 17 febbraio*/
$(document).ready(function(){

   $(".rAzienda").hover(function(){
	  $("#rich_azienda").show();	
	  $(".rAzienda").find("a").addClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "absolute";
	  	$("#cont_sx")[0].style.zIndex = -1;
	  }
	  
	},	
	function(){	
	  $("#rich_azienda").hide();	  
	  $(".rAzienda").find("a").removeClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "relative";
	  	$("#cont_sx")[0].style.zIndex = 0;
	  }
  });
  

  $(".rGovernance").hover(function(){
	  $("#rich_governance").show();	
	  $(".rGovernance").find("a").addClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "absolute";
	  	$("#cont_sx")[0].style.zIndex = -1;
	  }
	},	
	function(){	
	  $("#rich_governance").hide();	  
	  $(".rGovernance").find("a").removeClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "relative";
	  	$("#cont_sx")[0].style.zIndex = 0;
	  }

	});
  
  $(".rProducts").hover(function(){
	  $("#rich_services").show();	
	  $(".rProducts").find("a").addClass("bianco");
	 if (isIE()){
	  	$("#cont_sx")[0].style.position = "absolute";
	  	$("#cont_sx")[0].style.zIndex = -1;
	  }
	},	
	function(){	
	  $("#rich_services").hide();	  
	  $(".rProducts").find("a").removeClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "relative";
	  	$("#cont_sx")[0].style.zIndex = 0;
	  }

	});
  
  $(".rTechnology").hover(function(){
	  $("#rich_technology").show();	
	  $(".rTechnology").find("a").addClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "absolute";
	  	$("#cont_sx")[0].style.zIndex = -1;
	  }
	},	
	function(){	
	  $("#rich_technology").hide();	  
	  $(".rTechnology").find("a").removeClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "relative";
	  	$("#cont_sx")[0].style.zIndex = 0;
	  }

	});
  
  $(".rSustainability").hover(function(){
	  $("#rich_sustainability").show();	
	  $(".rSustainability").find("a").addClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "absolute";
	  	$("#cont_sx")[0].style.zIndex = -1;
	  }
	},	
	function(){	
	  $("#rich_sustainability").hide();	  
	  $(".rSustainability").find("a").removeClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "relative";
	  	$("#cont_sx")[0].style.zIndex = 0;
	  }

	});
  
  $(".rInvestor").hover(function(){
	  $("#rich_investor").show();	
	  $(".rInvestor").find("a").addClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "absolute";
	  	$("#cont_sx")[0].style.zIndex = -1;
	  }
	},	
	function(){	
	  $("#rich_investor").hide();	  
	  $(".rInvestor").find("a").removeClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "relative";
	  	$("#cont_sx")[0].style.zIndex = 0;
	  }

	});
 
  $(".rMedia").hover(function(){
	  $("#rich_media").show();	
	  $(".rMedia").find("a").addClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "absolute";
	  	$("#cont_sx")[0].style.zIndex = -1;
	  }
	},	
	function(){	
	  $("#rich_media").hide();	  
	  $(".rMedia").find("a").removeClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "relative";
	  	$("#cont_sx")[0].style.zIndex = 0;
	  }

	});
  
   $(".rJobs").hover(function(){
	  $("#rich_jobs").show();	
	  $(".rJobs").find("a").addClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "absolute";
	  	$("#cont_sx")[0].style.zIndex = -1;
	  }
	},	
	function(){	
	  $("#rich_jobs").hide();	  
	  $(".rJobs").find("a").removeClass("bianco");
	  if (isIE()){
	  	$("#cont_sx")[0].style.position = "relative";
	  	$("#cont_sx")[0].style.zIndex = 0;
	  }

	});
  
  
 }); 

/*modifica 17 febbraio*/


$(document).ready(function(){
	$(document).pngFix();
});

/*resize colonne*/

 $(document).ready(function(){
	$('#comunicati_rotate').jshowoff( {speed:6000, controls:false, links:false } );
	document.getElementById('cont_sx').style.height = '560px';
	document.getElementById('cont_news').style.height = '560px';
	document.getElementById('news').style.display = 'none';	
	
	//document.getElementById('cont_sx').style.height = '594px';
	//$("#cont_sx")[0].parentNode.parentNode.parentNode.style.marginTop="0px";
	//document.getElementById('cont_news').style.height = '594px';
	//document.getElementById('news').style.display = 'none';	
});

function resize_div(){

	var mc=document.getElementById('cont_sx');
	var sd=document.getElementById('cont_dx');
	var sn=document.getElementById('news');
	var scn=document.getElementById('cont_news');
	var sl=document.getElementById('lancio');
	var sb=document.getElementById('breaking');
	var sbOffsetHeight = 0;
	if(sb){
		sbOffsetHeight = sb.offsetHeight;
	}
	var sc=document.getElementById('comunicati');
	
	if(mc.offsetHeight<=sd.offsetHeight){
		mc.style.height=(sd.offsetHeight)+'px';
		sn.style.height=(sd.offsetHeight-sl.offsetHeight-sbOffsetHeight-sc.offsetHeight -110)+'px';
		scn.style.height=(sd.offsetHeight-sl.offsetHeight-sbOffsetHeight-sc.offsetHeight -110)+'px';
	}else if(sd.offsetHeight<=mc.offsetHeight){
		sd.style.height=(mc.offsetHeight)+'px';	
              }
}

//window.onload = resize_div;		

/*grandezza font*/

function setFontSize(size) {
	var body = document.getElementsByTagName('body')[0];
	var percentuale = "11px"; // default
	if (size == 1) percentuale = "11px";
	if (size == 2) percentuale = "13px";
	if (size == 3) percentuale = "15px";
	body.style.fontSize = percentuale;
}

/*menu lingue*/
/*caricamento ritardato div news e resize_div*/

$(document).ready(function(){
	setTimeout(function() {
		//wt per i link del lancio
		var lanciohref = $('#lancio div.dx a');
		for (h=0; h<lanciohref.length;h++){
			if(lanciohref[h].href.indexOf("?")!=-1){
				lanciohref[h].href = lanciohref[h].href + "&home_2010_it_tab=editorial";
			}
			else{
				lanciohref[h].href = lanciohref[h].href + "?home_2010_it_tab=editorial";
			}
		}
	}, 1000);
	//
	setTimeout(function() { $('#news').fadeIn(2500); }, 4500); 
	setTimeout(function() {
			var countNews = 0;
		   
			var div = document.getElementById('news');
			if(div){
				var ul = div.childNodes[0];
			       	if(ul){
			        	countNews = ul.children.length;
			       	}
			}
			     
			if(document.getElementById("loadedNews")){
			      var loadedNews = document.getElementById("loadedNews");
			      var htmlLoadedNews = loadedNews.innerHTML;
			      loadedNews.innerHTML = /*countNews + */" " + htmlLoadedNews;
			}
		},5000);
	setTimeout("resize_div()", 5000);
	
	/*$(".apri").click(function(){
		if($("#nav3").css("display") == "none"){
			$("#nav3").slideToggle("slow");
			$(".apri").toggleClass("active");
		}
		else {
			$("#nav3").slideToggle("slow");
			$(".apri").toggleClass("active");
		}
	});*/
});


/*scroll verticale*/

    var scrolling = null; 
  
    function scroll_up() { 
        var d = document.getElementById('news'); 
  
        d.scrollTop = d.scrollTop - 10; 
  
        scrolling = window.setTimeout(function() { 
            scroll_up(); 
        }, 100); 
    } 
  
    function scroll_down() { 
        var d = document.getElementById('news'); 
  
        d.scrollTop = d.scrollTop + 10; 
  
        scrolling = window.setTimeout(function() { 
            scroll_down(); 
        }, 100); 
    } 
  
    function stop_scroll() { 
        window.clearTimeout(scrolling); 
    }
	
/*scroll hover*/ 
  
 $(document).ready(function(){	
	 
	 $("#img_G01").hover(function(){
										
	  $(".G01").show();	
	},	
	function(){	
	  $(".G01").hide();	  

	});
	 
	 $("#img_G01-0").hover(function(){
										
	  $(".G01-0").show();	
	},	
	function(){	
	  $(".G01-0").hide();	  

	});
	 
	  $("#img_G01-1").hover(function(){
										
	  $(".G01-1").show();	
	},	
	function(){	
	  $(".G01-1").hide();	  

	});
	  
	   $("#img_G01-2").hover(function(){
										
	  $(".G01-2").show();	
	},	
	function(){	
	  $(".G01-2").hide();	  

	});
	   
	    $("#img_G01-3").hover(function(){
										
	  $(".G01-3").show();	
	},	
	function(){	
	  $(".G01-3").hide();	  

	});

	 $("#img_G01-4").hover(function(){
										
	  $(".G01-4").show();	
	},	
	function(){	
	  $(".G01-4").hide();	  

	});
	 
	  $("#img_G01-5").hover(function(){
										
	  $(".G01-5").show();	
	},	
	function(){	
	  $(".G01-5").hide();	  

	});
	  
	   $("#img_G01-6").hover(function(){
										
	  $(".G01-6").show();	
	},	
	function(){	
	  $(".G01-6").hide();	  

	});
	
	$("#img_G01-7").hover(function(){
										
	  $(".G01-7").show();	
	},	
	function(){	
	  $(".G01-7").hide();	  

	});
	
	$("#img_G01-8").hover(function(){
										
	  $(".G01-8").show();	
	},	
	function(){	
	  $(".G01-8").hide();	  

	});
	
	$("#img_G01-9").hover(function(){
										
	  $(".G01-9").show();	
	},	
	function(){	
	  $(".G01-9").hide();	  

	});
	
	$("#img_G01-10").hover(function(){
										
	  $(".G01-10").show();	
	},	
	function(){	
	  $(".G01-10").hide();	  

	});
	
	$("#img_G01-11").hover(function(){
										
	  $(".G01-11").show();	
	},	
	function(){	
	  $(".G01-11").hide();	  

	});
	
	$("#img_G01-12").hover(function(){
										
	  $(".G01-12").show();	
	},	
	function(){	
	  $(".G01-12").hide();	  

	});
	
	$("#img_G01-13").hover(function(){
										
	  $(".G01-13").show();	
	},	
	function(){	
	  $(".G01-13").hide();	  

	});
	 
});


