// IMAGE GALLERY SCRIPTS
// =====================

function error_img(error){
error.alt="0";
error.src="images/no_img.jpg";
}

function prev_pg(){
pg=pg-1;
if (pg==-1) {pg=pages[dir];}
var new_src=0;
var p=pg*12;
for (i=0; i<12; i++) {
	new_src=i+p+1;
	var new_thumb=document.getElementsByName("thumbnail");
	new_thumb[i].src="thumbs/"+dir+"/"+new_src+".jpg";
	new_thumb[i].alt=new_src;
	}
document.getElementById("pageof").innerHTML='<p align="center">Page '+(pg+1)+' of '+(pages[dir]+1)+'.<\/p>';
}

function next_pg(){
pg=pg+1;
if (pg==(pages[dir]+1)) {pg=0;}
var new_src=0;
var p=pg*12;
for (i=0; i<12; i++) {
	new_src=i+p+1;
	var new_thumb=document.getElementsByName("thumbnail");
	new_thumb[i].alt=new_src;
	new_thumb[i].src="thumbs/"+dir+"/"+new_src+".jpg";	
	}
document.getElementById("pageof").innerHTML='<p align="center">Page '+(pg+1)+' of '+(pages[dir]+1)+'.<\/p>';
}

function closeIMG(){
document.getElementById("img_win").innerHTML='';
document.getElementById("img_win").style.visibility='hidden';
}

function openIMG(img_src){
if (img_src!="0") {
	document.getElementById("img_win").innerHTML='<p align="center"><img src="gallery/'+dir+'/'+img_src+'.jpg" onClick="javascript: closeIMG();"><\/p><p>Click to close...<\/p>';
	document.getElementById("img_win").style.visibility='visible';
}
}


function change(){
pg=-1;
dir=document.getElementById("gal_list").value;
next_pg();
}