﻿/*
Copyright 2007 - Conrad StudioWorks LLC

Requires: Moo Tools library v1.1 or greater.

This dynamically loads content into any div.

*/

function loadData (urlOfDataToLoad, IdOfLocationToLoadData, method, galleryTitle)
{
	//Create the Ajax control.
	var myAjax = new Ajax(urlOfDataToLoad, {method: method, 
	                                        update: $(IdOfLocationToLoadData),
	                                        //Load loading wheel.
	                                        onRequest: function(){$(IdOfLocationToLoadData).setHTML("<img src='../../images/ajaxLoader.gif' alt='Loading...' />");}, 
	                                        //Kill loading wheel, and if an on complete has been passed, process it.	                                        
			                                onComplete: function(){
			                                                        //If we just loaded the gallery_loading_area then start the slideshow
			                                                        if(IdOfLocationToLoadData == "gallery_loading_area")
			                                                        {
			                                                            function startGallery(){var studentSlideshow = new gallerySet($('myGallerySet'), {timed: true, useThumbGenerator: true, textShowGallerySelector: 'Back to index', textGallerySelector: '', embedLinks: false}) };
			                                                            window.addEvent('domready', startGallery);
			                                                            
			                                                            if(galleryTitle != null)
			                                                            {
			                                                                $('galleryTitle').setHTML(galleryTitle);
			                                                            }
			                                                        }
			                                                        
			                                                      },
			                                onFailure: function(){$(IdOfLocationToLoadData).setHTML("<strong>Error:</strong> Data not found.");}
	                                       });
    //Run Ajax control.
    myAjax.request();
}        
