var win = null;

function startSlideShow(mypage,myname,w,h,scroll)
{
	if (win) {
	win.close();
	}
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';
	win = window.open(mypage+"&imgID="+BigImageCurrent,myname,settings)
	win.focus();
	return false;
}
var BigImageCurrent=1;
var ThumbScrollPosition=0;
function putBigImg(thumb_id){
	//m_src=document.getElementById("thumb_img_"+thumb_id).src;
	//m_src = thumb_id.src
	//m_src = m_src.replace("&height=72","&width=300");
	if(thumb_id >= GalleryCollection.length){
		thumb_id = GalleryCollection.length-1;
	}
	document.getElementById("big_img").src= '/_gallery/image_sizer.php?imgurl='+GalleryCollection[thumb_id]+'&width=300';
	BigImageCurrent = thumb_id;
	return false;
}

function putNext(){
	if( BigImageCurrent < (GalleryCollection.length)-1){
		BigImageCurrent++;
		putBigImg(BigImageCurrent);
	}
	return false;
}

function putPrev(){
	if(BigImageCurrent >0){
		BigImageCurrent--;
		putBigImg(BigImageCurrent);
	}
	return false;
}

function scrollNext(){
	if((Math.ceil(GalleryCollection.length/3)-1) > (ThumbScrollPosition)){ 
		ThumbScrollPosition++;
		document.getElementById("scroller").style.marginLeft=(-1*(ThumbScrollPosition*360))+"px";
		putBigImg(((ThumbScrollPosition*3)+1));
	}
	return false;
}

function scrollPrev(){
	if(ThumbScrollPosition >0 ){ 
		ThumbScrollPosition--;
		document.getElementById("scroller").style.marginLeft=(-1*(ThumbScrollPosition*360))+"px";
		putBigImg(((ThumbScrollPosition*3)+1));
	}
	return false;
}

