﻿/* ****************************************************
 *  
 *  Control Description box display
 * 
**************************************************** */	
var DescriptionBox={ //begin object DescriptionBox
// -----------------------------------------------------------------------------------
//  Description Box , display , hide , populate
// -----------------------------------------------------------------------------------
displayType : 'full',    // 'full' or 'roll'    
iFixedSouth : 0,
iFixedEast : 0,
CurrentImage : new String(),
FirstImage : new String(),
sOpenDescID : null, 
NotFoundtImage : "notfound",
iChunk : 0,
iChunkStep : 6,
iChunkDelay : 15,
// -----------------------------------------------------------------------------------
//  dummy constructor
// -----------------------------------------------------------------------------------
Constructor : function(aEast, aSouth, aDisplayType)
{
    this.iFixedSouth = aSouth;
    this.iFixedEast = aEast;
    this.CurrentImage = Common.getCurrentImageName();
    this.FirstImage = Common.getFirstImageName();
    if (this.CurrentImage == null || this.CurrentImage == "")
        this.CurrentImage = this.FirstImage;
    if (aDisplayType != "" && aDisplayType != null) this.displayType = aDisplayType;    
},
// ---------------------------------------------------------------------------------
//  main function, doDesc, that hides any open pop-up Descs, determines 
// which Desc DIV to access, and starts its display of current Description 
// public method
// ---------------------------------------------------------------------------------
RollUp : function(e) 
{ 
	if (!e)  //for ff
        var e = window.event;  // ie code
	e.cancelBubble = true;
	e.returnValue = false;
    this.sOpenDescID = Common.getCurrentImageName().toLowerCase();
    var eDesc = document.getElementById(this.sOpenDescID);
	if (eDesc == null)
    {
        this.sOpenDescID = this.NotFoundtImage;
        eDesc = document.getElementById(this.sOpenDescID);
		if (eDesc == null) return false;
	}
	this.iChunk =  eDesc.clientHeight;
	var eDescWidth = eDesc.clientWidth;  
	var eDescHeight = eDesc.clientHeight; 
	with (eDesc)
	{
	    style.cssText = ""; 
	    style.clip = "rect(0 0 0 0)";
	    style.left = (this.iFixedEast -eDescWidth) + "px"; 
	    style.top = (this.iFixedSouth - eDescHeight) + "px";
	    style.visibility = "visible";
	}
	var t = setTimeout("DescriptionBox.ShowDesc("+eDescWidth+", "+eDescHeight+")", this.iChunkDelay);
}, // end Display method
// ---------------------------------------------------------------------------------
// remove the box by rolling down 
// public method
// ---------------------------------------------------------------------------------
RollDown : function(e) 
{ 
    if (this.sOpenDescID != null) 
    {
        var eDesc = document.getElementById(this.sOpenDescID);
	    if (eDesc == null) 
	    {
	    DescriptionBox.Remove();
	    return false;
	    }
	    this.iChunk =  0;  
	    var eDescWidth = eDesc.clientWidth; 
	    var eDescHeight = eDesc.clientHeight; 
	    var t = setTimeout("DescriptionBox.HideDesc("+eDescWidth+", "+eDescHeight+")", this.iChunkDelay);
	}
}, // end RollDown method
// ---------------------------------------------------------------------------------
//  main function, will display the complete description in one shot 
// which Desc DIV to access, and starts its display of current Description 
// public method
// ---------------------------------------------------------------------------------
Display : function(aId) 
{ 
	if (this.displayType == 'roll') {
	    this.Rollup(null);
	}
	else {
	    if (aId == null)
	        this.sOpenDescID = Common.getCurrentImageName().toLowerCase();
	    else
	        this.sOpenDescID = aId.toLowerCase();
	    var eDesc = document.getElementById(this.sOpenDescID);
	    if (eDesc == null)
        {
            this.sOpenDescID = this.NotFoundtImage;
            eDesc = document.getElementById(this.sOpenDescID);
		    if (eDesc == null) return false;
	    }
	    with (eDesc)
	    {  // this discription box is not an overlay
	        style.left = this.iFixedEast + "px"; 
	        style.top = this.iFixedSouth + "px";
	        style.visibility = "visible";
	    }
	}    
},  // end Display method
// --------------------------------------------------------------------------
// Function Kill the description text : public method
// --------------------------------------------------------------------------
Remove : function() 
{
    if (this.sOpenDescID != null) 
	{
        var eDesc = document.getElementById(this.sOpenDescID);
	    with (eDesc)
	    {
		    style.visibility = "hidden";
		    style.clip = "rect(0 0 0 0)";
		    style.cssText = ""; 
		    style.left = "-800px"; 
		    style.top = "-800px";
		}
		this.sOpenDescID = null;
	}
}, // end RemoveDesc method 
// ----------------------------------------------------------------------------
// Function which incrementally displays Desc in appropriate style
// private method
// ----------------------------------------------------------------------------
ShowDesc : function(aWidth, aHeight)
{
    if (this.sOpenDescID != null) 
	{
        var eDesc = document.getElementById(this.sOpenDescID);
        this.iChunk -= this.iChunkStep;
	    eDesc.style.clip = "rect(" + this.iChunk + "pt " + aWidth + "pt " + aHeight + "pt 0pt)";
	    if (this.iChunk > 0) 
		    var t = setTimeout("DescriptionBox.ShowDesc("+aWidth+", "+aHeight+")", this.iChunkDelay);
	}
}, // end ShowDesc method
// ----------------------------------------------------------------------------
// Function which incrementally hide Desc in appropriate style
// private method
// ----------------------------------------------------------------------------
HideDesc : function(aWidth, aHeight)
{
    if (this.sOpenDescID != null)
    {
        var eDesc = document.getElementById(this.sOpenDescID);
        this.iChunk += this.iChunkStep;
	    eDesc.style.clip = "rect(" + this.iChunk + "pt " + aWidth + "pt " + aHeight + "pt 0pt)";
	    if (this.iChunk <= aHeight) 
		    var t = setTimeout("DescriptionBox.HideDesc("+aWidth+", "+aHeight+")", this.iChunkDelay);
		else
    	    DescriptionLink.Display();    
	}
	else 
	{
        DescriptionBox.Remove();
	    DescriptionLink.Display();    
    }
} // end HideDesc method

} // end Object DescriptionBox

/* ****************************************************
 *  
 *  Control Description link to description box
 * 
 * ****************************************************/	
var DescriptionLink={ //begin DescriptionLink Object
// ---------------------------------------------------------------------
//  Description Link : hide or show the link to the description
// ---------------------------------------------------------------------
visibility : true,      // true or false
sDescriptionLinkID : "",
iChunk : 0,
iChunkStep : 6,
iChunkDelay : 15,

/* -----------------------------------------------------------------------------------
   Constructor for the Object
-------------------	---------------------------------------------------------------- */
Constructor : function(aDescriptionLinkID, aVisibility)
{ 
    if (aVisibility == false) this.visibility = false;
    else aVisibility = true;
    this.sDescriptionLinkID = aDescriptionLinkID;
},
/* -----------------------------------------------------------------------------------
   Display, will display the "photo description link" over the image
   public method
-------------------	---------------------------------------------------------------- */
Display : function(e) 
{ 
    if (!this.visibility) return;
    if (!e) { e = window.event; }
	if (e == null)  
	{
	    DescriptionLink.ShowLink();
	}
	else
	{
	    e.cancelBubble = true;
	    e.returnValue = false;
        DescriptionLink.ShowLink();
    }	
}, // end Display function
/* -----------------------------------------------------------------------------------
   private method, Display the discription link
-------------------	---------------------------------------------------------------- */
ShowLink : function ()
{
    if ("object" == typeof(document.getElementById(this.sDescriptionLinkID)))
	{
	    this.iChunk = this.iChunkStep;
		var eDescLink = document.getElementById(this.sDescriptionLinkID);
		with (eDescLink)
		{
		    style.clip = "rect(0 0 0 0)";
		    style.visibility = "visible";
    	}
		var t = setTimeout("DescriptionLink.Layout()", this.iChunkDelay);
	}
	return;
},
/* -------------------------------------------------------------------------------
   Function Kill the description link
 --------------------------------------------------------------------------------*/
 Remove :	function() 
 {
    if ("object" == typeof(document.getElementById(this.sDescriptionLinkID))) 
	{
	    document.getElementById(this.sDescriptionLinkID).style.visibility = "hidden";
	}
 },
/* ---------------------------------------------------------------------------------
// Function which incrementally displays Desc link in appropriate style
----------------------------------------------------------------------------------*/    
Layout : function()
{
	if ("object" == typeof(document.getElementById(this.sDescriptionLinkID)))
	{
		var eDescLink = document.getElementById(this.sDescriptionLinkID);
	    var xWidth = eDescLink.clientWidth;   // ff fix?
	    var xHeight = eDescLink.clientHeight; // ff fix? 
	    var iPctWidth = xWidth * (this.iChunk / 100);
	    eDescLink.style.clip =  "rect(0pt " + iPctWidth + "pt " + xHeight + "pt 0pt)";
	    if (100 >= this.iChunk) 
		    var t =setTimeout("DescriptionLink.Layout()", this.iChunkDelay);
	    this.iChunk += this.iChunkStep;
	}
}

} // end DescriptionLink Object

