String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function boz_saveModuleOrder(menuId, pubId, position)
{
    showHorizontalAJAXLoader(true);

    var contentType = "application/x-www-form-urlencoded; charset=UTF-8";

    var processURL = "./AJAX/reorderModulePosition.jsp";

    var ajaxRequest = initialiseAJAXRequest();

    ajaxRequest.onreadystatechange = function()
    {
        // The XMLHttpRequest.readyState of "4" signifies the successful completion of the HTTP interaction.
        if (ajaxRequest.readyState == 4)
        {
            if (ajaxRequest.status == 200)
            {
                returnError = ajaxRequest.responseText;

                // return header takes up 11 characters. If greater, then error message was returned.
                if (returnError.length > 11)
                {
                    alert("bozCommon saveModuleOrder Error : " + returnError);
                }
                else
                {
                    window.document.location = "./index.jsp?m=" + menuId;
                }
            }
            else if (ajaxRequest.status == 204)
            {
                // Error;
            }
            showHorizontalAJAXLoader(false);
        }
    };

    ajaxRequest.open("POST", processURL, true);
    ajaxRequest.setRequestHeader("Content-Type", contentType);
    ajaxRequest.send("objid=" + pubId + "&omov=" + position);
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function boz_print() {
    window.print();
}

function login2() {
    var ajaxRequest = initialiseAJAXRequest();
    var UOMGID = document.getElementById("UOMGList").value;
    var processURL = uncacheurl("AJAX/login2FO.jsp"
        + "?UOMGID=" + UOMGID
        );
    ajaxRequest.onreadystatechange = function() {
        if (ajaxRequest.readyState == 4) {
            if (ajaxRequest.status == 200) {
                window.document.location = "./index.jsp";
            } else {
                alert("status= " + ajaxRequest.status + "\nresponseText= " + ajaxRequest.responseText);
            }
        }
    };
    ajaxRequest.open("GET", processURL, true);
    ajaxRequest.send(null);
}

/* BXMLForm_ChangeSelect() is called from the onchange or onKeyPress event of a select element
 * created by BXMLFormBuilder. 
 * param selectObj - the select object which fired the on change event. 
 */ 
 function BXMLForm_ChangeSelect(selectObj) { 
  // get the ID of select Obj 
  var sobjID = selectObj.id; 
  // get the index of the selected option 
  var idx = selectObj.selectedIndex; 
  // get the value of the selected option 
  var which = selectObj.options[idx].value;

  if (sobjID == "EvntSTyp") {
   filterBXMLForm_ActionTypes(which);
  }
}

function safeParameter(param) {
    var safeParam = param.replace(/%/g,"%25" );
    safeParam = safeParam.replace(/&/g,"%26" );
    safeParam = safeParam.replace(/ /g,"%20" );
    safeParam = safeParam.replace(/#/g,"%23" );
    safeParam = safeParam.replace(/\+/g,"%2B" );
    safeParam = safeParam.replace(/,/g,"%2C" );
    safeParam = safeParam.replace(/\//g,"%2F" );
    safeParam = safeParam.replace(/:/g,"%3A" );
    safeParam = safeParam.replace(/;/g,"%3B" );
    safeParam = safeParam.replace(/</g,"%3C" );
    safeParam = safeParam.replace(/=/g,"%3D" );
    safeParam = safeParam.replace(/>/g,"%3E" );
    safeParam = safeParam.replace(/\?/g,"%3F" );
    safeParam = safeParam.replace(/@/g,"%40" );
    safeParam = safeParam.replace(/\[/g,"%5B" );
    safeParam = safeParam.replace(/\\/g,"%5C" );
    safeParam = safeParam.replace(/\]/g,"%5D" );
    safeParam = safeParam.replace(/{/g,"%7B" );
    safeParam = safeParam.replace(/}/g,"%7D" );
    safeParam = safeParam.replace(/~/g,"%7E" );
    return safeParam;
}

function dhtmlLoadScript(url)
{
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e); 
}