/* <3 JS */

var csm = {};

csm.init = function() {
  csm.dropdowns();
  csm.homeCycle();
  //csm.loadPages();
  $('.scrollable').jScrollPane();
};

csm.loadPages = function(){
  $("a#logo").live("click", function(e){ e.preventDefault(); $("div.inner").fadeOut("fast"); $("#product-cycle").cycle('resume'); });
  $("a.populate").live("click", function(e){
    e.preventDefault();
    var url = $(this).attr("href");
    var inner = $("div.inner");
    
    if(inner.length > 0){ 
      inner.fadeOut("fast", function(){
        $(this).remove();
        grabIt(url);
      }); 
    }else{ grabIt(url); }
    
    $("#product-cycle").cycle('pause');
  });
  
  function grabIt(url){
    $.get(url, function(data) {
      var contentNeeded = $(data).find("div.inner");
      $("#content").prepend(contentNeeded); 
      $("#content").find("div.inner").fadeIn("fast");
    });
  }
}

csm.homeCycle = function(){
  $("#product-cycle").cycle({});
}

csm.dropdowns = function(){
  $("ul.dropdown li").hover(function(){
    $(this).addClass("hover");
    $('ul:first',this).css('visibility', 'visible');
  }, function(){
    $(this).removeClass("hover");
    $('ul:first',this).css('visibility', 'hidden');
  });

  $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");
};

$(function() { csm.init(); });

