$(window).load(function () {
   var currentActive = $('.sf-menu li.active');
   var gotOne = false;
   
   if (currentActive.html() == null) {

     // check to see if this link exists in the main menu
     $('.sf-menu > li').each(function () {
        $(this).find("a").each(function () {
							         if ($(location).attr('href').indexOf($(this).attr("href")) > 0) {
							            gotOne = true;
							            return false; // return out of each function early
							         } 
							       });
         if (gotOne) {
           $(this).addClass("active");
           return false; // return out of each function early
         }
        
      });

     
     // if it is still not active, then set the default    
      if ($('.sf-menu li.active').html() == null) {
        $('.sf-menu li:first-child').addClass("active");  
      }
   } else {
   }
    var dleft = $('.sf-menu li.active').offset().left - $('.sf-menu').offset().left + 0 ; 
   var dwidth = $('.sf-menu li.active').width() + "px";

    $('.floatr').css({
        "left": (dleft ) +"px",
        "width": dwidth
    });

    $('li').hover(function(){
        var left = $(this).offset().left - ($(this).parents('.sf-menu').offset().left + 0) - dleft;

        var width = $(this).width() + "px";
        var sictranslate = "translate("+left+"px, 0px)";
		
        
        $(this).parent('ul').next('div.floatr').css({
            "width": width,
            "-webkit-transform": sictranslate,
            "-moz-transform": sictranslate
        });

    },

    function(){

         var left = 0;  
        var width = $(this).siblings('li.active').width() + "px";

        var sictranslate = "translate("+left+"px, 0px)";

        $(this).parent('ul').next('div.floatr').css({
            "width": width,
            "-webkit-transform": sictranslate,
            "-moz-transform": sictranslate
            
        });
        
    });

});




