// by Glen Murphy. Script located at http://bodytag.org/

var bt_total = 0;
var bt_loaded = 0;
var bt_out = '';
var bt_preimages;

// Text to use for when loading has finished
//var bt_text_finished = 'Done';
var bt_text_finished = '';

// Text to prefix the percentage
//var bt_text_prefix = 'Loaded: ';
var bt_text_prefix = '';

function bt_forcedone() {
	document.getElementById('bt_container').innerHTML = bt_text_finished;
	bt_done();
}

function bt_arrived(o) {

	bt_loaded += bt_preimages[o][1];

	var bt_percentage = Math.round((bt_loaded/bt_total)*100);
	//document.getElementById('bt_container').innerHTML = bt_text_prefix+bt_percentage+'%';

	if(bt_percentage == 100) {
		bt_forcedone();
	}
}

function preLoadWedding1() {
	// Time in seconds to wait before giving up on preload (broken 
	// images can cause the load to never get to 100%).

	var bt_timeout = 8;

	// Array of images to load; feel free to make this as long or
	// as short as you want. First element is filename (include path
	// to file), second is size of images in kB.

	var numOfImages = 18;
	var imgURL = 'images/galleries/wedding1/';
	var thumbURL = imgURL + 'thumbnails/';
	var imgLabel = 'img';
	
	setupImages(numOfImages, imgURL, thumbURL, imgLabel);	
	loadImages();
}

function preLoadWedding2() {
	// Time in seconds to wait before giving up on preload (broken 
	// images can cause the load to never get to 100%).

	var bt_timeout = 8;

	// Array of images to load; feel free to make this as long or
	// as short as you want. First element is filename (include path
	// to file), second is size of images in kB.

	var numOfImages = 14;
	var imgURL = 'images/galleries/wedding2/';
	var thumbURL = imgURL + 'thumbnails/';
	var imgLabel = 'img';
	
	setupImages(numOfImages, imgURL, thumbURL, imgLabel);	
	loadImages();
}


function preLoadWedding3() {
	// Time in seconds to wait before giving up on preload (broken 
	// images can cause the load to never get to 100%).

	var bt_timeout = 8;

	// Array of images to load; feel free to make this as long or
	// as short as you want. First element is filename (include path
	// to file), second is size of images in kB.

	var numOfImages = 12;
	var imgURL = 'images/galleries/wedding3/';
	var thumbURL = imgURL + 'thumbnails/';
	var imgLabel = 'img';
	
	setupImages(numOfImages, imgURL, thumbURL, imgLabel);	
	loadImages();
}

function preLoadExecutive() {
	// Time in seconds to wait before giving up on preload (broken 
	// images can cause the load to never get to 100%).

	var bt_timeout = 8;

	// Array of images to load; feel free to make this as long or
	// as short as you want. First element is filename (include path
	// to file), second is size of images in kB.

	var numOfImages = 17;
	var imgURL = 'images/galleries/executive/';
	var thumbURL = imgURL + 'thumbnails/';
	var imgLabel = 'executive';
	
	setupImages(numOfImages, imgURL, thumbURL, imgLabel);	
	loadImages();
}

function preLoadFamily() {
	// Time in seconds to wait before giving up on preload (broken 
	// images can cause the load to never get to 100%).

	var bt_timeout = 8;

	// Array of images to load; feel free to make this as long or
	// as short as you want. First element is filename (include path
	// to file), second is size of images in kB.

	var numOfImages = 17;
	var imgURL = 'images/galleries/family/';
	var thumbURL = imgURL + 'thumbnails/';
	var imgLabel = 'img';
	
	setupImages(numOfImages, imgURL, thumbURL, imgLabel);	
	loadImages();
}


function preLoadModeling() {
	// Time in seconds to wait before giving up on preload (broken 
	// images can cause the load to never get to 100%).

	var bt_timeout = 8;

	// Array of images to load; feel free to make this as long or
	// as short as you want. First element is filename (include path
	// to file), second is size of images in kB.

	var numOfImages = 13;
	var imgURL = 'images/galleries/modeling/';
	var thumbURL = imgURL + 'thumbnails/';
	var imgLabel = 'img';
	
	setupImages(numOfImages, imgURL, thumbURL, imgLabel);	
	loadImages();
}

function preLoadStudios() {
	// Time in seconds to wait before giving up on preload (broken 
	// images can cause the load to never get to 100%).

	var bt_timeout = 8;

	// Array of images to load; feel free to make this as long or
	// as short as you want. First element is filename (include path
	// to file), second is size of images in kB.

	var numOfImages = 5;
	var imgURL = 'images/galleries/studios/';
	var thumbURL = imgURL + 'thumbnails/';
	var imgLabel = 'img';
	
	setupImages(numOfImages, imgURL, thumbURL, imgLabel);	
	loadImages();
}

function preLoadCorporateEvent() {
	// Time in seconds to wait before giving up on preload (broken 
	// images can cause the load to never get to 100%).

	var bt_timeout = 8;

	// Array of images to load; feel free to make this as long or
	// as short as you want. First element is filename (include path
	// to file), second is size of images in kB.

	var numOfImages = 14;
	var imgURL = 'images/galleries/corporate-event/';
	var thumbURL = imgURL + 'thumbnails/';
	var imgLabel = 'img';
	
	setupImages(numOfImages, imgURL, thumbURL, imgLabel);	
	loadImages();
	
}

function preLoadRestorations() {
	// Time in seconds to wait before giving up on preload (broken 
	// images can cause the load to never get to 100%).

	var bt_timeout = 8;

	// Array of images to load; feel free to make this as long or
	// as short as you want. First element is filename (include path
	// to file), second is size of images in kB.

	var numOfImages = 11;
	var imgURL = 'images/galleries/restorations/';
	var thumbURL = imgURL + 'thumbnails/';
	var imgLabel = 'img';
	
	setupImages(numOfImages, imgURL, thumbURL, imgLabel);	
	loadImages();
}

function setupImages(numOfImages, imgURL, thumbURL, imgLabel) {

	thumbnails = new Array(numOfImages);
	images = new Array(numOfImages);
	bt_preimages = new Array(numOfImages);

	for (i = 0; i < numOfImages; i++) {
		
		//create the imgage and thumbnail array
		imgStr = imgLabel + (i+1) + ".jpg";
		thumbnails[i] = thumbURL + imgStr;
		images[i] = imgURL + imgStr;
		//alert('images[' + i + '] = ' + images[i]);

		//initialize the preLoad image array
		bt_preimages[i] = new Array(2);
		bt_preimages[i][0] = images[i];
		bt_preimages[i][1] = 50;
	}
	
}	
function loadImages() {

	showPleaseWait();

	bt_out += '<div id="bt_container"></div>';

	for(i = 0; i < bt_preimages.length; i++) {
		//alert('bt_preimages[' + i +'][0] = ' + bt_preimages[i][0]);
		bt_total += bt_preimages[i][1];
		bt_out += '<img src="'+bt_preimages[i][0]+'" width="1" height="1" onload="bt_arrived('+i+');" style="position:absolute; top:-1000px;" />';
	}

	//write that data out to the div so that the 'onload' can run for each image
	document.getElementById('preloadImages').innerHTML = bt_out;

}


function showPleaseWait()
{
	var pleaseWait = document.getElementById('pleasewaitScreen');

	if (pleaseWait != null) {
		pleaseWait.style.visibility = "visible";
	} 	
}	

function hidePleaseWait()
{
	var pleaseWait = document.getElementById('pleasewaitScreen');
		
	//lengthy_calculation();
		
	if (pleaseWait != null) {
		pleaseWait.style.visibility = "hidden";
	}	
}

function lengthy_calculation()
{
	var x,y

	for(x=0;x<1000000;x++)
	{
		y += (x * y) / (y - x);
	}
}

var message="Sorry, right-click has been disabled";
///////////////////////////////////
function clickIE() 
{
	if (document.all) {
		//(message);
		return false;
	}
}

function clickNS(e) 
{
	if (document.layers || (document.getElementById && !document.all)) {
		
		if (e.which==2||e.which==3) {
			//(message);
			return false;
		}
	}
}

if (document.layers)
{
	document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;
} else {
	document.onmouseup=clickNS;document.oncontextmenu=clickIE;
}

document.oncontextmenu=new Function("return false")