$(document).ready(function () {
  $("#projects, #next_steps, #about, #sidebar").addClass('disabled');
	$(".project_set, #projects .indented, #overlay").hide();

  $("#yes_logged_in").click(function(event){
    event.preventDefault();
    $("#login_status").addClass('disabled');
    $("#login_content").slideUp('fast', function(){
      $("#overlay, #projects, #next_steps, #about, #sidebar").removeClass('disabled').slideDown();
      setTimeout(function(){
        $("#overlay").hide();
        $(".project_set, #projects .indented").fadeIn();
      }, 25000);
      
      $("#loading_progress").progressbar({ value: 0 });
      setInterval(function(){
        var progress = $( "#loading_progress" ).progressbar( "option", "value" );
        $("#loading_progress").progressbar("option", "value", progress + 2);
       }, 500);
       $("ul.project_set").load('/dashboard?projects=true');
    });    
  });



  $("#help .indented").hide();
  $("#help h2").click(function(event) {
		event.preventDefault();
		$(this).parent().siblings(".indented").slideToggle();
		$('#click_here').hide();
	});

  $(".help_icon").click(function(event){
	$("#help .indented").show(0, function(){
		$('#click_here').hide();
		$("#help").effect("highlight", {}, 3000);
	});	
  });
	
  $('input.ui-datepicker').datepicker();

  $("table.sortable").dataTable({
		"bPaginate": false,
		"bInfo": false
		}	
	);
	$('input.default_value').defaultValue();  

  $("tr.highlight_row td").effect("highlight", {}, 10000)
  
  $("input.create").each(function () {
    var text = $(this).attr('value');
    $("<a href='#' class='minibutton'><span>" + text + "</span></a>")
      .click(function (event) {
        event.preventDefault();
        $(this).parents('form').submit();
      })
      .insertAfter($(this));
    $(this).hide();
  })
  
	$('a.minibutton').bind({
		mousedown: function() {
			$(this).addClass('mousedown');
		},
		blur: function() {
			$(this).removeClass('mousedown');
		},
		mouseup: function() {
			$(this).removeClass('mousedown');
		}
	});
});