function showPic (whichpic,img_id) { 	
 	if (document.getElementById) {
	  var fname=whichpic.href.split("/");	  
	  	  
	  // Remove the border around the thumbnail
	  document.getElementById('b'+document.getElementById('image_id').innerHTML).className = 'thumbnail_off';
	  
	  var id_len = whichpic.id.length;
	  document.getElementById('image_id').innerHTML = whichpic.id.substring(id_len, 1);
	  
	  //document.getElementById('fname').innerHTML = fname[fname.length-1];
	  document.getElementById('fname').innerHTML = document.getElementById('p'+img_id).innerHTML;
	  
	  // Put a border around the thumbnail
	  document.getElementById('b'+img_id).className = 'thumbnail_on';
	  
	  if (document.getElementById('placeholder').filters) 
	  	document.getElementById('placeholder').filters[0].apply();	  
	  document.getElementById('placeholder').src = whichpic.href;
	  if (document.getElementById('placeholder').filters)
	  	document.getElementById('placeholder').filters[0].play();	  	  
	  if (whichpic.title) {
		   document.getElementById('desc').childNodes[0].nodeValue = whichpic.title;
		} else {
		   document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
		}		
	  return false;
	} else {
	  return true;
 	}
}
function nextImage (curpage,maxpage) { 	
 	var curIndex; 		
 	
 	var img_id = document.getElementById('image_id').innerHTML;
 	if (img_id.length>0)
 		curIndex = ArraySearch(img_id,jsArray);
 	else
 		curIndex = 0;
 				
	if (curIndex<jsArray.length-2)
 		showPic (document.getElementById('n'+jsArray[curIndex+1]),jsArray[curIndex+1]); 	 	 	 	 		 		
 	else
 		if (curpage<maxpage) {
 			if (location.href.indexOf('&pag=')>0) 
 				location.href=location.href.replace('&pag='+curpage,'&pag='+(curpage+1));
 			else	
 				location.href=location.href+'&pag='+(curpage+1);
 		}
}
function previousImage (curpage,maxpage) { 	
 	var curIndex; 	
 	
 	var img_id = document.getElementById('image_id').innerHTML;
 	if (img_id.length>0)
 		curIndex = ArraySearch(img_id,jsArray);
 	else
 		curIndex = 0;
 	
 	if (curIndex>0)
 		showPic (document.getElementById('n'+jsArray[curIndex-1]),jsArray[curIndex-1]); 	 	
 	else
 		if (curpage>1) {
 			if (location.href.indexOf('&pag=')>0) 
 				location.href=location.href.replace('&pag='+curpage,'&pag='+(curpage-1));
 			else	
 				location.href=location.href+'&pag='+(curpage-1);
 		}
}
function ArraySearch( searchS, arraySA ) {
 var I = 0;
 var minI = 0;
 var maxI = arraySA.length - 1;
 //
 var s = "";
 //
 var foundB = false;
 //
 I = minI - 1;
 while ( ( I <= maxI ) && ( !( foundB ) ) ) {
  I = I + 1;
  s = arraySA[ I ];
  foundB = ( searchS == s );
  }
 if ( foundB ) {
  return( I );
 }
 else {
  return(-1); 
 }
}