/**
  * Checks/unchecks all options of a <select> element
  *
  * @param   string   the form name
  * @param   string   the element name
  * @param   boolean  whether to check or to uncheck the element
  *
  * @return  boolean  always true
  */
function setSelectOptions(the_form, the_select, do_check)
{
    var selectObject = document.forms[the_form].elements[the_select];
    var selectCount  = selectObject.length;

    for (var i = 0; i < selectCount; i++) {
        selectObject.options[i].selected = do_check;
    } // end for

    return true;
} // end of the 'setSelectOptions()' function



/** Check/uncheck group of checkboxes
  *
  */
function check_all(form_name,field_name)
{
        form = document.forms[form_name];
        for ( var z=0; z<form.elements.length; z++ )
                if (form.elements[z].name==field_name && form.elements[z].offsetLeft) form.elements[z].checked=true;
}
function uncheck_all(form_name,field_name)
{
        form = document.forms[form_name];
        for ( var z=0; z<form.elements.length; z++ )
                if (form.elements[z].name==field_name) form.elements[z].checked=false;
}

/**
 * open popup
 */
function popup(href, w, h) {window.open(href, '', 'width='+w+',height='+h+',toolbar=yes,menubar=no,scrollbars=yes,resizable=yes'); return false;}




function DisableText(ids)
{
	element = ids;
	if (element.disabled==true) {
		
	element.disabled=false;
	}
	else{
	element.disabled=true;
	}
    
}

/* Function to disable Radio buttons on Bulk Edit page (../gaztracker/jnts/bulkedit.php) 
** explicitly made for Sambungan field only!
*/
function DisableRadio()
{	
	if (document.editfrm.sambungan[0].disabled == true)
	{
	document.editfrm.sambungan[0].disabled=false;
	document.editfrm.sambungan[1].disabled=false;
	}
	else 
	{
	document.editfrm.sambungan[0].disabled=true;
	document.editfrm.sambungan[1].disabled=true;
	}   

}

function NumCheck(ids)
{
	check_form = document.forms.branch_frm;
	element=ids;
	if ( !/^(\d+(\.)?([0-9])?([0-9])?)$/.test(element.value))
	{
		alert('Value for Total Amount is incorrect! \n\n Currency format : Amount or Amount.dd (Ringgit.Sen)');
			//document.getElementById('dep_org_name').focus();
			//check_form.element.focus();
			//check_form.dep_org_total.focus();
		return false;
		check_form.element.focus();
	}
			
		return true;
}
