function getVal(name){
	var val = window.location.querystring[name];
	if(val==null||val=='')
		val = '0';
	var filter = /^\d*$/i
	if(!filter.test(val))
		val = '0';
	return eval(val)
}
window.location.querystring = (function() {   
    var result = {};   
    var querystring = window.location.search;   
    if (!querystring)   
        return result;   
    var pairs = querystring.substring(1).split("&");   
    var splitPair;   
    for (var i = 0; i < pairs.length; i++) {   
        splitPair = pairs[i].split("=");   
        result[splitPair[0]] = splitPair[1];   
    }   
    return result;   
})(); 
function ShowPreview1(nPos)
{
	var oDiv = document.getElementById("preview_" + nPos);
	if (oDiv != null)
		oDiv.style.display = "inline";
}

function HidePreview1(nPos)
{
	var oDiv = document.getElementById("preview_" + nPos);
	if (oDiv != null)
		oDiv.style.display = "none";
}

function ShowPicture1(strID,prefix)
{
	for (i = 0; i < aPhotos.length; i++)
	{
		if (aPhotos[i][0] == strID)
		{
			document.getElementById("LargeImage").src = aPhotos[i][1];
			document.getElementById("LargeImage").alt = aPhotos[i][1];
			document.getElementById("LargeImageDescr").innerHTML = aPhotos[i][2];
			nCurrentShowPicturePos = i;
		}
		var oPage = document.getElementById("a_preview_" + i);
		if (oPage != null)
			oPage.className = (aPhotos[i][0] == strID ? "box_select" : "box");	
	}

}

function ShowPhotoDescription1(isShow,pref)
{
	if (isShow)
	{
		$('#HidePhotoDescription'+pref).css("display", "block");
		$('#ShowPhotoDescription'+pref).css("display", "none");
		$('#LargeImageDescr').css("display", "block");
	}
	else
	{
		$('#HidePhotoDescription'+pref).css("display", "none");
		$('#ShowPhotoDescription'+pref).css("display", "block");
		$('#LargeImageDescr').css("display", "none");
	}
	return false;
}

var bStopSlideShow = false;

function ShowAllPhoto1(itemPos, isLast, pref)
{
	bStopSlideShow = false;
	$("#StartSlideShow"+pref).hide();
	$("#StopSlideShow"+pref).show();
	SlideShow1(itemPos, isLast, pref);
	return false;
}

function SlideShow1(itemPos, isLast, pref){
	if(nCurrentShowPicturePos+1>=itemPos){
		if(eval(isLast)==1)
			StopSlideShow1(pref);
		else{
			bStopSlideShow = true;
			var items = $id("a_preview_" + nCurrentShowPicturePos).parentNode.getElementsByTagName("a");
			window.location = items[items.length-1].href+"&play=1";
		}
	}

	if (!bStopSlideShow)
	{
		nCurrentShowPicturePos++;
		ShowPicture1(aPhotos[nCurrentShowPicturePos][0], pref);
		setTimeout("SlideShow1(" + itemPos + ", '" + isLast + "', '" + pref + "');", 3000);
	}
}

function PictureSrc(){
	if(currentTab==0)
		document.write("<img id='LargeImage' src='" + aPhotos[nCurrentShowPicturePos][1] + "' alt='"+aPhotos[nCurrentShowPicturePos][1]+"' />");
}

function PictureDescr(){
	if(currentTab==0)
		document.write(aPhotos[nCurrentShowPicturePos][2]);
}

function StopSlideShow1(pref)
{
	$("#StopSlideShow"+pref).hide();
	$("#StartSlideShow"+pref).show();
	bStopSlideShow = true;
	return false;
}

function continePlay(){
	window.location.href = '#tabs';
	$id("StartSlideShow"+(currentItem+1)).getElementsByTagName("a")[0].onclick()
}
var currentTab = getVal("tab");
var currentItem = getVal("item");
var currentPlay = getVal("play");
var nCurrentShowPicturePos = 10*currentItem;