	
	(function($){
  $.fn.shuffle = function() {
    return this.each(function(){
      var items = $(this).children();
      return (items.length)
        ? $(this).html($.shuffle(items))
        : this;
    });
  }

  $.shuffle = function(arr) {
    for(
      var j, x, i = arr.length; i;
      j = parseInt(Math.random() * i),
      x = arr[--i], arr[i] = arr[j], arr[j] = x
    );
    return arr;
  }
})(jQuery);
	
	$(document).ready(function(){

  	var h = $(window).height();
	var galleriaHeight = h-72;
	var w = $(".content").width();
	$("#galleria").width(w);
	$(".caption").width(w);
	
 if($('body').height() > 720) {
	 	$("#galleria").height(galleriaHeight);
		$("#galleria").css({"height":galleriaHeight});
 }else{
	 	var galleriaHeight = h-72;
	  	$("#galleria").height(galleriaHeight);
		$("#galleria").css({"height":galleriaHeight});
 }
	
	 	 $(function () {
				 $.ajax({
					  type: "GET",
					  url: "/galleries/home-img/PhotoGallery.xml", // replace with absolute URL of your gallery's xml file
					  dataType: "xml",
					  success: function(xml) {
						  $(xml).find('img').each(function() {
							 var location = '/galleries/home-img/'; // replace with absolute path to the directory that holds your images
							 var url = $(this).attr('src');
							 var alt = $(this).attr('alt');
							  $('<img src="'+location+''+url+'" alt="'+alt+'"/>').appendTo('#galleria');
							  
						  });
																		
						// Load theme
						Galleria.loadTheme('/js/src/themes/dots/galleria.dots.js');



						 $('#galleria').galleria({
								image_crop: false, // crop all images to fit
								thumb_crop: true, // crop all thumbnails to fit
								transition: 'fade', // crossfade photos
								extend: function() { 
								this.bind(Galleria.IMAGE, function(e) {
							
										$('.caption').html(this.$('info-description').html());
							
									})
								}
								
						   
						   });
   

		  
					  }
	  
				  });
	
			  })
	
		
	});
	                  



