// JavaScript Document
function jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/* ########   current_images should be presented in this format, or similar ############# */

function pageInit(){
if(typeof current_images!='undefined'){
	if(current_images.length>1){
	doGallery();
	}else if(current_images.length ==1){
	doImage()
	}
	}
}
function doGallery(){// this code makes the gallery thumbs
if (typeof gal == 'undefined'){showImage(0)}// show the first image if the page has just loaded
	gal='<div id="thumblock"><div id="thumbtop"></div><br><br><br>';
	  for(i=0;i<current_images.length;i++){
		var imgname =imgfolder + current_images[i].path + '/thumbs/thum_'+ current_images[i].file;
		
		//file,path,credits,comment
		var title = current_images[i].title; 
		gal+='<div class="thumb"><a href="javascript:showImage('+i+')"><img src="'+ imgname +'" alt="'+ current_images[i].comment+'" border="0"></a></div>'
	}	
gal+=('<div class="clear"><br></div></div>');
update('thumbs',gal);
/* not doc.write .... do update */
}

function doImage(){

var imgname =imgfolder+ current_images[0].path +'/'+ current_images[0].file;

	if (typeof current_images[0].credits !='undefined' && current_images[0].credits !=''){
		var credit = ' ('+current_images[0].credits +')';
	}else{credit=''} 
if (typeof current_images[0].comment !='undefined'){
	var comment = current_images[0].comment;
	}else{comment=''} 

var caption = comment + credit;
var data='<div align="center"><img src="'+imgname+'" id="currentimage" alt="'+caption+'"></div>';
	data +='<p class="img_caption">'+caption+'</p>';
update('bigImage',data);
}

/************  show the chosen picture  ***********/
function showImage(imgval){
	arraypos=imgval;
	//alert (imgval);
	if (arraypos <0){arraypos= current_images.length-1};
	if (arraypos ==current_images.length){
	arraypos=0};
	
	if (typeof current_images[arraypos].comment !='undefined'){
		var comment = current_images[arraypos].comment;
	}else{comment=''} 
	
	if (typeof current_images[arraypos].credits !='undefined' && current_images[arraypos].credits !=''){
		var credit = ' ('+current_images[arraypos].credits +')';
	}else{credit=''} 
	

	var imgname =imgfolder+ current_images[arraypos].path +'/'+ current_images[arraypos].file;
	var title = current_images[arraypos].title;
	var caption = comment + credit;
	//if(typeof current_images[arraypos].comment )
	var data = '<div align="center" id="showImageText">';
	data += '<a href="javascript:showImage(arraypos-1);">Previous</a>';
	data +=' | '+(arraypos +1) + ' of '+ current_images.length + ' | ';
	data += '<a href="javascript:showImage(arraypos+1);">Next</a><br></div>';
	data += '<div align="center"><img src="'+imgname+'" id="currentimage" alt="'+caption+'"></div>';
	data +='<p class="img_caption">'+caption+'</p>';
	update('bigImage',data);
}

/* ########   update the chosen area - a useful multi-purpose function #######  */

function update(target,data) { 
var ie4=Boolean(document.all && !document.getElementById);
var target=(ie4)?document.all[target]:document.getElementById(target);
target.innerHTML=data;
}