    var startLeft = 0;
    var factor = 640;
    var startNav = 0;
    var endNav = 4;

    function homePageInit()
{


        $("a.mod").click(function(){
            gaPagetracker('Homepages','Homepage Module',$(this).attr('title'));
        });

         $(".toprated ul a").click(function(){
            gaPagetracker('Homepages','Homepage Top Rated',$(this).html());
        });

        var f = 0;

        $("#cycle_nav li a").click(function(){
           $("#cycle_nav li a").removeClass('over');
           var html =  $(this).html();
           $("#cycleText").fadeOut(1000,function(){
              $(this).html(html).fadeIn(1000);
           });
           var href = $(this).attr('href');
           var c = getURLParam(href);//which one did we choose
           startNav = c;
           if($("#cycle_control a").attr('class').match(/stopped/)==null) {h_clearTimer();h_setTimer();}
           var endPosition = -1 * c * factor;
           if(f!=0)
           {
               $("#cycle_banner #cycler").fadeOut(1000,function(){
                    if(startNav==0) $(this).css({left:0});
                    else $(this).css({left:endPosition});

                    $(this).fadeIn(1000);

               });

           }
           f++;
                 if(startNav!=endNav) $(this).addClass('over');
                 else
                 {
                     $("#cycle_0 a").addClass('over');
                     startNav = 0;
                 }
           return false;
        });

        $("#cycle_0 a").trigger('click');
      //  h_setTimer();


        $("#cycle_control a").toggle(function(){
           h_clearTimer();
           $(this).addClass('stopped');
        },function(){
           h_setTimer();
           $(this).removeClass('stopped');
        });

        startToprated();
        postLoadCycle();

}

    function h_setTimer() {
        $("#cycle").everyTime(7000,"timer_cycle",function () {
             
             startNav++;
             $("#cycle_"+startNav+" a").trigger('click');
                
		});

	}

	function h_clearTimer(){
		$("#cycle").stopTime('timer_cycle');
	}

    function getURLParam(url)
    {
          var hrefS = url.split('#');
          return parseInt(hrefS[1]);
    }


    function postLoadCycle()
    {
        var troopHTML = '';
        var count = 0;
            $('#cycler li a').each(function(){
                count++;
                var h3 = $(this).find('h3').html();
             //   $(this).html('');
                
                if(count > endNav) count = 1;
                if(count==troopsCount) troopHTML = '<div style="text-decoration:none;">'+cupsDonated+'</div>';
                else troopHTML = '';
             //   $(this).html(troopHTML+'');
               // console.log($(this).html())
            });
        count = 0;

        $('#cycler li a').click(function(){
           var title = $(this).children('img').attr('alt');
            gaPagetracker('Homepages',globalSpot+' Spotlight',title);
            return true;
        });
    }

    function startToprated()
    {
        $(".toprated .size3 a").click(function(){
            var count = 0;
            $(".toprated .size3 a").removeClass('active');
            $(this).addClass('active');
            var c = getURLParam($(this).attr('href'));
            $('.toprated li').each(function(){
                count++;
                if(c==count) $(this).removeClass('hidden');
                else if($(this).attr('class')!='hidden') $(this).addClass('hidden');
            });
            count = 0;
            return false;
        });
    }


    window['homePageInit'] = homePageInit;
