// JavaScript Document
function PageResize()
{
	var MainTable;
	MainTable = document.getElementById("MainTable");
		
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	var newHeight;
	newHeight = myHeight;
	MainTable.style.height = newHeight + "px";
}


//////////////////////////////////////////////////////
//Search Highlight
//////////////////////////////////////////////////////
var noHighlight=false;
function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{
	if ((!highlightStartTag) || (!highlightEndTag)) {
		highlightStartTag = '<span class="searchHighlight">';
		highlightEndTag = '</span>';
	}
	var newText = "";
	var i = -1;
	var lcSearchTerm = searchTerm.toLowerCase();
	var lcBodyText = bodyText.toLowerCase();
	
	while (bodyText.length > 0) {
		i = lcBodyText.indexOf(lcSearchTerm, i+1);
		if (i < 0) {
			newText += bodyText;
			bodyText = '';
		} else {
			if (bodyText.lastIndexOf('>', i) >= bodyText.lastIndexOf('<', i)) {
				if (lcBodyText.lastIndexOf('/script>', i) >= lcBodyText.lastIndexOf('<script', i)) {
					newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
					bodyText = bodyText.substr(i + searchTerm.length);
					lcBodyText = bodyText.toLowerCase();
					i = -1;
				}
			}
		}
	}
	return newText;
}
function highlightSearchTerms(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
	if (window.searchHighlighted) return;
	if (!document.body || typeof(document.body.innerHTML) == 'undefined') return false;
	searchText = unescape(searchText).split('+').join(' ');
	if (treatAsPhrase) searchArray = [searchText];
  		else searchArray = searchText.split(' ');
	var bodyText = document.body.innerHTML;
	for (var i = 0; i < searchArray.length; i++) bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
	document.body.innerHTML = bodyText;
	searchHighlighted = 1;
	return true;
}

function searchHighlight() {
	if (location.pathname.indexOf('/Search/') != -1) {
		var _GET = parseString(location.href.substring(location.href.indexOf('?')+1));
		if (_GET['q']) highlightSearchTerms(_GET['q']);
		return;
	}
	if (document.referrer && !noHighlight) {
		var referer = document.referrer;
		referer = referer.substring(referer.indexOf('?')+1);
		var _GET = parseString(referer);
		if (_GET['q']) highlightSearchTerms(_GET['q']);
	}
}
//End Search Highlight