

//-------- * Global Function ------------//
function trim(str2trim,char2trim){
	return str2trim.replace(/^\s+|\s+$/g,"");
}
function ltrim(str2trim,char2trim){
	return str2trim.replace(/^\s+/,"");
}
function rtrim(str2trim,char2trim){
	return str2trim.replace(/\s+$/,"");
}

function wrap_string(the_str, max_chr) {	
	wrap_the_str = the_str.substring(0, max_chr);
	if(the_str.length > max_chr)
		wrap_the_str += "....";
	
	return wrap_the_str;
}

function left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function stringPad(nom, count_digit, str){
	while(String(nom).length < count_digit) 
		nom = str + nom;
	return nom;
}
//-------- * Global Function ------------//

function onMouseOverRow(that_row){
	that_row.style.backgroundColor = (that_row.style.backgroundColor == "" ? "#E7E7FA" : "");
}

function onMouseOver_MenuTop(that_row,submenu_x){
	if(that_row.className == "menuTop_inactive" || that_row.className == "menuTop_active")
		that_row.className = (that_row.className == "menuTop_active" ? "menuTop_inactive" : "menuTop_active");
}

function onMouseOver_SideMenu(that_row,submenu_x){
	if(that_row.className == "subsidemenu_inactive" || that_row.className == "subsidemenu_active")
		that_row.className = (that_row.className == "subsidemenu_active" ? "subsidemenu_inactive" : "subsidemenu_active");
		
	if(that_row.className == "sidemenu_inactive" || that_row.className == "sidemenu_active")
		that_row.className = (that_row.className == "sidemenu_active" ? "sidemenu_inactive" : "sidemenu_active");
		
	if(that_row.className == "sidemenuBar_inactive" || that_row.className == "sidemenuBar_active")
		that_row.className = (that_row.className == "sidemenuBar_active" ? "sidemenuBar_inactive" : "sidemenuBar_active");
	
	if(submenu_x != ""){ // submenu
		if(submenu_ID = document.getElementById(submenu_x))
			submenu_ID.style.display = (submenu_ID.style.display == "block" ? "none" : "block");
	}
}

function resize_iframe(frame_id){
	that_id = document.getElementById(frame_id);
	that_id.height = that_id.contentWindow.document.body.scrollHeight;
	that_id.style.display = "block";
}
