/* 	Image and Ajax Loader for Kate Schutt site
	Barking Dog Studios
	David Lachapelle
	Last Modified: February 20th, 2007
*/

/*	Initilization function
	Begins loading of the images in the image array and sets the corresponding onload functions
	Note: Safari cannot preload images right now either
*/

var isLoading = true;

function init() {
	if(BrowserDetect.browser != "Safari" && BrowserDetect.browser != "Camino" && BrowserDetect.browser != "Opera") {
		var pics = Array();
		//need to load all the images on this page before loading the background panels
		for(var i = 0; i < images.length; i++) {
			pics[i] = new Image();
			pics[i].src = images[i][0];
			pics[i].onload = function() { checkLoadedImages(this); };
		}
	} else {
		ajax_beginLoad();
	}
}

/*	Image onload function
	Determines when all the images have been loaded and when they have, begins making ajax calls
*/
function checkLoadedImages(img) {
	var i;
	for(i = 0; i < images.length; i++) {
		if(images[i][0] == img.src.replace(root_site,"")) {
			images[i][1] = true;
		}
	}

	for(i = 0; i < images.length; i++) {
		if(images[i][1] == false)
			return;
	}

	ajax_beginLoad();
}

/*	Ajax loader
	Fairly simple, just begins loading content using the container data.
*/
function ajax_beginLoad() {
	ajax_loadContent(containers[0][0], containers[0][1]);
	return;
}
