_nv	= navigator.appVersion.toLowerCase();

isDOM	= (document.getElementById) ? true : false;
isNS	= (document.layers) ? true : false;
isIE	= (document.all) ? true : false;
isIE4	= isIE && !isDOM;
isIE55	= ((_nv.indexOf("msie 6.0")!=-1||_nv.indexOf("msie 5.5")!=-1)) ? true : false;

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}

String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

String.prototype.isNumeric = function() {
	var RegExp = /^(-)?(\d*)(\.?)(\d*)$/;
	var result = this.match(RegExp);
	return result;
}

String.prototype.isAlpha = function() {
	var RegExp = /^[a-zA-Z]?(-)?(\.?)$/;
	var result = this.match(RegExp);
	return result;
}

String.prototype.isAlphaNumeric = function() {
	var RegExp = /\w/;
	var result = this.match(RegExp);
	return result;
}

function doCapitalize(str) {
	return str.toLowerCase().replace(/\b[a-z]/g, cnvrt);
	function cnvrt() {
	    return arguments[0].toUpperCase();
	}
}

function addEvent(obj, evType, fn) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, true);
		return true;
	}
	else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+ evType, fn);
		return r;
	}
	else {
		return false;
	}
}

function removeEvent(obj, evType, fn, useCapture) {
	if (obj.removeEventListener) {
		obj.removeEventListener(evType, fn, useCapture);
		return true;
	}
	else if (obj.detachEvent) {
		var r = obj.detachEvent("on"+ evType, fn);
		return r;
	}
	else {
		alert("Handler could not be removed");
	}
}

function getViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 
	return window.undefined; 
}

function getViewportWidth() {
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
	return window.undefined; 
}

function getStartXPosition_Array(img_name) {
	var objImg, imgW;
	objImg = document.images[img_name];
	
	return getXPosition(objImg);
}

function getStartYPosition_Array(img_name) {
	var objImg, imgH;
	objImg = document.images[img_name];
	
	return getYPosition(objImg);
}

function getXPosition(imgElem) {// Called by getStartXPosition_Array1.
	xPos = eval(imgElem).offsetLeft;
	tempEl = eval(imgElem).offsetParent;
	while (tempEl != null) {
		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}
	return xPos;
}

function getYPosition(imgElem) {// Called by getStartYPosition_Array1.
	yPos = eval(imgElem).offsetTop;
	tempEl = eval(imgElem).offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
	}
	return yPos;
}

function getX(elemID) {
	if (document.getElementById(elemID)) {
		xPos = document.getElementById(elemID).offsetLeft;
		tempEl = document.getElementById(elemID).offsetParent;
		
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		}
		return xPos;
	}
	else {
		return null;
	}
}

function getY(elemID) {
	if (document.getElementById(elemID)) {
		yPos = document.getElementById(elemID).offsetTop;
		tempEl = document.getElementById(elemID).offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		return yPos;
	}
	else {
		return null;
	}
}

function getW(elemID) {
	if (document.getElementById(elemID)) {
		return document.getElementById(elemID).offsetWidth;
	}
	else {
		return null;
	}
}

function getH(elemID) {
	if (document.getElementById(elemID)) {
		return document.getElementById(elemID).offsetHeight;
	}
	else {
		return null;
	}
}

function openwin(pageurl,winName,features) {
	window.open(pageurl,winName,features);
}

function Trim(s)  {
	// Remove leading spaces and carriage returns
	while (s.substring(0,1) == ' ')
	{
		s = s.substring(1,s.length);
	}

	// Remove trailing spaces and carriage returns
	while (s.substring(s.length-1,s.length) == ' ')
	{
  		s = s.substring(0,s.length-1);
	}

	return s;
}

function checkChar(oElement,filter,e) {
	if(oElement.onkeypress){
		if(document.all){
			var sKey=String.fromCharCode(event.keyCode);
			var re=new RegExp(filter);
				if(sKey!="\r" && sKey!="\b" && !re.test(sKey))
					event.returnValue=false;
				event.keyCode=sKey.charCodeAt(0);
		}else{
			document.captureEvents(Event.ONKEYPRESS);
				var sKey=String.fromCharCode(e.which);
				var re=new RegExp(filter);
				if(sKey!="\r" && sKey!="\b" && !re.test(sKey))return false;
		}
	}
}

function validate_email(email_address) {
	var emailStr=email_address.value;
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) 
	{
		return false;
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	if (user.match(userPat)==null)
	{
		return false;
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) 
	{
		for (var i=1;i<=4;i++)
		{
			if (IPArray[i]>255)
			{
			return false;
			}
		}
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null)
	{
		return false;
	}
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3)
	{
	   return false;
	}
	if (len<2)
	{
		return false;
	}
	
	return true;
}

function validate_username(uname) {
	var unameStr = uname.value;
	var unamePat = /^[a-zA-Z0-9_\-]+$/
	var testUsername = unameStr.match(unamePat)
	
	if (testUsername == null) {
		return false;
	}
	else {
		if (unameStr.length<6)
		{
			return false;
		}
		
		if (unameStr.length>12)
		{
			return false;
		}
	}

	return true;
}

function validate_password(pword) {
	var pwordStr=pword.value;
	var pwordPat=/^[a-zA-Z0-9_\-]+$/
	var testPassword=pwordStr.match(pwordPat)
	
	if (testPassword == null)
	{
		return false;
	}
	else
	{
		if (pwordStr.length<4)
		{
			return false;
		}
		
		if (pwordStr.length>10)
		{
			return false;
		}
	}

	return true;
}

function validate_numeric(strInput, Min, Max) {
	var numericStr	= strInput.value;
	var numericPat	= /^[0-9]+$/
	var testNumeric	= numericStr.match(numericPat)
	
	if (testNumeric == null) {
		return false;
	}
	else {
		if (Min > 0) {
			if (numericStr.length<Min) {
				return false;
			}
		}
		
		if (Max > 0) {
			if (numericStr.length>Max) {
				return false;
			}
		}
	}

	return true;
}

function validate_date(mydate) {
	var dateStr=mydate.value;
	var datePat=/^\d{1,2}[\/\-\.]\d{1,2}[\/\-\.]((\d{4})|(\d{2}))$/
	var testDate=dateStr.match(datePat)
	if (testDate == null)
	{
		return false;
	}
	else
	{
		if (dateStr.length<6)
		{
			return false;
		}
		
		if (dateStr.length>10)
		{
			return false;
		}
	}

	return true;
}

function GetXmlHttpObject(handler) { 
	var objXmlHttp = null;

	if (navigator.userAgent.indexOf("Opera") >= 0) {
		objXmlHttp = new XMLHttpRequest();
		objXmlHttp.onload = handler;
		objXmlHttp.onerror = handler;
		
		return objXmlHttp;
	}

	if (navigator.userAgent.indexOf("MSIE")>=0) {
		var strName = "Msxml2.XMLHTTP";
		if (navigator.appVersion.indexOf("MSIE 5.5") >= 0)
		{
			strName = "Microsoft.XMLHTTP";
		}
		
		try {
			objXmlHttp = new ActiveXObject(strName);
			objXmlHttp.onreadystatechange = handler;
			return objXmlHttp;
		}
		catch(e) {
			alert("Error. Scripting for ActiveX might be disabled")
			return;
		}
	}

	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp = new XMLHttpRequest();
		objXmlHttp.onload = handler;
		objXmlHttp.onerror = handler;
		
		return objXmlHttp;
	}
}

function exeAjax(url, fvars, fname) {
	xml = GetXmlHttpObject(fname);

	xml.open ("POST", url , false);
	xml.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
	xml.send (fvars);
}

function exeAjaxA(url, fvars, fname) {
	xml = GetXmlHttpObject(fname);

	xml.open ("POST", url , true);
	xml.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
	xml.send (fvars);
}

function prepareTextBoxes() {
	if ((navigator.appName.indexOf("Microsoft") >= 0) && tboxCSS == 1) {
		if (!document.getElementsByTagName)
			return;

		var oi=0;
		var thisObj;
		var objs = document.getElementsByTagName("input");

		for (oi=0;oi<objs.length;oi++) {
			thisObj = objs[oi];
			if (thisObj.getAttribute('type') == 'text') {
				thisObj.className = 'text ' + thisObj.className;
			}

			if (thisObj.getAttribute('type') == 'password') {
				thisObj.className = 'text ' + thisObj.className;
			}

			if (thisObj.getAttribute('type') == 'file') {
				thisObj.className = 'text ' + thisObj.className;
			}

			if (thisObj.getAttribute('type') == 'button') {
				thisObj.className = 'btn ' + thisObj.className;
			}

			if (thisObj.getAttribute('type') == 'submit') {
				thisObj.className = 'btn ' + thisObj.className;
			}
		}
	}
}

function resizePop(v) {
	var btmY = window.getStartYPosition_Array('btmIMG');
	
	var popW = (document.body.clientWidth);
	var popH = (document.body.clientHeight);
	
	var winW = (window.parent.document.body.clientWidth);
	var winH = (window.parent.document.body.clientHeight);
	
	if (btmY < winH) {
		var hdif = (btmY+2) - popH;
		//window.parent.document.getElementById('popupFrame').style.height = (parseInt(window.parent.document.getElementById("popupFrame").style.height, 10) + hdif) +"px";

		popH = (parseInt(window.parent.document.getElementById("popupFrame").style.height, 10) + hdif);
		window.parent.document.getElementById('popupFrame').style.height = popH +"px"
	}
	
	window.parent.centerPopWin(popW, popH);
}

var popWinTitleWidth = 0;
var popWinTitleHeight = 0;

function getPopTitleW() {
	if (window.parent && window.parent.document.getElementById('popupTBImageR')) {
		popWinTitleWidth = window.parent.document.getElementById('popupTBImageR').offsetParent.offsetLeft;
	}
	
	if (document.getElementById('btmIMG')) {
		popWinTitleHeight = document.getElementById('btmIMG').offsetParent.offsetTop;
	}
}

function reBuildPopTitle(rsDir) {
	var popSelect = '<select>';
	popSelect = popSelect +'<option>Please select an option</option>';
	
	var tblTabs = window.parent.document.getElementById('popTabs');
	if (document.getElementsByTagName) {
		for (i=0; i<tblTabs.rows.length; i++) {
			for (j=0; j<tblTabs.cells.length; j++) {	
				if (tblTabs.cells[j].id) {
					if (rsDir == 1) {
						tblTabs.rows[i].deleteCell(tblTabs.rows[i].cells[j].cellIndex);
					}
				}
				else {
					for (x=0; x<tblTabs.rows[i].cells[j].getElementsByTagName('a').length; x++) {
						if (tblTabs.rows[i].cells[j].getElementsByTagName('a')[x].href) {
							popSelect = popSelect +'<option>'+ tblTabs.rows[i].cells[j].getElementsByTagName('a')[x].innerHTML +'</option>';	
						}
					}
					
					if (rsDir == 1) {
						tblTabs.rows[i].cells[j].style.display = 'none';
					}
					else {
						tblTabs.rows[i].cells[j].style.display = '';
					}
				}
			}
		}
	}
	popSelect = popSelect +'</select>';
	
	if (rsDir == 1) {
		var objTR = tblTabs.rows(0);
		var objTD = objTR.insertCell(-1);
		objTD.id = 'detailsTab';
		objTD.className = 'popTab';
		objTD.innerHTML = "<h1><a>Details</a></h1>";
	
		window.parent.document.getElementById('popOptions').innerHTML = popSelect;
	}
}

function resizePopWin(doRS) {
	if (doRS == null) {
		doRS = true;
	}
	
	var doRSw = false;
	var doRSh = false;

	var btmY = window.getStartYPosition_Array('btmIMG');

	//var winW = (window.parent.document.body.clientWidth + window.parent.document.documentElement.clientWidth);
	//var winH = (window.parent.document.body.clientHeight + window.parent.document.documentElement.clientHeight);

	//var popW = (document.body.clientWidth + document.documentElement.clientWidth);
	//var popH = (document.body.clientHeight + document.documentElement.clientHeight);
	
	var winW = (window.parent.document.body.clientWidth);
	var winH = (window.parent.document.body.clientHeight);

	var popW = (document.body.clientWidth);
	var popH = (document.body.clientHeight);
	
	if (popW > (winW-200)) {
		popW = (winW - 200);
		doRSw = true;
	}
	else {
		doRSw = false;
	}

	if (popH > (winH-200)) {
		popH = winH - 200;
		doRSh = true;
	}
	else {
		doRSh = false;
		
		if (doRS) {
			if (btmY < popH) {
				popH = btmY + 2;
				doRSh = true;
			}
		}
	}
	
	if (popWinTitleWidth > popW) {
		window.setTimeout("reBuildPopTitle(1)", 20);
	}

	if (doRSw || doRSh) {
		window.parent.centerPopWin(popW, popH);
		
		var titleBarHeight = parseInt(window.parent.document.getElementById("popupTitleBar").offsetHeight, 10);

		gPopFrame = window.parent.document.getElementById("popupFrame");
		gPopupMask = window.parent.document.getElementById("popupMask");
		gPopupContainer = window.parent.document.getElementById("popupContainer");

		gPopupContainer.style.width = popW + "px";
		gPopupContainer.style.height = (popH+titleBarHeight) + "px";
		
		// need to set the width of the iframe to the title bar width because of the dropshadow
		// some oddness was occuring and causing the frame to poke outside the border in IE6
		gPopFrame.style.width = parseInt(window.parent.document.getElementById("popupTitleBar").offsetWidth, 10)-2 + "px";
		gPopFrame.style.height = (popH) + "px";
	}
}

var returnVar = "";

function onUT() {
	if (xml.readyState == 4 || xml.readyState == "complete") {
		returnVar = xml.responseText;
	}
}

function getUT(ut) {
	var url = "/_ssi/ajax/_getUT.asp";
	var fvars = "ut="+ ut;

	exeAjax(url, fvars, onUT);
	return returnVar;
}

function mnuMouseOver(e) {
	var self = this;
	var xyPosLMnu = self.style.backgroundPosition;

	if (xyPosLMnu == '0px 0px') {
		self.style.backgroundPosition = '-150px 0px';
	}
	else if (xyPosLMnu == '-450px 0px') {
		self.style.backgroundPosition = '-600px 0px';
	}
	else if (xyPosLMnu == '-900px 0px') {
		self.style.backgroundPosition = '-1050px 0px';
	}
}

function mnuMouseOut(e) {
	var self = this;
	var xyPosLMnu = self.style.backgroundPosition;
	
	if (xyPosLMnu == '-150px 0px') {
		self.style.backgroundPosition = '0px 0px';
	}
	else if (xyPosLMnu == '-600px 0px') {
		self.style.backgroundPosition = '-450px 0px';
	}
	else if (xyPosLMnu == '-1050px 0px') {
		self.style.backgroundPosition = '-900px 0px';
	}
}

function sLeftMenu(mnu) {
	mnuParent = document.getElementById('pMenu');
	if (mnu) {
		mnu = document.getElementById(mnu);
	}
	
	for (i=0; i<mnuParent.childNodes.length; i++) {
		var mnuSub = mnuParent.childNodes[i];
		
		if (mnuSub.nodeName && (' '+ mnuSub.nodeName.toLowerCase()).indexOf(' h') != -1 && mnuSub.childNodes) {
			var mnuChild = mnuSub.childNodes[0];
			while (mnuChild.nodeName && mnuChild.nodeName.toLowerCase() != 'a') {
				mnuChild = mnuChild.nextSibling;
			}
			if (mnuSub.nodeName.toLowerCase() == 'h1') {
				mnuChild.style.backgroundPosition = '0px 0px';
			}
			else if (mnuSub.nodeName.toLowerCase() == 'h2') {
				mnuChild.style.backgroundPosition = '-450px 0px';
			}
			else if (mnuSub.nodeName.toLowerCase() == 'h3') {
				mnuChild.style.backgroundPosition = '-900px 0px';
			}
			mnuChild.onmouseover = mnuMouseOver;
			mnuChild.onmouseout = mnuMouseOut;
		}
		
		if (mnuSub.className && (' '+ mnuSub.className +' ').indexOf(' mnuSubTab ') != -1) {
			mnuSub.style.display = 'none';
		}
	}
	
	if (mnu) {
		var mnuSub = mnu.parentNode.nextSibling;
		while (!mnuSub.className) {
			mnuSub = mnuSub.nextSibling;
		}

		if (mnuSub.previousSibling) {
			var mnuPrev = mnuSub.previousSibling;
			while (mnuPrev.nodeName && mnuPrev.nodeName.toLowerCase() != 'h1') {
				mnuPrev = mnuPrev.previousSibling;
			}

			if (mnuPrev.childNodes) {
				mnuPrev.childNodes[0].style.backgroundPosition = '-450px 0px';
				mnuPrev.childNodes[0].onmouseover = '';
				mnuPrev.childNodes[0].onmouseout = '';
			}
		}

		if (mnuSub.className && (' '+ mnuSub.className +' ').indexOf(' mnuSubTab ') != -1) {
			mnuSub.style.display = '';
		}

		if (mnuSub.nextSibling) {
			mnuNext = mnuSub.nextSibling;
			while (mnuNext.nodeName && mnuNext.nodeName.toLowerCase() != 'h1') {
				mnuNext = mnuNext.nextSibling;
			}

			if (mnuNext.childNodes) {				
				mnuNext.childNodes[0].style.backgroundPosition = '-900px 0px';
				mnuNext.childNodes[0].onmouseover = mnuMouseOver;
				mnuNext.childNodes[0].onmouseout = mnuMouseOut;
			}
		}
	}
}

function printFrame() {
	window.frames['pWindow'].focus();
	window.frames['pWindow'].print();
}