var imgOpenNode;
var imgCloseNode;
/******************** TreeView ********************/
function SetImages(openNode, closeNode)	{
	imgOpenNode = openNode;
	imgCloseNode = closeNode;
}

function Expand(liObj)	{
	var current = liObj.parentNode;
	
	for( i = 0; i < current.childNodes.length; i ++ )	{
		if(current.childNodes[i].nodeName=='UL')	{
			if(current.childNodes[i].offsetHeight == 0)	{
				current.childNodes[i].style.display = 'block';
				liObj.src = imgOpenNode;
			}
			else	{
				current.childNodes[i].style.display = 'none';
				liObj.src = imgCloseNode;
			}
			return;
		}
	}
}


var DestWnd; 
var Params = document.location.search.substring(1).split('&');
/******************** TreeView: Toolbox ********************/
function ViewPage(url)	{
	if( url )
		DestWnd = window.open(url, 'DestWnd').focus(); 
	return false;
	/*var id = Params[1].split('=')[1]; var url = '
	if(this._mask.EndsWith("%"))
		sb.Append(this._mask.Replace("%", "'+id"));
	else
		sb.Append(this._mask.Replace("%", "'+id +'"));
	sb.Append("; DestWnd = window.open(url, 'DestWnd').focus(); return false;
	*/
}
			
function ActionObj(type){
	if (type) 
		var url = document.location.pathname + '?pId='+ Params[0].split('=')[1] + (Params[1] ? ('&oId=' + Params[1].split('=')[1]) : '&oId=-1') + '&action=' + type; 
	document.location.replace(url); 
	return false;
}

function SetGroup(obj)	{
	var id = obj.value; 
	var url = document.location.pathname + '?pId='+ Params[0].split('=')[1] +'&oId=' + id + '&action='+ (Params[2] ? Params[2].split('=')[1] : ""); 
	document.location.replace(url); 
}

/*
function SelectPage(obj, id)	{
	var url = document.location.pathname + '?pId='+ Params[0].split('=')[1] +'&oId=' + id;	
	document.location.replace(url);
}
*/



/******************** Validators ********************/
function ValidateIt(obj, btnId)	{
	var btnCtrl = document.getElementById(btnId);
	if( btnCtrl )
		btnCtrl.disabled = trim(obj.value).length == 0;
}

function ValidateIt_byCtrlId(objId, btnId)	{
	var obj = document.getElementById(objId);
	if( obj )
		ValidateIt(obj, btnId)
}

function ValidateIt_delay(objId, btnId) {
	window.setTimeout('ValidateIt_byCtrlId("'+ objId +'", "'+ btnId +'")', 25);
}



/******************** string functions ********************/
 function ltrim( source ){
	var index = 0;
	while( source.charAt(index) == " " ) index++;
	return source.substr(index);
 }

function rtrim( source ){
	if( source.length == 0 )
		return source;
	var index = source.length - 1;
	while( source.charAt(index) == " " ) index--;
	return source.substring(0, index + 1);
 }

 function trim( source ){
	return ltrim(rtrim(source));
 }



