//popobjct controls objct and hoverbox objects

var domSobjct = null; 	//objct object
var oldDomSobjct = null; //old objct object
var domSubobjct=null; 	//sub objct object
var oldDomSubobjct=null; //old sub objct object
var domSubSubobjct=null; 	//sub objct object
var oldDomSubSubobjct=null; //old sub objct object
var mstatus = 0;		//0. click (hide immediately) 
			//1.roll-off (delay hide) 
			//2.interrupt hide
var subStatus = 0;	//0. click 1.roll-off 2.interrupt-hide 
var subSubStatus=0;	//0. click 1.roll-off 2.interrupt-hide 
var ts = 0;		//sub objct rolover/click status
var MAX_CALL_COUNT = 6; //max number of recursive calls to produce 
				//setTimeout() delay in delayHide()
var callCount = 0;	//counts recursive calls of delayHide()
var callSubCount = 0;	//counts recursive calls of delayHideSub()
var callSubSubCount = 0;//counts recursive calls of delayHideSubSub()
var pause = 250;	//m. sec delay of setTimeout() in delayHide
var objctLeft = 0;	//left position of domobjct	
var objctTop = 0;	//top position of domobjct
var subobjctTop = 0;	//top position of domSubobjct
var subSubobjctTop = 0;	//top position of domSubSubobjct

/*findDOM shortens typing of the getElementById layer reference*/

function findDOM(objectID,styl)
{
   //not a style object
   if(styl==0)
   {
      return (document.getElementById(objectID));
   }
   else
   {
      return (document.getElementById(objectID).style);
   }
}//end findDOM

/////////////////

   /*
     popobjct:
     1. sets the previous objct's visibility to hidden 
     2. moves it to bottom layer
     3. sets new objct's visibility to visible
     4. moves it to top layer
   */
   
function popobjct(objctNum)
{
   mstatus = 2;//objct roll-over
   
   //hide old objct if necessary
   if (oldDomSobjct) 
	{
	oldDomSobjct.visibility = 'hidden';
	oldDomSobjct.zIndex = '0';
	oldDomSobjct = null;
	mstatus = 2;
	callCount = 0;
	}
   //hide old sub objct if necessary
	if (oldDomSubobjct) 
	{
	 oldDomSubobjct.visibility = 'hidden';
	 oldDomSubobjct.zIndex = '0';
	 oldDomSubobjct = null;
	 subStatus = 2;
	 callSubCount = 0;
	}
  
  //Defines the names of the objct objects
   
   var idobjct = 'objctHead';
   var domobjct = findDOM(idobjct,0);//get objct object

   var idobjctOpt = 'objctHead' + objctNum;
   var domobjctOpt = findDOM(idobjctOpt,0);//get objct object

   var idSobjct = 'objct' + objctNum;
   var domSobjct = findDOM(idSobjct,1);//get objct object.style

   /*Defines the position of the objct options layer*/
   objctLeft = (domobjct.offsetLeft) + (domobjctOpt.offsetLeft) + 1;
   objctTop = (domobjct.offsetTop) + (domobjct.offsetHeight);

   /*Positions and shows the objct*/
   //if requested objct is different than
   if (oldDomSobjct != domSobjct)
   {
      domSobjct.left = objctLeft;
      domSobjct.top = objctTop;
      domSobjct.visibility = 'visible';
      domSobjct.zIndex = '200';
      oldDomSobjct = domSobjct;
      //popSub(objctLeft+136, objctTop);
   }

   /*Resets oldDom if it is the same as the current DOM*/
   else { oldDomSobjct = null; }
}//end popobjct

   /*
     popobjct:
     1. sets the previous objct's visibility to hidden 
     2. moves it to bottom layer
     3. sets new objct's visibility to visible
     4. moves it to top layer
   */
   

/////////////////

   /*
     popSubobjct:
     1. sets the previous sub objct's visibility to hidden 
     2. moves it to bottom layer
     3. sets new sub objct's visibility to visible
     4. moves it to top layer
   */
   
function popSubobjct(objctNum, subLeft, top)
{
   subStatus = 2;//sub objct roll-over
   
   //hide old sub objct if necessary
   if (oldDomSubobjct) 
   {
      oldDomSubobjct.visibility = 'hidden';
      oldDomSubobjct.zIndex = '0';
      oldDomSubobjct = null;
      subStatus = 2;
      callSubCount = 0;
   }
  
  //Defines the names of the sub objct objects
//alert(objctNum);
   var idSubobjct = 'subobjct3_' + objctNum;
   domSubobjct = findDOM(idSubobjct,1);//get objct object

   //Defines the position of the objct options layer
   subobjctTop = 26 + top;

   //Positions and shows the objct
   //if requested objct is different than old
   if (oldDomSubobjct != domSubobjct)
	
   {

      domSubobjct.left = subLeft;
      domSubobjct.top = subobjctTop;
      domSubobjct.visibility = 'visible';
      domSubobjct.zIndex = '202';
      oldDomSubobjct = domSubobjct;
   }
  //Resets oldDom if it is the same as the current DOM
   else 
   { 
      oldDomSubobjct = null; 
   }

}//end popSubobjct


////////////////////


   /*
     popSubSubobjct:
     1. sets the previous sub sub objct's visibility to hidden 
     2. moves it to bottom layer
     3. sets new subSub objct's visibility to visible
     4. moves it to top layer
   */
   
function popSubSubobjct(objctNum, subLeft, top)
{
   subSubStatus = 2;//subSub objct roll-over
   
   //hide old subSub objct if necessary
   if (oldDomSubSubobjct) 
   {
      oldDomSubSubobjct.visibility = 'hidden';
      oldDomSubSubobjct.zIndex = '0';
      oldDomSubSubobjct = null;
      subSubStatus = 2;
      callSubSubCount = 0;
   }
  
  //Defines the names of the sub objct objects
//alert(objctNum);
   var idSubobjct = 'subobjct3_' + objctNum;
   domSubSubobjct = findDOM(idSubobjct,1);//get objct object

   //Defines the position of the objct options layer
   subSubobjctTop = 26 + top;

   //Positions and shows the objct
   //if requested objct is different than old
   if (oldDomSubSubobjct != domSubSubobjct)
	
   {

      domSubSubobjct.left = subLeft;
      domSubSubobjct.top = subSubobjctTop;
      domSubSubobjct.visibility = 'visible';
      domSubSubobjct.zIndex = '205';
      oldDomSubSubobjct = domSubSubobjct;
   }
  //Resets oldDom if it is the same as the current DOM
   else 
   { 
      oldDomSubSubobjct = null; 
   }

}//end popSubSubobjct


////////////////////


/*
   delayHide:
   1. delayHide is called at objct link roll-off (status 1)
   2. immediate hide (status 0 & delayHide called) occurs 
      at objct link click
   3. break out of delayHide() if status 2, another roll-over 
      occurs (popobjct sets status 2)
   4. if status is 1, recursively call delayHide until 
      callCount = MAX_CALL_COUNT
*/
 
function mdelayHide()
{
 /*
   if-block description:
   1. Hides the old objct
   2. resets objct conditions,
   3. stops the function's running on click or another roll-over
 */
    if ((oldDomSobjct) && (mstatus == 0))
    {
        oldDomSobjct.visibility = 'hidden';
        oldDomSobjct.zIndex = '0';
        oldDomSobjct = null;
        callCount = 0;
        return false;
    }

   //Interrupts the function if another objct is opened
    if (mstatus == 2)
    {
      callCount = 0; return false;
    }

      /*
      1. Repeats the function adding 1 to callCount each time until
      	 callCount is equal to lDelay 
      2. sets 'status' to 0 so that
         the objct will hide when it runs again
      */
    if (mstatus == 1)// roll off link
    {
        callCount = callCount + 1;
        if (MAX_CALL_COUNT <= callCount) 
        { 
        	mstatus = 0; 
        }
        
        //recursive call of delayHide() (self)
        if (MAX_CALL_COUNT >= callCount) 
        { 
        	setTimeout('mdelayHide(' + mstatus + ')',pause);//pause=300 
        }
    }
}//end delayHide

//////////////////

function delayHideSub()
{
 /*
   delayHideSub:
   if-block description:
   1. Hides the old sub objct
   2. resets sub objct conditions,
   3. stops the function's running on click or another roll-over
 */
    if ((oldDomSubobjct) && (subStatus == 0))
    {
        oldDomSubobjct.visibility = 'hidden';
        oldDomSubobjct.zIndex = '0';
        oldDomSubobjct = null;
        callSubCount = 0;
        return false;
    }

   //Interupts the function if another objct is opened
    if (subStatus == 2)
    {
      callSubCount = 0; return false;
    }

      /*
      1. Repeats the function adding 1 to callCount each time until
      	 callCount is equal to lDelay 
      2. sets 'subStatus' to 0 so that
         the objct will hide when it runs again
      */
    if (subStatus == 1)// roll off link
    {
        callSubCount = callSubCount + 1;
        if (MAX_CALL_COUNT <= callSubCount) 
        { 
        	subStatus = 0;
        }
        
        //recursive call of delayHideSub() (self)
        if (MAX_CALL_COUNT >= callSubCount) 
        { 
           setTimeout('delayHideSub(' + subStatus + ')',pause);//pause=250 
        }
    }
}//end delayHideSub

///////////////////////

function delayHideSubSub()
{
 /*
   delayHideSubSub:
   if-block description:
   1. Hides the old subSub objct
   2. resets subSub objct conditions,
   3. stops the function's running on click or another roll-over
 */
    if ((oldDomSubSubobjct) && (subSubStatus == 0))
    {
        oldDomSubSubobjct.visibility = 'hidden';
        oldDomSubSubobjct.zIndex = '0';
        oldDomSubSubobjct = null;
        callSubSubCount = 0;
        return false;
    }

   //Interupts the function if another objct is opened
    if (subSubStatus == 2)
    {
      callSubSubCount = 0; return false;
    }

      /*
      1. Repeats the function adding 1 to callSubSubCount each time until
      	 callCount is equal to lDelay 
      2. sets 'subSubStatus' to 0 so that
         the objct will hide when it runs again
      */
    if (subSubStatus == 1)// roll off link
    {
        callSubSubCount = callSubSubCount + 1;
        if (MAX_CALL_COUNT <= callSubSubCount) 
        { 
        	subSubStatus = 0;
        }
        
        //recursive call of delayHideSubSub() (self)
        if (MAX_CALL_COUNT >= callSubSubCount) 
        { 
           setTimeout('delayHideSubSub(' + subSubStatus + ')',pause);//pause=250 
        }
    }
}//end delayHideSubSub

///////////////////////

function popDialog(layerName, diaLeft, diaTop)
{
	var popDlg = findDOM(layerName,1);
	popDlg.left=diaLeft;
	popDlg.top=diaTop;
	popDlg.zIndex = '98';
	popDlg.visibility="visible";
}//end popDialog

//////////////

function dialogHide(layerName)
{
	var popDlg=findDOM(layerName,1);
	popDlg.visibility="hidden";
}//end dialogHide

//////////////

