var 
	siteWidth  = 741,
	firstDay   = wdMonday,
	index      = 0, 
	imgGallery;
//=================================================================================================
function customResize( width )
{
	var
		imgBack    = document.getElementById("imgBack"), 
		divGallery = document.getElementById("divGallery"), 
		size       = getSize( szPage );
	
	if ( imgBack )
	{
		imgBack.style.zIndex     = 1000;
		imgBack.style.width      = size.width  + "px";
		imgBack.style.height     = size.height + "px";
		
		divGallery.style.zIndex  = 1001;
		divGallery.style.left    = (size.width - 452) / 2  + "px";
	}
	
	imgGallery = document.getElementById("imgGallery")
}
//=================================================================================================
function priorImage( ID )
{
	var
		gallery = galleries[ID];
	
	if ( typeof( gallery ) != "undefined")
	{
		if ( index > 0 )
			imgGallery.src = gallery.images[--index].link( true );
		else
		{
			index = gallery.images.length - 1;
			imgGallery.src = gallery.images[index].link( true );
		}
		
		imgGallery.alt = gallery.images[index].name;
	}
}
//-------------------------------------------------------------------------------------------------
function nextImage( ID )
{
	var
		gallery = galleries[ID];
	
	if ( typeof( gallery ) != "undefined")
	{
		if ( index < gallery.images.length - 1 )
			imgGallery.src = gallery.images[++index].link( true );
		else
		{
			index = 0;
			imgGallery.src = gallery.images[index].link( true );
		}
		
		imgGallery.alt = gallery.images[index].name;
	}
}
//=================================================================================================
function closeGallery()
{
	var
		imgBack    = document.getElementById("imgBack"), 
		divGallery = document.getElementById("divGallery");
	
	imgBack.style.display    = "none";
	divGallery.style.display = "none";
	
	currID = null;
}
//=================================================================================================
var
	currID = null;
//-------------------------------------------------------------------------------------------------
function showGallery( ID )
{
	var
		gallery    = galleries[ID], 
		imgBack    = document.getElementById("imgBack"), 
		imgLeft    = document.getElementById("imgLeft"), 
		imgRight   = document.getElementById("imgRight"), 
		divGallery = document.getElementById("divGallery"), 
		imgGallery = document.getElementById("imgGalleryBig"), 
		trGallery  = document.getElementById("trGallery");
	
	if ( typeof( gallery ) != "undefined" && gallery.images.length && currID != ID )
	{
		imgGallery.src = gallery.images[0].link( true );
		
		while ( trGallery.childNodes.length )
			trGallery.removeChild( trGallery.firstChild );
		
		for ( var i = 0; i < gallery.images.length; i++ )
		{
			var
				td  = trGallery.appendChild( document.createElement("TD") ), 
				a   = td.appendChild( document.createElement("A") ), 
				img = a.appendChild( document.createElement("IMG") );
			
			if ( i < gallery.images.length - 1 )
				td.style.paddingRight = "9px";
			
			a.href     = "javascript:showImage( " + ID + ", " + i + " );";
			img.src    = gallery.images[i].link();
			img.alt    = gallery.images[i].name;
			img.width  = 56;
			img.height = 41;
			img.border = 0;
		}
		
		if ( gallery.images.length > 6 )
		{
			imgLeft.src  = "img/arrowLeft.gif";
			imgRight.src = "img/arrowRight.gif";
		}
		else
		{
			imgLeft.src  = "img/pixTrans.gif";
			imgRight.src = "img/pixTrans.gif";
		}
		
		imgBack.style.display    = "block";
		divGallery.style.display = "block";
		
		currID = ID;
	}
}
//-------------------------------------------------------------------------------------------------
function showImage( ID, index )
{
	var
		gallery    = galleries[ID], 
		imgGallery = document.getElementById("imgGalleryBig");
	
	if ( typeof( gallery ) != "undefined")
	{
		imgGallery.src = gallery.images[index].link( true );
		imgGallery.alt = gallery.images[index].name;
	}
}
//=================================================================================================
var
	scrollTimer = null;
//-------------------------------------------------------------------------------------------------
function scroll2Left()
{
	var
		divScroll = document.getElementById("divScroll");
	
	if ( divScroll.scrollLeft > 0 )
	{
		divScroll.scrollLeft -= 4;
		scrollTimer = setTimeout("scroll2Left();", 15 );
	}
	else
		divScroll.scrollLeft = 0;
	
}
//-------------------------------------------------------------------------------------------------
function scroll2Right()
{
	var
		divScroll = document.getElementById("divScroll");
	
	
	if ( divScroll.scrollLeft < divScroll.scrollWidth )
	{
		divScroll.scrollLeft += 4;
		scrollTimer = setTimeout("scroll2Right();", 15 );
	}
	else
		divScroll.scrollLeft = divScroll.scrollWidth;
}
//-------------------------------------------------------------------------------------------------
function stopScroll()
{
	clearTimeout( scrollTimer );
	scrollTimer = null;
}
//=================================================================================================
var
	galleries = new Array();
//-------------------------------------------------------------------------------------------------
TGallery = function( ID )
{
	galleries[ID] = this;
	this.ID       = ID;
	this.images   = new Array();
}
//-------------------------------------------------------------------------------------------------
TGallery.prototype.addImage = function( smallID, bigID, name )
{
	this.images[this.images.length] = new TImage( this, smallID, bigID, name );
}
//=================================================================================================
TImage = function( owner, smallID, bigID, name )
{
	this.owner   = owner;
	this.smallID = smallID;
	this.bigID   = bigID;
	this.name    = name;
}
//-------------------------------------------------------------------------------------------------
TImage.prototype.imageTag = function( big )
{
	var
		width  = 56, 
		height = 41, 
		ID     = this.smallID;
	
	if ( typeof( big ) != "undefined" && big == true )
	{
		width  = 410;
		height = 270;
		ID     = this.bigID;
	}
	
	return "<img src=\"/showfile.asp?ID=" + ID + "\" alt=\"" + this.name + "\" width=\"" + width + "\" height=\"" + height + "\" />";
}
//-------------------------------------------------------------------------------------------------
TImage.prototype.link = function( big )
{
	var
		ID = this.smallID;
	
	if ( typeof( big ) != "undefined" && big == true )
		ID = this.bigID;
	
	return "/showfile.asp?ID=" + ID;
}
//=================================================================================================
