function GetElementById(id) {
if (document.getElementById(id)) {
return document.getElementById(id);
} else if (document.all[id]) {
return document.all[id];
} else if (document.layers && document.layers[id]) {
return (document.layers[id]);
} else {
return false;
}
}
function toggle_visibility(id)  {
if (GetElementById(id).style.display == 'none')
GetElementById(id).style.display =  '';
else
GetElementById(id).style.display =  'none';
}
function showImgSelected(imgId, selectId, imgDir) {
imgDom     = GetElementById(imgId);
selectDom  = GetElementById(selectId);
imgDom.src = "http://runcms/"+ imgDir + "/" + selectDom.options[selectDom.selectedIndex].value;
}
function justReturn() {
return;
}
function openWithSelfMain(url,name,width,height) {
var options = "width=" + width + ",height=" + height + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no";
new_window = window.open(url, name, options);
window.self.name = "main";
new_window.moveTo(((screen.availWidth/2)-(width/2)),((screen.availHeight/2)-(height/2)))
new_window.focus();
}
function setElementColor(id, color) {
GetElementById(id).style.color = "#" + color;
}
function setElementFont(id, font) {
GetElementById(id).style.fontFamily = font;
}
function setElementSize(id, size) {
GetElementById(id).style.fontSize = size;
}
function changeDisplay(id) {
var elestyle = GetElementById(id).style;
if (elestyle.display == "") {
elestyle.display = "none";
} else {
elestyle.display = "block";
}
}
function toggleDisplay(id) {
var elestyle = GetElementById(id).style;
if (elestyle.display == "block" || elestyle.display == "") {
elestyle.display = 'none';
} else {
elestyle.display = "block";
}
}
function setVisible(id) {
GetElementById(id).style.visibility = "visible";
}
function setHidden(id) {
GetElementById(id).style.visibility = "hidden";
}
function makeBold(id) {
var eleStyle = GetElementById(id).style;
if (eleStyle.fontWeight != "bold") {
eleStyle.fontWeight = "bold";
} else {
eleStyle.fontWeight = "normal";
}
}
function makeItalic(id) {
var eleStyle = GetElementById(id).style;
if (eleStyle.fontStyle != "italic") {
eleStyle.fontStyle = "italic";
} else {
eleStyle.fontStyle = "normal";
}
}
function makeUnderline(id) {
var eleStyle = GetElementById(id).style;
if (eleStyle.textDecoration != "underline") {
eleStyle.textDecoration = "underline";
} else {
eleStyle.textDecoration = "none";
}
}
function appendSelectOption(selectMenuId, optionName, optionValue) {
var selectMenu = GetElementById(selectMenuId);
var newoption  = new Option(optionName, optionValue);
selectMenu.options[selectMenu.length] = newoption;
selectMenu.options[selectMenu.length].selected = true;
}
function disableElement(target) {
var targetDom = GetElementById(target);
if (targetDom.disabled != true) {
targetDom.disabled = true;
} else {
targetDom.disabled = false;
}
}
function CheckAll(formname, switchid) {
var ele = document.forms[formname].elements;
var switch_cbox = GetElementById(switchid);
for (var i=0; i<ele.length; i++) {
var e = ele[i];
if ( (e.name != switch_cbox.name) && (e.type == 'checkbox') ) {
e.checked = switch_cbox.checked;
}
}
}
function setRequired(arguments) {
var size = setRequired.arguments.length;
for (i=0; i<size; i++) {
var id    = setRequired.arguments[i];
var field = GetElementById(id);
if (field.value == "") {
alert("Заполните поля тема и сообщение." + setRequired.arguments[i]);
field.focus();
return false;
}
}
}

function getHTTPRequestObject()
{
	var xmlHttpRequest;
	if (typeof ActiveXObject != 'undefined')
	{
		xmlHttpRequest = new ActiveXObject('Microsoft.XMLHTTP');
	}
	else if (typeof XMLHttpRequest != 'undefined')
	{
		xmlHttpRequest = new XMLHttpRequest();
	}
	else
	{
		xmlHttpRequest = false;
	}
	return xmlHttpRequest;
}

var httpRequester = getHTTPRequestObject();

var READY_STATE_COMPLETE=4;

function makeAJAXCall(ajaxUrl, data, responseFunction)
{
	if (httpRequester)
	{
		httpRequester.open("POST", ajaxUrl, true);
		httpRequester.onreadystatechange = responseFunction;
		httpRequester.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		httpRequester.send(data);
	}
}