function PhotoReport(index, totalCount)
{
	this.index = index;
	this.totalCount = totalCount;
	this.Init = function()
	{
		var instance = this;
		$(document).ready(function()
		{
			//init photo navigation
			$("div.photoreport div.navigation a.prev-photo").click(function()
			{
				instance.Prev();
				return false;
			});
			$("div.photoreport div.navigation a.next-photo").click(function()
			{
				instance.Next();
				return false;
			});
			$("div.thumbnails img").each(function(i)
			{
				var index = i;
				$(this).parent().click(function()
				{
					instance.Load(index);
					return false;
				});
			});
		});
	};
	this.Next = function ()
	{
		this.index++;
		if (this.index >= this.totalCount)
			this.index = 0;
		this._getPhoto();
	};
	this.Prev = function ()
	{
		this.index--;
		if (this.index < 0)
			this.index = this.totalCount - 1;
		this._getPhoto();
	};
	this.Load = function(index)
	{
		this.index = index;
		this._getPhoto();
	};
	this._getPhoto = function()
	{
		var postData = {};
		postData.sender = "ajax";
		postData.requestedPhoto = this.index;
		$.post(location.href, postData, function(data, textStatus)
		{
			var o = JSON.parse(data);
			$("div.thumbnails img.active-photo").removeClass();
			$("div.thumbnails").scrollTo($("div.thumbnails img:eq(" + activeReport.index + ")"), 500, {axis: 'x',offset:-435});
			$("div.thumbnails img:eq(" + activeReport.index + ")").addClass("active-photo");
			$("div.photoreport div.current-photo img.active-photo").attr("src", o.url).load(function()
			{
				$.event.trigger('onImageShow', [{src: "photoview"}]);
			});
		});
		if (this.index >= (this.totalCount - 1))
			$("div.photoreport div.navigation a.next-photo").hide();
		else
			$("div.photoreport div.navigation a.next-photo").show();
		if (this.index == 0)
			$("div.photoreport div.navigation a.prev-photo").hide();
		else
			$("div.photoreport div.navigation a.prev-photo").show();
	};
	this.Init();
}
function AddToFavorites()
{
	if (navigator.appName != 'Microsoft Internet Explorer')
	{
		window.sidebar.addPanel(document.title, window.location.href,"");
	}else
	{
		window.external.AddFavorite(window.location.href, document.title);
	}
}