
function getItemID(ID){
	
	if(document.getElementById){
		me = document.getElementById(ID);
	}

return me;
}

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|$)");
	var j = 0;
	for (i = 0; i < elsLen; i++) {
		if (pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function expandit(id){
	var theobj = getItemID(id);
	var menu_item_all = getElementsByClass("menu_item")

	if(theobj.style.display=="none"){
		// shrink all the other menu item first
		for(i=0; i<menu_item_all.length; i++){
			menu_item_all[i].style.display="none"
		}
	
		theobj.style.display="";
	}
	else{
		theobj.style.display="none";
	}
	
}

/************************************************************************* 
	The fastest trim function
*************************************************************************/

function BestTrim(str) {  
	var start = -1,  end = str.length;  
	while (str.charCodeAt(--end) < 33);  
	while (str.charCodeAt(++start) < 33);  
	return str.slice(start, end + 1);  
};  

/************************************************************************
	Check all the other checkboxes in the specified form (form_name), using
	the specified checkbox (ctrl_check) . 
*************************************************************************/

function CheckAll(form_name, ctrl_check){
    var objForm = document.forms[form_name];
    var objLen = objForm.length;
    for (var iCount = 0; iCount < objLen; iCount++){
        if (ctrl_check.checked == true){
            if (objForm.elements[iCount].type == "checkbox"){
                objForm.elements[iCount].checked = true;
            }
        }
        else
        {
            if (objForm.elements[iCount].type == "checkbox"){
                objForm.elements[iCount].checked = false;
            }
        }
    }
}

/************************************************************************
	Open New subwindow
	page=document url, w=width, h=height, sb=scrollbar
*************************************************************************/

function OpenSubWin( page, w, h, sb ){  
	var sw = screen.width, sh = screen.height;
	var ulx = ((sw-w)/2), uly = ((sh-h)/2);
	var sbt = (sb==1) ? 'yes' : 'no';

	var paramz = 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars='+sbt+',width='+w+',height='+h+'';
	var oSubWin = window.open( "", "SubWin", paramz );

	oSubWin.moveTo( ulx, uly );
	oSubWin.location.replace( page );
}

function OpenSubWin2( page ){  
	//var sw = screen.width, sh = screen.height;
	//var ulx = ((sw-w)/2), uly = ((sh-h)/2);
	//var sbt = (sb==1) ? 'yes' : 'no';

	var paramz = 'toolbar=no,location=no,directories=no,status=no,menubar=no, scrollbars=yes';
	var oSubWin = window.open( "", "SubWin", paramz );

	//oSubWin.moveTo( ulx, uly );
	oSubWin.location.replace( page );
}

