// floater_lister.js -- Variables and functions for floating icon, "lister" object and TOC popup menus
// Coupled together to make the object initialization work

// set global variables for floating menu
var floater_x; // Starting X position of floater
var floater_y; // Starting Y position of floater
var floater_yy; // Current Y position of floater
var scroll_y = 0; // Current amount of scrolling
var scroll_yy = 0; // Amount of scrolling, last time checked
var mflag = false; // Page hasn't loaded yet. Don't allow user DHTML events until page loads

// set global variables for lister 
listobj = new Object; // lister object 
var interval_id; // reference to setInterval method 


// BEGIN Initialize DHTML Elements and Event Capture
function init() {

	if (!isOther) {
		mflag = true;
		create_objects(); // Function to create either ie, netscape or dom objects
		if (isClippable) { init_lister(); } // Initialize constants for "lister" object. 
		
		floater_x = theobjs["floater"].objGetLeft();
		floater_y = theobjs["floater"].objGetTop();
		floater_yy = floater_y;
		setInterval("floater()", 200); // Start tracking "floater" object position
	}	

} // END init()


// floater to move floating menu if necessary
function floater() {

	if (isLayers) { scroll_y = self.pageYOffset; 
	} else if (isDivs) { scroll_y = document.body.scrollTop; 
	} else if (isDOM) { scroll_y = window.pageYOffset; }

	if (scroll_y != scroll_yy) { 
		floater_yy = Math.max(floater_y-scroll_y,10); // 10 marks how close the floater can get to the top of the browser window
		theobjs["floater"].objMoveAbsolute(floater_x,scroll_y+floater_yy);
		scroll_yy = scroll_y;
	}		

} // END floater function


//////////////////// Initialization and Crawl functions for Lister /////////////////////////////

//BEGIN Initialize Constants for object
function init_lister() {

	listobj = theobjs['lister'];

	listobj.initX1 = 0;
	listobj.initY1 = listobj.objGetTop();

	listobj.changeX1 = listobj.initX1;
	listobj.changeY1 = listobj.initY1;
	
	listobj.initclipX1 = 0;
	listobj.initclipY1 = 0;
	listobj.initclipX2 = 168;
	listobj.initclipY2 = 100;

	listobj.clipX1 = 0;
	listobj.clipY1 = 0;
	listobj.clipX2 = 168;
	listobj.clipY2 = 100;

	listobj.deltaY = 0;
	listobj.speedY = 11;
	
	if (!isIE4Mac) { 
		listobj.objShow();
	}

} // END init_lister()


// BEGIN Move lister UP or Down
function crawler(vector) {

	if (!mflag) { return; }
	if (vector == 0) { 
		clearInterval(interval_id);
	} else { 
		listobj.deltaY = listobj.speedY*vector;
		crawl();
		interval_id = setInterval("crawl()",150); 
	}
	
}

// BEGIN Move listbox contents UP or DOWN
function crawl() {

	var yy = listobj.deltaY;
	
	if ((listobj.clipY1 - yy) <= (listobj.initclipY1)) {
		yy = listobj.clipY1 - listobj.initclipY1;
		clearInterval(interval_id); 
	}
	
	listobj.clipY1 -= yy;
	listobj.clipY2 -= yy;

	listobj.changeY1 += yy;

	listobj.objMoveAbsolute(listobj.changeX1,listobj.changeY1);
	listobj.objSetClipRect(listobj.clipX1,listobj.clipY1,listobj.clipX2,listobj.clipY2);

} // End crawl()


// BEGIN Reset listbox to Initial Position
function crawltop() {

	if (!mflag) { return; }
	listobj.clipY1 = listobj.initclipY1;
	listobj.clipY2 = listobj.initclipY2;

	listobj.changeY1 = listobj.initY1;

	listobj.objMoveAbsolute(listobj.changeX1,listobj.changeY1);
	listobj.objSetClipRect(listobj.clipX1,listobj.clipY1,listobj.clipX2,listobj.clipY2);

} // End crawltop()


//////////////////// Show and Hide functions for TOC Menus /////////////////////////////

// BEGIN show a hidden object
function obj_show(some_obj) {

	if (!mflag) { return; }
	if (isOther) { return; }
	var new_obj = theobjs[some_obj];
	new_obj.objShow();

} // End m_show(some_obj)


// END hide an object
function obj_hide(some_obj) {

	if (!mflag) { return; }
	if (isOther) { return; }
	var new_obj = theobjs[some_obj];
	new_obj.objHide();

} // End m_hide(some_obj)