	var dom 	= document.getElementById ? 1 : 0;
	var ie		= document.all ? 1 : 0;
	var mac		= (navigator.userAgent.indexOf("Mac") > -1) ? 1 : 0;
	var ieReal	= (ie && (!mac) && ( typeof(window.offscreenBuffering) != 'undefined') ) ? 1 : 0;
	var opera	= (navigator.userAgent.indexOf("Opera") > -1) ? 1 : 0;
	var opera7	= (navigator.userAgent.indexOf("Opera/7") > -1) ? 1 : 0;
	var opera8	= (navigator.userAgent.indexOf("Opera/8") > -1) ? 1 : 0;
	var isActiveX = ieReal;
	var isSp2		= ieReal && (window.navigator.userAgent.indexOf("SV1") != -1);
	
	var ie7    = ieReal && ((navigator.userAgent.indexOf("MSIE 7.") > -1) ? 1 : 0);
	
	


	function activeXInstalled(szActiveXAlias) {
		if(!isActiveX) return -10;
		if( !(dom && ie) ) return -1;
		try {
	        var oInstance = new ActiveXObject(szActiveXAlias);
	        oInstance = null;
			return 1;
		} catch(e) {
			return 0;
		}
	}


	function getById(eleId) {
		if(dom) {
			return document.getElementById(eleId);
		}
		else if(ie) {
			return document.all[eleId];
		}
		else {
			return null;
		}
	}

	function getComputedStyleSafe(oElement, property) {
		result = false;
		if(ie) {
			result = oElement.currentStyle[property];
		}
		else if(document.documentElement && document.defaultView) {
			result = document.defaultView.getComputedStyle(oElement, null).getPropertyValue(property);
		}
		else {
			result = false;
		}

		return result;
	}

	function doContains(oElementA, oElementB) {
		if(ieReal) {
			return oElementA.contains(oElementB)
		}
		else if(dom){
			while(oElementB.parentNode) {
				if( (oElementB = oElementB.parentNode) == oElementA ) return true;
			}
			return false;
		}

	}

	function alterClass(oElement, szClasses) {
		result = false;
		do {
			if( !(dom || ie) || (opera && !(opera7 || opera8) ) ) break;
			if(oElement) oElement.className = szClasses;

			result = true;
		} while(0);
		return result;
	}

	function getCssClass(oElement) {
		var result = '';
		do {
			if( !(dom || ie) || (opera && !(opera7 || opera8) ) ) break;
			if(oElement) result = oElement.className;
		} while(0);

		return result;
	}

	function getAttrib(oElement, attrib) {
		return !dom ? oElement.getAttribute(attrib, false) : oElement.getAttribute(attrib);
	}

	function setAttrib(oElement, attrib, value) {
		return !dom ? oElement.setAttribute(attrib, value, false) : oElement.setAttribute(attrib, value);
	}



	function setValueById(elementId, val, force) {
		oElement = getById(elementId);
		setValue(oElement, val, force);
	}



	function setValue(oElement, val, force) {
		do {
			if(!oElement) break;

			if(oElement.value == '' || force) oElement.value = val;
		} while(0);
	}

	function goTo(url) {
		location.href=url;
	}

	function openWindow(theURL,winName,features) {
  		window.open(theURL,winName,features);
	}

// ------------------------------------------------------------------------------------------------
	var szOldRowClassname		= '';

	function rowOver(oElement, szClassname) {
		szOldRowClassname = getCssClass(oElement);
		alterClass(oElement, szClassname);
	}

	function rowOut(oElement) {
		alterClass(oElement, szOldRowClassname)
		szOldRowClassname = '';
	}



// ------------------------------------------------------------------------------------------------

	function changeImgSrcElement(elementId, szUrl) {
		changeImgSrcObject( getById(elementId) , szUrl);
	}

	function changeImgSrcObject(oElement, szUrl) {
		do {
			if(!oElement) break;
			if( oElement.tagName.toLowerCase() != 'img' ) break;

			if( typeof(oElement.src) == 'undefined' ) break;

			oElement.src = szUrl;

		} while(0);
	}
// ------------------------------------------------------------------------------------------------
	function scrollIntoViewByElement(elementId, bAlignToTop) {
		scrollIntoViewObject(getById(elementId, bAlignToTop))
	}

	function scrollIntoViewObject(oElement, bAlignToTop) {
		do {
			if(!oElement) break;
			if(!oElement.scrollIntoView) break;

			oElement.scrollIntoView(bAlignToTop);

		} while(0);
	}

// ------------------------------------------------------------------------------------------------
	function doExpandDetailById(idFldCnt, idInput, show, evlShow, evlHidden) {
		oFldCnt = getById(idFldCnt);
		oInput	= getById(idInput);
		doExpandDetail(oFldCnt, oInput, show, evlShow, evlHidden);
	}


	function doExpandDetail(oFldCnt, oInput, show, evlShow, evlHidden) {
		do {
			if(oFldCnt == null) break;
			bShow = true;

			switch(show) {
				case 0:
					bShow = false;
					if(evlHidden) eval(evlHidden);
				break;
				case 1:
					bShow = true;
					if(evlShow) eval(evlShow);
				break;
				default:
					if(oFldCnt.style.display == 'none') {
						bShow = true;
						if(evlShow) eval(evlShow);
					}
					else {
						if(evlHidden) eval(evlHidden);
						bShow = false;
					}
				break;
			} // switch

			oFldCnt.style.display	= getDisplayValueByObject(oFldCnt, bShow);

			if(oInput == null) break;

			if( typeof(oInput.tagName) == 'undefined' ) break;
			szTagName = oInput.tagName.toLowerCase();

			if(szTagName == 'input') {
				if( typeof(oInput.type) == 'undefined' ) break;
				szInputType = oInput.type.toLowerCase();
			}
			else {
				szInputType = szTagName;
			}

			switch(szInputType) {
				case 'button':
					oInput.value = bShow ? '-' : '+';
				break;
				case 'checkbox':
					oInput.checked = bShow;
				break;
				case 'radio':
					oInput.checked = bShow;
				break;
				case 'img':
					szAttribName = (bShow ? 'expanded' : 'collapsed');
					szUrl = getAttrib(oInput, szAttribName);
					if(szUrl) changeImgSrcObject(oInput, szUrl);
				break;
			}

		} while(0);
	}

	function getDisplayValueByObject(oElement, bShow) {
		result = bShow ? '' : 'none';
		do {
			if(!bShow) break;

			if( typeof(oElement.tagName) == 'undefined' ) break;

			szTagName = oElement.tagName.toLowerCase();
			if(ieReal) szTagName = 'div';

			switch(szTagName) {
				case 'table':
					result = 'table';
				break;
				case 'tr':
					result = 'table-row';
				break;
				case 'tbody':
					result = 'table-row-group';
				break;
				case 'thead':
					result = 'table-header-group';
				break;
				case 'tfoot':
					result = 'table-footer-group';
				break;
				case 'div':
					result = 'block';
				break;
				case 'ul':
				case 'ol':
				case 'li':
					result = 'list-item';
				break;


				default:
					result = 'inline';
				break;
			}

		} while(0);
		return result;
	}

// ------------------------------------------------------------------------------------------------

function expanderShow(elementId) {
	setValueById(elementId, 1, 1)
}

function expanderHide(elementId) {
	setValueById(elementId, 0, 1)
}


// ------------------------------------------------------------------------------------------------
	function doSelectById(elementId) {
		if(oElement = getById(elementId)) {
			oElement.focus();
			oElement.select();

		}
	}

	function doCopyById(elementId) {
		if(oElement = getById(elementId)) {
			oElement.focus();
			oElement.select();
			window.clipboardData.setData("Text",oElement.innerText);

		}
	}
// ------------------------------------------------------------------------------------------------

function showWnd(url, alias, width, height, resizable, status) {
	return window.open(url, alias, "width=" + width + ",height=" + height + ",resizable=" + resizable + ",toolbar=0,location=0,directories=0,status=" + status + ",menuBar=0,scrollbars=auto");
}


var hdlChart = null;


function showChart(url) {
	hdlChart = window.open(url, 'CHART', 'width=750,height=620,left=100,top=100,resizable=0,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollbars=0')
}

function closeChart() {
	if(hdlChart) hdlChart.close();
}
