function displayNone(_id){
	var _element = document.getElementById(_id);
	if (_element) _element.style.display = 'none';
}
function highlightItem(item, newClassName){
	item.oldClassName = item.className;
	item.className = newClassName;
}
function normalizeItem(item){
	item.className = item.oldClassName;
}
function dropdownFlip(_name){
	if (document.readyState == 'complete'){
		_container = document.getElementById(_name + '_Container')
		_arrow = document.getElementById(_name + '_ArrowImg')
		
		if (_container.style.display == 'none'){
			_container.style.display = 'block';
			_arrow.src = dropdownArrowImgUp.src
		}
		else {
			_container.style.display = 'none';
			_arrow.src = dropdownArrowImgDown.src
		}
	}		
}
function chooseAllCheckboxes(_checked, _name){
	var _checkboxes = document.forms[0].elements[_name]
	if (_checkboxes){
		for (i = 0; i < _checkboxes.length; i++){
			if (!_checkboxes[i].disabled){_checkboxes[i].checked = _checked}
		}	
	}
}
function chekcboxesAreChecked(_name){
	var _checkboxes = document.forms[0].elements[_name]
	if (_checkboxes.length == undefined){
		return(_checkboxes.checked);
	}
	else{
		for (i = 0; i < _checkboxes.length; i++){
			if (_checkboxes[i].checked){
				return(true);
			}
		}
	}
	return(false);
}

function FunctionExists(_name){
	var _tmp = eval('typeof(' + _name + ')');
	if (_tmp!="undefined") return(true);
	else return(false);
}
function centerWindow(_width, _height, _src){
	var _theWindow
	if (_src!=undefined) {_theWindow = _src} 
	else {_theWindow = window}

	_theWindow.resizeTo(_width, _height);
	var x = Math.round((_theWindow.screen.availWidth - _width)/2)
	var y = Math.round((_theWindow.screen.availHeight - _height)/2)	
	_theWindow.moveTo(x,y)
}
function openMessage(_url){
	var _messageWindow
	if(window.parent._opener){		
		_messageWindow = window.parent._opener.open(_url, '_blank', 'toolbar=no,statusbar=no,locationbar=no')
	}
	else{
			_messageWindow = window.open(_url, '_blank', 'toolbar=no,statusbar=no,locationbar=no')
	}
	centerWindow(600, 700, _messageWindow)
	return(_messageWindow)
}
function openNewWindow(_url, _title, _modal, _width, _height, _arguments, _features){
	//alert(_modal);
	if (_modal){		
		var arguments, features; 
		if (_arguments != 'undefined' && _arguments != ''){
			arguments = _arguments;
		}
		else{
			arguments = 'dialogWidth:'+ _width + 'px; dialogHeight:' + _height + 'px;center:yes;resizable:no;status:no;help:no;edge:raised;';
		}
		if (_features != 'undefined' && _features != ''){
			features = _features;
		}
		else{
			features = 'dialogWidth:'+ _width + 'px; dialogHeight:' + _height + 'px;center:yes;resizable:no;status:no;help:no;edge:raised;';
		}	

		var returnValue = window.showModalDialog(BaseHref + 'modal_dialog.asp?p_strUrl=' + escape(_url) + '&p_strTitle=' + escape(_title), arguments, features);
	 // var returnValue = window.showModalDialog(_url, arguments, features);

		return(returnValue)
	}
	else{		
		//alert(_features);
		var _newWindow = window.open(_url, '_blank', _features)
		centerWindow(_width, _height, _newWindow)
		return(_newWindow)
	}
}
function markPageAsLoading(){
	var pageLoading = document.getElementById('PageIsLoading')
	var pageOpacity = document.getElementById('PageIsLoadingOpacity')
	var pageLoadingContent = document.getElementById('PageIsLoadingContent')
	//var page =  document.getElementById('Page')
	//alert(document.body.offsetHeight);
	
	var width = document.body.offsetWidth;
	var height = document.body.offsetHeight;

/*
width = document.body.offsetWidth - document.body.style.marginLeft - document.body.style.marginRight;
height = document.body.style.offsetHeight - document.body.style.paddingBottom - document.body.style.paddingTop;
*/

	pageOpacity.style.width =  width + 'px';
	pageOpacity.style.height =  height + 'px';
	pageLoading.style.width =  width + 'px';
	pageLoading.style.height =  height + 'px';
	pageLoadingContent.style.top = (height/2 - 100) + 'px';
//	pageOpacity.style.visibility = 'visible';
//	pageLoading.style.visibility = 'visible';
	hideSelectBoxes(true);
	pageOpacity.style.display = 'block';
	pageLoading.style.display = 'block';
}
function markPageAsLoaded(){	
	var pageLoading = document.getElementById('PageIsLoading')
	var pageOpacity = document.getElementById('PageIsLoadingOpacity')
//	pageOpacity.style.visibility = 'hidden';
//	pageLoading.style.visibility = 'hidden';			
	pageOpacity.style.display = 'none';
	pageLoading.style.display = 'none';
	hideSelectBoxes(false);
}
function hideSelectBoxes(_hide){
		var aSelectBoxes = document.body.getElementsByTagName("SELECT");
		for (i = 0; i < aSelectBoxes.length; i++){
			if (_hide) aSelectBoxes[i].style.visibility = 'hidden';
			else aSelectBoxes[i].style.visibility = 'visible';
		}
}
