function queryString( qsElement ) 
{
	var q = unescape(location.search.substr(1)).split('&');
	for ( var i=0; i<q.length; i++ ) {
		var t=q[i].split('=');
		if ( t[0].toLowerCase() == qsElement.toLowerCase() ) return t[1];
	}
	return '';
}

function loadContent( thePage ) 
{
	var theQS = queryString('cf'); 

	switch ( thePage ) {
		case "index":
			htmlInclude( './content/indexContent.htm', 'index' );
			break;
		case "cp":
			switch ( theQS ) {
			case "ov":
				htmlInclude( './content/cp_ov.htm', 'cp' );
				document.images['cp_ov'].src = "./images/overview_down.gif";
				break;
			case "co":
				htmlInclude( './content/cp_counseling.htm', 'cp' );
				document.images['cp_co'].src = "./images/co_down.gif";
				break;
			case "ra":
				htmlInclude( './content/cp_riskAssessment.htm', 'cp' );
				document.images['cp_ra'].src = "./images/ra_down.gif";
				break;
			case "of":
				htmlInclude( './content/cp_offices.htm', 'cp' );
				document.images['cp_of'].src = "./images/of_down.gif";
				break;
			case "cm":
				htmlInclude( './content/cp_committees.htm', 'cp' );
				document.images['cp_cm'].src = "./images/cm_down.gif";
				break;
			case "bo":
				htmlInclude( './content/cp_boardOversight.htm', 'cp' );
				document.images['cp_bo'].src = "./images/bo_down.gif";
				break;
			case "cc":
				htmlInclude( './content/cp_conductCodes.htm', 'cp' );
				document.images['cp_cc'].src = "./images/cc_down.gif";
				break;
			case "tc":
				htmlInclude( './content/cp_training.htm', 'cp' );
				document.images['cp_tc'].src = "./images/tc_down.gif";
				break;
			case "rs":
				htmlInclude( './content/cp_reporting.htm', 'cp' );
				document.images['cp_rs'].src = "./images/rs_down.gif";
				break;
			case "id":
				htmlInclude( './content/cp_investigations.htm', 'cp' );
				document.images['cp_id'].src = "./images/id_down.gif";
				break;
			case "ps":
				htmlInclude( './content/cp_personnelStrategies.htm', 'cp' );
				document.images['cp_ps'].src = "./images/ps_down.gif";
				break;
			case "as":
				htmlInclude( './content/cp_audits.htm', 'cp' );
				document.images['cp_as'].src = "./images/as_down.gif";
				break;
			case "ea":
				htmlInclude( './content/cp_externalAssessments.htm', 'cp' );
				document.images['cp_ea'].src = "./images/ea_down.gif";
				break;
			case "tp":
				htmlInclude( './content/cp_thirdParty.htm', 'cp' );
				document.images['cp_tp'].src = "./images/tp_down.gif";
				break;
			case "ii":
				htmlInclude( './content/cp_internalIssues.htm', 'cp' );
				document.images['cp_ii'].src = "./images/ii_down.gif";
				break;
			case "cu":
				htmlInclude( './content/cp_corporateCulture.htm', 'cp' );
				document.images['cp_cu'].src = "./images/cu_down.gif";
				break;
			case "do":
				htmlInclude( './content/cp_documentation.htm', 'cp' );
				document.images['cp_do'].src = "./images/do_down.gif";
				break;
			default:
				htmlInclude( './content/cp_ov.htm', 'cp' ); 
				document.images['cp_ov'].src = "./images/overview_down.gif";
				break;
			}
			break;
		case "cd":
			switch ( theQS ) {
			case "ov":
				htmlInclude( './content/cd_ov.htm', 'cd' );
				document.images['cd_ov'].src = "./images/overview_down.gif";
				break;
			case "ac":
				htmlInclude( './content/cd_addressingConflicts.htm', 'cd' );
				document.images['cd_ac'].src = "./images/aci_down.gif";
				break;
			case "ci":
				htmlInclude( './content/cd_conductingIntInv.htm', 'cd' );
				document.images['cd_ci'].src = "./images/cii_down.gif";
				break;
			case "rd":
				htmlInclude( './content/cd_regulatoryDefense.htm', 'cd' );
				document.images['cd_rd'].src = "./images/rd_down.gif";
				break;
			case "mrs":
				htmlInclude( './content/cd_monitorships.htm', 'cd' );
				document.images['cd_mrs'].src = "./images/mrs_down.gif";
				break;
			default:
				htmlInclude( './content/cd_ov.htm', 'cd' ); 
				document.images['cd_ov'].src = "./images/overview_down.gif";
				break;
			}
			break;
		case "attorneys":
			if ( theQS == "jk" ) {
				htmlInclude( './content/jkBio.htm', 'attorneys' );
			} else if ( theQS == "rw" ) {
				htmlInclude( './content/rwBio.htm', 'attorneys' ); 
			} else {
				htmlInclude( './content/rwBio.htm', 'attorneys' ); 
			}
			break;
		case "ie":
			htmlInclude( './content/experience.htm', 'ie' );
			break;
		case "pub":
			htmlInclude( './content/publications.htm', 'pub' );
			break;
		case "pres":
			htmlInclude( './content/presentations.htm', 'pres' );
			break;
		case "contact":
			htmlInclude( './content/contactInfo.htm', 'contact' );
			break;
		default:
			htmlInclude( './content/filenotfound.htm', thePage ); 
			break;
	}
}
/*
// Set the distance of the footer from the bottom of the page's content.
// This function ensures a minimum gap between the content and the footer.  Purely cosmetic.
*/
function setFooterMarginTop( thePage )
{
	var vOffset = 0;
	var bName = navigator.appName;
	var bVer = parseFloat(navigator.appVersion);
	var browser = "";
	if ( bName == "Netscape" ) {
		browser = "FireFox"
	} else {
		browser = bName;
	}
	var MIN_CONTENT_HEIGHT = 390;
	var curContentHeight = 0;
	var theQS = queryString('cf'); 

	if ( thePage == 'index' || thePage == 'cp' || thePage == 'cd' ) {
		curContentHeight = parseFloat( document.getElementById( "contentRight" ).offsetHeight );
	} else {
		curContentHeight = parseFloat( document.getElementById( "content" ).offsetHeight );
	}

	if ( browser == "FireFox" && ( thePage == 'index' || thePage == 'cp' || thePage == 'cd' ) ) {
		document.getElementById( "contentRight" ).style.height = "400px";
	} else if ( browser != "FireFox" && ( thePage == 'index' || thePage == 'cp' || thePage == 'cd' ) ) {
		document.getElementById( "contentRight" ).style.height = "100%";
	} else if ( browser == "FireFox" && !( thePage == 'index' || thePage == 'cp' || thePage == 'cd' ) ) {
		document.getElementById( "content" ).style.height = "100%";
	} else {
		document.getElementById( "content" ).style.height = "100%";
	}
	if ( browser == "FireFox" && ( thePage == 'attorneys' || thePage == 'pub' || thePage == 'pres' ) ) {
		document.getElementById( "footerBox" ).style.marginTop = "0px";
	} else if ( browser == "FireFox" && !( thePage == 'attorneys' || thePage == 'pub' || thePage == 'pres' ) ) {
		document.getElementById( "footerBox" ).style.marginTop = "20px";
	} else {
		if ( curContentHeight >= MIN_CONTENT_HEIGHT ) {
			document.getElementById( "footerBox" ).style.marginTop = vOffset + "px";
		} else {
			document.getElementById( "footerBox" ).style.marginTop = ( MIN_CONTENT_HEIGHT - curContentHeight + vOffset ) + "px";
		}
	}

	document.getElementById( "footerBox" ).style.visibility = "visible";
}

function openDisclaimerWin()
{
	var bName = navigator.appName;
	var bVer = parseFloat(navigator.appVersion);
	var browser = "";
	if ( bName == "Netscape" ) {
		window.open( "./disclaimer.htm", "disclaimer", "width=818px, height=557px" );
	} else {
		window.open( "./disclaimer.htm", "disclaimer", "width=818px, height=600px" );
	}
}

function openLinkWindow( theUrl )
{
	window.open( theUrl, "linkWin" );
}

function htmlInclude( fileURL, includePage ) 
{
	if ( window.ActiveXObject ) {
		xmlhttp = new ActiveXObject( 'Microsoft.XMLHTTP' ); 
		if ( xmlhttp ) {
			if ( includePage == 'index' || includePage == 'cp' || includePage == 'cd' ) {
				xmlhttp.onreadystatechange = htmlFileReadyRight;
			} else {
				xmlhttp.onreadystatechange = htmlFileReady;
			}
			xmlhttp.open( 'GET', fileURL, false );
			xmlhttp.send();
		}
	} else if ( window.XMLHttpRequest ) {
		xmlhttp = new XMLHttpRequest();
		if ( includePage == 'index' || includePage == 'cp' || includePage == 'cd' ) {
			xmlhttp.onreadystatechange = htmlFileReadyRight;
		} else {
			xmlhttp.onreadystatechange = htmlFileReady;
		}
		xmlhttp.open( "GET", fileURL, true );
		xmlhttp.send( null );
	}
}

function htmlFileReady() 
{
	if ( xmlhttp.readyState == 4 ) { 
		if ( xmlhttp.status == 200 ) { 
			document.getElementById('content').innerHTML = xmlhttp.responseText;
		} else {
			// File Not Found
			document.getElementById('content').innerHTML = "<h1>Content File Not Found! Error 1001.</h1>";
		}
	}
}

function htmlFileReadyRight() 
{
	if ( xmlhttp.readyState == 4 ) { 
		if ( xmlhttp.status == 200 ) { 
			document.getElementById('contentRight').innerHTML = xmlhttp.responseText;
		} else {
			// File Not Found
			document.getElementById('contentRight').innerHTML = "<h1>Content File Not Found! Error 1001.</h1>";
		}
	}
}
