function GalleryPage( strControllerURL ){
	this.ControllerURL = strControllerURL;
	this.BaseLocation = window.location;
	this.Init();
};

GalleryPage.prototype.objPostProperties = function( objPostProperties ){
	this.PostProperties = objPostProperties;
};

GalleryPage.prototype = new PageControllerClass;
GalleryPage.prototype.Init = function(){
	var objSelf = this;
	this.SetBusy(true);
	$('div#albumimages a').css(
		{opacity:"1",filter:'alpha(opacity=100)','background-color':"#ffffff"}
		).mouseover(function(){$(this).stop().animate(
			{opacity:".8",filter:'alpha(opacity=80)','background-color':"#ffffff"},{duration:50})
		}).mouseout(function(){$(this).stop().animate(
			{opacity:"1",filter:'alpha(opacity=100)','background-color':"#ffffff"},{duration:50}
		);}
	);

	$('a._thumbnail').click(
		function(objEvent){
			var $this = $(this);
			objSelf.SubmitSelected($this);
			objEvent.preventDefault();
			return(false);
		}
	);
	$('a._next').click(
		function(objEvent){
			var $this = $(this);
			objSelf.SubmitSelected($this);
			objEvent.preventDefault();
			return(false);
		}
	);
	$('a._prev').click(
		function(objEvent){
			var $this = $(this);
			objSelf.SubmitSelected($this);
			objEvent.preventDefault();
			return(false);
		}
	);

	this.SetBusy(false);
};

GalleryPage.prototype.SubmitSelected = function( jLink ){
	var objSelf = this;
	var objPostProperties = objSelf.getLinkProps( jLink );
	objSelf.SubmitSelectHandler( objPostProperties , jLink );
};

GalleryPage.prototype.SubmitSelectHandler = function( objPostProperties , jLink ){
	var objSelf = this;
	$('a#mainImage img').attr('src',objPostProperties.thumbnail);
	$('a#mainImage').attr('href',objPostProperties.directLink);

	var nextRowID = parseInt(objPostProperties.row)-parseInt(1);
	var prevRowID = parseInt(objPostProperties.row)+parseInt(1);
	if(prevRowID == $('#lastrow').val()){prevRowID=$('#firstrow').val();};
	if(nextRowID <= $('#lastrow').val()){nextRowID=$('#lastrow').val();};

	var prevLink = $('a[rev='+prevRowID+']');
	var nextLink = $('a[rev='+nextRowID+']');
	var prevLinkProps = objSelf.getLinkProps(prevLink);
	var nextLinkProps = objSelf.getLinkProps(nextLink);
	objSelf.setLinkProps(prevLinkProps,$('a._prev'));
	objSelf.setLinkProps(nextLinkProps,$('a._next'));
};

GalleryPage.prototype.setLinkProps = function( objPostProperties, jLink ){
	jLink.attr('href',objPostProperties.href);
	jLink.attr('rel',objPostProperties.thumbnail);
	jLink.attr('title',objPostProperties.directLink);
	jLink.attr('id',objPostProperties.id);
	jLink.attr('rev',objPostProperties.row);
};

GalleryPage.prototype.getLinkProps = function( jLink ){
	var objPostProperties = {
		"href": jLink.attr("href"),
		"thumbnail": jLink.attr("rel"),
		"directLink": jLink.attr("title"),
		"id": jLink.attr("id"),
		"row": jLink.attr("rev")
	};
	return objPostProperties;
};