 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 popWindow(URL) {
	popwin = window.open(URL, "PopUpWindow", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600")
	popwin.opener = self
	popwin.focus()
}

function showHide(ID, state) {
	alert(DHTMLversion);
	if (DHTMLversion != "Disabled") {
		
		
		if (DHTMLversion.indexOf("NS4", 0) > -1) {
			if (!state) {
				var currentState = document.layers[ID].style.visibility;
			}
			
			if (state == 1 || currentState == "hidden") {
				document.layers[ID].visibility = "show";
			} else {
				document.layers[ID].visibility = "hide";
			}
		} else {
			if (!state) {
				var currentState = document.getElementById(ID).style.visibility
			}
			alert("currentState: " + currentState);
			if (state == 1 || currentState == "hidden") {
				document.getElementById(ID).style.visibility = "visible";
				document.getElementById(ID).style.position = "static";
			} else {
				document.getElementById(ID).style.visibility = "hidden";
				document.getElementById(ID).style.position = "absolute";
			}
		}
		//alert("done")
	}
}

function showHideNoMovement(ID, state) {
	if (DHTMLversion != "Disabled") {
		
		
		if (DHTMLversion.indexOf("NS4", 0) > -1) {
			if (!state) {
				var currentState = document.layers[ID].style.visibility;
			}
			
			if (state == 1 || currentState == "hidden") {
				document.layers[ID].visibility = "show";
			} else {
				document.layers[ID].visibility = "hide";
			}
		} else {
			if (!state) {
				var currentState = document.getElementById(ID).style.visibility
			}
			
			if (state == 1 || currentState == "hidden") {
				document.getElementById(ID).style.visibility = "visible";
				//document.getElementById(ID).style.position = "static";
			} else {
				document.getElementById(ID).style.visibility = "hidden";
				//document.getElementById(ID).style.position = "absolute";
			}
		}
		//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) {
				 if (navigator.appName=="Netscape") {
				  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 = "";
}

function getImage(inputName) {
		//document.write("About to get Image: " + image_name +"<BR>");
		var myImage = document [inputName];
		browserName = navigator.appName;
       	browserVer = parseInt(navigator.appVersion);
        if (browserName == "Netscape" && browserVer == 3) {
			if (myImage.length) {
				return myImage[myImage.length-1];
			} else return myImage;
		} else {
			return myImage;
		}
	}


function imageSwap(which, state, imageType) {
	// this script needs getImage function and Browser sniffer function
	    if (goodVersion) {
			//var thisImage = document.images[which];
			var thisImage = getImage(which);
			var thisImageSrc = thisImage.src;
			var imageName = thisImageSrc.substring(0,thisImageSrc.indexOf("_o"));
            if (state == 0) {
                thisImage.src = imageName + "_off." + imageType
            } else {
                thisImage.src = imageName + "_on." + imageType
          	}
        }
    }
	
function imageSwapNoState(which, imageType) {
	// this script needs getImage function and Browser sniffer function
	    if (goodVersion) {
			//var thisImage = document.images[which];
			var thisImage = getImage(which);
			var thisImageSrc = thisImage.src;
			var imageName = thisImageSrc.substring(0,thisImageSrc.indexOf("_o"));
			if (thisImageSrc.indexOf("_off") >= 0) {
				state = 1;
			} else {
				state = 0;
			}
            if (state == 0) {
                thisImage.src = imageName + "_off." + imageType
            } else {
                thisImage.src = imageName + "_on." + imageType
          	}
        }
    }
	
function openFAQ(questionID, answerID, arrow, rowCount, thisRow) {
	//swap style for question
	
	changeClass(questionID, 'faqQuestionOver');
	//swap arrow from open to down
	imageSwapNoState(arrow, 'jpg');
	//show faq answer
	//showHide(answerID, 1);
	showHide(answerID);
	//close all the other faq's
	for (i=1;i<=rowCount;i++) {
		if (i != thisRow) {
			nextAnswer = 'Answer' + i;
			nextArrow = 'faqarrow' + i;
			
			//alert("This popup is temporary,  please ignore:  \nNext Answer: " + nextAnswer);
			var currentState = document.getElementById(nextAnswer).style.visibility;
			
			if (currentState == "visible") {
				showHide(nextAnswer, 0);
				imageSwapNoState(nextArrow, 'jpg');
			}
		}
	}
}

function changeClass(id, newClass) {
	//alert("This popup is temporary,  please ignore:  \n" + id + "\n" + newClass);
	identity=document.getElementById(id);
	identity.className=newClass;
}

function sideNavRollover(idList, cssClass) {
	//this swaps the class of all the id's in the list to the specified class
	
	var idArray = idList.split(",");
  	var idArrayLen = idArray.length;
	
	for(id=0;id<(idArrayLen);id+=1){
		changeClass(idArray[id], cssClass);
	}
}


function detectFlashVersion(){	
	//alert("hello form the detectFlashVersion function");
	if (navigator.plugins){
		// Check for old plugin description first
		// Description format: Shockwave Flash 4.0 r5
		if (navigator.plugins["Shockwave Flash 2.0"]) {
			var flashDescription = navigator.plugins["Shockwave Flash 2.0"].description;
			flashVersionInstalled = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
		} else if (navigator.plugins["Shockwave Flash"]) {
			var flashDescription = navigator.plugins["Shockwave Flash"].description;
			flashVersionInstalled = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
		}
	}
		
	if(navigator.userAgent.indexOf("WebTV") != -1) {
		flashVersionInstalled = 2;
	}
	
	// alert("installed: " + flashVersionInstalled + " >= min: " + minFlashVersionRequired);
	if (flashVersionInstalled >= minFlashVersionRequired) { 		// user has a new enough version
		
		isRequiredFlashVersionInstalled = true;	
	}
	
	// alert(flashVersionInstalled)
}



function showHideV2(ID, isReturn) {
	/* Just passing the ID will determine the current state and change it to the opposite visibility state */
	
	if(!isReturn) {
		var isReturn = 0;
	}
	//alert(isReturn);
	DHTMLversion = "MSIE";
	if (DHTMLversion != "Disabled") {
		// hack so that is doc.layers not defined, then use MSIE
		
	
		if (DHTMLversion == "MSIE" || DHTMLversion == "NS6") {
			
			//var currentState = document.all[ID].style.visibility;
			var currentState = document.getElementById(ID).style.visibility
		} else {
			var currentState = document.layers[ID].style.visibility;
		}
	}
	
	state = 1
	if (currentState == "visible") {
		state = 0;
	} else {
		state = 1;
		
	}
	
	// alert("The current state of: " + ID + " is: " + currentState);
	var newState = false;
	
	if (DHTMLversion != "Disabled") {
		
		
		if (DHTMLversion == "MSIE" || DHTMLversion == "NS6") {
			//var myObject = document.all[ID].style
			var myObject = document.getElementById(ID).style
		} else {
			var myObject = document.layers[ID]
		}
		if ((state == 1) || (state == true)) {
			
			myObject.visibility = "visible";
			myObject.position = "static";
			newState = true;
			//myObject.top = 100
			//myObject.left = 100
		} else {
			myObject.visibility = "hidden";
			myObject.position = "absolute";
			//myObject.top = 100
			//myObject.left = 100
		}
	}
	
	if (isReturn == 1) {
		return newState;
	}
	
}