function popUpWin (url, win, width, height, options) {
	var leftPos = (screen.availWidth - width) / 2;
	var topPos = (screen.availHeight - height) / 2;
	options += 'width=' + width + ',height=' + height + ',left=' + leftPos + ',top=' + topPos;
	return window.open(url, win, options);
}

function OpenWnd(name, w, h, getHandle)
{
	var wnd = self.open(name, "new"+name.length,
		"width="+w+",height="+h+",status=1,toolbar=0,menubar=0,scrollbars=1,resizable=1");
		
	if (getHandle != null) return wnd;
}

function CheckFindFormValues(src, sContainer)
{	
	var frm = src.form;
	var doDisable = false;
	// check for need to disable some fields
	for(var i=0; i < frm.elements.length; ++i)
	{
		var el = frm.elements[i];
		var elType = new String(el.type);
		var elName = new String(el.id);
		if ((elType == "text" || elType.search("select") != -1) & elName.search(sContainer) == 0)
		{
			if (el.value != "")
			{
				doDisable = true;
				break;
			}				
		}
	}
	
	// disable all fields except with value
	for(var i=0; i < frm.elements.length; ++i)
	{
		var el = frm.elements[i];
		var elType = new String(el.type);
		if (elType == "text" || elType.search("select") != -1)
		{
			if(doDisable & el.value == "")
			{
				el.disabled = true;
				el.style.backgroundColor='lightgrey';
			}
			else
			{
				el.disabled = false;
				el.style.backgroundColor='white';
			}
			// this block needed for date boxes only
			// start
			if (elType == "text")
			{
				if (el.parentElement.parentElement.children[1]) // check if tr has second td
				{
					var childButton = el.parentElement.parentElement.children[1].children[0];
					var childTable = childButton.children[0];
					// check if second td has button with image
					if (childButton)
					{
						if (childButton.type == "button")
						{
							//var image = childTable.children[0].children[0].children[0].children[0];
							childButton.disabled = (doDisable & el.value == "");
						}
					}
				}
			}
			// end			
		}
	}	
}

function ResetButton_OnClick(sender)
{
	var frm = sender.form;
	for (var j = 0; j < frm.elements.length; j++)
	{
		var el = frm.elements[j];
		if (el.type == 'text' || el.type.search('select') != -1)
		{
			el.value = "";
		}
		else if (el.type == 'radio' & el.value == 1)
		{
			// Note: we set radio as default in group which has value=1
			el.checked = true;
		}
	}
	// this function is defined at HeaderBase control which is expected
	// on each page where ResetButton_OnClick can be invoked
	setFocusByDefault();
}
