
function loadExtJSCallback(sScriptSrc, callbackfunction) {
	var oHead = document.getElementsByTagName('head')[0];

	if(oHead) {	
		var oScript = document.createElement('script');
		var loadFunction = function() {
			if(this.readyState == 'complete' || this.readyState == 'loaded') {
				callbackfunction(); 
			}
		};

		oScript.setAttribute('src', sScriptSrc);
		oScript.setAttribute('type', 'text/javascript');
		oScript.onreadystatechange = loadFunction;
		oScript.onload = callbackfunction;
		
		oHead.appendChild(oScript);
	}
}

function add_photo_gallery() {
	$('a[rel^="lightbox"]').prettyPhoto({
		theme: gallery_theme, 
		overlay_gallery: false, 
		autoplay: gallery_autoplay
	});
}

function init_photo_gallery() {
	if(undefined === window.gallery_theme) window.gallery_theme = 'light_square';
	if(undefined === window.gallery_autoplay) window.gallery_autoplay = true;
	loadExtJSCallback("http://www.michaelscatering.com.au/./includes/admin/jscript/prettyPhoto/jquery.prettyPhoto.js", add_photo_gallery);
}

if(!(window.jQuery)) loadExtJSCallback('http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js', init_photo_gallery);
else $(document).ready(function() { init_photo_gallery(); });


