// <SCRIPT language="javascript">
<!-- Begin

////////////////////////////////////////////////////////////////////////////////
// Project:	  Library
// Customer:	Boeing
// Page:	    clientlib.js
// Purpose:	  Client-Side Script Library
//
// Date	Ver		Analyst         Description
// ---------------------------------------------------------------------------
// 00/07 1.0.0 Gavin McCarter	Initial Development
//	

// Global Declarations


function Left(strText, intLength) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	Left
	//	Purpose:	Return the left intLength characters of a string.
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 n/a		Gavin McCarter	Initial Development
	//	

	var strReturn = "";

	strReturn = strText.substr(0, intLength);	
	
	return(strReturn);
}


function Right(strText, intLength) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	Right
	//	Purpose:	Return the right intLength characters of a string.
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 n/a		Gavin McCarter	Initial Development
	//	

	var strReturn;

	strReturn = strText.substr(strText.length - intLength, intLength);	
	
	return(strReturn);
}


function Replicate(strText, intCount) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	Replicate
	//	Purpose:	Return a string consisting of strText repeated intCount times.
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 n/a		Gavin McCarter	Initial Development
	//	

	var intLoop;
	var strReturn = "";
	
	for (intLoop = 1; intLoop <= intCount; intLoop++) {
		strReturn += strText;
	}
	
	return(strReturn);
}


function LTrim(strText) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	LTrim
	//	Purpose:	Remove all spaces from the left of a string.
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 1.0.0	Gavin McCarter	Initial Development
	//	

	var strReturn;

  strReturn = strText;
  while (Left(strReturn, 1) == " ") {
    strReturn = Right(strReturn, strReturn.length - 1);
  }

	return(strReturn);
}


function RTrim(strText) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	RTrim
	//	Purpose:	Remove all spaces from the right of a string.
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 1.0.0	Gavin McCarter	Initial Development
	//	

	var strReturn;

  strReturn = strText;
  while (Right(strReturn, 1) == " ") {
    strReturn = Left(strReturn, strReturn.length - 1);
  }

	return(strReturn);
}


function AllTrim(strText) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	AllTrim
	//	Purpose:	Remove all spaces from the both ends of a string.
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 1.0.0	Gavin McCarter	Initial Development
	//	

	return(LTrim(RTrim(strText)));
}


function RemoveSpaces(strText) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	RemoveSpaces
	//	Purpose:	Remove all spaces from a string.
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 1.0.0	Gavin McCarter	Initial Development
	//	

	var strReturn = "";
	var strChar;
	var intLoop;

  for (intLoop = 0; intLoop < strText.length; intLoop++) {
    strChar = strText.substring(intLoop, intLoop + 1);
    if (strChar != " ") {
      strReturn += strChar;
    }
	}

	return(strReturn);
}


function URLEncodeSpaces(strText) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	URLEncodeSpaces
	//	Purpose:	Remove all spaces from a string.
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 1.0.0	Gavin McCarter	Initial Development
	//  00/07       Gavin McCarter  Improved to use string.replace
	//	

	return(strText.replace(/\s/g, '%20'));
}


function URLEncodeEmail(strText) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	URLEncodeEmail
	//	Purpose:	Remove all spaces, @, . and _ chracters from a string.
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 1.0.0	Gavin McCarter	Initial Development
	//	

	return(strText.replace(/\s/g, '%20').replace(/@/g, '%40').replace(/\./g, '%2E').replace(/_/g, '%5F'));

}


function IsDate(strDate){
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	IsDate
	//	Purpose:	Return True if the supplied date is valid.
	//						Valid formats are MM/DD/YY and MM/DD/YYYY.
	//
	//	Date	Ver		Analyst											Description
	//	---------------------------------------------------------------------------
	//	00/12 n/a	Gavin McCarter & Sasquatch		Initial Development
	//  02/05 n/a Gavin McCarter								Updated to fail on dates such as 13/31/2002.
	//	

	var regexMMDDYY =/^\d{1,2}\/\d{1,2}\/\d{2}$/;
	var regexMMDDYYYY = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
	var strTemp = '';
	var intPos = 0;
	var strMonth = '';
	var strDay = '';
	var strYear = '';
	var blnResult = false;
	
	strDate = AllTrim(strDate);

	if (regexMMDDYY.test(strDate) || regexMMDDYYYY.test(strDate)) {
		strTemp = strDate;
		intPos = strTemp.indexOf('/');
		strMonth = Left(strTemp, intPos);
		strTemp = Right(strTemp, strTemp.length - intPos - 1);
		intPos = strTemp.indexOf('/');
		strDay = Left(strTemp, intPos);
		strYear = Right(strTemp, strTemp.length - intPos - 1);

		if (strYear.length == 2) {
			if (strYear < '30') {
				strYear = '20' + strYear;
			} else {
			  strYear = '19' + strYear;
			}
		}
		var dteTest = new Date(Date.parse(strMonth + '/' + strDay + '/' + strYear));
		//alert('Year = ' + strYear + ', ' + dteTest.getYear() + '\nMonth = ' + strMonth + ', ' + (dteTest.getMonth() + 1) + '\nDay = ' + strDay + ', ' + dteTest.getDate());
		if (Nstr(dteTest.getYear(), 2) == Nstr(strYear, 2) && Nstr(dteTest.getMonth() + 1, 2) == Nstr(strMonth, 2) && Nstr(dteTest.getDate(), 2) == Nstr(strDay, 2)) {
			blnResult = true;
		}
	}

	return(blnResult);
}


function IsNumeric(strNumber){
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	IsNumeric
	//	Purpose:	Return True if the supplied value is a valid number.
	//
	//	Date	Ver		Analyst											Description
	//	---------------------------------------------------------------------------
	//	02/05 n/a		Gavin McCarter 							Initial Development
	//	
	
  var strValidChars = '-1234567890.';  
  var intDecimalPoints = 0;
  var intLoop;
  var strChar;
  var blnResult = true;

  for (intLoop=0; intLoop < strNumber.length; intLoop++) {
		strChar = strNumber.substring(intLoop, intLoop+1);
    if (strChar == ".") {
			intDecimalPoints++; 
		}
    if (strChar == "-" && intLoop != 0) { 
			blnResult = false;
		}
    if (strValidChars.indexOf(strChar, 0) == -1) {
			blnResult = false;
    }
  }
  if (intDecimalPoints > 1) {
		blnResult = false;
	}
  return(blnResult);
}


function Nstr(vntNumber, intLength) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	Nstr
	//	Purpose:	Return a numeric string consisting of vntNumber padded, on the left
	//						with zeros, to the specified length.
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 n/a		Gavin McCarter	Initial Development
	//	

	var strReturn;
	
	strReturn = Replicate("0", intLength) + vntNumber; 
	strReturn = Right(strReturn, intLength);

	return(strReturn);
}


function MonthName(intMonth) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	MonthName
	//	Purpose:	Return the text name of the specified month
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 n/a		Gavin McCarter	Initial Development
	//	

	var strReturn;

	switch (intMonth) {
		case 0:	
			strReturn = "January";
			break;
		case 1:
			strReturn = "February";
			break;
		case 2:
			strReturn = "March";
			break;
		case 3:
			strReturn = "April";
			break;
		case 4:
			strReturn = "May";
			break;
		case 5:
			strReturn = "June";
			break;
		case 6:
			strReturn = "July";
			break;
		case 7:
			strReturn = "August";
			break;
		case 8:
			strReturn = "September";
			break;
		case 9:
			strReturn = "October";
			break;
		case 10:
			strReturn = "November";
			break;
		case 11:
			strReturn = "December";
			break;
		default:
			strReturn = ""
			break;
	}
		
	return(strReturn);
}


function Mod(dblNumerator, dblDenominator) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	Mod
	//	Purpose:	Return dblNumerator MOD dblDenominator
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 n/a		Gavin McCarter	Initial Development
	//	

	var dblReturn;
	
	dblReturn = dblNumerator - (Math.floor(dblNumerator / dblDenominator) * dblDenominator);
	
	return(dblReturn);
}


function WebCard(strBemsID) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	WebCard
	//	Purpose:	Display pop-up Web Card for the specified Bems ID
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	01/09 n/a		Gavin McCarter	Initial Development
	//	

	var strURL = 'http://card.web.boeing.com/WebCard.cfm?id=' + strBemsID;
	var objWindow = window.open(strURL,'WebCard','height=310,width=450,resizeable=no,scrollbars=no');
	objWindow.focus();
}


function DebugObject(objObject) {
  ////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	DebugObject
	//	Purpose:	List all properties of the specified object
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 n/a		Gavin McCarter	Initial Development
	//	
  
  var strResult = '';
  var objProperty;
  
  if (isMinNS4) {
		for (objProperty in document.layers[objObject]) {
			strResult += objProperty + ' ' + document.layers[objObject][objProperty] + '\n';
		}
	}
  else {
		if (document.all) {
			for (objProperty in objObject) {
				strResult += objProperty + ' ' + objObject[objProperty] + '\n';
      }
		}
	}
  alert(strResult);
  return strResult;
 }


function FileNameExtension(strFileName) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	FileNameExtension
	//	Purpose:	Return the extension (excluding the .) for the supplied file name
	//	
	
	var strReturn = '';
	var lngPos = strFileName.length - 1;
	
	while (lngPos > 0 && strFileName.substr(lngPos, 1) != '.') {
		strReturn = strFileName.substr(lngPos, 1) + strReturn;
		lngPos -= 1;
	}
	return strReturn;
}


function AutoImageSwap(strImageName) {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	AutoMouseOver
	//	Purpose:	Handle menu mouse over
	//	Assumes:  1. dhtmllib.js is included.
	//						2. Mouse Over image is has the same name with _hover appended.
	//							 for example:  normal.jpg and normal_hover.jpg
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	03/01 n/a		Gavin McCarter	Initial Development
	//	
	
	var strCurrentFileName;
	var strExtension;
	var strFileName;
	var objImage = getImage(strImageName);
	if (objImage) {
		strCurrentFileName = objImage.src;
		strExtension = FileNameExtension(strCurrentFileName);
		strFileName = Left(strCurrentFileName, strCurrentFileName.length - strExtension.length - 1);
		if (Right(strFileName, 6) == '_hover') {
			objImage.src = Left(strFileName, strFileName.length - 6) + '.' + strExtension;
		} else {
			objImage.src = strFileName + '_hover' + '.' + strExtension;
		}
	} else {
		alert('AutoImageSwap could not find an image named: ' + strImageName);
	}
}


function tlbrMouseOver(strImgName, strImgFile, blnMouseOver, strHelpText) {
  ////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	tlbrMouseOver
	//	Purpose:	Handle menu mouse over
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 n/a		Gavin McCarter	Initial Development
	//	

  var objImage
  
  if (blnMouseOver) {
    lngStatusTimer = setTimeout("window.status = '" + strHelpText + "';", 100);
  }
  else {
    clearTimeout(lngStatusTimer);
    window.status = "";
  }
    
  objImage = document.images[strImgName];
  objImage.src = strImgFile;
  
}


function ClientWindowResize() {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	ClientWindowResize
	//	Purpose:	Called on Window Resize - attempt to work around Netscape 
	//						ReSize bug.
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/11 n/a		Gavin McCarter	Initial Development
	//	

	if (!isMinIE4) {
		setTimeout('window.location.href = window.location.href', 500);
	}
}


function ClientResizeInit() {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	ClientResizeInit
	//	Purpose:	Called from body.onLoad to initialize library handling of window
	//						resize.
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/11 n/a		Gavin McCarter	Initial Development
	//	

	window.onresize = ClientWindowResize;
}


function ClientPageInit() {
	////////////////////////////////////////////////////////////////////////////////
	//	Project:	Library
	//	Customer:	Boeing
	//	Function:	PageInit
	//	Purpose:	Called from body.onLoad to initialize variables, start timers, etc.
	//
	//	Date	Ver		Analyst         Description
	//	---------------------------------------------------------------------------
	//	00/07 n/a		Gavin McCarter	Initial Development
	//	

   
}

// End -->
//</SCRIPT>

