$(document).ready(function(){
      $.fn.toggleFade=function(speed){
		 var display=$(this).css('display');
		 if(display=="none"){
			 $(this).fadeIn(speed);
			 return null;
		 }
		 $(this).fadeOut(speed);
		 return null;
	 }			  
	//$("ul.vertical li.active").children("ul").fadeIn("fast");
/*
	$("ul.horisontal .nav_1").hover(function() { //Hover over event on list item
			var index=$(this).attr("index");
                        var submenu=$(this).children("#submenu_"+index);
			submenu.fadeIn("fast");
	}, function(){$(this).find("ul.submenu_1").fadeOut("fast");} );
*/	
	$("ul.submenu_2 .active").parent().parent().find(".menu").addClass("active");
	$("ul.submenu_1 .active").parent().parent("li").addClass("active");
        
        $(".section").hover(function() {$(this).children("#section_1").addClass("hidden"); $(this).children("#section_2").removeClass("hidden");}, function() {$(this).children("#section_2").addClass("hidden"); $(this).children("#section_1").removeClass("hidden");});

 (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();

(function() {	
   var msie6 = jQuery.browser == 'msie' && jQuery.browser.version < 7;
    if (!msie6) {  
       var mmtop = jQuery('#main_menu').offset().top - parseFloat($('#main_menu').css('margin-top').replace(/auto/, 0));
        if($("#share_buttons_single_page").length != 0){
           var sbtop = jQuery('#share_buttons_single_page').offset().top - parseFloat($('#share_buttons_single_page').css('margin-top').replace(/auto/, 0));
         }
         if($(window).width()>1100){
           $(window).scroll(function (event) {
            var scrollposition = $(this).scrollTop();
            if($("#share_buttons_single_page").length != 0){
              if (scrollposition >= sbtop-70) {
                // if so, ad the fixed class
                  $('#share_buttons_single_page').addClass('fixed');
                  } else {
                // otherwise remove it
                      $('#share_buttons_single_page').removeClass('fixed');
                   }
              }
              if (scrollposition >= mmtop) {
                  // if so, ad the fixed class
                $('#main_menu').addClass('fixed');
                $('#page_content').css({"margin-top":"33px"});
                $('#main_menu').append("<div class='m'></div>");
              } else {
                // otherwise remove it
                $('#main_menu').removeClass('fixed');
                $('#page_content').css({"margin-top":"-20px"});
                $("#main_menu").find(".m").remove();
              }
            });
        }
        else{
            $('#share_buttons_wrapper').css({"position":"relative","left":"0px","margin":"0px","width":"480px"});
            $('#share_buttons_single_page').css({"position":"inherit","width":"460px","margin":"0px"});
            $('.wdt_button').css({"clear":"none","float":"left","padding":"5px"});
        }  
    }
})();	
});
