var IsDuplicateScrollEvent = 0;

jQuery(document).ready(function () {
SetupGoogleAnalyticsTrackEvents();
});

function SetupGoogleAnalyticsTrackEvents()
{
TrackEventsForMinimumPageScroll();
}

function TrackEventsForMinimumPageScroll()
{
   jQuery(window).scroll(function(){
 var scrollPercent = GetScrollPercent();

 if(scrollPercent > 85)
 {
   if(IsDuplicateScrollEvent == 0)
   {
 IsDuplicateScrollEvent = 1;
 // alert("Page Scrolled to 90% in " + document.location.href);
 	//var _gaq = _gaq || [];
 	_gaq.push(['_trackEvent','Scrolling','Consumata la homepage','Homepage']);
  }
 }
   });
}

function GetScrollPercent()
{
 var bottom = jQuery(window).height() + jQuery(window).scrollTop();
 var height = jQuery(document).height();

 return Math.round(100*bottom/height);
}
