/*******************************************************************************
____________________________ API DOCUMENTATION BEGIN ___________________________
````````````````````````````````````````````````````````````````````````````````
Provides framework for classes, methods and properties.

````````````````````````````````````````````````````````````````````````````````
_____________________________ API DOCUMENTATION END ____________________________
*******************************************************************************/

//------------------------------------------------------------------------------
// CLASS CONSTRUCTORS BEGIN
//------------------------------------------------------------------------------

//CLASS CONSTRUCTOR-- the super class
function Class_Super() {}

//Prototype derive/extend (single inheritance only)
Spawn_Object.prototype = new Class_Super;

//Prototype properties
Class_Super.prototype.zIndexCounter = 500; //global index counter for all elements in a page

//CLASS CONSTRUCTOR-- creates an generic object with foundation properties
function Spawn_Object(argDivID) {
 this.objCss = document.getElementById(argDivID).style; //create reference to [object CSSStyleDeclaration]
 this.objDivElement = document.getElementById(argDivID); //create reference to [object HTMLDivElement]
 this.objDivID = argDivID; //set element ID
 eval(this.obj + "=this"); //for methods using setTimeouts, setInterval, or eval's to call itself
}

//------------------------------------------------------------------------------
// CLASS CONSTRUCTORS END
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// METHODS BEGIN
//------------------------------------------------------------------------------

//METHOD-- set height property of object
function _setHeight(argHeight, argSynch) {
 this.objH = argHeight;
 if(argSynch) this.m_synchHeightProperty(); //synch to element property
}

Class_Super.prototype.m_setHeight = _setHeight;

//------------------------------------------------------------------------------

//METHOD-- set width property of object
function _setWidth(argWidth, argSynch) {
 this.objW = argWidth;
 if(argSynch) this.m_synchWidthProperty(); //synch to element property
}

Class_Super.prototype.m_setWidth = _setWidth;

//------------------------------------------------------------------------------

//METHOD-- get height of element
function _getHeight() {
 return this.objDivElement.offsetHeight;
}

Class_Super.prototype.m_getHeight = _getHeight;

//------------------------------------------------------------------------------

//METHOD-- get width of element
function _getWidth() {
 return this.objDivElement.offsetWidth;
}

Class_Super.prototype.m_getWidth = _getWidth;

//------------------------------------------------------------------------------

//METHOD-- synchs elements height property with objects height property
function _synchHeightProperty() {
 this.objCss.height = this.objH+"px";
}

Class_Super.prototype.m_synchHeightProperty = _synchHeightProperty;

//------------------------------------------------------------------------------

//METHOD-- synchs elements width property with objects width property
function _synchWidthProperty() {
 this.objCss.width = this.objW+"px";
}

Class_Super.prototype.m_synchWidthProperty = _synchWidthProperty;

//------------------------------------------------------------------------------

//METHOD-- set top property of object
function _setTop(argTop) {
 this.objY = argTop; 
 this.m_synchTopProperty();
}

Class_Super.prototype.m_setTop = _setTop;

//------------------------------------------------------------------------------

//METHOD-- set left property of object
function _setLeft(argLeft) {
 this.objX = argLeft; 
 this.m_synchLeftProperty();
}

Class_Super.prototype.m_setLeft = _setLeft;

//------------------------------------------------------------------------------

//METHOD-- get top property of object
function _getTop(argTop) {
 return this.objDivElement.offsetTop; 
}

Class_Super.prototype.m_getTop = _getTop;

//------------------------------------------------------------------------------

//METHOD-- get left property of object
function _getLeft(argLeft) {
 return this.objDivElement.offsetLeft; 
}

Class_Super.prototype.m_getLeft = _getLeft;

//------------------------------------------------------------------------------

//METHOD-- synchs elements top property with objects top property
function _synchTopProperty() {
 if(document.all) {this.objCss.pixelTop = this.objY;}
 else {this.objCss.top = this.objY+"px";} 
}

Class_Super.prototype.m_synchTopProperty = _synchTopProperty;

//------------------------------------------------------------------------------

//METHOD-- synchs elements left property with objects left property
function _synchLeftProperty() {
 if(document.all) {this.objCss.pixelLeft = this.objX;}
 else {this.objCss.left = this.objX+"px";} 
}

Class_Super.prototype.m_synchLeftProperty = _synchLeftProperty;

//------------------------------------------------------------------------------

//METHOD-- sets display property to block
function _displayBlock() {
 this.objCss.display = "block";
}

Class_Super.prototype.m_displayBlock = _displayBlock;

//------------------------------------------------------------------------------

//METHOD-- sets display property to none
function _displayNone() {
 this.objCss.display = "none";
}

Class_Super.prototype.m_displayNone = _displayNone;

//------------------------------------------------------------------------------

//METHOD-- returns display property of object
function _getDisplay() {
 return this.objCss.display;
}

Class_Super.prototype.m_getDisplay = _getDisplay;

//------------------------------------------------------------------------------

//METHOD-- sets background image
function _setBackgroundImage(argImagePath) {
 this.objCss.backgroundImage = "url("+argImagePath+")";
}

Class_Super.prototype.m_setBackgroundImage = _setBackgroundImage;

//------------------------------------------------------------------------------

//METHOD-- sets Alpha background image (IE only)
function _setAlphaImage(argImagePath) {
 if(document.all) this.objCss.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+argImagePath+"', sizingMethod='scale')";
 else this.m_setBackgroundImage(argImagePath);
}

Class_Super.prototype.m_setAlphaImage = _setAlphaImage;

//------------------------------------------------------------------------------

//METHOD-- moves object to new coordinates
function _moveTo(argY, argX) {
 this.objX = parseInt(argX);
 this.objY = parseInt(argY);
 this.m_synchTopProperty();
 this.m_synchLeftProperty();
}

Class_Super.prototype.m_moveTo = _moveTo;

//------------------------------------------------------------------------------

//METHOD-- sets height and width of mask
function _setMask() {
 this.m_setHeight(50, true);
 this.m_setWidth(50, true);
 
 //get height
 var theWindowHeight = getBrowserWindowHeight();
 var theBodyHeight = getBodyHeight();
  
 //get width
 var theWindowWidth = getBrowserWindowWidth();
 var theBodyWidth = getBodyWidth();
 
 //alert("Window: " + theWindowHeight + " " + theWindowWidth + "\n" + "Body: " + theBodyHeight + " " + theBodyWidth + "\n" + window.scrollMaxY);

 //set mask height
 if(theWindowHeight >= theBodyHeight) {this.m_setHeight(theWindowHeight, true);}
 else {this.m_setHeight(theBodyHeight, true);}

 //set mask width
 if(theWindowWidth >= theBodyWidth) {this.m_setWidth(theWindowWidth, true);}
 else {this.m_setWidth(theBodyWidth, true);}
 
 this.m_displayBlock(); //display the mask
}

Class_Super.prototype.m_setMask = _setMask;

//------------------------------------------------------------------------------

//METHOD-- centers an object vertically and horizontally within the browser window
function _positionObjCenterXY(argPageWidth) {
 var theBrowserWinWidth = getBrowserWindowWidth();
 var theBrowserWinHeight = getBrowserWindowHeight();
 
 if(argPageWidth != false) //if website is fixed width (not liquid)
 {
	if(theBrowserWinWidth > argPageWidth) theBrowserWinWidth = argPageWidth;
 }
 
 var leftPosition = getObjectPositionLeft(theBrowserWinWidth, this.objW);
 var topPosition = getObjectPositionTop(theBrowserWinHeight, this.objH);

 this.m_moveTo(topPosition, leftPosition);
}

Class_Super.prototype.m_positionObjCenterXY = _positionObjCenterXY;

//------------------------------------------------------------------------------
// METHODS END
//------------------------------------------------------------------------------