/*  page and server configuration and state management parameters 
File:			cdw_pagestate.js
Author:			Corti Designworks LLC
Use:			Maximus Corporate Site 
Purpose:		Contains the site configuration control parameters that may be edited 
				when migrating the site to partner locations, or promoting the site 
				from developent to staging to production
Version:		0.9 for pre-production QA,
Date:			18-JUL-2003
Mods:		
*/

/*************** begin SECTION: PageState ****************************
	The "pagestate" js object hold several content variable that change on a per-page basis
	These default values (to avoid nulls) are superceded in script on each html page
*/
var oCDW_pagestate				= new Object; 		

oCDW_pagestate.pageimage 		= "aboutmaximus.jpg"; 					// value is only a placeholder
oCDW_pagestate.pagename 		= "MAXIMUS";							// value is only a placeholder
oCDW_pagestate.sectionname 		= "MAXIMUS";				            // value is only a placeholder
oCDW_pagestate.sectionimage 	= "placeholder.jpg";					// value is only a placeholder
// end SECTION: PageState


/*************** begin SECTION: Dynamic URL creation *************************
*/
oCDW_pagestate.mainimageprefix			= "../images/";
oCDW_pagestate.commontopimageprefix 	= "../images/common/";	// location of top area images
oCDW_pagestate.corpsite_prefix			= "/corporate/pages/";
// CCBN values for URL prefixes
// oCDW_pagestate.mainimageprefix			= "http://media.corporate-ir.net/media_files/nys/mms/redesign/images/";
// oCDW_pagestate.commontopimageprefix		= "http://media.corporate-ir.net/media_files/nys/mms/redesign/images/common/";


//	Maximus Server names
oCDW_pagestate.maximusserver_corpstaging_name 			= "http://new.maximus.com"	// "http://12.150.182.194";
oCDW_pagestate.maximusserver_corpproduction_name 		= "http://www.maximus.com";

//
oCDW_pagestate.maximusserver_corpstaging_prefix 		= oCDW_pagestate.maximusserver_corpstaging_name 	+ oCDW_pagestate.corpsite_prefix;
oCDW_pagestate.maximusserver_corpproduction_prefix 		= oCDW_pagestate.maximusserver_corpproduction_name 	+ oCDW_pagestate.corpsite_prefix;

/* CCBN Investor Server Names
	as of (16-Sep-03) both stage & prod servers use:
	http://phx.corporate-ir.net/phoenix.zhtml?c=88279&p=
*/
oCDW_pagestate.investorserver_stagingprefix 			= "http://phx.corporate-ir.net/phoenix.zhtml?c=88279&p=";
oCDW_pagestate.investorserver_productionprefix 			= "http://phx.corporate-ir.net/phoenix.zhtml?c=88279&p=";
/* CCBN - old pre-xmlserver version (up to 16-Sep-03)
oCDW_pagestate.investorserver_stagingprefix 			= "http://www.corporate-ir.net/ireye_redesign/";
oCDW_pagestate.investorserver_productionprefix 			= "http://www.corporate-ir.net/ireye/";
*/

/********************************************************************************
*																				*
*			Note to CCBN, setting you MUST HAVE set CORRECTLY are:				*
*																				*
*	a) 	oCDW_pagestate.remoteserver	= "YES"										*
*																				*
*	b) 	oCDW_pagestate.operationalsetting 	= "STAGING"   or					*
*											= "PRODUCTION"  appropriately 		*
*																				*
*	c) 	oCDW_pagestate.localserverfilesonly_override	= "NO"					*
*																				*
*	d)	oCDW_pagestate.extname 			= ""									*
*																				*
*	This is done by swaping which lines are active vs. commented.				*																				*																				*
*********************************************************************************
*/

oCDW_pagestate.isremoteserver					= "NO";  
// oCDW_pagestate.isremoteserver					= "YES";  	// CCBN Setting

// oCDW_pagestate.operationalsetting 		= "PRODUCTION";		// 
oCDW_pagestate.operationalsetting	 		= "STAGING";		// development or staging

/************************  end of CCBN Note ************************************/


if (oCDW_pagestate.isremoteserver == "YES") {					// value for CCBN
	if (oCDW_pagestate.operationalsetting == "PRODUCTION") {
			oCDW_pagestate.maximusserver_name		= oCDW_pagestate.maximusserver_corpproduction_name;
			oCDW_pagestate.maximusserver_prefix		= oCDW_pagestate.maximusserver_corpproduction_prefix;
			oCDW_pagestate.investorserver_prefix 	= oCDW_pagestate.investorserver_productionprefix;
			//
		} else {
			oCDW_pagestate.maximusserver_name		= oCDW_pagestate.maximusserver_corpstaging_name;
			oCDW_pagestate.maximusserver_prefix		= oCDW_pagestate.maximusserver_corpstaging_prefix;
			oCDW_pagestate.investorserver_prefix 	= oCDW_pagestate.investorserver_stagingprefix;
		} 
}
	
if (oCDW_pagestate.isremoteserver == "NO") {					// value for maximus and CDW servers
	if (oCDW_pagestate.operationalsetting == "PRODUCTION") {
			oCDW_pagestate.maximusserver_name		= oCDW_pagestate.maximusserver_corpproduction_name;
			oCDW_pagestate.maximusserver_prefix		= "./";
			oCDW_pagestate.investorserver_prefix 	= oCDW_pagestate.investorserver_productionprefix;
			//
		} else {
			oCDW_pagestate.maximusserver_name		= oCDW_pagestate.maximusserver_corpstaging_name;
			oCDW_pagestate.maximusserver_prefix		= "./";
			oCDW_pagestate.investorserver_prefix 	= oCDW_pagestate.investorserver_stagingprefix;
		}
}	
// end SECTION: Dynamic URL creation

/****************** begin SECTION: Web Server Technology Control Variables **********************************

	.localserverfilesonly_override	- 	Forces top drop down menu items to link only to
										local pages on whatever the local server is.
										Mostly this overrides CCBN Investor Pages, so
										you see mock-ups, not the live CCBN server pages.	
										Value must be YES or NO.

	.extname	Contains various file name extensions, dynamically added to basic file names, 
				depending on web server type.  MUST be edited when migrating the script 
				between server types
*/	

oCDW_pagestate.localserverfilesonly_override	= "NO"			// normal - staging or production operation 
// oCDW_pagestate.localserverfilesonly_override	= "YES"			// for CDW test only at local CDW or Maximus servers


// oCDW_pagestate.extname 			= "";   		// use for AOL
// oCDW_pagestate.extname 			= ".jsp";   	// use for Java/JSP, like WebSphere
oCDW_pagestate.extname 			= ".asp";   		// use for Microsoft IIS/ASP

// end SECTION: Web Server Technology Control Variables 

/**************** begin SECTION: define global js functions *********************************** 
*/

// For debug - syntactic definition blanks
 function maxHREF(pagefilename) {}
 function maxOPTION(pagefilename) {}
 function maxHostedSiteHREF(pagefilename) {}
 function ccbnHREF(pagefilename) {}
// 

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function jumptoselectListURL( selectList ) { 
	// purpose:		for an html drop down select list that jumps to another page when user picks item
	// parameters:	selectList 	- always use "this", see below
	// requires:	URL in value parameter of list item
	// example:		<select name="prodList" id="prodList" onchange="jumptoselectListURL( this )">
	//				<option selected value="#">-Select Product-</option>
    //		        <option value="http://assetsolutions.maximus.com/fleetfocus.M5.cfm">FleetFocus</option>
	//
	var newIndex = selectList.selectedIndex; 
	var theurl = "";
	if ( newIndex == 0 ) {	// noop if its the first item "-select product-"
		theurl = theurl; 
	} else { 
		theurl = selectList.options[ newIndex ].value; 
		if (theurl != "") {window.location.href = theurl; }
	}
}

 
function maxHREF(pagefilename) {		
	//  purpose:	Needed to generate HTML & URLs that match several environments 
	//				site may be hosted on (e.g. MS vs AOL, Maximus vs CCBN)
	//				Creates html <a href..> tag with URL values for Maximus hosted pages 
	// parameters:	maxpagefilename		- maximus page name, without file extension
	var sTemp 	= "";
	var sHREF 	= "";
	if (pagefilename == '') {	// if there's no name passed, stay in same place
		sTemp = "#";
	} else {
		sTemp = oCDW_pagestate.maximusserver_prefix + pagefilename + oCDW_pagestate.extname;
	}
	sHREF 	= '<a href="' + sTemp + '">';
	document.write(sHREF);
}
 
function maxOPTION(pagefilename) {   	
	//  purpose:	Needed due to shared files with CCBN.  
	//				Creates html <option..> tag with URL values appropriate to hosting server
	// parameters:	maxpagefilename		- maximus page name, without file extension
	var sTemp 	= "";
	var sHREF 	= "";
	if (pagefilename == '') {	// if there's no name passed, stay in same place
		sTemp = "#";
	} else {
		sTemp = oCDW_pagestate.maximusserver_prefix + pagefilename + oCDW_pagestate.extname;
	}
	sHREF 	= '<option value="' + sTemp + '">';
	document.write(sHREF);
}
 

function maxHostedSiteHREF(pagefilename) {	
	//  purpose:	Needed due to shared files with CCBN. 
	//				Creates HREF tag link to other hosted sites, like foundation 
	var sTemp 	= "";
	var sHREF 	= "";
	if (pagefilename == '') {	// if there's no name passed, stay in same place
		sTemp = "#";
	} else {
		sTemp = oCDW_pagestate.maximusserver_name + '/' + pagefilename;
	}
	sHREF 	= '<a href="' + sTemp + '">';
	document.write(sHREF);
}

function ccbnHREF(ccbnpagefilename, maxpagefilename) {	
	//  purpose:	Needed due to shared files with CCBN. 
	//				Creates html <a href..> tag with URL values for CCBN hosted pages 
	//	parameters:	ccbnpagefilename	- ccbn page name, not full URL (ex: ir_site.zhtml?ticker=MMS&script=200)
	// 				maxpagefilename		- maximus page name, without file extension
	var sTemp 	= "";
	var sHREF 	= "";
	if ((ccbnpagefilename == '')||(maxpagefilename == '')) {	// if there's no name passed, stay in same place
		sTemp = "#";
	} else {
		if (oCDW_pagestate.localserverfilesonly_override == "YES") {
			sTemp = oCDW_pagestate.maximusserver_prefix + maxpagefilename + oCDW_pagestate.extname;	// CDW test only
		} else {
			sTemp = oCDW_pagestate.investorserver_prefix + ccbnpagefilename;
		}
	}
	sHREF 	= '<a href="' + sTemp + '">';
	document.write(sHREF);
}


function popupWinFeatures(url,w,h,menu) {
	// sample call ... href="javascript:printpopup1('x.html',700,500,1)"
	//
	x = Math.floor((screen.width - w) / 2);
	y = Math.floor((screen.height - h) / 2);        
	now = new Date();
	features = "screenx="+x+",screeny="+y+",left="+x+",top="+y+",width="+w+",height="+h+",location=no,resizable=yes"+",directories=no,status=no,scrollbars=yes";
	if (menu != null) {
		//features += ",menubar=yes,toolbar=yes,scrollbars=yes";
		features += ",menubar=yes,toolbar=yes";
	} else {
		//features += ",menubar=no,toolbar=no,scrollbars=no"; 
		features += ",menubar=no,toolbar=no"; 
	}
	window.open(url,"newwin",features);
}


//
// begin: printing support functions
//
//		This is a strictly client side JavaScript page print operation that uses
// 		the DOM structure inherent to the corporate web site, and eliminates images etc.
// 		The invoking link is of the following form
// <a href="javascript: void 0" onclick="javascript: printThisPage(); return false;">Print this page</a>
//
var printhtml	= "";
var printURL	= location.href;
var printpgheadlinearea	= "";
var printpgbodyarea		= "";

function printCleanContent(originalContent){
	// Purpose: erases html content not appropriate for printing (includes, images etc)
	//
	// <TAG[^>]*>(.*?)<\/TAG> = Note: generalized regex for reasing a tag and its contained content
	//
	oC	= originalContent;
	var toBeDeletedRegEx		= new Array;
		toBeDeletedRegEx[0]		= /<!--([^>])*-->/i;		// erase comments, because of SSI includes
		toBeDeletedRegEx[1]		= /<img([^>])*>/i;			// erase images
		toBeDeletedRegEx[2]		= /<DIV id=leftrulearea[^>]*>(.*?)<\/DIV>/i;	
		toBeDeletedRegEx[3]		= /<DIV id=rightrulearea[^>]*>(.*?)<\/DIV>/i;	
		toBeDeletedRegEx[4]		= /<DIV class=verticalrule[^>]*>(.*?)<\/DIV>/i;	

	
	var toBeReplacedWith		= "";

	for (var i = 0; i < toBeDeletedRegEx.length; i++){
		var newContent		= "";
		while(toBeDeletedRegEx[i].test(oC)){
			var oM = "";
			var matchResult = oC.match(toBeDeletedRegEx[i]);
			if (matchResult != null){
				oM = matchResult[0];
			}else{
				oM = "none matched";
			}
			newContent	= oC.replace(toBeDeletedRegEx[i], toBeReplacedWith);
			oC			= newContent;
		}
	}
	return oC;
}

function printGetContent(){

// alert("see if pgbodyarea object exists ... " + document.getElementById('pgbodyarea'));

	if (document.getElementById('pgheadlinearea')){
		var pgheadline		= document.getElementById('pgheadlinearea').innerHTML;
	}
	if (document.getElementById('pgbodyarea')){
		var pgbody			= document.getElementById('pgbodyarea').innerHTML;
	}
	tempContent			= "";
	
	tempContent			= printCleanContent(pgheadline);
	pgheadline			= tempContent;
	
	tempContent			= printCleanContent(pgbody);
	pgbody				= tempContent;
	
	if (pgheadline) {printpgheadlinearea = pgheadline}else{printpgheadlinearea = ""};
	if (pgbody) {printpgbodyarea = pgbody}else{printpgbodyarea = ""};
}

function printBuildContent(){
	printhtml		= "<html><HEAD><TITLE>" +
	oCDW_pagestate.pagename +
	"</TITLE>" +
	"<meta http-equiv='Pragma' content='no-cache'>" +
	"<meta http-equiv='Expires' content='0'>" +
	"<meta http-equiv='Refresh' content='1800'>" +
	"<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>" +
	"<link rel='stylesheet' href='../css/max3col.css' type='text/css'>" +
	"<scr" + "ipt language=JavaScript1.2 src='../scripts/cdw_pagestate.js' type=text/javascript></SCR" + "IPT>" +
	"</HEAD>" +
	"<body bgcolor='#FFFFFF' link='#666699' vlink='#666699' alink='#666699'>" +
	// Corporate web site title
	"<span class='intpageheader'>MAXIMUS Corporate Web Site<br><br></span>" +
	// Page Title
	"<SPAN class='intpageheader'><A href='" +
	location.href +
	"' class='intpageheader'>" +
	oCDW_pagestate.pagename +
	"</A></SPAN><br><br>" +
	// URL label
	"<span class='bodycopy'>To print this page, select <b>File</b> then <b>Print</b> from your browser</span><br>" +
	"<span class='verd8ptregular'>URL: " +
	printURL +
	"</span><hr><br>" +
	// Main content headline and body
	printpgheadlinearea +
	"<br><br>" +
	printpgbodyarea +
	"</body></html>" ;
}

function printPopup3(){
	printGetContent();
	printBuildContent();
//	alert(printhtml);
	document.open("","","").document.write(printhtml);
	document.close;
}

function printThisPage(){printPopup3()}
//
// end: printing support functions

// end SECTION: define global js functions

/*
*/