// JavaScript Document
var galleryAjaxURL = '../lib/gallery/gallery.ajax.php'

function LoadPhotoGallery(folder)
{
	//alert("Begin load gallery for folder:" + folder);
	ActivateLoader(true, "gallery");
	
	$.ajax({
  		
		type: "POST",
		url: galleryAjaxURL,
		cache: false,
		data:{type:"photo", key:folder, image_folder:".."},
		dataType: "html",
		success: UpdatePhotoGallery
		});
}

function UpdatePhotoGallery(html)
{
	//alert(html);
	
	// Stop loader icon
	ActivateLoader(false, "gallery");

	// Update gallery div and run gallery again
	$("#gallery").html(html);
	
	// Run gallery
	RunPhotoGallery();
}

function RunPhotoGallery()
{
	$('#gallery').galleria(
	{
	height:380,
	
	// Shows navigation as cursor for webkit
    	_webkitCursor: true,

	// Animates the thumnails
    	_animate: true,
	
	//Defines how the main image will be cropped inside its container
	imageCrop:false,
	
	//Sets how Galleria should crop when in fullscreen mode
	fullscreenCrop:false
	
	});
}

function LoadVideoGallery(id)
{
	ActivateLoader(true, "videogallery");
	
	$.ajax({
  		
		type: "POST",
		url: galleryAjaxURL,
		cache: false,
		data:{type:"video", key:id},
		dataType: "html",
		success: UpdateVideoGallery
		});
}

function UpdateVideoGallery(html)
{
	//alert(html);
	
	// Stop loader icon
	ActivateLoader(false,"videogallery");

	// Update gallery div and run gallery again
	$("#videogallery").html(html);
}

function ActivateLoader(bActivate, elementid)
{
	if( bActivate )
	{
		$("#"+elementid).html('<div class="loader"><img src="../data/images/loader.gif" alt="Please Wait: Loading Images" /></div>');
	}
	else
	{
		$("#"+elementid).html('');
	}
}


