 if (document.images) {
	goodVersion = true;
} else {
	goodVersion = false;
}
	
// Begin Browser and DHTML detect	
var BrowserVersion = parseFloat(navigator.appVersion.substring(0, 4));

var BrowserType = "Unknown";
var isMSIE = false;
var isNS = false;
if (navigator.appVersion.indexOf("MSIE") != -1) {
	BrowserType = "MSIE";
	isMSIE = true;
} else if (navigator.userAgent.indexOf("Mozilla", 0) > -1) {
	BrowserType = "NS";
	isNS = true;
}

var OSType = "Unknown";
var isWin = false;
var isMac = false;
if (navigator.userAgent.indexOf("Win", 0) > -1) {
	OSType = "Win";
	isWin = true;
} else if (navigator.userAgent.indexOf("Macintosh", 0) > -1) {
	OSType = "Mac";
	isMac = true;
}
	
var DHTMLversion = "Disabled";
if (BrowserVersion >= 4) {
	if (BrowserType == "MSIE") {
		if (OSType == "Mac") {
			// Disable buggy Mac MSIE DHTML
			DHTMLversion = "Disabled";
		} else {
			DHTMLversion = "MSIE";
		}
	} else if (BrowserType == "NS") {
		if (BrowserVersion >= 6) {
			// Disable buggy NS6 DHTML
			DHTMLversion = "Disabled";
		} else {
			DHTMLversion = "NS";
		}
	}
}
// End Browser and DHTML detect	

function showHide(ID, state) {
	if (DHTMLversion != "Disabled") {
		if (DHTMLversion.indexOf("NS4", 0) > -1) {
			if (state == 1) {
				document.layers[ID].visibility = "show";
			} else {
				document.layers[ID].visibility = "hide";
			}
		} else {
			//alert(ID)
			if (state == 1){
				document.getElementById(ID).style.visibility = "visible";
			} else {
				document.getElementById(ID).style.visibility = "hidden";
			}
		}
		//alert("done")
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  
  	if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function P7_Snap() { //v2.67 by PVII
	//P7_Snap(snapToDivID,divID,offset_x,offset_y);
	var g,x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,tw,q0,xx,yy,w1,pa='px',args=P7_Snap.arguments;
	a=parseInt(a);
 	if (document.layers||window.opera){
		pa='';
	}
	for(k=0;k<(args.length);k+=4){
 		if((g=MM_findObj(args[k]))!=null){
			if((el=MM_findObj(args[k+1]))!=null){
 				a=parseInt(args[k+2]);
				b=parseInt(args[k+3]);
				//alert('div=' + g.name + '; swapDiv=' + 'el=' + el.name + '; a=' + a + '; b=' + b);
				x=0;
				y=0;
				ox=0;
				oy=0;
				p="";
				tx=1;
 				da="document.all['"+args[k]+"']";
				if(document.getElementById){
						d="document.getElementsByName('"+args[k]+"')[0]";
						if(!eval(d)){
							d="document.getElementById('"+args[k]+"')";
							if(!eval(d)){
								d=da;
							}
						}
						} else if(document.all){
						d=da;
					}
					if(document.all||document.getElementById){
						while(tx==1){
								p+=".offsetParent";
							if(eval(d+p)){
								x+=parseInt(eval(d+p+".offsetLeft"));
								y+=parseInt(eval(d+p+".offsetTop"));
								}else{
								tx=0;
							}
						}
						ox=parseInt(g.offsetLeft);
						oy=parseInt(g.offsetTop);
						
						tw=x+ox+y+oy;
							if(tw==0||(navigator.appVersion.indexOf("MSIE 4")>-1&&navigator.appVersion.indexOf("Mac")>-1)){
								ox=0;
							oy=0;
							if(g.style.left){
								x=parseInt(g.style.left);
								y=parseInt(g.style.top);
								
							}else{
									w1=parseInt(el.style.width);
								bx=(a<0)?-5-w1:-10;
								a=(Math.abs(a)<1000)?0:a;
								b=(Math.abs(b)<1000)?0:b;
									x=document.body.scrollLeft+event.clientX+bx;y=document.body.scrollTop+ev
ent.clientY;
							}
						}
					}else if(document.layers){
					x=g.x;
					y=g.y;
					q0=document.layers,dd="";
					for(var s=0;s<q0.length;s++){
							dd='document.'+q0[s].name;
						if(eval(dd+'.document.'+args[k])){
							x+=eval(dd+'.left');
							y+=eval(dd+'.top');
							
								break;
						}
					}
				}
				e=(document.layers)?el:el.style;
				xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);
				if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){
					xx+=parseInt(document.body.leftMargin);
					yy+=parseInt(document.body.topMargin);
				}
				
				//Find the height of the div in question...
				//thingyHeight = e.height;
				
				// ---------------------------------------------------------------------------------
				// Get the vertical offset if the submenu will fall below the page.
				// ---------------------------------------------------------------------------------
				
				minHeight = 200; //Minimum height from the top to move a div if it bumps the bottom of the window
				
				
				// Get the window height...
				//if (parseInt(navigator.appVersion)>3) {
				//alert(navigator.appName);
				 if (navigator.appName=="Netscape" || navigator.appName == "Opera") {
				  winW = window.innerWidth;
				  winH = window.innerHeight;
				 }
				 if (navigator.appName.indexOf("Microsoft")!=-1) {
				  winW = document.body.offsetWidth;
				  winH = document.body.offsetHeight;
				 }
				//}
			
				
				// Get the current scroll position
				var scrollYValue
				if (DHTMLversion == "NS6") {
					scrollYValue = window.scrollY;
				} else {
					scrollYValue = document.body.scrollTop;
				}
				
				// Get the snapTo position of the parent DIV called (divID):
				//alert("snapToDivID: " + snapToDivID);
				
			
				//alert("DHTMLVersion: " + DHTMLversion + "\nScreenHeight: " + winH + "\nScrollValue: " + scrollYValue);
				
				divHeight = 0;
				divHeight = parseInt(e.top);
				snapToDivHeight = parseInt(el.clientHeight);
				
				topPosition = yy;
				//alert("top: " + snapToDivHeight );

				endPosition = topPosition + snapToDivHeight;
				maxEndPosition = scrollYValue + winH - 15;
				overlap = maxEndPosition - endPosition;
				
				
				//alert("overlap: " + overlap);
				tempNewY = yy + overlap;
				
				//alert("projected End of page: " + maxEndPosition + "\noverlap: " + overlap + "\nDivHeight:  " + snapToDivHeight);
				if (overlap < 5)  {
					//  Set the new end position up higher
					yy = yy + overlap;
					
					if (tempNewY < minHeight) {
						yy = minHeight;
					}
				}
				
				// ---------------------------------------------------------------------------------
				// End of vertical offset calculations
				// ---------------------------------------------------------------------------------
				
				
				//alert("divHeight: " + divHeight);
				
				
				//e.left=xx+pa;
				e.left=xx+pa;
				e.top=yy+pa;
				//alert(xx + " + " + pa + "\nyy+pa" + yy + " + " + pa)
				}
			}
		}
}








var navTimeout = 0;
var bgTimeout = 0;
var allTO = 0;
var div1On = "";
var div2On = "";
var div2IndivOn = "";
var div3On = "";

function sideNavOn(divID, parentID, navLevel, snapToDivID, snapWidth) {	

	//clear timeout for turning everything off
	clearTimeout(allTO);
	
	//0. turn off any others at this level and their children
	if (navLevel == 1) {
		if (div1On != "") {
			document.getElementById(div1On).className='';
			div1On = "";
		}
		if (div2On != "") {
			showHide(div2On,0);
			div2On = "";
		}
		if (div2IndivOn != "") {
			document.getElementById(div2IndivOn).className='background';
			div2IndivOn = "";
		}
		if (div3On != "") {
			showHide(div3On,0);
			div3On = "";
		}
		
		//2. set me to be the one on
		div1On = parentID;
		
		//3. set my child to be the one on
		div2On = divID;
	} else if (navLevel == 2) {
		/*if (div2On != '' AND div2On != snapToDivID) {
			showHide(div2On,0);
			div2On = "";
		}*/
		if (div3On != '') {
			showHide(div3On,0);
			div3On = "";
		}
		if (div2IndivOn != "") {
			document.getElementById(div2IndivOn).className='background';
			div2IndivOn = "";
		}
		
		//2. set me to be the one on
		div2On = parentID;
		div2IndivOn = snapToDivID;
		
		//3. set my child to be the one on
		div3On = divID;
	}
	
	if (!snapWidth) {
		snapWidth = 193;
	}
	
	
	
	
	//move the sub level to line up with me
	P7_Snap(snapToDivID,divID,snapWidth,-7);
	
	//1. show the subLevel
	showHide(divID,1);
	
	//change the bgcolor
	document.getElementById(snapToDivID).className='backgroundAlt';
}

function sideNavOff(divID, timeoutMS) {	
	myFunctionCall = "sideNavAllOff()";
	allTO = setTimeout(myFunctionCall, 1000);
}

function sideNavAllOff() {
	//reset bg on nav1
	document.getElementById(div1On).className='background';
	
	//turn off nav 2 & 3
	if (div2On != "") {
		showHide(div2On,0);
		
	}
	if (div2IndivOn != "") {
		document.getElementById(div2IndivOn).className='background';
	}
	if (div3On != "") {
		showHide(div3On,0);
	}
	div1On = "";
	div2On = "";
	div3On = "";
}

// example: <a href="javascript:toggleCheckboxes(document.hotlistForm.HotList)">Toggle All Checkboxes</a>
function toggleCheckboxes(objForm) {
	for (i=0;i<objForm.length;i++) {
		objForm[i].checked = !(objForm[i].checked)
	}
}
