var SUBMITTING  = false;

function checkUncheckAll(theElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm[z].checked = theElement.checked;
	  }
     }
    }
function ShowHideDiv(divname, status)
{
	var obj = GetID(divname);
	obj = obj.style;
	obj.display = status;		
	return false;
}
function DoSubmit(frm, fncname, txt, notext, msgdivid)
{	
	txt = txt || 'Loading...';
	msgdivid = msgdivid || 'i_msgbox';
	notext = notext || false;
	frmid = frm.id;
	
	if(!SUBMITTING)
	{	SUBMITTING = true;
		ShowLoading(msgdivid,txt,notext);
		fncname = 'xajax_' + fncname + '(xajax.getFormValues(frm), frmid)';
		eval(fncname);
	}
	else
	{	
		alert('Your request is being processed.');
	}
	return false;		
}
function ShowLoading(id,txt,notxt)
{
	 id = id || "i_msgbox"; 
	 txt = txt || "&nbsp;&nbsp;Loading...";
	 notxt = notxt || false;
	 var obj = GetID(id);
	 
	 if(obj)
	 {	
	 	if(!notxt)
		{
			obj.innerHTML = '<center><br/><br/><img src="/images/loading.gif" title="Please try again if this takes too long" alt="Communicating with server..."/><br/><font size="1" color="gray">'+txt+'</font></center>';
			
		}
		else
		{
			obj.innerHTML = '<center><img src="/images/loading.gif" title="Please try again if this takes too long" alt="Communicating with server..."/></center>';
		}
		
	 }

}
function GetID(var1)
{
	return document.getElementById(var1);
}
function CallServerFunction(func, msgdivid, txt, confirmation)
{
	confirmation = confirmation || "";
	txt = txt || 'Loading...';
	msgdivid = msgdivid || 'i_msgbox';
	if(confirmation!="")
	{
		if(!confirm(confirmation))
			return false;
	}
	
	ShowLoading(msgdivid, txt);
	func = 'xajax_'+func;
	eval(func);
}

function getValue(obj)
{
	return document.getElementById(obj).value;
}

function popup(url, height, width, scrollbars)
{
	var left = (screen.width-parseInt(width))/2;
	var top = (screen.height-parseInt(height))/2;
	var newwindow=window.open(url,'name','height='+height+',width='+width+',scrollbars='+scrollbars+',left='+left+',top='+top+',resizable=true');
	if (window.focus) {newwindow.focus()}
}
