function buttonOMD(controlId, align) {
	document.getElementById(controlId+"bn_r").className="bn_r"+align+" on_r";
	document.getElementById(controlId+"bn_l").className="bn_l"+align+" on_l";
}

function buttonOMU(controlId, align) {
	document.getElementById(controlId+"bn_r").className="bn_r"+align;
	document.getElementById(controlId+"bn_l").className="bn_l"+align;
}

function refreshBrowser() {
  window.location.reload(true); 
}

function hashPassword() {
	var password = document.getElementById("password").value;
	var password_fake = getPassword(password.length);
	document.getElementById("hash").value = hex_md5(password);
	document.getElementById("password").value = password_fake;
}

function hashProfile() {
	var password = document.loginProfile.password.value;
	var password_new = document.loginProfile.password_new.value;
	var password_verfiy = document.loginProfile.password_verify.value;
	var password_fake = getPassword(password_new.length);
	document.loginProfile.md5.value = hex_md5(password);
	document.loginProfile.password.value = getPassword(password.length);
	document.loginProfile.md5_new.value = hex_md5(password_new);
	document.loginProfile.password_new.value = password_fake;
	document.loginProfile.md5_verify.value = hex_md5(password_verfiy);
	document.loginProfile.password_verify.value = password_fake;
}

function limitText(limitField, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } 
}

function getRandomNum(lbound, ubound) {
	return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}

function getRandomChar() {
	var charSet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	return charSet.charAt(getRandomNum(0, charSet.length));
}

function getPassword(length) {
	var rc = "";
	if (length > 0) {
		for (var idx = 0; idx < length; ++idx) {
			rc = rc + getRandomChar();
		}
	}
	return rc;
}

function posY(aEvent) {
	posy = 0;
	if (aEvent.pageY) {
        posy = aEvent.pageY;
	}
	else if (aEvent.clientY) {
        posy = aEvent.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
	return posy;
}

function initializeTinyMCE(style, locale) {
	tinyMCE.init({
		entity_encoding : "named",
		entities : "",		
		theme : "advanced",
		plugins : "table,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,searchreplace,print,contextmenu,filemanager",
		theme_advanced_buttons2_add : "separator,forecolor,backcolor",
		theme_advanced_buttons2_add_before: "cut,copy,paste,separator,search,replace,separator",
		theme_advanced_buttons3_add_before : "tablecontrols,separator",
		theme_advanced_buttons3_add : "emotions,iespell,advhr,separator,print",
		theme_advanced_toolbar_location : "bottom",
		theme_advanced_toolbar_align : "left",
		theme_advanced_path_location : "bottom",
		plugin_insertdate_dateFormat : "%Y-%m-%d",
		plugin_insertdate_timeFormat : "%H:%M:%S",
		extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border|alt=|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
		verify_html : true,
		// Webflex: dynamic settings ---------------------------------------
		content_css : "css/"+style+"/style.css",
		language : locale
		// ----------------------------------------------------------------- 
	});
	mcFileManager.init({
		document_base_url : "/",
		relative_urls : true,
		remove_script_host : true
	});	
}