function dump(obj) {
  var result = '';
  for (var i in obj)
    result+= i + ' = ' + obj[i] + '\r';
  alert(result);
}
function GEBI(id){
	return top.document.getElementById(id);
}
function showcat(){
	var mi = GEBI('menucat');
	//dump(mi.style);
	mi.style.borderColor = 'gray';
	mi.style.borderStyle = 'solid';
	mi.style.borderWidth = '1px';

	var p = mi.parentNode;
	//alert(p.offsetTop);

	var mi2 = GEBI('menucat2');
	mi2.style.display='';
	mi2.style.left = mi.offsetWidth-3;
	mi2.style.top = -100;
}
var it = new Array(0,0);
function tryclose(item){
	var mi = GEBI('menucat');
	var mi2 = GEBI('menucat2');
	it[item]=0;
	if(it[0]==0&&it[1]==0){
		mi.style.borderColor = 'white';
		mi2.style.display='none';
	}
}

function to_color_the_table( table_id, color1, color2){
	var table = GEBI(table_id);
	var objs = table.getElementsByTagName('tr');
	for (var i = 0; i < objs.length; i++) {
		if(i%2)
			objs[i].style.backgroundColor = color1;
		else
			objs[i].style.backgroundColor = color2;
	}
}

function getXmlHttp(){
	var xmlhttp;
	try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E)
		{
			xmlhttp = false;
		}
	}
	if(!xmlhttp && typeof XMLHttpRequest!='undefined')
	{
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}
var req = getXmlHttp();
req.onreadystatechange = function() {  
	if (req.readyState == 4) { 
		if(req.status == 200) {
			//alert(req.responseText);
			if(req.responseText.length>0)
				eval(req.responseText);
		}
	}
}

function LP(mod,vars){
	var p = new Date();
	var rnd = p.getTime();//Math.floor(Math.random()*100000);
	if(vars!='' && vars!='undefined'){
		mod=mod+'&'+vars;
	}
	req.open('GET', '/mod.php?mod='+mod+'&rnd='+rnd, true);
	req.send(null);
}

function sendChatLine(){
	LP("chat_add","line="+encodeURIComponent(GEBI("chatLine").value)+"&to="+encodeURIComponent(GEBI("privateNameBox").value));
	GEBI("chatLine").value = '';
	GEBI("chatLine").focus();
}
var chatLineNum = 0;
function refreshChatWindow(){
	LP("chat_load","chatLineNum="+chatLineNum);
}
function refreshUsersWindow(){
	LP("chat_users","");
}
var new_message_title_interval = 0;
function new_message_title(){
	var title = top.document.title;
	var nTitle = title.split('*NewMessage* ').join(' ');
	if(title==nTitle){
		top.document.title = '*NewMessage* '+title;
	}else{
		top.document.title = nTitle;
	}
}
