function CaptureKeyStorke(valueEvent) { 
	var keyPressed = null;
	
	if (window.event) {
		keyPressed = window.event.keyCode; //IE
	} else {
		keyPressed = valueEvent.which; //Firefox
	}
	
	if (keyPressed == 13) {
		LoadItem();
	}
}

//Start: Section to handle element state change triggered by user.
var cobjPreviousHighlightItem = null;

function Highlight(element) {
	LoseHighlight();
	
	switch (element.className) {
	case 'ListItem':
		element.className = 'ListItem_Highlight';
		cobjPreviousHighlightItem = element;
		
		break;
	case 'Button_Enabled':
		element.className = 'Button_Highlight';
		cobjPreviousHighlightItem = element;
		
		break;
	case 'ListHeader':
		element.className = 'ListHeader_Highlight';
		cobjPreviousHighlightItem = element;
		
		break;
	}
}

function LoseHighlight() {
	if (cobjPreviousHighlightItem != null) {
		switch (cobjPreviousHighlightItem.className) {
		case 'ListItem_Highlight':
			cobjPreviousHighlightItem.className = 'ListItem';
			
			break;
		case 'Button_Highlight':
			cobjPreviousHighlightItem.className = 'Button_Enabled';
			
			break;
		case 'ListHeader_Highlight':
			cobjPreviousHighlightItem.className = 'ListHeader';
			
			break;
		}
	}
}

function EnabledListButtons() {
	if (window.document.getElementById("btnTopView") != null) {
		window.document.getElementById("btnTopView").className = 'Button_Enabled';
	}
	
	if (window.document.getElementById("btnTopEdit") != null) {
		window.document.getElementById("btnTopEdit").className = 'Button_Enabled';
	}
	
	if (window.document.getElementById("btnTopDelete") != null) {
		window.document.getElementById("btnTopDelete").className = 'Button_Enabled';
	}
	
	if (window.document.getElementById("btnBottomView") != null) {
		window.document.getElementById("btnBottomView").className = 'Button_Enabled';
	}
	
	if (window.document.getElementById("btnBottomEdit") != null) {
		window.document.getElementById("btnBottomEdit").className = 'Button_Enabled';
	}
	
	if (window.document.getElementById("btnBottomDelete") != null) {
		window.document.getElementById("btnBottomDelete").className = 'Button_Enabled';
	}
}
//End: Section to handle element state change triggered by user.

//Start: Section to handle dynamic search form interface.
var flgCriteria2IsVisable = [];
var strCriteria2Value = [];

function SwitchCriteria2(searchNumber) {
	var strSearch_Number = "";
	
	if (searchNumber != null) {strSearch_Number = "_" + searchNumber;}
	
	with (window.document) {
		if (getElementById("Function" + strSearch_Number) != null) {
			var flgCriteria2IsVisable_TMP = false;
			var strCriteria2Value_TMP = new String;
			
			if (searchNumber == null) {
				if (flgCriteria2IsVisable.length == 0) {flgCriteria2IsVisable[0] = false;}
				if (strCriteria2Value.length == 0) {strCriteria2Value[0] = "";}
				
				flgCriteria2IsVisable_TMP = flgCriteria2IsVisable[0];
				strCriteria2Value_TMP = strCriteria2Value[0];
			} else {
				for (var numIndex = flgCriteria2IsVisable.length; flgCriteria2IsVisable.length <= searchNumber; numIndex++) {
					flgCriteria2IsVisable[numIndex] = false;
				}
				
				for (var numIndex = strCriteria2Value.length; strCriteria2Value.length <= searchNumber; numIndex++) {
					strCriteria2Value[numIndex] = "";
				}
				
				flgCriteria2IsVisable_TMP = flgCriteria2IsVisable[searchNumber];
				strCriteria2Value_TMP = strCriteria2Value[searchNumber];
			}
			
			if (getElementById("Function" + strSearch_Number).value == "IsBetween") {
				if (flgCriteria2IsVisable_TMP == false) {
					switch (searchNumber != null ? strFunctionDivState[searchNumber] : strFunctionDivState) {
					case "Timestamp":
						ShowCriteria2Div_Timestamp(searchNumber);
						break;
					case "Date":
						ShowCriteria2Div_Date(searchNumber);
						break;
					case "Time":
						ShowCriteria2Div_Time(searchNumber);
						break;
					default:
						ShowCriteria2Div(searchNumber);
						break;
					}
					
					if (searchNumber == null) {
						flgCriteria2IsVisable = true;
					} else {
						flgCriteria2IsVisable[strSearch_Number] = true;
					}
					
					if (strCriteria2Value_TMP) {
						if (getElementById("Criteria2" + strSearch_Number) != null) {
							getElementById("Criteria2" + strSearch_Number).value = strCriteria2Value_TMP;
						}
					}
				}
			} else {
				if (getElementById("Criteria2" + strSearch_Number) != null) {
					if (searchNumber == null) {
						strCriteria2Value[0] = getElementById("Criteria2" + strSearch_Number).value;
					} else {
						strCriteria2Value[strSearch_Number] = getElementById("Criteria2" + strSearch_Number).value;
					}
				}
				
				if (getElementById("Criteria2Div" + strSearch_Number) != null) {
					getElementById("Criteria2Div" + strSearch_Number).innerHTML = "";
				}
				
				if (searchNumber == null) {
					flgCriteria2IsVisable = false;
				} else {
					flgCriteria2IsVisable[strSearch_Number] = false;
				}
			}
		}
	}
}

function ShowFunctionDiv_String(searchNumber) {
	var strSearch_Number = new String;
	var strSearchNumber = new String;
	
	if (searchNumber != null) {
		strSearch_Number = "_" + searchNumber;
		strSearchNumber = "" + searchNumber;
	}
	
	if (window.document.getElementById("FunctionDiv" + strSearch_Number) != null) {
		window.document.getElementById("FunctionDiv" + strSearch_Number).innerHTML = "&nbsp;<select id='Function" + strSearch_Number + "' name='Function" + strSearch_Number + "' onfocus='javascript: SwitchFunction(" + strSearchNumber + ")'><option value='Is'>is</option><option value='IsNot'>is not</option><option value='IsStartingWith' selected>is starting with</option><option value='IsEndingWith'>is ending with</option><option value='IsContaining'>is containing</option></select>";
	}
}

function ShowFunctionDiv_nText(searchNumber) {
	var strSearch_Number = new String;
	var strSearchNumber = new String;
	
	if (searchNumber != null) {
		strSearch_Number = "_" + searchNumber;
		strSearchNumber = "" + searchNumber;
	}
	
	if (window.document.getElementById("FunctionDiv" + strSearch_Number) != null) {
		window.document.getElementById("FunctionDiv" + strSearch_Number).innerHTML = "&nbsp;<select id='Function" + strSearch_Number + "' name='Function" + strSearch_Number + "' onfocus='javascript: SwitchFunction(" + strSearchNumber + ")'><option value='IsStartingWith' selected>is starting with</option><option value='IsEndingWith'>is ending with</option><option value='IsContaining'>is containing</option></select>";
	}
}

function ShowFunctionDiv_Containing(searchNumber) {
	var strSearch_Number = new String;
	var strSearchNumber = new String;
	
	if (searchNumber != null) {
		strSearch_Number = "_" + searchNumber;
		strSearchNumber = "" + searchNumber;
	}
	
	if (window.document.getElementById("FunctionDiv" + strSearch_Number) != null) {
		window.document.getElementById("FunctionDiv" + strSearch_Number).innerHTML = "&nbsp;<select id='Function" + strSearch_Number + "' name='Function" + strSearch_Number + "' onfocus='javascript: SwitchFunction(" + strSearchNumber + ")'><option value='IsContaining'>is containing</option></select>";
	}
}

function ShowFunctionDiv_Integer(searchNumber) {
	var strSearch_Number = new String;
	var strSearchNumber = new String;
	
	if (searchNumber != null) {
		strSearch_Number = "_" + searchNumber;
		strSearchNumber = "" + searchNumber;
	}
	
	if (window.document.getElementById("FunctionDiv" + strSearch_Number) != null) {
		window.document.getElementById("FunctionDiv" + strSearch_Number).innerHTML = "&nbsp;<select id='Function" + strSearch_Number + "' name='Function" + strSearch_Number + "' onchange='javascript: SwitchCriteria2(" + strSearchNumber + ");' onfocus='javascript: SwitchFunction(" + strSearchNumber + ")'><option value='='>is =</option><option value='<>'>is not =</option><option value='<'>is <</option><option value='>'>is ></option><option value='<='>is <=</option><option value='>='>is >=</option><option value='IsBetween'>is between</option></select>";
	}
}

function ShowFunctionDiv_DateTime(searchNumber) {
	var strSearch_Number = new String;
	var strSearchNumber = new String;
	
	if (searchNumber != null) {
		strSearch_Number = "_" + searchNumber;
		strSearchNumber = "" + searchNumber;
	}
	
	if (window.document.getElementById("FunctionDiv" + strSearch_Number) != null) {
		window.document.getElementById("FunctionDiv" + strSearch_Number).innerHTML = "&nbsp;<select id='Function" + strSearch_Number + "' name='Function" + strSearch_Number + "' onchange='javascript: SwitchCriteria2(" + strSearchNumber + ");' onfocus='javascript: SwitchFunction(" + strSearchNumber + ")'><option value='Is'>is</option><option value='IsNot'>is not</option><option value='IsBefore'>is before</option><option value='IsAfter'>is after</option><option value='IsOrIsBefore'>is or is before</option><option value='IsOrIsAfter'>is or is after</option><option value='IsBetween'>is between</option></select>";
	}
}

function ShowFunctionDiv_Boolean(searchNumber) {
	var strSearch_Number = new String;
	var strSearchNumber = new String;
	
	if (searchNumber != null) {
		strSearch_Number = "_" + searchNumber;
		strSearchNumber = "" + searchNumber;
	}
	
	if (window.document.getElementById("FunctionDiv" + strSearch_Number) != null) {
		window.document.getElementById("FunctionDiv" + strSearch_Number).innerHTML = "&nbsp;<select id='Function" + strSearch_Number + "' name='Function" + strSearch_Number + "' onchange='javascript: SwitchCriteria2(" + strSearchNumber + ");' onfocus='javascript: SwitchFunction(" + strSearchNumber + ")'><option value='Is'>is</option><option value='IsNot'>is not</option></select>";
	}
}

function ShowCriteria1_Text(searchNumber) {
	var strSearch_Number = new String;
	var strSearchNumber = new String;
	
	if (searchNumber != null) {
		strSearch_Number = "_" + searchNumber;
		strSearchNumber = "" + searchNumber;
	}
	
	if (window.document.getElementById("Criteria1Div" + strSearch_Number) != null) {
		window.document.getElementById("Criteria1Div" + strSearch_Number).innerHTML = "&nbsp;<input type='text' id='Criteria1" + strSearch_Number + "' name='Criteria1" + strSearch_Number + "' value='' />";
	}
}

function ShowCriteria1_Select_Boolean(searchNumber) {
	var strSearch_Number = new String;
	var strSearchNumber = new String;
	
	if (searchNumber != null) {
		strSearch_Number = "_" + searchNumber;
		strSearchNumber = "" + searchNumber;
	}
	
	if (window.document.getElementById("Criteria1Div" + strSearch_Number) != null) {
		window.document.getElementById("Criteria1Div" + strSearch_Number).innerHTML = "&nbsp;<select id='Criteria1" + strSearch_Number + "' name='Criteria1" + strSearch_Number + "'><option value='Yes'>Yes</option><option value='No'>No</option></select>";
	}
}

function ShowCriteria2Div(searchNumber) {
	var strSearch_Number = new String;
	var strSearchNumber = new String;
	
	if (searchNumber != null) {
		strSearch_Number = "_" + searchNumber;
		strSearchNumber = "" + searchNumber;
	}
	
	if (window.document.getElementById("Criteria2Div" + strSearch_Number) != null) {
		window.document.getElementById("Criteria2Div" + strSearch_Number).innerHTML = "&nbsp;and&nbsp;<input type='text' id='Criteria2" + strSearch_Number + "' name='Criteria2" + strSearch_Number + "' value='' />";
	}
}

function GetOptionByIndex(valueSelectBox, valueIndex) {
	for (var numIndex = 0; numIndex < valueSelectBox.length; numIndex++) {
		if ((valueSelectBox.options[numIndex].index == valueIndex)) {
			return valueSelectBox.options[numIndex];
		}
	}
}

function GetOptionByValue(valueSelectBox, valueValue) {
	for (var numIndex = 0; numIndex < valueSelectBox.length; numIndex++) {
		if ((valueSelectBox.options[numIndex].value == valueValue)) {
			return valueSelectBox.options[numIndex];
		}
	}
}

function GetOptionByText(valueSelectBox, valueText) {
	for (var numIndex = 0; numIndex < valueSelectBox.length; numIndex++) {
		if ((valueSelectBox.options[numIndex].text == valueText)) {
			return valueSelectBox.options[numIndex];
		}
	}
}

function AddOptionToEnd(valueSelectBox, valueValue, valueText) {
	if (valueSelectBox) {
		valueSelectBox.options[valueSelectBox.options.length] = new Option(valueText, valueValue);
		valueSelectBox.selectedIndex = valueSelectBox.length - 1;
	}
}

function AddOptionInOrderOfText(valueSelectBox, valueValue, valueText) {
	if (valueSelectBox) {
		var arrReplacement = new Array();
		var flgOptionAdded = false;
		var numSelectedIndex = new Number;
		
		for (var numIndex = 0; numIndex < valueSelectBox.length; numIndex++) {
			if (flgOptionAdded) {
				arrReplacement[arrReplacement.length] = new Array(valueSelectBox.options[numIndex].value, valueSelectBox.options[numIndex].text);
			} else if (WhichStringComesFirst(valueSelectBox.options[numIndex].text, valueText) == 2) {
				arrReplacement[arrReplacement.length] = new Array(valueValue, valueText);
				numSelectedIndex = arrReplacement.length - 1;
				arrReplacement[arrReplacement.length] = new Array(valueSelectBox.options[numIndex].value, valueSelectBox.options[numIndex].text);
				flgOptionAdded = true;
			} else {
				arrReplacement[arrReplacement.length] = new Array(valueSelectBox.options[numIndex].value, valueSelectBox.options[numIndex].text);
			}
		}
		
		if (!flgOptionAdded) {
			arrReplacement[arrReplacement.length] = new Array(valueValue, valueText);
			numSelectedIndex = arrReplacement.length - 1;
		}
		
		valueSelectBox.options.length = 0;
		
		for (var numIndex = 0; numIndex < arrReplacement.length; numIndex++) {
			valueSelectBox.options[numIndex] = new Option(arrReplacement[numIndex][1], arrReplacement[numIndex][0]);
		}
		
		valueSelectBox.selectedIndex = numSelectedIndex;
	}
}

function DeleteOptionByValue(valueSelectBox, valueValue) {
	var arrReplacement = new Array();
	
	for (var numIndex = 0; numIndex < valueSelectBox.length; numIndex++) {
		if (valueSelectBox.options[numIndex].index != valueValue) {
			arrReplacement[arrReplacement.length] = new Array(valueSelectBox.options[numIndex].value, valueSelectBox.options[numIndex].text);
		}
	}
	
	valueSelectBox.options.length = 0;
	
	for (var numIndex = 0; numIndex < arrReplacement.length; numIndex++) {
		valueSelectBox.options[numIndex] = new Option(arrReplacement[numIndex][1], arrReplacement[numIndex][0]);
	}
}

function DeleteOptionByIndex(valueSelectBox, valueIndex) {
	var arrReplacement = new Array();
	
	for (var numIndex = 0; numIndex < valueSelectBox.length; numIndex++) {
		if (numIndex != valueIndex) {
			arrReplacement[arrReplacement.length] = new Array(valueSelectBox.options[numIndex].value, valueSelectBox.options[numIndex].text);
		}
	}
	
	valueSelectBox.options.length = 0;
	
	for (var numIndex = 0; numIndex < arrReplacement.length; numIndex++) {
		valueSelectBox.options[numIndex] = new Option(arrReplacement[numIndex][1], arrReplacement[numIndex][0]);
	}
}

function DeleteSelectedOption(valueSelectBox) {
	if (valueSelectBox.selectedIndex != -1) {
		var arrReplacement = new Array();
		var numNextSelectedIndex = new Number;
		
		if (valueSelectBox.length == 1) {
			numNextSelectedIndex = -1;
		} else if (valueSelectBox.selectedIndex == valueSelectBox.length - 1) {
			numNextSelectedIndex = valueSelectBox.selectedIndex - 1;
		} else {
			numNextSelectedIndex = valueSelectBox.selectedIndex;
		}
		
		for (var numIndex = 0; numIndex < valueSelectBox.length; numIndex++) {
			if (numIndex != valueSelectBox.selectedIndex) {
				arrReplacement[arrReplacement.length] = new Array(valueSelectBox.options[numIndex].value, valueSelectBox.options[numIndex].text);
			}
		}
		
		valueSelectBox.options.length = 0;
		
		for (var numIndex = 0; numIndex < arrReplacement.length; numIndex++) {
			valueSelectBox.options[numIndex] = new Option(arrReplacement[numIndex][1], arrReplacement[numIndex][0]);
		}
		
		valueSelectBox.selectedIndex = numNextSelectedIndex;
	}
}

function DeleteSelectedOptions(valueSelectBox) {
	if (valueSelectBox.selectedIndex != -1) {
		var arrReplacement = new Array();
		
		for (var numIndex = 0; numIndex < valueSelectBox.options.length; numIndex++) {
			if (!valueSelectBox.options[numIndex].selected) {
				arrReplacement[arrReplacement.length] = new Array(valueSelectBox.options[numIndex].value, valueSelectBox.options[numIndex].text);
			}
		}
		
		valueSelectBox.options.length = 0;
		
		for (var numIndex = 0; numIndex < arrReplacement.length; numIndex++) {
			valueSelectBox.options[numIndex] = new Option(arrReplacement[numIndex][1], arrReplacement[numIndex][0]);
		}
	}
}

/*
	ValidDate - true for valid date, false for invalid
*/
function IsValidDate(PossibleDate) {
	var PDate = new String(PossibleDate);
	
	var regex = /(^\d{1,2})\/(\d{1,2})\/(\d{4,4})|(^\d{1,2})\/(\d{1,2})\/(\d{2,2})/;
	
	if (regex.test(PDate)) {
		var month = new String(RegExp.$1);
		var day = new String(RegExp.$2);
		var year = new String(RegExp.$3);
		
		if (month.length == 0) {
			month = new String(RegExp.$4);
			day = new String(RegExp.$5);
			year = new String(RegExp.$6);
		}
		
		var today = new Date();
		var thisYear = new String(today.getFullYear());
		
		if (year.length == 2) {					
			if (year > 50) {
				year = String(Number(thisYear.substring(0, 2)) - 1) + year;
			} else {
				year = thisYear.substring(0, 2) + year;
			}
		}
		
		if (month < 1 || month > 12) {return false;}

		if (day < 1 || day > 31) {return false;}

		if ((month==4 || month == 6 || month == 9 || month == 11) && day > 30) {return false;}

		if (month == 2) {// check for february 29th 
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			
			if (day > 29 || (day == 29 && !isleap)) {
				return false;
			}
		}
		
		if ((Number(year) < Number(thisYear) - 250) || (Number(year) > Number(thisYear) + 250) ) {return false;}
			
		return true;
	}
	
	return false;
}

var objLastOptionsDisplayed = null;

function ToggleElementDisplay(ClickedElement, ElementName, Direction, XOffset, YOffset) {
	if (ClickedElement != null && window.document.getElementById(ElementName) != null) {
		if (objLastOptionsDisplayed != null) {
			objLastOptionsDisplayed.style.display = "none";
		}
		
		if (objLastOptionsDisplayed == window.document.getElementById(ElementName)) {
			objLastOptionsDisplayed = null;
		} else {
			objLastOptionsDisplayed = window.document.getElementById(ElementName);
			
			objLastOptionsDisplayed.style.display = "";
			objLastOptionsDisplayed.style.position = "absolute";
			
			switch (Direction.toLowerCase()) {
			case "up":
				objLastOptionsDisplayed.style.left = ((GetElementPosition(ClickedElement).x) + XOffset) + "px";
				objLastOptionsDisplayed.style.top = ((GetElementPosition(ClickedElement).y - objLastOptionsDisplayed.offsetHeight - 2) + YOffset) + "px";
			
				break;
			case "down":
				objLastOptionsDisplayed.style.left = ((GetElementPosition(ClickedElement).x) + XOffset) + "px";
				objLastOptionsDisplayed.style.top = ((GetElementPosition(ClickedElement).y + 22) + YOffset) + "px";
			
				break;
			case "center":
				objLastOptionsDisplayed.style.left = (GetBrowserCurrentCenter().x - Math.round(objLastOptionsDisplayed.offsetWidth / 2)) + "px";
				objLastOptionsDisplayed.style.top = (GetBrowserCurrentCenter().y - Math.round(objLastOptionsDisplayed.offsetHeight / 2)) + "px";
				
				break;
			}
		}
	}
}

function ElementHideState(element, hideElement) {
	if (element != null) {
		if (hideElement) {
			if (!element.className.match(/Hide/)) {
				element.className += " Hide";
			}
		} else {
			if (element.className.match(/Hide/)) {
				element.className = element.className.replace(/ ?Hide/, "");
			}
		}
	}
}

function TogglePopupDisplay(ClickedElement, ElementName, Direction, XOffset, YOffset, Width, Height) {
	if (ClickedElement != null && window.document.getElementById(ElementName) != null) {
		if (objLastOptionsDisplayed != null) {
			ElementHideState(objLastOptionsDisplayed, true);
		}
		
		if (objLastOptionsDisplayed == window.document.getElementById(ElementName)) {
			objLastOptionsDisplayed = null;
		} else {
			objLastOptionsDisplayed = window.document.getElementById(ElementName);
			
			ElementHideState(objLastOptionsDisplayed, false);
			
			if (Width != null) {
				objLastOptionsDisplayed.style.width = Width + "px";
			}
			
			if (Height != null) {
				objLastOptionsDisplayed.style.height = Height + "px";
			}
			
			if (window.document.getElementById("ScrollDiv") != null) {
				window.document.getElementById("ScrollDiv").style.width = (Width - 10) + "px";
				window.document.getElementById("ScrollDiv").style.height = (Height - 35) + "px";
			}
			
			switch (Direction.toLowerCase()) {
			case "up":
				objLastOptionsDisplayed.style.left = ((GetElementPosition(ClickedElement).x) + XOffset) + "px";
				objLastOptionsDisplayed.style.top = ((GetElementPosition(ClickedElement).y - objLastOptionsDisplayed.offsetHeight - 2) + YOffset) + "px";
			
				break;
			case "down":
				objLastOptionsDisplayed.style.left = ((GetElementPosition(ClickedElement).x) + XOffset) + "px";
				objLastOptionsDisplayed.style.top = ((GetElementPosition(ClickedElement).y + 22) + YOffset) + "px";
			
				break;
			case "center":
				objLastOptionsDisplayed.style.left = (GetBrowserCurrentCenter().x - Math.round(objLastOptionsDisplayed.offsetWidth / 2)) + "px";
				objLastOptionsDisplayed.style.top = (GetBrowserCurrentCenter().y - Math.round(objLastOptionsDisplayed.offsetHeight / 2)) + "px";
				
				break;
			}
		}
	}
}

function GetElementPosition(e) {
	if (e != null) {
		var objParent = e.offsetParent;
		var numLeft = e.offsetLeft;
		var numTop = e.offsetTop;
		
		while (objParent != null) {
			numLeft += objParent.offsetLeft;
			numTop += objParent.offsetTop;
			objParent = objParent.offsetParent;
		}
		
		return {x:numLeft, y:numTop};
	} else {
		return {x:0, y:0};
	}
}

function OpenLinkInNewWindow(url) {
	window.open(url);
	return false;
}

function SubmitDotNetForm() {
	if (window.document.getElementById("aspnetForm") != null) {
		window.document.getElementById("aspnetForm").submit();
	}
}

function GetBrowserWindowSize() {
	var numWidth = 0;
	var numHeight = 0;
	
	// all except Explorer
	if (self.innerHeight != null) {
		numWidth = self.innerWidth;
		numHeight = self.innerHeight;
	// Explorer 6 Strict Mode
	} else if (window.document.documentElement != null && window.document.documentElement.clientHeight != null) {
		numWidth = window.document.documentElement.clientWidth;
		numHeight = window.document.documentElement.clientHeight;
	// other Explorers
	} else if (window.document.body != null) {
		numWidth = window.document.body.clientWidth;
		numHeight = window.document.body.clientHeight;
	}
	
	return {width:numWidth, height:numHeight};
}

/*
function GetWebPageSize() {
	var numWidth = 0;
	var numHeight = 0;
	
	with (window.document.body) {
		// all but Explorer Mac
		if (scrollHeight > offsetHeight) {
			numWidth = scrollWidth;
			numHeight = scrollHeight;
		// Explorer Mac;
		// would also work in Explorer 6 Strict, Mozilla and Safari
		} else {
			numWidth = offsetWidth;
			numHeight = offsetHeight;
		}
	
	return {width:numWidth, height:numHeight}
}
*/

function GetBrowserWindowScrollingOffset() {
	var numX = 0;
	var numY = 0;
	
	// all except Explorer
	if (self.pageYOffset != null) {
		numX = self.pageXOffset;
		numY = self.pageYOffset;
	// Explorer 6 Strict
	} else if (document.documentElement != null && document.documentElement.scrollTop != null) {
		numX = document.documentElement.scrollLeft;
		numY = document.documentElement.scrollTop;
	// all other Explorers
	} else if (document.body) {
		numX = document.body.scrollLeft;
		numY = document.body.scrollTop;
	}
	
	return {x:numX, y:numY};
}

function GetBrowserCurrentCenter() {
	var numX = 0;
	var numY = 0;
	
	return {
		x:Math.round(GetBrowserWindowScrollingOffset().x + (GetBrowserWindowSize().width / 2)),
		y:Math.round(GetBrowserWindowScrollingOffset().y + (GetBrowserWindowSize().height / 2))
	};
}

// Initializes a new instance of the StringBuilder class
// and appends the given value if supplied
function StringBuilder(value) {this.strings = new Array(""); this.append(value);}
// Appends the given value to the end of this instance.
StringBuilder.prototype.append = function(value) {if (value != null) {this.strings.push(value);}};
// Clears the string buffer
StringBuilder.prototype.clear = function() {this.strings.length = 1;};
// Converts this instance to a String.
StringBuilder.prototype.toString = function(){return this.strings.join("");};