function add_msgs( msgs, max )
{
	var msgs_div = document.getElementById('msgs');

	for ( id = 0; id < msgs.length; id++ )
	{
		if ( eval( "window.parent." + msgs[ id ][2] + "_last_msg_id" ) >= msgs[ id ][0] )
			continue;

		var msg = window.parent.parse_url_macros( msgs[ id ][1] );

		if ( end_id - start_id > max )
		{
			to_del = document.getElementById( 'msg_'+start_id );
			start_id++;

			msgs_div.removeChild( to_del );			
		}
		else
		{
		//	alert ( end_id+' - '+start_id+' <= '+ max);
		}

		end_id++;

		// Method 1

	//	msgs_div.innerHTML += "<div id='msg_"+end_id+"'>"+msgs[id]+"</div>";
	
		// Method 2 - DOM
	
		to_write = document.createElement("div");

		to_write.id = 'msg_'+end_id;
		to_write.innerHTML = msg;

		msgs_div.appendChild( to_write );
	}

	scroll_bottom();
}

function set_info( txt, channel )
{
	var info_div = eval( "window.parent.document.getElementById( 'chat_" + channel + "_info' );" );
	
	info_div.innerHTML = txt;
}

function update_action( channel )
{
	eval("window.parent.document." +channel+ ".action = window.parent." +channel+ "_action + '&last_msg_id=' + window.parent." +channel+ "_last_msg_id;");

	if ( eval("window.parent." +channel+ "_list") )
	{
		eval("window.parent.document." +channel+ ".action += '&list=' + window.parent." +channel+ "_list;");
	}
}

function scroll_bottom()
{
	window.scroll(0, 0);
	window.scroll(0, 99999);
//	window.scroll(0, document.getElementById('scrollTo').offsetHeight);
}

function change_online_list( new_list, new_hash, channel )
{
	var list_div = eval("window.parent.document.getElementById('" + channel + "_online');");
	
	list_div.innerHTML = window.parent.parse_url_macros( new_list );

	eval("window.parent." +channel+ "_list = new_hash;");
}
