 /*steve 2/10/2004 */
 
function pageInit(){

	if(typeof current_images!='undefined'){
			if(current_images.length>1){
			doGallery();
			}else if(current_images.length ==1){doImage();}
	}
}



// if there is a searchable variable get that picture
var searchOn = window.location.href.indexOf("reqpic");
if (searchOn>0){
	var searchPlace = window.location.href.substring(searchOn);
	var searchOn = searchPlace.indexOf('=')+1;
	var reqpic = searchPlace.substr(searchOn);
	requested(reqpic);
}
function requested(reqpic){
	for(var i in current_images){
		for (var k in current_images[i]){
		if ( reqpic == current_images[i][k]){
		pickPic= i;
		};
		}
	}
}

function doGallery(){// this code makes the gallery thumbs
if (typeof gal == 'undefined')nogal=1;
	gal='<div id="bigImage"></div>';
	  for(i=0;i<current_images.length;i++){  
	  
	  var path=current_images[i].path;
		var imgname =imgfolder +path+ '/thumbs/'+ current_images[i].file;
		gal +='<div class="thumb"><a href="javascript:showImage('+i+')"><img src="'+imgname+'"></a></div>';
	}	
	
	gal+=('<p class="clearboth"><br></p>');// end of the thumb block
	update('gallery',gal);
	if (nogal){
	if(typeof pickPic!='undefined'){showImage(pickPic)
	}else{showImage(0);}
	}
}



function showImage(imgval){// this is if there is more than one image
	arraypos=eval(imgval);
	var path=current_images[arraypos].path;
	var imgname =imgfolder +path+'/'+ current_images[arraypos].file;
	if (arraypos <0){arraypos= current_images.length-1};
	if (arraypos ==current_images.length){arraypos=0};	
	
	if (typeof current_images[arraypos].title =='undefined'){
		var title = '';
	}else{var title=current_images[arraypos].title};
	
	if (typeof current_images[arraypos].comment !='undefined'){
		var comment = current_images[arraypos].comment;
	}else{comment=''} 

	
	var title = current_images[arraypos].title;
	var data = '';
	data += '<img src="'+imgname+'" id="currentimage" alt="'+title +'">';
	data +='<p class="imgCaption"><strong> '+comment+'</strong></p>';

	update('bigImage',data);
}


function doImage(){// only one image .. then doImage


	var path= current_images[0].path;
	var imgname =imgfolder +path+'/'+ current_images[0].file;
	if (typeof current_images[0].title =='undefined'){
		var title = '';
	}else{var title=current_images[0].title};

if (typeof current_images[0].comment !='undefined'){
		var comment = current_images[0].comment;
	}else{comment=''} 
	
	var data = '';
	data += '<img src="'+imgname+'" id="currentimage" alt="'+title +'">';
	data +='<p class="imgCaption"><strong> '+comment+'<\/strong><\/p>';
	//alert(data)
	update('bigImage',data);
}


function update(target,data) { 
var ie4=Boolean(document.all && !document.getElementById);
var target=(ie4)?document.all[target]:document.getElementById(target);
target.innerHTML=data;
}