
//**********************************************************************************************************************
//  Picture Display Functions
//**********************************************************************************************************************
// arr_gal_picture = new Array();
currentPic = 0;
var height = 0;
var width = 0;

//-----------------------------------------------------------------------------		
//  AssignSingleGalleryPicInfo
//-----------------------------------------------------------------------------		
function AssignSingleGalleryPicInfo(pic)
{
	arr_gal_picture[0] = "/auctions/pictures/batch/" + pic;
	ShowGalleryPicByIndex(0);
//	ShowHideGalleryButtons();
}

//-----------------------------------------------------------------------------		
//  PrevGalleryPic
//-----------------------------------------------------------------------------		
function PrevGalleryPic()
{
	if (currentPic > 0)
	{
		ShowGalleryPicByIndex(currentPic - 1)
		ShowHideGalleryButtons();
	}
}

//-----------------------------------------------------------------------------		
//  NextGalleryPic
//-----------------------------------------------------------------------------		
function NextGalleryPic()
{
	if (currentPic < arr_gal_picture.length -1)
	{
		ShowGalleryPicByIndex(currentPic + 1)
		ShowHideGalleryButtons();
	}
}

//-----------------------------------------------------------------------------		
//  getGalleryWidthAndHeight
//-----------------------------------------------------------------------------		
function getGalleryWidthAndHeight() 
{
	width = this.width;
	height = this.height;
			
	// Show the prev and next buttons
	ShowHideGalleryButtons();

    return true;
}

//-----------------------------------------------------------------------------		
//  loadGalleryFailure
//-----------------------------------------------------------------------------		
function loadGalleryFailure() 
{
    alert("'" + this.name + "' failed to load.");
    return true;
}

//-----------------------------------------------------------------------------		
//  GalleryHideIt
//-----------------------------------------------------------------------------		
function GalleryHideIt()
{
	scrollLeft = GetScrollLeft();
	scrollTop =  GetScrollTop();

	var x=document.getElementById("picx");			x.style.visibility="hidden";
	var px=document.getElementById("picPrev");		px.style.visibility="hidden";
	var px=document.getElementById("picNext");		px.style.visibility="hidden";
	var px=document.getElementById("mainRow");		px.style.visibility="visible";
	
	grayOut(false);
	
}

//-----------------------------------------------------------------------------		
//  ShowHideGalleryButtons
//-----------------------------------------------------------------------------		
function ShowHideGalleryButtons()
{
	// Make sure both previous and next buttons are visible
	var px=document.getElementById("picPrev");		px.style.visibility="visible";
	var px=document.getElementById("picNext");		px.style.visibility="visible";

	// Display or ghost the previous picture Button
	if (currentPic > 0)
	{
		GalleryShadeIt("picPrev", 100);
	}
	else
	{
		GalleryShadeIt("picPrev", 50);
	}

	// Display or ghost the next picture Button
	if (currentPic < arr_gal_picture.length -1)
	{
		GalleryShadeIt("picNext", 100);
	}
	else
	{
		GalleryShadeIt("picNext", 50);
	}

}

//-----------------------------------------------------------------------------		
//  GalleryShadeIt - elementName and opacity (0-100)
//-----------------------------------------------------------------------------		
function GalleryShadeIt(elementName, opacity)
{
	var opaque = (opacity / 100);
	var sNode=document.getElementById(elementName);
	
	sNode.style.opacity=opaque;                      
	sNode.style.MozOpacity=opaque;                   
	sNode.style.filter='alpha(opacity='+opacity+')'; 
}


//-----------------------------------------------------------------------------		
//  ShowGalleryPicByIndex
//-----------------------------------------------------------------------------		
function ShowGalleryPicByIndex(picIndex)
{
	var containerHeight, buttonHeight, pictureHeight, descHeight, buttonY, pictureY, descY;
	buttonHeight = 25;		descHeight = 120;

	// Set the current picture index to the displayed picture
	currentPic = picIndex;

	// Calculate widths and heights
	pictureHeight = arr_gal_height[picIndex];	
	containerHeight = buttonHeight + descHeight + pictureHeight + 10;
	buttonY = 2;	 pictureY = buttonY + 2 + buttonHeight;		descY = pictureY + 2 + pictureHeight;

	// Set the heights, Y offsets and widths
	var pNode = document.getElementById("picx");		pNode.style.height = containerHeight + "px";
	var pNode = document.getElementById("picDesc");		pNode.style.top = descY + "px";		pNode.style.height = descHeight + "px";



	// Show the gallery buttons
	ShowHideGalleryButtons();
	
	// Get the pixel positions of the scrollable area
	scrollLeft = GetScrollLeft();	scrollTop =  GetScrollTop();
	if (scrollTop < 60 ) scrollTop = 60;

	// Hide the main row
	var px=document.getElementById("mainRow");		px.style.visibility="hidden";

	// Set the IMG src tag to the picture path
	var px=document.getElementById("picName");		px.src=unescape(arr_gal_picture[picIndex]);

	// Set the visibility of the picture display box
	var x=document.getElementById("picx");			x.style.visibility="visible";

	// Set the height of the over all div



	// Calculate the page width and height 
	if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) 
	{
		var pageWidth = document.body.scrollWidth;
		var pageHeight = document.body.scrollHeight;
	} 
	else
	if( document.body.offsetWidth ) 
	{
		var pageWidth = document.body.offsetWidth;
		var pageHeight = document.body.offsetHeight;
	} 

	// Get the width of the picture display box
	picBoxWidth = parseInt(x.style.width);

	// position the picture display box
	x.style.top=50;
	xPos = (pageWidth - picBoxWidth) / 2; if (xPos < 0) xPos = 0;
	x.style.left = xPos;
	
//	x.style.left=205;

	x.style.top=scrollTop + 5;
//	x.style.left=scrollLeft+5;
//	x.style.top=225;

/*
	// Load an image and set the onLoad and onError callbacks
	var myImage = new Image();
	myImage.name = unescape(arr_gal_picture[picIndex]);
	myImage.onload = getGalleryWidthAndHeight;
	myImage.onerror = loadGalleryFailure;
	myImage.src = unescape(arr_gal_picture[picIndex]);
*/

	// Set the Title Text
	var tNode=document.getElementById("picTitle");		tNode.firstChild.data = unescape(arr_gal_title[picIndex]);

	// Set the Desc Text
	var tNode=document.getElementById("picDesc");		tNode.firstChild.data = unescape(arr_gal_desc[picIndex]);

	// Gray out the screen
	grayOut(true);
	
}

