// JavaScript Document

/* GLOBALS */
slideshow_dim = '';
/* END GLOBALS */

/*
 * Fades out all items save slideshowimage and controller
 *
 */
function dimSlideshow() {
 switch(slideshow_dim) {
 	case "off" :
 	case '':
 	slideshow_dim = 'moving';
	/*
 	$("body").animate({
 		backgroundColor: "#333"
 	}, 200);
	*/
 	$("#introduction, .title, .nav_menu:not('#image_flick_menu'), #logo_img, .hit_counter, #site_statistics_holder").animate({
 		opacity: 0
 	}, 200, function() {
		$("body").bind("click", dimSlideshow);
 		slideshow_dim = "on";
 	});
 	break;
 	case "on" :
 	slideshow_dim = 'moving';
	/*
 	$("body").animate({
 		backgroundColor: "#fff"
 	}, 200);
	*/
 	$("#introduction, .title, .nav_menu:not('#image_flick_menu'), #logo_img, .hit_counter, #site_statistics_holder").animate({
 		opacity: 1
 	}, 200, function() {
		$("body").unbind('click', dimSlideshow)
 		slideshow_dim = "off";
 	});
 	break;
 	case "moving" :
 	break;
  }
 }
 
 /* Hit counter */
 $(function() {
   // Load and show stats
   $("#site_statistics").click(function() {
     $("#site_statistics_holder").show();
     $.ajax({
       url: "/stats/hits/",
       type: "GET",
       success: function(data, textStatus){
         // Show stats
         $("#site_statistics_holder").html(data);
         // Attach extra stats action
         $(".hits_expand").click(function(eventObject) {
           // Get element
           var a = $(eventObject.target)
           // Get content element
           var c = a.parent().siblings("td").children(".stat_content");
           // Toggle content
           c.toggle()
           // Change link
           var status = c.css("display");
           if(status == "none") {
             a.html("more");
           } else {
             a.html("less");
           }
           return false;
         });
       },
       error: function () {
         var str = "&nbsp;&nbsp;Temporarily unavailable.";
         $("#site_statistics_holder").html(str);
       }
     });
     return false;
   });
 });

