var imnewmsg = 0;
function OpenIMChat(login,second){
	var urll = "/a-iminit/"+(login? ("ulogin-"+login+"/") : "");//+"<*SESSION>";
	var wnd = window.open("","imwindow",
	"width=1030,height=620,toolbar=no,location=no,menubar=no,resizable=yes");
	
	try{
		if(!wnd.imchat){
			wnd.document.location.href = urll;
		}else{
			wnd.imchat.fChtNewContact(login);
		}
	}catch(e){ wnd.close(); if(!second) OpenIMChat(login,true);}
}

function SetIMMsg(n){
	imnewmsg = n;
	var el1 = document.getElementById("immessage_n");
	var el2 = document.getElementById("immessage");
	if(el1) el1.innerHTML = n? n : '0';
	if(el2) el2.className = n? 'messagenew' : 'message';
}

function OpenIMMsg(ischat){
	if(imnewmsg){
		imnewmsg--;
		if(ischat) fw.chat.fChtNewContact();
		else OpenIMChat();
	}
}

var dynbaner = [];
dynbaner.add = function(id){
	this.push(id);
}
dynbaner.reload = function(){
	for(var n =0; n < this.length; n++){
		var el = document.getElementById(this[n]);
		if(el && el.firstChild){
			var cp = el.firstChild.cloneNode(true);
			el.removeChild(el.firstChild);
			el.appendChild(cp);
		}
    }
}