// New library object for dynamic layers 
//Global document object
d = window.document
loaded = false;


// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
//     
//     
//     a >> lib api
//     
//     
// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o

function lib_bwCheck(){
	this.ver = navigator.appVersion
	this.agent = navigator.userAgent
	this.dom = document.getElementById?1:0
	this.opera5 = this.agent.indexOf("Opera 5")>-1
	this.ie5 = (this.agent.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0
	this.ie6 = (this.agent.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0
	this.ie4 = (document.all && !this.dom && !this.opera5)?1:0
	this.ie = this.ie4||this.ie5||this.ie6
	this.mac = this.agent.indexOf("Mac")>-1
	this.ns6 = (this.dom && parseInt(this.ver)>=5)?1:0
	this.ns4 = (document.layers && !this.dom)?1:0
	this.bw = (this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5)
	return this
}
bw = new lib_bwCheck() // Browser object

function lib_obj(obj){
	this.el = bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval('document.' + obj):0;
	this.css = bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
	this.moveIt = lib_moveIt;
	this.showIt = lib_showIt;
	this.hideIt = lib_hideIt;
	return this;
}


function lib_moveIt(x,y){
	if (x){this.x=x; this.css.left = x;}
	if (y){this.y=y; this.css.top = y}
}

function lib_showIt(){this.css.visibility = "visible"}
function lib_hideIt(){this.css.visibility = "hidden"}

// DHTML fix detection for Netscape browser resize
if (d.layers) {
	origWidth=innerWidth;
	origHeight=innerHeight;
	onresize=DHTMLfix;
}
		
// DHTML fix for Netscape browser resize
function DHTMLfix() {
	if (origWidth != innerWidth || origHeight != innerHeight) {
		location.reload();
	}
}

function fixNav(){
	if(d.all)history.go(0)
	if (d.layers) {
		DHTMLfix();
	}
}


// X Position Layer relative to anchor image
function get_xPos(object,offset){
	if(d.layers && !d.dom){
		xPos = d.images[object].x
	} else {
		xPos = d.images[object].offsetLeft;
		tempEl = d.images[object].offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
		    tempEl = tempEl.offsetParent;
		}
	}
	if (offset) xPos = xPos + offset;
	return xPos;
}


// Y Position Layer relative to anchor image 
function get_yPos(object,offset){
	if(d.layers && !d.dom){
		yPos = d.images[object].y
	} else {
		yPos = d.images[object].offsetTop;
		tempEl = d.images[object].offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
		    tempEl = tempEl.offsetParent;
		}
	}
	if (offset) yPos = yPos + offset;
	yPos = yPos + 24;
	return yPos
}

// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
//     
//     
//     b >> onload placement functions
//     
//     
// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o

// function called onload to initialize dynamic elements
function init(){
	place_menus();
	loaded = true;
}


// menu placement


function place_menus(){
	mDiv = new Array();
	for (var i=0;i<menu_ar.length;i++){
		mDiv[menu_ar[i]] = new lib_obj('m' + menu_ar[i]);
		mDiv[menu_ar[i]].moveIt(get_xPos(menu_ar[i]),get_yPos(menu_ar[i]));
	}
	loaded=true;
}


// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
//     
//     
//     c >> drop down menus
//     
//     
// o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o


// put the NAME attribut of the images that trigger the dropdowns in this array
menu_ar = new Array();
menu_ar[0] = 'k12';
menu_ar[4] = 'highedu';
menu_ar[1] = 'chifam';
menu_ar[2] = 'wrkcom';
menu_ar[3] = 'wlfbar';

// menu variables
delay=500;
active = menu_ar[0];
timer = null;

// menu functions 
function changeActive(which){
	if (loaded){
		clearTimeout(timer);
		mDiv[active].hideIt();
		m_rollout(active);
		active=which;
		mDiv[active].showIt();
		m_rollover(active);
	}
}

function killIt(){
	if (loaded){
		mDiv[active].hideIt();
		m_rollout(active);
	}
}

function killMenu(){
	if (loaded){
		timer = setTimeout("killIt()",delay);
	}
}

function sleep(){
	clearTimeout(timer);
}

// 		MENU ROLLOVERS
function load_menu_rollovers(){
	mro_ar = new Array();
	for (var i=0;i<menu_ar.length;i++){
		mro_ar[menu_ar[i]] = new Array();
		mro_ar[menu_ar[i]]['off']=new Image();
		mro_ar[menu_ar[i]]['on']=new Image();
		mro_ar[menu_ar[i]]['off'].src="../../images/site/nav_"+menu_ar[i]+".gif";
		mro_ar[menu_ar[i]]['on'].src="../../images/site/nav_"+menu_ar[i]+"-on.gif";
	}
}

load_menu_rollovers();

function m_rollover(which){
	document.images[which].src = mro_ar[which]['on'].src;
}

function m_rollout(which){
	document.images[which].src = mro_ar[which]['off'].src;
}




// REVISED 2-22-2006

/*     TOP NAV IMAGE ROLLOVER FUNCTIONS        */
var ro_array = new Array();
ro_array[0] = 'about';
ro_array[1] = 'careers';
ro_array[2] = 'inprac';
ro_array[3] = 'rsch';
ro_array[4] = 'contact';
ro_array[5] = 'supportMDRC';
ro_array[6] = 'logo';
ro_array[7] = 'pub';

// END REVISED 2-22-2006



function load_rollovers(){
	ro_ar = new Array();
	for (var i=0;i<ro_array.length;i++){
		ro_ar[ro_array[i]] = new Array();
		ro_ar[ro_array[i]]['off']=new Image();
		ro_ar[ro_array[i]]['on']=new Image();
		ro_ar[ro_array[i]]['off'].src= "../../images/site/topnav_" + ro_array[i] + ".gif";
		ro_ar[ro_array[i]]['on'].src= "../../images/site/topnav_" + ro_array[i] + "-on.gif";
	}
}

// init ROs 
load_rollovers();


function rollover(active){    // can handle multiple rollovers, just add more to argument list
	for (var i=0; i<arguments.length; i++){
		document.images[active].src = ro_ar[active]['on'].src;
	}
}

function rollout(active){      // can handle multiple rollovers, just add more to argument list
	for (var i=0; i<arguments.length; i++){
		document.images[active].src = ro_ar[active]['off'].src;
	}
}
    /*     IMAGE ROLLOVER FUNCTIONS        */

/*        SUBMIT FORMS ON SELECT  - GO TO SUPLIED URL      */

function goto_URL(object) {
     window.location.href =
 object.options[object.selectedIndex].value;
}
/*        SUBMIT FORMS ON SELECT        */


