// JavaScript Document
/** -----------------------------------------------
  Image Preloader - v.1.1
  (c) 2007 http://www.haan.net
  You may use this script but please leave the credits on top intact.
  Please inform us of any improvements made.
  When useful, we will add your credits.
------------------------------------------------ */
var imgGal = new Array();
function imgPreload(imgQueue) {
	//alert('imgPreload(); '+imgQueue.length);
 	for (i=0;i<imgQueue.length;i++) {
  		imgGal[i] = new Image();
  		imgGal[i].src = imgQueue[i]; // change file extension, if necessary.
 		// uncomment next line for testing; click OK to continue loop and cancel to break
		//imgLoaded[i].onload=function(){ alert('onload:'+imgLoaded[i].src);}
		//if(imgGal[i].complete) alert('load complete:'+imgGal[i].src);
		//alert(imgQueue[i]);
 	}
}

/**
 get all of Tag A is attribut 'rel' start with 'lightbox' 
 and put into array for preload function
*/
/*var imgQueue = new Array();
function getImageQueue(){
	//alert('getImageQueue()');
	var tagA = document.getElementsByTagName('a');
		for(var i=0; i<tagA.length; i++){
			if(tagA[i].getAttribute('rel') != null && tagA[i].getAttribute('rel').match(/^boatgal/) )
				imgQueue.push(tagA[i].href);
		}//end for
//	alert('Image in queue:'+imgQueue.length);
}//end function
*/
/** 
 call the function with the list of images (unique part of names)
 Multiple onload function created by: Simon Willison
 http://simon.incutio.com/archive/2004/05/26/addLoadEvent
*/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
addLoadEvent(function() {
	//alert('addLoadEvent');
	//getImageQueue(); // push image url to imgQueue, for preload function
	
	
	if(typeof gallery != 'undefined' && gallery.length > 0)	
		imgPreload(gallery);
	else alert(typeof gallery);
	
	btStart_click();//start slideshow
	thumPrev();//thumbnail bar
	
});
