$(document).ready(function(){

  // Dropdown example for topbar nav
  // ===============================

  $("body").bind("click", function (e) {
    $('a.menu').parent("li").removeClass("open");
  });

  $("a.menu").click(function (e) {
    var $li = $(this).parent("li").toggleClass('open');
    return false;
  });
  
  $(".linav").hover(function () {
    var $li = $(this).addClass('open');
  },function() {
	var $li = $(this).removeClass('open'); 
  });  
	
	$('.pricetable').delegate('td','mouseover mouseleave',function(e) {
		if(e.type == "mouseover") {
			if(($(this).index()) == 0) return false;
			$("col").eq($(this).index()).addClass("hover");
		}else {
			if(($(this).index()) == 0) return false;
			$("col").eq($(this).index()).removeClass("hover");
		}
	});

  // add on logic
  // ============

  $('.add-on :checkbox').click(function() {
    if ($(this).attr('checked')) {
      $(this).parents('.add-on').addClass('active');
    } else {
      $(this).parents('.add-on').removeClass('active');
    }
  });


  // Disable certain links in docs
  // =============================

  $('ul.tabs a, .pagination a, a.close, a.prevent').click(function(e) {
    e.preventDefault();
  });

  // Close X
  $('#msg a.close').click(function(e){
	  e.preventDefault();
	  $('#msg').hide('slow',function(){
		$('#msg').remove();  
	  });
  });
  
  // email replace [at] and [dot]
  $('.jemail').text($('.jemail').text().replace('[at]','@'));
  $('.jemail').text($('.jemail').text().replace('[dot]','.'));


  // open new window
  $('.blank').attr('target','_blank');
  
  // banner
  $('.banner').colorbox();
	// tooltip on td status
	$('.banner,.tip').twipsy({animate:false,placement:'below',offset:-40});  
});

