$(document).ready( function () {
  var intime = 0;
  var outtime = 1000;

  $('a.lightbox').lightBox({
    overlayBgColor: '#000',
    overlayOpacity: 0.6,
    imageLoading: '/images/loader.gif',
    imageBtnClose: '/images/lightbox-btn-close.gif',
    imageBtnPrev: '/images/lightbox-btn-prev.gif',
    imageBtnNext: '/images/lightbox-btn-next.gif',
  });
  
  $(".jscrollpane").jScrollPane();
  if($("#col_b").length > 0) {
    $("#col_b").hide().show("fade");
  }
  $(".node").children("ul").hide();
  $(".node a").click(function () {
    if($(this).next("ul:visible").length > 0) $(this).next("ul").slideUp("slow"); else $(this).next("ul").slideDown("slow");
    $(this).next("ul").parent("li").siblings("li:visible").children("ul").slideUp("slow");
  });
  $(".leaf a").click(function () { window.location = $(this).attr("href"); } );
  $(".active").parent().parent().parent().show();
  $(".active").parent().show();
  $("#keyword").focus(function () {
    if($(this).val() == 'Search') $(this).val("");
  });
  $("#keyword").blur(function () {
    if($(this).val() == '') $(this).val("Search");
  });
  
  $("#aclose").click(
    function(){
      $(".jscrollpane").jScrollPaneRemove();
      var w = $('#col_a').width();
      if($('#col_b').length > 0){
        if(w == 150){
          $("#col_a .content").hide();
          $("#col_a").animate( {width:10}, 300 );
          $(this).children("img").attr('src', '/themes/ds/images/nav-off.png');
          if($("#col_b").width() == 100){
            $("#col_c").animate( {width:990}, 400 );
            $(".jscrollpane").fadeOut(outtime).width(960).jScrollPane().fadeIn(intime);
          } else {
            $("#col_c").animate( {width:1080}, 75 );
            $(".jscrollpane").fadeOut(outtime).width(1050).jScrollPane().fadeIn(intime);
          }
        } else {
          $("#col_a .content").show("slow");
          $("#col_a").animate( {width:150}, 300 );
          $(this).children("img").attr('src', '/themes/ds/images/nav.png');
          if($("#col_b").width() == 100){
            $("#col_c").animate( {width:850}, 175);
            $(".jscrollpane").fadeOut(outtime).width(820).jScrollPane().fadeIn(intime);
          } else {
            $("#col_c").animate( {width:940}, 75);
            $(".jscrollpane").fadeOut(outtime).width(910).jScrollPane().fadeIn(intime);
          }
        }
      }
    }
  );
  
  $("#bclose").click(
    function () {
      $(".jscrollpane").jScrollPaneRemove();
      var w = $('#col_b').width();
      if(w == 100){
        $("#col_b .content").hide("slow");
        $("#col_b").animate( {width:10}, 400 );
        if($("#col_a").width() == 150) {
          $("#col_c").animate( {width:940}, 400 );
          $(".jscrollpane").fadeOut(outtime).width(910).jScrollPane().fadeIn(intime);
        } else {
          $("#col_c").animate( {width:1080}, 400 );
          $(".jscrollpane").fadeOut(outtime).width(1050).jScrollPane().fadeIn(intime);
        }
      } else {
        $("#col_b .content").show("slow");
        $("#col_b").animate( {width:100} );
        if($("#col_a").width() == 150) {
          $("#col_c").animate( {width:850}, 300 );
          $(".jscrollpane").fadeOut(outtime).width(820).jScrollPane().fadeIn(intime);
        } else {
          $("#col_c").animate( { width:990}, 350 );
          $(".jscrollpane").fadeOut(outtime).width(960).jScrollPane().fadeIn(intime);
        }
      }
    }
  );
  
  
    
  $("#sub-nav-img").jCarouselLite({
    btnNext: "#sub-nav-next",
    btnPrev: "#sub-nav-prev",
    mouseWheel: true,
    vertical: true,
    circular: false,
    visible: 5
  });
  
  $("#slideshow").jCarouselLite({
    btnNext: ".next",
    btnPrev: ".prev",
    mouseWheel: true,
    circular: false,
    visible: 6
  });
  
});
