function onCheckAll(ctrlPrefix, state, suffix)
{
	var i;
	var objCtrl;
	
	if(suffix != "" && suffix != null && suffix != "undefined")
		fname = "listform"+suffix;
	else
		fname = "listform";

	for (i = 0; i < eval("document.forms."+fname).elements.length; i++)
	{
		objCtrl = eval("document.forms."+fname).elements[i];
		if (objCtrl.name.substring(0,ctrlPrefix.length) == ctrlPrefix && objCtrl.disabled == false)
			objCtrl.checked = state;
	}
}

function submitForm(cmd, fmname) 
{ 
	if( typeof document.forms[fmname] != "object" ) return;
	document.forms[fmname].idx.value = cmd;
	document.forms[fmname].submit();
}

function Start(page, title, param)
{
	var args = param.split(",");
	var ts = "top=";
	if(!param.match(ts))
	{
		var ht = 0;
		for(i = 0; i < args.length; i++)
		{
			arg = args[i].split("=");
			if(arg[0] == "height")
				ht = arg[1];
		}
		var t = 0;
		if(window.innerHeight)
			t = Math.round((window.innerHeight - ht) / 2);
		else
			t = Math.round((document.body.clientHeight - ht) / 2);
		
		param = param + ",top=" + t;
	}
	var ls = "left=";
	if(!param.match(ls))
	{
		var wd = 0;
		for(i = 0; i < args.length; i++)
		{
			arg = args[i].split("=");
			if(arg[0] == "width")
				wd = arg[1];
		}
		var l = 0;
		if(window.innerWidth)
			l = Math.round((window.innerWidth - wd) / 2);
		else
			l = Math.round((document.body.clientWidth - wd) / 2);
		param = param + ",left=" + l;
	}
	var r;
	r = this.open(page, title, param);
}

function bab_selectFirstInputField(filterclass)
	{
	if (!document.getElementsByTagName)
		{
		return;
		}
	function in_array(val,arr)
		{
		for (var i in arr )
			{
			if ( arr[i] == val)
				return true;
			}
		return false;
		}

	var filter = false;
	if (typeof filterclass != 'undefined')
		filter = filterclass.split(',');
		

	var el = document.getElementsByTagName('input');
	for (var i =0 ; i < el.length ; i++)
		{
		
		if ((el[i].type == 'text' || el[i].type == 'password') && el[i].value == '' )
			{
			if (filter && typeof el[i].className != 'undefined' && el[i].className != '')
				{
				if (!in_array(el[i].className,filter))
					{
					el[i].focus();
					el[i].select();
					return;
					}
				}
			else
				{
				el[i].focus();
				el[i].select();
				return;
				}
			}
		}
	}

var quick_popup_obj = null;
function quick_popup(url,divisor,menubar)
{
	if (!menubar)
		menubar = 'no';
	else
		menubar = 'yes';
	
	if (quick_popup_obj == null || quick_popup_obj.closed || quick_popup_obj == 0)
	{
		if (typeof divisor == 'undefined')
		{
			divisor_h = 3;
			divisor_v = 3;
		}
		
		if(isNaN(divisor))
		{
			dinx = divisor.indexOf("_");
			if(dinx == -1)
			{
				divisor_h = divisor;
				divisor_v = divisor;
			}
			else
			{
				divisor_h = divisor.substring(0,dinx);
				divisor_v = divisor.substr(dinx+1);
			}
		}
		else
		{
			divisor_h = divisor;
			divisor_v = divisor;
		}
		
		var wd = Math.round(screen.width/divisor_h);
		var hd = Math.round(screen.height/divisor_v);
		var w = screen.width-wd;
		var h = menubar == 'yes' ? Math.round((screen.height-hd)/1.5) : screen.height-hd;
		var l = Math.round(wd/2);
		var t = Math.round(hd/2);
		var name = 'quick_popup'+Math.floor(Math.random() * 99999999);
		
		if (quick_popup_obj == 0)
		{
			window.open(url,name,'status=yes,menubar='+menubar+',personalbar=no,width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=yes,resizable=yes');
			quick_popup_obj = null;
		}
		else
			quick_popup_obj = window.open(url,name,'status=yes,menubar='+menubar+',personalbar=no,width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=yes,resizable=yes');
	}
	else
	{
		quick_popup_obj.focus();
		quick_popup_obj.location.href = url;
	}
}


// Top Navigation 
var active_ddm = null;
var not_to_kill = null;
var timer;
function showDDM(ddm)
{
	elm = document.getElementById(ddm);
	if(active_ddm != null)
		active_ddm.style.visibility = "hidden";
	elm.style.visibility = "visible";
	elm.style.left = absLeft(elm.parentNode)+"px";
	//elm.style.top = absTop(elm.parentNode) + elm.parentNode.getAttribute("height") + "px";
	active_ddm = elm;
	not_to_kill = elm;
}
function killDDM(ddm, time)
{
	if(not_to_kill == document.getElementById(ddm))
		not_to_kill = null;
	timer = setTimeout("hideDDM('"+ddm+"')",time * 1000);
}
function hideDDM(ddm)
{
	elm = document.getElementById(ddm);
	if(elm != not_to_kill)
	{
		elm.style.visibility = "hidden";
		if(active_ddm == elm) active_ddm = null;
	}
}
function protectDDM(ddm)
{
	not_to_kill = elm;
	clearTimeout(timer);
}


function showDDM2(ddm)
{
	elm = document.getElementById(ddm);
	if(active_ddm != null)
		active_ddm.style.visibility = "hidden";
	elm.style.visibility = "visible";
	elm.style.top = absTop(elm.parentNode)+"px";
	elm.style.left = absLeft(elm.parentNode) + 5 + "px";
	//elm.style.top = absTop(elm.parentNode) + elm.parentNode.getAttribute("height") + "px";
	active_ddm = elm;
	not_to_kill = elm;
}


function absLeft(el)
{
	return (el.offsetParent) ? el.offsetLeft+absLeft(el.offsetParent) : el.offsetLeft;
}
function absTop(el) 
{
	return (el.offsetParent) ? el.offsetTop+absTop(el.offsetParent) : el.offsetTop;
}

