// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults


$(document).ready(function() {
  
  $('#slides').bxGallery({
  		maxwidth: '',              // if set, the main image will be no wider than specified value (in pixels)
  		maxheight: '350',             // if set, the main image will be no taller than specified value (in pixels)
  		thumbwidth: 35,           // thumbnail width (in pixels)
  		thumbcrop: true,          // if true, thumbnails will be a perfect square and some of the image will be cropped
  		croppercent: .12,          // if thumbcrop: true, the thumbnail will be scaled to this 
  								   // percentage, then cropped to a square
  		thumbplacement: 'bottom',  // placement of thumbnails (top, bottom, left, right)
  		thumbcontainer: '',        // width of the thumbnail container div (in pixels)
  		opacity: .8,               // opacity level of thumbnails           // if set, text will display while images are loading
  		load_image: '/images/loading.png',
  		                           // image to display while images are loading
  		wrapperclass: 'outer'      // classname for outer wrapping div
  	});
    
	  // Load theme
    Galleria.loadTheme('/javascripts/galleria/themes/fullscreen/galleria.fullscreen.js');
    
    if ( !$.browser.msie ) {
      $('#galleria-bg').galleria({
          image_crop: true, // don’t crop images
          transition: 'fade', // sliding transition
          show_info: false, // don’t show captions
          thumbnails: false // hide the thumbnails
      });

      $('#galleria').galleria({
          image_crop: true, // don’t crop images
          transition: 'fade', // sliding transition
          show_info: false, // don’t show captions
          thumbnails: false // hide the thumbnails
      });
      
      $("a.hide").toggle(function() {
        $("#page").fadeOut();
        $("#sidebar").fadeOut();
        $("#intro").fadeOut();
        $(this).text("Show Menu")
      }, function() {
        $("#page").fadeIn();
        $("#sidebar").fadeIn();
        $("#intro").fadeIn();
        $(this).text("Show Gallery")
      });
    }
    
    $("a.popout").live("click", function(){
      $("body").prepend("<div class='main'></div>");
     var url = $(this).attr('href');
     if(url.substr(0,1) != "#"){
       $(".main").load(url, function(){
         $("a.close").live("click", function(){
           $(".main").html("");
           $(".main").fadeOut();
         });
    
       }).fadeIn('slow');
     }
       return false;
    });
    
    
  	
});
