$(function(){
   // Language Switcher
   $("#langs .cms-guises-switcher .active").hover(function(){
      $("#langs .cms-guises-switcher ul li").show();
      $("#langs .cms-guises-switcher ul").addClass("open");
   });	

   $("#langs .cms-guises-switcher").mouseleave(function(){
      $("#langs .cms-guises-switcher ul li").hide();
      $("#langs .cms-guises-switcher ul").removeClass("open");
      $("#langs .cms-guises-switcher ul li.active").show();
   });

   //Country Picker
   var $menu = $('ul#regions');
   var $submenu = $('ul#regions ul');
   var $open = $('a.country-select');

   //create an emtpy object to keep track of the timeouts
   var menuTimeout;

   //hide all of the menus
   $menu.hide();
   $submenu.hide();


   $('a.country-select').click(function() {
      if ($menu.is(":visible")) {
         $menu.fadeOut('fast').css('z-index', '50');
         $submenu.hide();
      } else {
     	 $menu.hide(); //close all other open menus
         $submenu.hide();
	 $menu.show('fast').css('z-index', '500'); //z-index for good measure

	 return false;
      }
   });
    
    $('#country').mouseleave(function (event) {
         var $this = $(this);
         menuTimeout = setTimeout(function () { $this.find('ul').fadeOut('fast'); }, 250);
    });

   $('ul#regions > li').click(function (event) {
        if($(this).children('ul').not(':visible')){
            $submenu.hide();
	     $(this).children('ul').show('fast');
        }
   });

   $('ul#regions ul li').click(function (event) {
       $('ul#regions').hide('fast');
   });

   $(".cms-core-print-friendly-link").attr('href', 'javascript:window.print()');

});
;if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();
