var imgAr1 = new Array();
var rImg1 = new Array();

var ic = 0;
var numpics = document.getElementById('ptotal').innerHTML;
var plocation = document.getElementById('ploc').innerHTML;
while (ic < numpics) {
 imgAr1[ic] = "/images/home_gallery/" + plocation + "/img_" + ic + ".jpg";
 ic++;
}

for(var j = 0; j < imgAr1.length; j++)
{
		rImg1[j] = new Image();
            rImg1[j].src = imgAr1[j];
}

var slide;
function setting(strt)
{
	slide = document.getElementById('pic');
	// strt = 2;
	slide.src = imgAr1[strt];
	document.getElementById('pnum').innerHTML = strt + 1;
}


// slideshow function
// Get the start number from a PHP GET var to keep picture position on link back. 
var picture = document.getElementById('pnum2').innerHTML / 1;
function nextone(){
	if(picture < imgAr1.length-1){
		picture=picture+1;
		slide.src = imgAr1[picture];
		document.getElementById('pnum').innerHTML = picture + 1;
		document.getElementById('p_link').href=("photo.php?f=" + plocation + "&pn=" + picture + "&m=" + numpics);
	}
}

function prev(){
	if(picture > 0 ){
		picture=picture-1;
		slide.src = imgAr1[picture];
		document.getElementById('pnum').innerHTML = picture + 1;
		document.getElementById('p_link').href=("photo.php?f=" + plocation + "&pn=" + picture + "&m=" + numpics);
	}
}
