function btnOMD(controlId) {
	document.getElementById(controlId).style.marginTop = "1px";
	document.getElementById(controlId).style.marginBottom = "-1px";
}

function btnOMU(controlId) {
	document.getElementById(controlId).removeAttribute("style");
}

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

function hashLogin() {
	// Hide the form before hashing the username ans password.
	document.getElementById("formLogin").style.visibility = "hidden";
	// Get the values.
	var username = document.getElementById("username").value;
	var password = document.getElementById("password").value;
	var salt = document.getElementById("md5_salt").value;
	// Hash the username and double-hash the password using the salt.
	document.getElementById("username").value = hex_md5(username);
	document.getElementById("password").value = hex_md5(hex_md5(password)+salt);
	// Don't submit the `salt`: delete it's value.
	document.getElementById("md5_salt").value = "";
}

function hashProfile() {
	// Hide the form before hashing the username ans password.
	document.getElementById("username").style.visibility = "hidden";
	// Get the values.
	var username = document.getElementById("username").value;
	// Hash the username.
	document.getElementById("username").value = hex_md5(username);
}

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 = "01234567890123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	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 : "autosave,contextmenu,filemanager,inlinepopups,searchreplace,table",
		theme_advanced_buttons1 : "bold,italic,underline,separator,justifyleft,justifycenter,justifyright,separator,bullist,numlist,separator,forecolor,removeformat,separator,charmap,image,separator,styleselect,formatselect",
		theme_advanced_buttons2 : "undo,redo,separator,search,replace,separator,table,cell_props,separator,row_before,row_after,delete_row,separator,col_before,col_after,delete_col,separator,split_cells,merge_cells,separator,link,unlink,separator,code",
		theme_advanced_buttons3 : "",
		theme_advanced_blockformats : "h1,h2,h3,p",
		theme_advanced_toolbar_location : "bottom",
		theme_advanced_toolbar_align : "left",
		theme_advanced_path_location : "bottom",
		extended_valid_elements : "h1[class],h2[class],h3[class],h4[class],h5[class],h6[class],p[class],div[class],ul[class],ol[class],li[class],a[name|href|target|title|onclick],img[class|src|border|alt=|title|width|height|name],span[class|align|style]",
		verify_html : true,
		// Webflex: dynamic settings ---------------------------------------
		content_css : "shared/css/shared_style.css,css/"+style+"/style.css",
		language : locale
		// ----------------------------------------------------------------- 
	});
	mcFileManager.init({
		document_base_url : "/",
		relative_urls : true,
		remove_script_host : true
	});	
}
