function loadBlock(command, action, blockID) {
	var selID = getSelectedIndexValue(obj);
	selectedText = getSelectedIndexText(obj);
	
	deleteRowsAfterPosition(pos);

	if(selID == "") return false;
	reqUrl = "/j/?cmd=getInfoChilds&id="+selID + "&line=" + pos;//commands_ajax.php
	
	request = new AjaxRequest(reqUrl, "GET", getChild_handler, true);
	request.send();
}

function getChild_handler(resp) 
{
	if(typeof resp.responseText == "undefined" || typeof resp.responseText == "null") return false;

	data = "";

	try {
		eval(resp.responseText);
	} catch(e) {
		alert(e);
	}
	//alert(showObj(data));
	txt = data['body'];
	title = data['title'];
	if(txt == false || txt.length<5)
	{
		checkInfFormAndSubmit();
	} else {
		var t_body = get_obj("information_table_body");
	
		tr = t_body.insertRow(t_body.rows.length);
		td = tr.insertCell(0);
		td.innerHTML = title;
		td = tr.insertCell(1);

		td.innerHTML = txt;
	}
	
	
	//var tr = document.createElement(
}
var containerID = "";
function loadURL(cmd, blockID) 
{
	if(blockID == "" || blockID == undefined) blockID = "mainContainer";
	containerID = blockID;
	document.body.onkeyup = null;
	if(!document.getElementById(blockID)) {
		var k = document.createElement("DIV");
		k.id = blockID;
		k.className = "window";
		document.body.appendChild(k);
	}

	reqUrl = cmd;
	request = new AjaxRequest(reqUrl, "GET", loadURL_handler, false);
	request.send();
}

function loadURL_handler(resp)
{
	if(resp.responseText == "0") {
		closeContainerWindow()
		alert("Error loading!");
		return;
	}
	get_obj(containerID).innerHTML = resp.responseText;

	//setDivPositionToCenter(containerID);

	if(document.getElementById("galleryImageBig")) {
		document.getElementById("galleryImageBig").onload = function(){
			setDivPositionToCenter(containerID);
		}
	}
	
	if(typeof NextCallFunction != "undefined" && NextCallFunction != null && NextCallFunction != "") {
		try {
			eval(NextCallFunction);
			NextCallFunction = null;
		} catch(e){}
	}

}

function nextImage(){
	try {
		id = get_obj("nextBtn").getAttribute("imageID");
		loadURL('/galshow/' + id);
	}catch(ex){}
}
function prevImage(){
	try {
		id = get_obj("prevBtn").getAttribute("imageID");
		loadURL('/galshow/' + id);	
	}catch(ex){}
}

function openContainerWindow(){
	openMainContainerShadow();
	get_obj(containerID).style.display = "block";
	get_obj(containerID).innerHTML = "Loading";
}

function closeContainerWindow(){
	openMainContainerShadow();
	document.getElementById("mainContainerShadow").style.display = "none";
	get_obj(containerID).style.display = "none";
	//get_obj(containerID).innerHTML = "";
}

function openMainContainerShadow(){
	var shad = get_obj("mainContainerShadow");
	shad.style.display = "block";
	document.getElementById("mainContainerShadow").style.position = "absolute";
	document.getElementById("mainContainerShadow").style.left = 0;
	document.getElementById("mainContainerShadow").style.top = 0;
	document.getElementById("mainContainerShadow").style.height = document.body.clientHeight + "px";
	document.getElementById("mainContainerShadow").style.width = document.body.clientWidth + "px";

}

function setDivPositionToCenter(divID) 
{
	kk = get_obj(divID);
	w = kk.clientWidth/2;
	h = kk.clientHeight/2;
	//kk.className = "window";
	st = 0;//f_scrollTop();
	//document.title = st;
	y1 = Math.abs(document.body.scrollHeight-(document.body.scrollHeight - document.body.clientHeight))/2;
	x1 = Math.abs(document.body.scrollWidth - (document.body.scrollWidth - document.body.clientWidth))/2;
	var b = document.body;
	
	x = x1 - w;
	y = (y1 - h)*0.1 + st;

	get_obj(divID).style.left = x + "px";
	get_obj(divID).style.top = y + "px";
}

function loadCity(obj){
	containerID = "id_city_list";
	get_obj(containerID).innerHTML = "Loading...";
	reqUrl = "/j/?cmd=load&action=cityList&c=" + obj.options[obj.selectedIndex].value;
	request = new AjaxRequest(reqUrl, "GET", optionLoad_handler, false);
	request.send();
}

function optionLoad_handler(resp)
{
	if(resp.responseText == "0" || resp.responseText == "") {
		Alert("Error loading! Please, try again.");
		return;
	}
	get_obj(containerID).innerHTML = resp.responseText;
}


function setReaded(msgid){
	mid = msgid;
	reqUrl = "/j/?cmd=message&action=read&id=" + msgid;
	request = new AjaxRequest(reqUrl, "GET", setRead_hendler, true);
	request.send();
}

function setRead_hendler(resp)
{
	if(resp.responseText == "0") {
		return false;
	}
	get_obj('msg_status_' + mid).style.display = "none";
	var c = get_obj("msgbox").innerHTML;
	c--;
	if(c<0) c=0;
	get_obj("msgbox").innerHTML = c;
	get_obj("newmsg2").innerHTML = c;
	open_layer("delLink_" + mid);
}

function deleteMessage(id){
	mid = id;
	reqUrl = "/j/?cmd=message&action=delete&id=" + id;
	request = new AjaxRequest(reqUrl, "GET", delMsg_hendler, true);
	request.send();
}

function delMsg_hendler(resp){
	if(resp.responseText == "0") {
		return false;
	}
	get_obj("msg_"+mid).innerHTML = "<p>Deleted</p>";
	var c = parseInt(get_obj("msgcount").innerHTML);
	var c1 = parseInt(get_obj("newmsg2").innerHTML);
	c--;
	if(c<0) c=0;
	get_obj("msgcount").innerHTML = c;
	if(c1 > c) {
		get_obj("newmsg2").innerHTML = c;
		get_obj("msgbox").innerHTML = c;
	}
}
