var paddingsize = 23;
var galleryimage = 0;
var galleryindent = 0;
var gwin;
var gbn;
var gbb;
function resetGallery() {
	gwin = new Animation(document.getElementById('galleryScrollbar'));
	gbb = new Animation(document.getElementById('gbackb'));
	gbn = new Animation(document.getElementById('gnextb'));
	galleryimage = 0;
	galleryindent = 0;
	var imagesize = document.getElementById('gi0');
	st_animation(document.getElementById('popupwindow'),'width', parseInt(document.getElementById('popupwindow').style.width), paddingsize+imagesize.width+150, 10, 25, true);
	st_animation(document.getElementById('popupwindow'),'height', parseInt(document.getElementById('popupwindow').style.height), paddingsize+imagesize.height+150, 10, 25, true);
}

function galleryNext() {
	if (document.getElementById('gi'+(galleryimage+1)) != null) {
		var imagesize = document.getElementById('gi'+galleryimage).width;
		var scrollerpos = galleryindent;
		galleryindent = scrollerpos+paddingsize+imagesize;
		st_animationb(gwin,'textIndent', scrollerpos, galleryindent, 10, 25, true);
		galleryimage++;
		var nextimagesize = document.getElementById('gi'+galleryimage);
		st_animationb(gwin,'width', parseInt(document.getElementById('galleryScrollbar').style.width), paddingsize+nextimagesize.width, 10, 25, true);
		st_animationb(gwin,'height', parseInt(document.getElementById('galleryScrollbar').style.height), paddingsize+nextimagesize.height, 10, 25, true);
		
		st_animation(document.getElementById('popupwindow'),'width', parseInt(document.getElementById('popupwindow').style.width), paddingsize+nextimagesize.width+150, 10, 25, true);
		st_animation(document.getElementById('popupwindow'),'height', parseInt(document.getElementById('popupwindow').style.height), paddingsize+nextimagesize.height+150, 10, 25, true);
		
		
		var nextimagesize = document.getElementById('gi'+(galleryimage+1));
	
		// Buttons Enable/Disable
		if (nextimagesize == null) {
			st_animationb(gbn,'opacity', parseInt(document.getElementById('gnextb').style.opacity), 0.5, 30, 0.05, true);
		} else {
			st_animationb(gbn,'opacity', parseInt(document.getElementById('gnextb').style.opacity), 1, 30, 0.05, true);
		}
		st_animationb(gbb,'opacity', parseInt(document.getElementById('gbackb').style.opacity), 1, 30, 0.05, true);
	}
}

function galleryPrevious() {
	if (document.getElementById('gi'+(galleryimage-1)) != null) {
		galleryimage--;
		var imagesize = document.getElementById('gi'+galleryimage).width;
		var scrollerpos = galleryindent;
		galleryindent = galleryindent-paddingsize-imagesize;
		st_animationb(gwin,'textIndent', scrollerpos, galleryindent, 10, 25, true);
		var nextimagesize = document.getElementById('gi'+galleryimage);
		st_animationb(gwin,'width', parseInt(document.getElementById('galleryScrollbar').style.width), paddingsize+nextimagesize.width, 10, 25, true);
		st_animationb(gwin,'height', parseInt(document.getElementById('galleryScrollbar').style.height), paddingsize+nextimagesize.height, 10, 25, true);
		
		st_animation(document.getElementById('popupwindow'),'width', parseInt(document.getElementById('popupwindow').style.width), paddingsize+nextimagesize.width+150, 10, 25, true);
		st_animation(document.getElementById('popupwindow'),'height', parseInt(document.getElementById('popupwindow').style.height), paddingsize+nextimagesize.height+150, 10, 25, true);
		
		
		var nextimagesize = document.getElementById('gi'+(galleryimage-1));
		
		// Buttons Enable/Disable
		if (nextimagesize == null) {
			st_animationb(gbb,'opacity', parseInt(document.getElementById('gbackb').style.opacity), 0.5, 30, 0.05, true);
		} else {
			st_animationb(gbb,'opacity', parseInt(document.getElementById('gbackb').style.opacity), 1, 30, 0.05, true);
		}
		st_animationb(gbn,'opacity', parseInt(document.getElementById('gnextb').style.opacity), 1, 30, 0.05, true);
	}
}
