/* major variation here - 2006 july */
 
function pageInit(){
	if(typeof current_images!='undefined'){
		if(current_images.length==1){doImage();
		}else{doGallery();}

		}
}



// 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;
var gal='';
	  for(i=0;i<current_images.length;i++){  
	 
	  var path=current_images[i].path;
	  var picUrl= current_images[i].path+'/'+current_images[i].file;
	
	var imgname =imgfolder +path+ '/thumbs/'+ current_images[i].file;
		
		gal +='<a href="javascript:popPic(\''+picUrl+'\',\' '+current_images[i].comment+'\')" title="image" class="thumb"><img src="'+imgname+'" border="0" alt="'+current_images[i].comment+'"></a>';
	}	
	update('gallery',gal);
}

function popPic(sPicURL,windowTitle) { 
if(typeof windowTitle =="undefined" || windowTitle ==""){windowTitle="Image Gallery"}

		window.open("gallerize.htm?"+sPicURL+'&'+windowTitle, "", "resizable=1,scrollbars=1,HEIGHT=200,WIDTH=400");
}





function doImage(){// only one image .. then doImage
  var picUrl= imgfolder+current_images[0].path+'/'+current_images[0].file;

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

	var data = '';
	data += '<div id="bigImg"><img src="'+picUrl+'" alt="'+comment +'">';
	data +='<strong> '+comment+'</strong></div>';
	update('gallery',data);
}


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