	var OnePath = '../';
	var TabContext = '';
				
    if (!window.ActiveXObject) 
    {
        Element.prototype.selectNodes = function(sXPath)
        {
            var oEvaluator = new XPathEvaluator();
            var oResult = oEvaluator.evaluate(sXPath, this, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
            var aNodes = new Array();
            if (oResult != null) 
            {
                var oElement = oResult.iterateNext();
                while(oElement) 
                {
                    aNodes.push(oElement);
                    oElement = oResult.iterateNext();
                }
            }
            return aNodes;
        }
        Element.prototype.selectSingleNode = function(sXPath) 
        {
            var oEvaluator = new XPathEvaluator();
            // FIRST_ORDERED_NODE_TYPE returns the first match to the xpath.
            var oResult = oEvaluator.evaluate(sXPath, this, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
            if (oResult != null) 
            {
                return oResult.singleNodeValue;

            } 
            else 
            {
                return null;
            }
        }
        
 	    getInnerText = function(node)
	    {
	        var ret = '';
	        if(null != node.innerText)
	        {
	            ret = node.innerText;
	        }
	        else
	        {
	            ret = node.textContent;
	        }
	        if(null == ret)
	        {
	            if(null != node.text && node.text.length >0)
	            {
	               ret = node.text;
	            }
	        }
    	    
	        return ret;
	    }

	    setInnerText = function(node, value)
	    {
	        if(null != node.innerText)
	        {
	            node.innerText = value;
	        }
	        else
	        {
	            node.textContent = value;
	        }
    	    
	        return ret;
	    }
	   // Element.prototype.addProperty("innerText", getInnerText, setInnerText); 
    }
    	
	function chkdate(objName) 
	{
		//var strDatestyle = "US"; //United States date style
		var strDatestyle = "EU";  //European date style
		var strDate;
		var strDateArray;
		var strDay;
		var strMonth;
		var strYear;
		var intday;
		var intMonth;
		var intYear;
		var booFound = false;
		var datefield = objName;
		var strSeparatorArray = new Array("-"," ","/",".");
		var intElementNr;
		var err = 0;
		var strMonthArray = new Array(12);
		strMonthArray[0] = "Jan";
		strMonthArray[1] = "Feb";
		strMonthArray[2] = "Mar";
		strMonthArray[3] = "Apr";
		strMonthArray[4] = "May";
		strMonthArray[5] = "Jun";
		strMonthArray[6] = "Jul";
		strMonthArray[7] = "Aug";
		strMonthArray[8] = "Sep";
		strMonthArray[9] = "Oct";
		strMonthArray[10] = "Nov";
		strMonthArray[11] = "Dec";
		strDate = datefield.value;
		if (strDate.length < 1) 
		{
			return true;
		}
		if (strDate.length < 6) 
		{
			return false;
		}
		for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) 
		{
			if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) 
			{
				strDateArray = strDate.split(strSeparatorArray[intElementNr]);
				if (strDateArray.length != 3) 
				{
					err = 1;
					return false;
				}
				else 
				{
					strDay = strDateArray[0];
					strMonth = strDateArray[1];
					strYear = strDateArray[2];
				}
				booFound = true;
			}
		}
		if (booFound == false) 
		{
			if (strDate.length>5) 
			{
				strDay = strDate.substr(0, 2);
				strMonth = strDate.substr(2, 2);
				strYear = strDate.substr(4);
			}
		}
		if (strYear.length == 2) 
		{
			strYear = SetEpoch(strYear);
		}
		else if (strYear.length>4)
		{
			return false;
		}


		// US style
		if (strDatestyle == "US") 
		{
			strTemp = strDay;
			strDay = strMonth;
			strMonth = strTemp;
		}
		intday = parseInt(strDay, 10);
		if (isNaN(intday)) 
		{
			err = 2;
			return false;
		}
		intMonth = parseInt(strMonth, 10);
		if (isNaN(intMonth)) 
		{
			for (i = 0;i<12;i++) 
			{
				if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) 
				{
					intMonth = i+1;
					strMonth = strMonthArray[i];
					i = 12;
				}
			}
			if (isNaN(intMonth)) 
			{
				err = 3;
				return false;
			}
		}
		intYear = parseInt(strYear, 10);
		if (isNaN(intYear)) 
		{
			err = 4;
			return false;
		}
		if (intMonth>12 || intMonth<1) 
		{
			err = 5;
			return false;
		}
		if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) 
		{
			err = 6;
			return false;
		}
		if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) 
		{
			err = 7;
			return false;
		}
		if (intMonth == 2) 
		{
			if (intday < 1) 
			{
				err = 8;
				return false;
			}
			if (LeapYear(intYear) == true) 
			{
				if (intday > 29) 
				{
					err = 9;
					return false;
				}
			}
			else 
			{
				if (intday > 28) 
				{
					err = 10;
					return false;
				}
			}
		}
		if (strDatestyle == "US") 
		{
			datefield.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
		}
		else 
		{
			datefield.value = intday + " " + strMonthArray[intMonth-1] + " " + strYear;
		}
			return true;
	}
		
	function LeapYear(intYear) 
	{
		if (intYear % 100 == 0) 
		{
			if (intYear % 400 == 0) { return true; }
		}
		else 
		{
			if ((intYear % 4) == 0) { return true; }
		}
		return false;
	}

	function doDateCheck(from, to) 
	{
		var ErrorCode = '';
		var clientMsg = '';
		
		if (Date.parse(from.value) <= Date.parse(to.value)) 
		{
			if(IsManagedPage)
			{
				ErrorCode = 'IMJS_DatesAreValid';
				clientMsg = GetLocalizedMessage(ErrorCode);
				alert(clientMsg);
			}
			else
			{
				alert("The dates are valid.");
			}
		}
		else 
		{
			if (from.value == "" || to.value == "") 
				if(IsManagedPage)
				{
					ErrorCode = 'EMJS_BothDatesRequired';
					clientMsg = GetLocalizedMessage(ErrorCode);
					alert(clientMsg);
				}
				else
				{
					alert("Both dates must be entered.");
				}
			else 
			{
				if(IsManagedPage)
				{
					ErrorCode = 'EMJS_ToDateMustOccurAfterFromDate';
					clientMsg = GetLocalizedMessage(ErrorCode);
					alert(clientMsg);
				}
				else
				{
					alert("To date must occur after the from date.");
				}
			}
		}
	}

	function OffsetDateByMonths(dtDate, nMonths)
	{
		var m = dtDate.getMonth() + nMonths;
		var d = (nMonths <0)?-12:12;		
		var yFactor = Math.floor(m /d);
		var mFactor = (yFactor >0)?m - (d *yFactor):m;
	
		return new Date(dtDate.getFullYear() + yFactor, mFactor, dtDate.getDate());
	}

	function SetEpoch(strYear)
	{
		//using 1930 as epoch
		if(parseInt(strYear) >30)
			return '19' + strYear;
		else
			return '20' + strYear;
	}

	function CheckAsc()
	{
		if (event.keyCode<48||event.keyCode>57)
			return false;
	}
	
	
	function MakeNumeric(ctl)
	{
		if(!CheckValidNumeric(ctl.value))
		{
			ctl.value='';
		}
	}

	function GetNumeric(ctl)
	{
		if(null==ctl)return 0;
		var val=parseInt(ctl.value);
		return(isNaN(val))?0:val;	
	}
	
	function ConvertUpper(objTextBox)
	{
		var strVal;
		strVal=objTextBox.value;	
		objTextBox.value=strVal.toUpperCase();
		
	}

	
	String.prototype.trim = function() 
	{
		return this.replace(/^\s*(\b.*\b|)\s*$/, "$1");
	}
	String.prototype.asId = function()
	{
		return (isNaN(this))?'0':this;
	}

	
	// Seting/Getting combo data
	function SetComboValue(cb, strValue)
	{
		var bSet = false;
		if(null == cb)return;
		cb.selectedIndex =0;
		for(var i=0; i<cb.length; i++)
		{
			if(cb.options[i].value==strValue && bSet == false)
			{
				cb.selectedIndex =i;
				cb.options[i].selected = true;
				bSet = true;				
			}	
			else
			{
				cb.options[i].selected = false;
			}
		}
	}
	function SetComboText(cb, strText)
	{
		if(null == cb)return;
		strText = strText.toUpperCase();
		for(var i=0; i <cb.length; i++)
		{
			if(GetTextValue(cb.options[i]).toUpperCase()==strText)
			{
				cb.selectedIndex=i;
				break;
			}	
		}
	}
	
	function GetComboText(cb)
	{
		var sel = '';
		if(null != cb)
		{
			if(null != cb.selectedIndex)
			{
				var i = cb.selectedIndex;
				if(i > -1)
					sel = GetTextValue(cb.options[i]);
			}
		}
			
		return sel.trim();
	}

	function GetComboValue(cb)
	{
		var sel = 0;
		if(null != cb)
		{
			if(null != cb.selectedIndex)
			{
				var i = cb.selectedIndex;
				if(i > -1)
					sel = cb.options[i].value;
			}	
		}
		return sel;
	}
	
	function IsValueInCombo(cb, value)
	{
		var ret = false;
		if(null != cb)
			if(null != cb.options)
				for(var i=0; i<cb.options.length; i++)
					if(cb.options[i].value==value)
					{
						i=cb.options.length;
						ret=true;
					}
		return ret;
	}
	
	
	function IsTextInCombo(cb, value)
	{
		var ret = false;
		if(null != cb)
			if(null != cb.options)
				for(var i=0; i<cb.options.length; i++)
					if(GetTextValue(cb.options[i]).toUpper()==value.toUpper())
					{
						i=cb.options.length;
						ret=true;
					}
		return ret;
	}	

//Grid Support functions

	function SetLBSelected()
	{
		var lb = document.getElementsByTagName('SELECT');
		if(null != lb)
		{
			var id = document.all.LBSelection.value;
			if(id > '0')
				SetLBSelectedById(lb, id);
		}
	}

	function SetLBSelectedById(lb, id)
	{
		if(null != lb && null != id && id > '0')
		{
			for(var o in lb.options)
			{
				if(o.value == id)
				{
					o.setAttribute('selected', true);
					return true;
				}
			}
		} 
	}
	
	function GetLBSelectedID()
	{
		var id = '0';
		var lb = window.event.srcElement;
		while (srcElem.tagName != "SELECT") 
			srcElem = srcElem.parentElement;
		
		if(srcElem.tagName != "SELECT") return;
		if(srcElem.selectedIndex <= 0 ) return;
		{
			id = srcElem.value;
		}
		return id;
	}
	
	function GetLBSelectedItem()
	{
		var item = window.event.srcElement;
		if(null != item)
		{
			if(item.tagName == 'OPTION')
				return item;
			else if(item.tagName == 'SELECT')
				return item.options[item.selectedIndex];
		}
	}
	
	function ClearLBSelection()
	{
		var lb=document.getElementsByTagName('SELECT');
		if(null != lb && lb.length >0)
			lb[0].selectedIndex=-1;
	}
	
	function IsItemInLB(lb, item)
	{
		if(null != lb && null != item)
		{
			for(var i =0; i <lb.options.length; i ++)
			{
				if(lb.options[i].value == item)
					return true;
			}
		}
	}
 
	function GetSessionClientNo(level)
	{
		var iClientNo = 0;
		var bRet = false;
		var arr = new Array("10", "0", "0");
		var p = GetPathOffset(level);
		var elm = ServerRequest(arr, p + '../common/DocumentRequest.aspx', false);
		if(null!=elm)
			if(null!=elm.childNodes[0])iClientNo=elm.text;
		
		return iClientNo;
	}
	
		
	function CompareDates(strLoDate, strHiDate, strLoName,  strHiName)
	{
		var bReturn = true; //assumption valid 
		try
		{
			var d1 = new Date(strLoDate);
			var d2 = new Date(strHiDate);
		}
		catch(e){}
		if(null != d1 && null != d2 &&(d1 > d2))
		{
			bReturn= false;
			if(null != strLoName && null != strHiName && strLoName != '' && strHiName != '')
				alert(strLoName + ' cannot be greater than ' + strHiName);
		}
		
		return bReturn;
	}
	
	
	function CheckValidDate(ctl)
	{
		try
		{
			var ad = new Date(ctl.value);
			if(null == ad || 'NaN' == ad)
			{
				return false;
			}
		}
		catch(e)
		{
			return false;
		}
		return true;
	}
	
	function CheckValidNumeric(strNumbers) 
	{
		var Parsed = parseInt(strNumbers).toString();
		
		if (isNaN(Parsed)) 
			return false;
		
		if (Parsed.length != strNumbers.length)
		{
			return false;
		}
		return true;
	}
	
	function CheckValidInt32(strNumbers) 
	{
		if ((CheckValidNumeric(strNumbers)) && ( strNumbers <= 2147483647)) 
			return true;
		return false;
	}
	
	function FlipCheckBoxes(b1, b2, b3, b4, b5)
	{
		var b = window.event.srcElement;
		var bChecked = false;
		if(null != b && (b.tagName == 'INPUT' && b.getAttribute('type')=='checkbox'))
		{
			if(null != b1 && b != b1)b1.checked = bChecked;
			if(null != b2 && b != b2)b2.checked = bChecked;
			if(null != b3 && b != b3)b3.checked = bChecked;
			if(null != b4 && b != b4)b4.checked = bChecked;
			if(null != b5 && b != b5)b5.checked = bChecked;
		}
	}
	
	function GetCheckBoxList(ctl)
	{
		var strArr = '';
		if (ctl.currentStyle.layoutFlow == 'horizontal')
		{
			for(var i =0; i <ctl.cells.length; i ++)
			{
				var item = ctl.cells[i];
				if(null != item && IsCheckListItemChecked(item, 'horizontal'))
					strArr += ',' + GetCheckListBoxItemValue(item, 'horizontal');
			}
		}
		else
		{
			for(var i =0; i <ctl.rows.length; i++)
			{
				var item = ctl.rows[i];
				if(null != item && IsCheckListItemChecked(item))
					strArr += ',' + GetCheckListBoxItemValue(item);	
			}
		}
		return strArr.substring(1);
	}
		
	function GetLeft(o)
	{
		var l = 0;
		var p=o;
		for(;p!=null;p=p.offsetParent)
		{
			l+=p.offsetLeft;	
		}
		return l;	
	}
	function GetTop(o)
	{
		var t = o.offsetHeight;
		var p = o;
		for(;p!=null;p=p.offsetParent)
		{
			t+=p.offsetTop +1;	
		}
		return t;	
	}

	function LocalizeStyles(styleName) 
	{
		var lnk = document.getElementsByTagName("LINK")[0];
		if(null!=lnk)lnk.href = styleName;
	}	
		
	function LocalizeDatePicker(PickerName) 
	{
		CalName = PickerName;
	}	

	
	function ShowMsg()
	{
		//InitializePage();	
		var DlgMsg = document.getElementById('ctl00_DlgMsg');
		if(DlgMsg && DlgMsg.value != '')
		{
			var s = DlgMsg.value;
			if(s.substring(0, 6) == '*CODE*' && s.length > 10)
			{
				var re = /\*CODE\*/gi;
				var fcode = s.replace(re, '');
				while(fcode.indexOf('*CODE*')>-1)
					fcode = fcode.replace(re, '');
				var funcs = fcode.split('|');
				if(funcs.length)
				{
					for(var i =0; i <funcs.length; i++)
					{
						try 
						{
					        if(window.execScript)
						    {
						        window.execScript(funcs[i]);
						    }
						    else
						    {
						        eval(funcs[i]);
						    }
						}
						catch (ex) 
						{
						    alert(ex.message + ' ' + funcs[i]);
						}
					}
				}
			}	
			else
				alert(s);
				DlgMsg.value = '';				
		}		
	}
	
	function ConfirmDelete(item)
	{
		var thisItem = 'this item';
		if(null != item && item.length >0)thisItem=item;
		
		if(IsManagedPage)
		{
			return window.confirm(GetLocalizedMessage('IMJS_AreYouSureYouWantToDelete') + ' ' + thisItem + '?');
		}
		else
		{
			return window.confirm('Are you sure you want to Delete ' + thisItem + '?');
		}
	}

	function ConfirmCancel(item)
	{
		var ErrorCode = 'IMJS_AreYouSureYouWantToCancel';
		var clientMsg = '';
		var thisItem = 'this item';
		if(null != item && item.length >0)thisItem=item;
		if(IsManagedPage)
		{
			clientMsg =  GetLocalizedMessage(ErrorCode);
			return window.confirm(clientMsg + thisItem + '?');
		}
		else
		{
			return window.confirm('Are you sure you want to Cancel ' + thisItem + '?');
		}
	}

	function ConfirmSave(item)
	{
		var thisItem = 'this item';
		var ErrorCode = 'IMJS_AreYouSureYouWantToSave';
		var clientMsg = '';
		
		if(null != item && item.length >0)thisItem=item;
		
		if(IsManagedPage)
		{
			clientMsg =  GetLocalizedMessage(ErrorCode);
			return window.confirm(clientMsg + thisItem + '?');
		}
		else
		{
			return window.confirm('Are you sure you want to Save ' + thisItem + '?');
		}
	}


	function ConfirmInsert(item)
	{
		var thisItem = '';
		var ErrorCode = 'IMJS_AreYouSureYouWantToCreateANew';
		var clientMsg = '';
		
		if(null != item && item.length >0)thisItem=item;
		if(IsManagedPage)
		{
			clientMsg = GetLocalizedMessage(ErrorCode, thisItem);
			return window.confirm(clientMsg+ '?');
		}
		else
		{
			return window.confirm('Are you sure you want to create a new ' + thisItem + ' record?');
		}
	}

	function ConfirmQuit()
	{
		var ErrorCode = 'IMJS_ConfirmExit';
		var clientMsg = '';
		
		
		if(IsManagedPage)
		{
			clientMsg =  GetLocalizedMessage(ErrorCode);
			return window.confirm(clientMsg);
		}
		else
		{
			return window.confirm('Are you sure you want to Exit?');
		}
	}

	function ConfirmUpdate(item)
	{
		var thisItem = 'this item';
		if(null != item && item.length >0)thisItem=item;
		var ErrorCode = 'IMJS_AreYouSureYouWantToUpdate';
		var clientMsg = '';
		
		if(IsManagedPage)
		{
			clientMsg =  GetLocalizedMessage(ErrorCode);
			return window.confirm(clientMsg + thisItem + '?');
		}
		else
		{
			return window.confirm('Are you sure you want to Update ' + thisItem + '?');
		}
	}
	
	function NotAvailable()
	{
		var ErrorCode = 'IMJS_NotAvailableInThisRelease';
		var clientMsg = '';
		
		if(IsManagedPage)
		{
			clientMsg =  GetLocalizedMessage(ErrorCode);
			alert(clientMsg);
		}
		else
		{
			alert('Not available in this release.');
		}
		return false;
	}

    function IsManagedPage()
    {
    	
        if(null!=document.getElementById('hidManaged'))
        {
	        return true;
        }
        else
        {
	        return false;
        }

    }

    function IsSecuredControl(ctrl)
    {
        var bRet = false;
        if(null != ctrl)
        {
	        bRet = (null != ctrl.getAttribute('Secured'));
        }

        return bRet;
    }	

    function ShowCalendar(ctl)
	{
		window.top.iCal.ShowCalendar(ctl, true);
	}
	
	function ShowCalendar(ctl, l, t)
	{
		window.top.iCal.ShowCalendar(ctl, l, t);
	}	
	
	
	function GetCheckListSelectedItemText(src)
	{
		var strRet = null;
		if(null != src && src.tagName == 'TABLE')
		{
			for(var i =0; i <src.rows.length; i ++)
			{
				if(src.rows[i].cells[0].childNodes[0].checked)
				{
					strRet = src.rows[i].cells[0].childNodes[1].innerText;
					break;
				}
			}
		}
		return strRet;
	}
	
	function GetCheckListSelectedItemValue(src)
	{
		var strRet = null;
		if(null != src && src.tagName == 'TABLE')
		{
			for(var i =0; i <src.rows.length; i ++)
			{
				if(src.rows[i].cells[0].childNodes[0].checked)
				{
					//strRet = src.rows[i].cells[0].childNodes[0].id;
					//strRet = strRet.substring(strRet.indexOf(src.id) + src.id.length +1);
					strRet = GetCheckListItemValue(src.rows[i].cells[0].childNodes[0]);
					break;
				}
			}
		}
		return strRet;
	}

	function SetCheckListSelectedItemText(value, ctl)
	{
		if(null != ctl && ctl.tagName == 'TABLE')
		{
			for(var i =0; i <ctl.rows.length; i ++)
			{
				if(ctl.rows[i].cells[0].childNodes[1].innerText == value)
				{
					src.rows[i].cells[0].childNodes[0].checked = true;
					break;
				}
			}
		}
	}
	
	function SetCheckListSelectedItemValue(value, ctl, strHorizontal)
	{
		if(null == ctl)return;
		value = ctl.id + '_' + (parseInt(value) -1).toString();
		
		if(null != ctl && ctl.tagName == 'TABLE')
		{
			
			if( strHorizontal == null )
			{
				for(var i =0; i <ctl.rows.length; i ++)
				{
					if(ctl.rows[i].cells[0].childNodes[0].id == value)
					{
						ctl.rows[i].cells[0].childNodes[0].checked = true;
						break;
					}
				}
			}
			else
			{
				for(var i =0; i <ctl.cells.length; i ++)
				{
					if(ctl.cells[i].childNodes[0].childNodes[0].id == value)
					{
						ctl.cells[i].childNodes[0].childNodes[0].checked = true;
						break;
					}
				}
		
			}
		}
	}
	
	function IsCheckListItemChecked(item, strHorizontal)
	{
		var thing;
		if (strHorizontal != null)
			thing = item.childNodes[0];
		else
			thing = item.cells[0].childNodes[0];
		
		if(thing.tagName=='SPAN')
			return thing.childNodes[0].checked;
		else
			return thing.checked;
	}
	
	function GetCheckListBoxItemValue(item, strHorizontal)
	{	
		var thing;
		if (strHorizontal != null)
			thing = item.childNodes[0];
		else
			thing = item.cells[0].childNodes[0];
			
		var chkbx = null;
		if(null != thing)
		{
			if(thing.tagName=='SPAN' && thing.childNodes.length)
				chkbx = thing.childNodes[0];
			else
				chkbx = thing;				
		}		
		return GetCheckListItemValue(chkbx);
	}
	
	function GetCheckListItemValue(item)
	{	if(null == item)return '';
		var value = item.getAttribute('value');
		if(null != value)return value;
		var strRet = item.id;		
		while (item.tagName != 'TABLE') 
			item = item.parentElement;
						
		if(item.tagName == 'TABLE')
			strRet = strRet.replace(item.id + '_', '');
			
		try
		{
			strRet = (parseInt(strRet) +1);
		}
		catch(e)
		{
			strRet = '0';
		}
			
		return strRet;
	}
	
	function GetCheckListItemText(item)
	{
		return item.nextSibling.innerText;
	}
	
	function AddCheckListItem(list, item, value)
	{
		if(null != list && list.tagName == 'TABLE')
		{
			var id = list.id;
			var num = list.rows.length;
			var row = list.insertRow(-1);
			var cell = row.insertCell();
			cell.innerHTML = CheckListItem.replace(/ItemId/, id + '_' + num ).replace(/ItemName/, id + ':' + num).replace(/ItemValue/, item);
		}
	}
	
	function ClearCheckListChecks(list)
	{
		if(null != list && list.tagName == 'TABLE')
			if (list.currentStyle.layoutFlow == 'horizontal')
			{
				for(var i =0; i <list.cells.length; i ++)
					list.cells[i].childNodes[0].checked = false;
			}
			else
			{
				for(var i =0; i <list.rows.length; i ++)
					list.rows[i].cells[0].childNodes[0].checked = false;
			}
	}
	
	function ZoomText(tb, disabled, depth)
	{	   //disabled is the status of the parents updateBtn enabled - when disabled we dont want the user to be able to add new Zoom text // MQ	 7/5/04
	    var res = window.showModalDialog(GetPathOffset(depth) + '../common/TextZoom.htm' + rVal() + '?isDisabled=' + disabled,tb,'dialogheight:350px;dialogwidth:435px;dialogtop:200;dialogleft:100;resizable:no;help:no;status:no');
		//var res = window.showModalDialog(GetPathOffset(depth) + '../common/TextZoom.htm' + rVal() ,tb,'dialogheight:350px;dialogwidth:435px;dialogtop:200;dialogleft:100;resizable:yes;help:no;status:no');
		if(null!=res)tb.value=res;
	}
	function GetPathOffset(depth)
	{
		var p = '';
		if(null != depth)
		{
			var d = parseInt(depth);
			for(var i =0; i < depth; i ++)
				p += OnePath;
		}
		return p;
	}

//Utility stuff
	function rVal()
	{
		
		var d = new Date();		
		return '?rv=' + d.getTime();
		
	}

	function KillCR()
	{
        if(null == event)return;
		if(event.keyCode == 13)
		{
			if(event.srcElement.tagName=='TEXTAREA')return;
			event.returnValue=false;
			event.cancel = true;
		}
	}

	function EnableControl(ctl, bEnable)
	{
		if(null==ctl)return;
		if(ctl.type == 'checkbox')
		{
			EnableCheckBox(ctl, bEnable);
			return;
		}
		if(ctl.type == 'button' || ctl.type == 'submit')
		{
			EnableButton(ctl, bEnable)
			return;
		}
		if('TEXTAREA;INPUT;SELECT'.indexOf(ctl.tagName)!=-1)ctl.runtimeStyle.backgroundColor = (bEnable)?'White':'LemonChiffon';
		if(null!=ctl.getAttribute('Secured'))bEnable=false;
		ctl.disabled = !bEnable;
	}
	
	function EnableCheckBox(checkbox, bEnable)
	{
		// fiona - only disables/enables the actual checkbox. Not the text associated with it. 
		// if you want the text disabled as well, use EnableControl
		if(null==checkbox)return;
		// Depends whether text is to the right or left of the checkbox whether
		// we need to disable childNode[0] or [1]
		if(null!=checkbox.getAttribute('Secured'))bEnable=false;
		if (checkbox.parentElement.childNodes[1].tagName == 'INPUT')
			checkbox.parentElement.childNodes[1].disabled = !bEnable;
		else
			checkbox.parentElement.childNodes[0].disabled = !bEnable;
	}

	function EnableButton(button, bEnable)
	{
		if(null==button || 'submit.image'.indexOf(button.type)<0 || button.className.indexOf('btn')!=0)return;
		var s = 'Disabled';
		var b = (null != bEnable)?bEnable:true;
		if(null!=button.getAttribute('Secured'))b=false;
		var cls = button.className.replace(s,'');
		button.className = (b)?cls:cls +s;
		button.disabled = !b;
	}
	
	function GetGridFromServer(arrItems, strUrl, strGridId)
	{
		var ret = '<table></table>';
		var strHTML = ServerRequest(arrItems, strUrl, true);
		if(null != strHTML)
		{
			var html = ExtractNodeStringByTagName(strHTML, 'HTML') //Is valid html?
			var grid = ExtractNodeStringByTagName(html, 'TABLE')
			if(null != grid && grid != '')ret = grid;
		}
		return ret;
	}
	
	function ExtractNodeStringByTagName(strHTML, strTag)
	{	var ret = '';
		if(null !=strHTML && null !=strTag)
		{
			var tag = strTag.toUpperCase();
			var i = strHTML.toUpperCase().indexOf('</' + tag + '>');
			i=(i >0)?i +8:0;
			ret = strHTML.substring(strHTML.toUpperCase().indexOf('<' + tag), i);
		}
		return ret;
	}

	
	function SetStatusValue(val)
	{
		if (null != window.top){
			if (null != window.top.frames[0]){
				if (null != window.top.frames[0].document){
					var s = window.top.frames[0].document.all.statusValue;
					if(null !=s)s.value = val;
				}
			}
		}	
	}

	function GetStatusValue()
	{
		if (null != window.top){
			if (null != window.top.frames[0])
				if (null != window.top.frames[0].document)
				{
					var s = window.top.frames[0].document.all.statusValue;		
					return(null !=s)?s.value:'';
				}
		}
		return 'Done';
	}
  
		
	function ResetCheckBoxList(lstListBoxName, bSet)
	{
		var d=document.all;
		for(i=0;i<d.item(lstListBoxName).rows.length;i++)
		{			
			d.item(lstListBoxName + "_" + i).checked=bSet;
		}
	
	}
	
	function CheckIfListItemSelected(lstListBoxName)
	{
		var d=document.all;
		for(i=0;i<d.item(lstListBoxName).rows.length;i++)
		{			
			if (d.item(lstListBoxName + "_" + i).checked==true)
			{
				return true;
			}
		}
		return false;
	}
	
	function SetCheckBoxListItem(lstListBoxName,strValue,arrRefArray)
	{
		var d=document.all;
		for(i=0;i<arrRefArray.length;i++)
		{			
			if (arrRefArray[i]==strValue)
			{
				d.item(lstListBoxName + "_" + i).checked=true;
			}
		}
	}
	
	function ServerRequest(arrItems, strUrl, bReturnEntireResponse)
	{
		//*** Generic wrapper for calls to XMLHTTP 
		//*** arrItems: An array of strings to send to server. Will be converted to xml nodelist before sending - in the form "<Params><Param>item1</Param><Param>item2</Param></Params>"
		//*** strUrl: The aspx page to call.
		//*** bReturnEntireResponse: When true, returns the entire HTML response as a string.  
		//***						 When false, will attempt to return an xml element from the response.
		//*** If an error occurs, it can be returned in the xml element and raised here at the end.
		//*** bReturnRawResponse : If Xml is not required then just set this to true and function will return the raw response
		
		var bAll = (null !=bReturnEntireResponse)?bReturnEntireResponse:false;
		var ret = null;
		if(null != arrItems && arrItems.length)
		{
			var ohttp = new XMLHttpRequest();
			if(null == ohttp)ohttp = new ActiveXObject('Microsoft.XMLHTTP');
			var strParams = '';
			for(var i =0; i < arrItems.length; i++)
			{
				strParams += '<Param>data</Param>'.replace(/data/, arrItems[i]); 	
			}
			var strXml = '<Params>data</Params>'.replace(/data/, strParams);
			
			if(null == strUrl || strUrl.length==0)strUrl = RequestUrl;
			ohttp.open('POST', strUrl, false);
			ohttp.send(strXml);
			var response = ohttp.responseText;
			if(bAll)
			{
				ret = response.substring(response.toUpperCase().indexOf('<HTML'));
			}
			else 
			{
			    response = response.substring(0, response.indexOf('\r\n'));
			    try
			    {
			        var elm = GetResponseElement(response);
			    }
			    catch(e){}
			    if(null != elm && null != elm.childNodes[0])ret = elm;
			}
		}
		/*
		if(null != ret)
		{
			if(null !=elm)
			{
			    var elmError = null;
			    if (window.ActiveXObject)
			    {
				    elmError = elm.childNodes[0].selectSingleNode('ErrorResult');
				}
				else
				{
                    elmError = elm.childNodes[0].childNodes[0];				
                }
				if(null != elmError)
				{
					alert(GetTextValue(elmError));
					ret = null;
				}
			}
		}
		*/
		return ret;
	}
	
	function GetResponseElement(response)
    {
        var elmReturn = null;
        var xd = null;
        if (window.ActiveXObject)
        {
            xd = new ActiveXObject("Microsoft.XMLDOM");
            xd.async=false;
            xd.loadXML(response);
        }
        else 
        {
            var parser=new DOMParser();
            xd = parser.parseFromString(response,"text/xml");
        }
        if(null != xd)
        {
            elmReturn = xd.documentElement;
        }
        
        return elmReturn;
    }
    
	function ValidateControl(Cntrl,obj,ErrMsg)
	{
		if(document.all.item(Cntrl).checked)
		{
			if(obj.value=="")
			{
				alert(ErrMsg);
			}
		}
	}
	
	function GetEventSource(e)
	{
	    var node = null;
	    if(null != window.event)
	    {
	        node = window.event.srcElement;
	    }
	    else
	    {
	        if(null != e)
	        {
	            node = e.target;
                while(node.nodeType != node.ELEMENT_NODE)
                {
	                node = node.parentNode;
	            }
	        }
	    }

        return node;
	}
	
    function SetTabContext(context)
    {
        TabContext = context;
    }

    
    function GetLocalizedMessage(messageId, params)
	{
	    var ret = '';
		var arr = new Array(1, messageId);
		if(null != params && params.length > 0)
		{
		    for(var i = 0; i < params.length; i ++)
		    {
		        arr[i + 2] = params[i];
		    }
		}		
		var elm = ServerRequest(arr, RequestUrl, false);
		if(null!=elm)
		{
			ret = GetTextValue(elm);
		}
		
		return ret;
    }
    
    function ConvertBoolean(value)
    {
        var numVal = parseInt(value);
        if(!NaN == numVal)
        {
            return numVal != 0;
        }
        
        var res = false;
        var val = value.toLowerCase();
        switch(val)
        {
            case 'y':
            {
                res = true;
                break;
            }
            case 'yes':
            {
                res = true;
                break;
            }
            case 'on':
            {
                res = true;
                break;
            }
            case 'true':
            {
                res = true;
                break;
            }
            case 't':
            {
                res = true;
                break;
            }           
        }
        
        return res;
    }
    
    function GetTextValue(node)
    {
        var ret = null;
        if(null != node)
        {
            if(null != node.innerText)
            {
                ret = node.innerText;
            }
            else if(null != node.textContent)
            {
                ret = node.textContent;
            }
            if(null == ret)
            {
                if(null != node.text && node.text.length >0)
                {
                   ret = node.text;
                }
                else
                {
                    ret = node;
                }
            }
        }
	    
        return ret;
    }

    function SetTextValue(node, value)
    {
        var ret = false;
        if(null != node.innerText)
        {
            node.innerText = value;
            ret = true;
        }
        else
        {
            node.textContent = value;
            ret = true;
        }
        
        return ret;
    }
    
    function GetIntValue(value)
    {
        var ret = 0;
        if(null != value && value.length)
        {
            try
            {
               ret = parseInt(value);
            }
            catch(e){}
        }
        
        return (isNaN(ret))? 0 : ret;            
    }    

    function GetFloatValue(value)
    {
        var ret = 0.0;
        if(null != value && value.length)
        {
            try
            {
               ret = parseFloat(value);
            }
            catch (e){}
        }
        
        return (isNaN(ret))? 0 : ret;            
    }
    
    //Thanks to www.mattkruse.com
    function LZ(x) 
    {   
        return(x < 0 || x > 9 ?"" :"0") + x
    }

    function formatDate(date, format) 
    {
	    format=format+"";
	    var result="";
	    var i_format=0;
	    var c="";
	    var token="";
	    var y=date.getYear()+"";
	    var M=date.getMonth()+1;
	    var d=date.getDate();
	    var E=date.getDay();
	    var H=date.getHours();
	    var m=date.getMinutes();
	    var s=date.getSeconds();
	    var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	    // Convert real date parts into formatted versions
	    var value=new Object();
	    if (y.length < 4) {y=""+(y-0+1900);}
	    value["y"]=""+y;
	    value["yyyy"]=y;
	    value["yy"]=y.substring(2,4);
	    value["M"]=M;
	    value["MM"]=LZ(M);
	    //value["MMM"]=MONTH_NAMES[M-1];
	    //value["NNN"]=MONTH_NAMES[M+11];
	    value["d"]=d;
	    value["dd"]=LZ(d);
	    //value["E"]=DAY_NAMES[E+7];
	    //value["EE"]=DAY_NAMES[E];
	    value["H"]=H;
	    value["HH"]=LZ(H);
	    if (H==0){value["h"]=12;}
	    else if (H>12){value["h"]=H-12;}
	    else {value["h"]=H;}
	    value["hh"]=LZ(value["h"]);
	    if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	    value["k"]=H+1;
	    value["KK"]=LZ(value["K"]);
	    value["kk"]=LZ(value["k"]);
	    if (H > 11) { value["a"]="PM"; }
	    else { value["a"]="AM"; }
	    value["m"]=m;
	    value["mm"]=LZ(m);
	    value["s"]=s;
	    value["ss"]=LZ(s);
	    while (i_format < format.length) 
	    {
		    c=format.charAt(i_format);
		    token="";
		    while ((format.charAt(i_format)==c) && (i_format < format.length)) 
		    {
			    token += format.charAt(i_format++);
			}
		    if (value[token] != null) 
		    {
		        result=result + value[token]; 
		    }
		    else 
		    { 
		        result=result + token; 
		    }
		}
	    return result;
    }

    function Relocate(destination)
    {
        if(null != destination)
        {
            window.location = destination;
            return false;
        }
    }
    
    function numericOnly(e)
    {
        var unicode = e.charCode ? e.charCode : e.keyCode;
        if( unicode != 8 && unicode != 9)
        { 
            if( unicode < 48 || unicode > 57 && unicode != 13)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
        else
        {
            return true;
        }
    }
    
    function ClearItems(items)
    {
        if(null != items)
        {
            for(var i = 0; i < items.length; i ++)
            {
                items[i].value = '';
            }
        }
    }
    function CheckDefaultControl(e)
    {
        var ret = true;
        if(e.keyCode==13)
        {
            var target = null;
            var ctl = document.getElementById('ctl00_SubmitControl');
            if(ctl && ctl.value.length > 0)
            {
                if(window.ActiveXObject)
                {
                    target = e.srcElement;
                }
                else
                {
                    if(e.target) target = e.target;
                }
            }
            if(null != target)
            {
                if(target.id != ctl.value)
                {
                    ret = false;
                    if (window.event) 
                    { 
                         window.event.cancelBubble = true; 
                         window.event.returnValue = false; 
                    } 
                    if (e && e.stopPropagation && e.preventDefault) 
                    { 
                         e.stopPropagation(); 
                         e.preventDefault(); 
                    }
                }
            }
        }
        
        return ret;
    }
