/******************************
Members Online Today (By Mwr247)
Copyright MUST stay intact please!
http://bigboardsresources.com/
******************************/

///////////////////////////////////////////
//Character entity support by CorruptioN //
//www.thecorruption.net                  //
///////////////////////////////////////////

var strings_characterEntities = new Array('lt', 'gt');
var strings_plainTextCharacters = new Array('<', '>');

//Converts a string with character entities (ie. &lt;) to plain text
function characterEntities_decode(inputString)
{
	var temp = inputString;
	var currentEntity = "";
	var i = 0;
	
	for (i = 0; i < strings_characterEntities.length; i++)
	{
		currentEntity = new RegExp('&' + strings_characterEntities[i] + ';', "gi");
		temp = temp.replace(currentEntity, strings_plainTextCharacters[i]);
	}
	
	return temp;
}

var mou=window.location.href.split('index.php')[0];
if(!mou){mou=window.location.href;}
if(mou.charAt(mou.length-1)!='/'){mou+='/';}

var date=new Date();
var gmtMS=date.getTime()+(date.getTimezoneOffset()*60000)+timezone*3600000;
var gmtTime=new Date(gmtMS);
var month=gmtTime.getMonth();
var day=gmtTime.getDate()-1;

var td=document.getElementsByTagName('td');
for(i=0;i<td.length;i++){
if(td[i].innerHTML.match('Forthcoming Calendar Events')&&td[i].className=='pformstrip'){
td[i].innerHTML='Members Online Today';td[i].id='mo_load';}
if(td[i].innerHTML=='There are no forthcoming calendar events'){td[i].innerHTML='No users online today';td[i].id='mo_list';}}

var mo_name='';
var mo_url='';
var mo_load=document.getElementById('mo_load');
var a=document.getElementsByTagName('a');
for(i=0;i<a.length;i++){
if(a[i].parentNode.parentNode.parentNode.parentNode.parentNode.id=='userlinks'&&a[i].href.match('showuser=')){mo_name=a[i].innerHTML;mo_link='Redirecting to [url='+a[i].href+']'+a[i].innerHTML+'\'s profile[/url]...';}
if(a[i].href.match('&eventid=')&&mo_load){a[i].parentNode.id='mo_list';}
if(a[i].innerHTML.match('\'s profile')){document.write('<meta http-equiv="refresh" content="0;url='+a[i].href+'">');}
if(a[i].href==mou+'index.php?act=calendar&code=newevent'){a[i].style.display='none';}}

var mo_list=document.getElementById('mo_list');
if(mo_list&&!mo_list.innerHTML.match(mo_name)){document.write('<iframe src="'+mou+'index.php?act=calendar" width="0px" height="0px" frameborder="no" id="mo_frame" name="mo_frame" />');}

for(i=0;i<a.length;i++){
if(a[i].href.match('&m='+(month+1)+'&d='+(day+1))&&!a[i].parentNode.parentNode.innerHTML.match(mo_name)){parent.document.getElementById("mo_frame").src=mou+'index.php?act=calendar&code=newevent';}}

var div=document.getElementsByTagName('div');
for(i=0;i<div.length;i++){
if(div[i].className=='caldate'&&div[i].innerHTML==day+1&&!div[i].parentNode.innerHTML.match(mo_name)){parent.document.getElementById("mo_frame").src=mou+'index.php?act=calendar&code=newevent';}}

if(window.location.href.match('&code=newevent')){var REPLIER=document.forms['REPLIER'];
REPLIER.event_title.value=characterEntities_decode(mo_name);
REPLIER.e_day.selectedIndex=day;
REPLIER.e_month.selectedIndex=month;
REPLIER.Post.value=mo_link;
REPLIER.submit.click();}