function ge() {
  var ea;
  for (var i = 0; i < arguments.length; i++) {
    var e = arguments[i];
    if (typeof e == 'string')
      e = document.getElementById(e);
    if (arguments.length == 1)
      return e;
    if (!ea)
      ea = new Array();
    ea.push(e);
  }
  return ea;
}

function checkAll(rNum, nNum){
 ge("cAll").checked = true; ge("cAll").value = 1;
 for(i=0;i<nNum;i++){ge('new'+i).checked = 1;}
 for(i=0;i<rNum;i++){ge('old'+i).checked = 1;}
}

function unCheckAll(rNum,nNum){
 ge("cAll").checked = false; ge("cAll").value = 0;
 for(i=0;i<rNum;i++){ge('old'+i).checked = 0;}
 for(i=0;i<nNum;i++){ge('new'+i).checked = 0;}
}

function check(rNum, nNum){
 ge("cAll").checked = false; ge("cAll").value = 0;
 for(i=0;i<nNum;i++){ge('new'+i).checked = 1;}
 for(i=0;i<rNum;i++){ge('old'+i).checked = 1;}
}

function NewMessInChatWindow(id, login)
{
	var urll = "http://wallnet.ru/0/mess/do.chat/";
	
	var wnd = window.open("","chat",
	"top=150, left=200, height=500, width=520, menubar=no, location=no,resizable=no,scrollbars=no, status=no");
	
	//wnd.onload = function() {wnd.AddContact (id);}
	
	try
	{
		if(!wnd.load){
			wnd.document.location.href = 'http://wallnet.ru/' + id + '/mess/do.chat/';
		}else{
			wnd.AddContact (id, login);
			window.blur();
			wnd.focus();
		}
	}catch(e)
	{
		wnd.close();
	}

	//window.open('http://wallnet.ru/'+id+'/mess/do.chat/', id+'chat', 'top=150, left=200, height=500, width=520, menubar=no, location=no,resizable=no,scrollbars=no, status=no');
}


function setCookie (name, value, expires, path, domain, secure) 
{
	document.cookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}

function getCookie(name) 
{
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function DELLMOD( id )	
{
	if ( !confirm('Вы точно хотите удалить этот МОД?') ){
		return;
	}
	var req = new JsHttpRequest();
	req.onreadystatechange = function() {
		document.getElementById('modcontent'+id).innerHTML = 'Удаление...';		
		if (req.readyState == 4) {
			document.getElementById('mod'+id).style.height = '0px';
			document.getElementById('mod'+id).style.display = 'none';
		}
	}
	req.open(null, 'http://wallnet.ru/ajax/mods.php', true);
	req.send( { task: 'dell', id: id } );
}
