var h;var remote = false;var a; var b;var maxHeight;var minHeight = 75;var sB;function doClose(module) {for (var i=0; i<modules.length; i++) {	if (modules[i].id == module) {			modules[i].remote = true;			break;	}			}shell = "wrapper_" + module;document.getElementById(shell).style.display = "none";openWin(module,"module_"+module+".html", 250, 300);}function minimize(i) {	toggleAdd = true;	var isopen = modules[i].open;	var ismax = modules[i].max;	var shell = "module_" + modules[i].id;	var child = "content_" + modules[i].id;	h = getModuleHeight(i);		// minimize	if (isopen) {		document.getElementById(child).style.display = "none";	hideFooter(i);	slide(shell);	modules[i].open = false;	modules[i].max = false;		// store in a cookie	setChip("modules", modules[i].id+"_open", 0);	setChip("modules", modules[i].id+"_max", 0);		}		// restore		else {				document.getElementById(child).style.display="block";		document.getElementById(shell).style.display="block";						// restore		modules[i].open = true; 				// store in a cookie		setChip("modules", modules[i].id+"_open", 1);						if (!ismax) {		mH = getModuleHeight(i);				//sB = getSidebar();			if (sB > maxHeight) {			h = Math.max(mH/2, minHeight);		}				else {			av = maxHeight - sB;	 		//alert(maxHeight + "-" + sB + "=" + av);			//alert(Math.floor(av/1.25) + ", " + minHeight);			h = Math.max(Math.floor(av/1.25),minHeight);			//alert(av + ", " + h);				}				/*		if ((sB + mH) > maxHeight) h = maxHeight - sB;				if ((sB + h) > maxHeight) h = Math.max (minHeight, maxHeight - sB);		*/						if (Math.abs(h-mH) < 15) h = mH;		else h = Math.min(h,mH);								document.getElementById(shell).style.height= h + "px";		}		// maximize		else {				if (document.all)		document.getElementById(shell).style.height= getModuleHeight(i) + "px";		else		document.getElementById(shell).style.height="inherit";						}		calculateMax(i);		showFooter(i);			}	sB = getSidebar();	//showSize();}function max(i) {	ismax = modules[i].max;	isopen = modules[i].open;	shell = "module_" + modules[i].id;	h = modules[i].height;		// reopen module	if (!isopen) {		minimize(i); 	}			else {		// maximize		if (!ismax) {		if (document.all) {		//document.getElementById(shell).style.height= getModuleHeight(i) + "px";		document.getElementById(shell).style.height="auto";		}		else {		document.getElementById(shell).style.height="inherit";		//document.getElementById(shell).style.height="auto";		}		modules[i].max = true;				// store in a cookie		setChip("modules", modules[i].id+"_max", 1);		  		}		// restore		else {				mH = getModuleHeight(i);				if (Math.abs(h-mH) < 25) h = mH;		else h = Math.min(h,mH);				document.getElementById(shell).style.height= h + "px";		modules[i].max = false; 				// store in a cookie		setChip("modules", modules[i].id+"_max", 0);				}		showFooter(i);		}		calculateMax(i);	allMin(i);	}function showFooter(i) {footer = "footer_" + modules[i].id;if (modules[i].footer)document.getElementById(footer).style.display="block";}function hideFooter(i) {footer = "footer_" + modules[i].id;if (modules[i].footer)document.getElementById(footer).style.display="none";}// this slides a module's shell, not the module itselffunction slide(target) {				h *= .5;			if (h > 5 && !remote) {		document.getElementById(target).style.height = h+"px";		setTimeout("slide('"+target+"')",1);	}	else {		document.getElementById(target).style.display = "none";	}}function module(id,count,open,max,height,priority,footer,remote) {this.id = id;this.count = count;this.open = open;this.max = max;this.height = height;this.priority = priority;this.footer = footer;this.remote = remote;}var modules = new Array();modules[0]=new module("quick",4,1,0,110,0,0,0);modules[1]=new module("recent",8,1,0,200,0,1,0);modules[2]=new module("report",5,1,0,150,0,1,0);modules[3]=new module("access",8,1,0,200,1,1,0);modules[4]=new module("hardware",1,1,0,200,1,1,0);modules[5]=new module("notify",5,1,0,200,1,1,0);function resizeLayout() {	if (a>1000) {		document.getElementById("container").style.width="900px";		document.getElementById("main").style.width="660px";	}	else {		document.getElementById("container").style.width="750px";		document.getElementById("main").style.width="510px";	}		document.body.className = document.body.className;}function module_init() {	updateItemCount()	getMaxHeight()		countSevere()			allMin(-1, 1);		if (severeCount>0)		setSevere();		resizeLayout();		}function re_init() {	getMaxHeight();		resizeLayout();}function setSevere() {newHeight = Math.floor((maxHeight - modules.length * 40) / severeCount);	for (var i=0; i<modules.length; i++) {		if (!modules[i].max && modules[i].priority && (getModuleHeight(i) > 30)) {			thisHeight = getModuleHeight(i);			modules[i].height = Math.min(newHeight,thisHeight);			theid = "module_"+modules[i].id;					if (document.getElementById(theid)) {				h = modules[i].height;								document.getElementById(theid).style.height = modules[i].height + "px";							}					}		} 		   			}var severeCount = 0;function countSevere() {for (i=0; i< modules.length; i++) {	if (modules[i].priority && getModuleHeight(i) > 30) 	severeCount++;}}function showSize() {sB = getSidebar();	//window.defaultStatus=sB;		}function getSidebar() {	sB = document.getElementById("sidebar").offsetHeight;	if (!sB || sB=="undefined") 	sB=0;	return sB;}function getModuleHeight(mod) {	mH = document.getElementById("content_" + modules[mod].id).offsetHeight;	//mH = document.getElementById("content_" + modules[mod].id).scrollHeight;	return mH;}function allMin(modNum, auto) {	remote = true;		var i = modules.length-1; 	while(i > modNum) { 		sB = getSidebar();		//window.defaultStatus=sB + ", " + maxHeight;	   	if (sB > maxHeight && !modules[i].max && modules[i].open) {	   		//alert(sB + ">" + maxHeight);	   		if (!auto || getModuleHeight(i) < 50)	   		minimize(i);	   			   		else if (!modules[i].priority) {	   			if (severeCount>0)	   				minimize(i);	   			else {	   				newHeight = Math.floor((maxHeight - modules.length * 40) / modules.length);					thisHeight = getModuleHeight(i);										modules[i].height = Math.min(newHeight,thisHeight);					document.getElementById("module_" + modules[i].id).style.height = modules[i].height + "px";		   			}	   		}	   		   	}		   	i--; 	}		remote = false;}function calculateMax(modNum) {ch = document.getElementById("container").offsetHeight;if (ch > maxHeight) {	allMin(modNum);}}function doThing() {	allMin(1);}function getMaxHeight() {    a = (document.getElementById && !document.all)?window.innerWidth:document.body.clientWidth;    b = (document.getElementById && !document.all)?window.innerHeight:document.body.clientHeight;	maxHeight = b - 20;		/*mainheight = document.getElementById("main").offsetHeight;	if (mainheight < maxHeight)	document.getElementById("main").style.height = (maxHeight - 35) + "px";	*/}function toggle(i) {if (document.getElementById("header_" + modules[i].id).style.display == "none") { dis="block"}else {dis = "none";}document.getElementById("module_" + modules[i].id).style.display = dis;document.getElementById("header_" + modules[i].id).style.display = dis;document.getElementById("footer_" + modules[i].id).style.display = dis;}function hidenav() {document.getElementById("nav").style.display = "none";}function removeItem(elm,uqid,module) {	mydiv = getParent(elm,"P");		mydiv.className = "translucent";		par = getParent(mydiv,"DIV");		time = 100;	if (!mac) time*=2;		setTimeout("par.removeChild(mydiv);",time);	setTimeout("updateItemCount();",time-(-50));				// eventually send a call to the database to flag this item	updateServer(uqid,"okay",module);		}function alpha(elm,per) {	elm.style.opacity = per;	elm.style.MozOpacity = per;	if (document.all)	elm.style.filter.alpha.opacity = 100*per;	/*	filter: alpha(opacity=50);	-moz-opacity: 0.5;	opacity: .5;	*/}function clearAll(target) {	toggleAdd = false;		for (var i=0; i<modules.length; i++) {		if (modules[i].id == target) {			//modules[i].count = 0;						updateItemCount()						shell = document.getElementById("content_"+target)			shell.className="translucent"			//alpha(shell,.5);						setTimeout("removeAll("+i+")",150);							}		}}function getGrandParent(elm,tag) {var ancestor = 0;	par = (document.all) ? elm.parentElement:elm.parentNode;	//alert(tag + ", " + par.tagName);	while (par.tagName != tag && ancestor<1) {		par = (document.all) ? par.parentElement:par.parentNode;		if (par.tagName == tag) ancestor++;		if (par==null) return;	}	return par;}function getParent(elm,tag) {	par = (document.all) ? elm.parentElement:elm.parentNode;	//alert(tag + ", " + par.tagName);	while (tag && par.tagName != tag) {		par = (document.all) ? par.parentElement:par.parentNode;		if (par==null) return;	}	return par;}var idstoremove = "";function removeAll(num) {	shell = document.getElementById("content_"+modules[num].id)			//shell.style.display="none";	for (var i=0; i<shell.childNodes.length; i++) {			if (shell.childNodes[i] && shell.childNodes[i].tagName=="P") {			// compile ids to send to server			idstoremove += shell.childNodes[i].id + "|";						shell.removeChild(shell.childNodes[i]);		}				if (i==shell.childNodes.length-1) {			shell.className='content';			updateItemCount();			toggleAdd = true;		}	}			while (modules[num].count>0) {		updateItemCount();		removeAll(num);	}			if (modules[num].count==0 && idstoremove.length>0) {					// send the ids to the server		updateServer(idstoremove,"okay",modules[num].id);				idstoremove="";	}	}var toggleAdd = true;function newItem(module) {var ar = eval("temp_"+module);var par_ar = eval("array_" + module);header = "header_" + module;	if (ar.length>0 && document.getElementById(header).style.display != "none") {		target="content_"+module;		target=document.getElementById(target);				nodes = target.childNodes;		insert = target.firstChild;		for (j=0; j<nodes.length; j++) {			if (nodes[j].tagName == "DIV") {				insert = nodes[j].nextSibling;				break;			}		}				newP = document.createElement("P");				//today = new Date()		//newP.id = module + today.getTime();		newP.id = ar[0].uqid;						target.insertBefore(newP,insert);				newP.innerHTML = getContent(ar,module,0);				// open the module if necessary		for (var i=0; i<modules.length; i++) {			if (modules[i].id == module && toggleAdd) {			//alert(modules[i].remote);				if (!modules[i].open) {					minimize(i);						if (modules[i].count < 3) {						max(i);					}				} 				break;			}		}							updateItemCount()					// highlight the new item			yellowFade(newP.id,0);						// add this item to the top of the original array		par_ar.unshift(ar[0])				// remove the array element we just used		ar.splice(0,1);				// if there are more items, get the next one		if (ar.length>0) setTimeout("newItem('"+module+"')",1000);		else loading = false;		}		loading = false;}var now = new Date();var nowdate = now.getDate();if (!img_root) img_root = "img/";// return a properly formatted module item for the sidebarfunction getContent(ar,module,i) {		closebutton = "<span class='modclose'><a href='javascript:void(0)' onclick=\"removeItem(this,'" +ar[i].uqid+"','" +module +"')\"><img src='"+img_root+"b_moduleclose.gif' width='13' height='13'><\/a><\/span>";				if (ar[i].date) {			evdt = ar[i].date; 			if (evdt.indexOf("/"+nowdate)>-1 || evdt.indexOf("/0"+nowdate+"/")>-1) {				datetype = "hidden";				timetype = "";						}			else { 				datetype = "";				timetype = "hidden"				}		}				switch(module) {			case "access":			string = closebutton;						string += "<a href='#' class='alert'><span class='hidden'>" + ar[i].sortname + "<\/span>" + ar[i].person + "<\/a><br>";			string += "<a href='#' class='item'>" + ar[i].event + "<\/a>, " + "<a href='#' class='item' title='"+ar[i].date + " " + ar[i].time +"'><span class="+datetype+">" + ar[i].date + " </span><span class="+timetype+">" + ar[i].time + "</span><\/a><br>";			string += "<a href='#' class='item'>" + ar[i].location + "<\/a>";						break;						case "hardware":			string = closebutton;					string += "<a href='#' class='alert'>" + ar[i].event + "<\/a><br>";			string += "<a href='#' class='item'>" + ar[i].reason + "<\/a>, " + "<a href='#' class='item' title='"+ar[i].date + " " + ar[i].time +"'><span class="+datetype+">" + ar[i].date + " </span><span class="+timetype+">" + ar[i].time + "</span><\/a><br>";			string += "<a href='#' class='item'>" + ar[i].location + "<\/a>";						break;						case "recent":			string = "";						timetype = "null"			if (datetype=="hidden") timetype="today";						string += "<a href='#' class='alert'>" + ar[i].action + "<\/a><br>";			string += "<a href='#' class='item'>" + ar[i].info + "<\/a><br>" ;			string += "<a href='#' class='item' title='"+ar[i].date + " " + ar[i].time +"'><span class="+datetype+">" + ar[i].date + " </span><span class="+timetype+">" + ar[i].time + "</span><\/a> by <a href='#' class='item'>" + ar[i].operator + "<\/a>";						break;						case "notify":			string = closebutton;					string += "<a href='#' class='alert'><span class='hidden'>" + ar[i].sortname + "<\/span>" + ar[i].person + "<\/a><br>";			string += "<a href='#' class='item'>" + ar[i].event + "<\/a>, " + "<a href='#' class='item' title='"+ar[i].date + " " + ar[i].time +"'><span class="+datetype+">" + ar[i].date + " </span><span class="+timetype+">" + ar[i].time + "</span><\/a><br>";			string += "<a href='#' class='item'>" + ar[i].location + "<\/a>";						break;						case "report":			string = "";					string += "<span class='pdficon'><a href='"+ar[i].path + ar[i].filename+"'><img src='"+img_root+"i_pdf.gif' width=18 height=16 border=0></a></span>";			string += "<a href='"+ar[i].path + ar[i].filename+"' class=item>" + ar[i].filename + "<\/a>";									break;						default:			string = "";						break;				}		return string;}function setUpSidebar() {			// get the open/max settings from the cookie	for (i=0; i<modules.length; i++) {			isopen = getChip("modules",modules[i].id+"_open");		ismax = getChip("modules",modules[i].id+"_max");				if (isopen==null || isopen==1) {			modules[i].open = true;		}		else modules[i].open = false;				if (ismax==1) {			modules[i].max = true;		}								}				for (var i=0; i<modules.length; i++) {		header = "header_"+modules[i].id;		loadEvents(modules[i].id);			// if this module is active on this page		if (document.getElementById(header)) {			if (document.getElementById(header).style.display!="none") {								polling = 5000 + Math.floor(Math.random()*5000);								setTimeout("retrieveCycle('"+modules[i].id+"')",polling);			}		}	}		module_init();		}function retrieveCycle(module) {	// we really only want to poll these three modules	// reduce server overhead	if (module == "access" || module == "hardware" || module == "notify") {						polling = 5000 + Math.floor(Math.random()*5000);						if (!loading) retrieveEvents(module);		else setTimeout("retrieveCycle('"+module+"')",polling);			}}function loadEvents(module) {var ar = eval("array_"+module);var i = 0;	if (ar.length>0) {		target="content_"+module;		target=document.getElementById(target);				nodes = target.childNodes;		insert = target.firstChild;		for (j=0; j<nodes.length; j++) {			if (nodes[j].tagName == "DIV") {				insert = nodes[j].nextSibling;				break;			}		}					while (i<ar.length) {			newP = document.createElement("P");			target.insertBefore(newP,insert);						newP.id = ar[i].uqid;			newP.innerHTML = getContent(ar,module,i);						i++;					}									// open only the items that have content		//document.getElementById("module_"+module).style.display = "block";	}			for (n=0; n<modules.length; n++) {		if (modules[n].id == module && modules[n].count>0) {						if (modules[n].open) {				document.getElementById("module_"+module).style.display = "block";								if (modules[n].footer) document.getElementById("footer_"+module).style.display = "block";									if (modules[n].max) {				if (document.all) {					document.getElementById("module_"+module).style.height="auto";				}				else {					document.getElementById("module_"+module).style.height="inherit";				}					}															}			else {				modules[n].open = false;				modules[n].max = false;			}								break;		}	}		}function startNew() {			}function yellowFade(elm,num) {	handle = document.getElementById(elm);	if (handle)	handle.style.backgroundColor = yellow[num];	num++;		//alert(yellow[num]);		delay = (num==1) ? 1000:50;			if (num<=yellow.length)	setTimeout("yellowFade('"+elm+"',"+num+")",delay);		}yellow = new Array("#F0DE3B","#F1DF40","#F1E046","#F2E14D","#F2E355","#F3E45D","#F3E666","#F4E770","#F5E97A","#F6EB84","#F7EC8F","#F7EE99","#F8F0A4","#F9F2AE","#FAF3B9","#FAF5C3","#FBF7CC","#FCF8D6","#FDFADF","#FDFBE7","#FFFFFF");function updateItemCount() {var thecount;	for (var i=0; i<modules.length; i++) {			elm = document.getElementById("count_"+modules[i].id)							con = document.getElementById("content_"+modules[i].id);			if (con) {						nodes = con.childNodes;			thecount=0;						for (j=0; j<nodes.length; j++) {				if (nodes[j].tagName == "P") {				thecount++				}			}						if (elm) {			elm.innerHTML=": "+ thecount + " ";							if (location.href.indexOf("module") > -1) {					tle = document.title;					par = tle.split(")");										if (par.length>1) tle = par[1];					else tle = par[0];										document.title = "("+ thecount + ") " + tle; 				}			}						modules[i].count = thecount;						if (modules[i].open && thecount==0) minimize(i);			}			}}function launchRemote(module) {	doClose(module);}