var currentContent = "";
var contentVisible = false;
var sliding = false;
var currentSender = null;

Cufon.replace('#navigation > li > a', { fontFamily: 'Negotiate Lt', hover:true });
Cufon.replace('h2', { fontFamily: 'FuturaHeavy' });
Cufon.replace('.accordion h3', { fontFamily: 'FuturaHeavy' });
/*Cufon.replace('#contentBlock h3', { fontFamily: 'FuturaHeavy' });*/

$(document).ready(function() {
  $("a.print").click(function(){window.print();});
  $(".accordion").accordion({autoHeight:false,collapsible:true,active:false});
  $("#certifications > ul > li > a").attr("href","javascript:;");

  $("#certifications > ul > li > a").hover(
    function(){
      var sender = $(this);
      var target = $("#"+$(this).attr("rel"));
      var mc_content = $("#mcContent");
    
      mc_content.html(target.html());
      $("#certifications li a").removeClass("active");
      currentSender = sender;
      
      if(mc_content.hasClass("collapsed")){
        mc_content.slideDown('fast',function(){
          mc_content.removeClass("collapsed");
          mc_content.addClass("expanded");
          sender.addClass("active");
          mc_content.css("height",target.height()+"px");
        });
      }else{
        mc_content.show();
        sender.addClass("active");
        mc_content.css("height",target.height()+"px");
      }
    },
    function(){
      
    }
  );
  $("#certifications").hover(
    function(){
      
    },
    function(eventObject){
        //alert(eventObject.currentTarget.id+" - " +eventObject.relatedTarget.id);
        var mc_content = $("#mcContent");
        mc_content.slideUp('slow',function(){
        $("#certifications li a").removeClass("active");
        mc_content.removeClass("expanded");
        mc_content.addClass("collapsed");
      });
    }
  );

  $("#navigation > li > a, .language a").hover(
    function(){
      if(!$(this).parent().hasClass("sliding")){
        $(this).parent().addClass("sliding");
        $(this).parent().find(".subNav").slideDown('fast').show();
        $(this).parent().hover(
          function() {},
          function(){
            $(this).parent().find(".subNav").slideUp('slow',function(){
              $(this).parent().removeClass("sliding");
            }).hide();
          }
        );
      }
  },function(){
    /* no onmouseexit */
  });
  
  $(".subNav > li > a").hover(function(){
    $(this).parent().addClass("hovered");
  },function(){
    $(this).parent().removeClass("hovered");
  });
  
  $('div#contentRight.locations a').click(function(){
    $('div#contentRight.locations li.active').removeClass('active');
    $('div#contentLeft div.location.active').removeClass('active').hide();
    
    $(this).parent().addClass('active');
    $('div#contentLeft div#location_'+$(this).attr('rel')).addClass('active').show();
  });
  
  $(".certificates a").each(function(){
    $(this).attr("target","_blank");
  });
});