(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);
			
		
jQuery.event.add(window, "load", resizeFrame);
/*jQuery.event.add(window, "resize", resizeFrame);*/

function resizeFrame() 
{
    	var h = $(window).height();
		var galleriaHeight = h - 218;

		$("#galleria").height(galleriaHeight);
		$(".galleria-container").height(galleriaHeight);
		$(".galleria-outer").height(galleriaHeight+18);
			 
}
	
	$(document).ready(function(){
		resizeFrame(); 
		
	 	 $(function () {
				 $.ajax({
					  type: "GET",
					  url: "/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 = '/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');
							  
						  });
						  
						  Galleria.loadTheme('/js/src/themes/dots/galleria.dots.js');

						  $('#galleria').galleria({
								image_crop: false, // crop all images to fit
								thumb_crop: false, // crop all thumbnails to fit
								transition_speed: 700, // slow down the crossfade
								show_counter: false,
								show_imagenav: false,
								image_margin: 2,
								autoplay:3000,
								clicknext: true,
								transition: 'fade', // crossfade photos
								extend: function() {
					
									this.bind(Galleria.IMAGE, function(e) {
							
										$('.counter').html(this.$('counter').html());
							
									})
						
									this.bind(Galleria.IMAGE, function(e) {
							
										$('.caption').html(this.$('info-description').html());
							
									})
								}
					
							});
		  
					  }
	  
				  });
	
			  })
	$(document).load(function(){
		resizeFrame();
	});
	
	$(document).resize(function(){
		resizeFrame();
	});
		
});
	                   
	// Load theme



