var watchObj;

function OpenMonitor()
	{
	myWindow = window.open("/html/picker.htm","picker","resize=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,copyhistory=0,width=300,height=460,top=5,left=5");
	myWindow.location = "/html/picker.htm";
	myWindow.focus();
	}

function delete_message(jid)
	{
	if (confirm('Are you sure you wish to remove this message?'))
		{window.location = 'icq-journal.pl?mode=delete&uin=' + getObj('journal').value + '&id=' + jid;}
	}

function message_privacy(jid,mode,params)
	{
	var desc = new Array;
	desc['N'] = 'Public';
	desc['N'] = 'Public';
	desc['M'] = 'Members Only';
	desc['V'] = 'Visitors Only';
	desc['F'] = 'Faves Only';
	desc['S'] = 'Selected Faves Only';
	desc['Y'] = 'Private';

	if (mode == 'S')
		{
		if (confirm('Would you like to edit this entry so that you can select which faves?'))
			{window.location = 'icq-journal.pl?uin=' + getObj('journal').value + '&' + params;}
		}
	else
		{
		if (confirm('Are you sure you wish to make this message ' + desc[mode] + '?'))
			{window.location = 'icq-journal.pl?mode=hide&uin=' + getObj('journal').value + '&id=' + jid + '&mode=' + mode;}
		}
	}

function hide_message(jid)
	{
	if (confirm('Are you sure you wish to hide this message?'))
		{window.location = 'icq-journal.pl?mode=hide&uin=' + getObj('journal').value + '&id=' + jid;}
	}

function new_message(maxposts)
	{
	if (confirm('Are you sure you wish to create a new message?'))
		{
		var theForm = document.editform;
		theForm.postNum.value = (parseInt(theForm.newpost.value)+1);
		theForm.postit.value = "Post Entry";
		theForm.newmess.disabled = true;
		theForm.title.value = '';
		theForm.comments.value = theForm.auto_comments.value;
		if (getObj('mce_editor_comments'))
			{getObj('mce_editor_comments').contentWindow.document.body.innerHTML = theForm.auto_comments.value;}
		theForm.mess_id.value = '';
		document.getElementById('postSpan').innerHTML = '<b>' + theForm.postnum.value + '</b> of <b>' + maxposts + '</b>';
		}
	}

function toggle_div()
	{
	if (document.getElementById)
		{
		var dd = document.editform.private;

		if (dd.options[dd.options.selectedIndex].value == 'S')
			{document.getElementById('favDiv').style.display = 'block';}
		else
			{document.getElementById('favDiv').style.display = 'none';}
		}
	}


function update_preview()
   {
   var thedate = new Date();
   var now = thedate.getTime();
   var theSel = document.editform.character;
   var theCur = theSel.options[theSel.selectedIndex].value;
   if (theCur != '')
      {
      if (theCur > 0)
         {document.getElementById('preview').src = bandwidth + '/characters/' + theCur.toLowerCase() + '.gif?' + now;}
      else
         {document.getElementById('preview').src = bandwidth + '/characters/' + theCur.toLowerCase() + '.gif';}
      }
   else
      {document.getElementById('preview').src = bandwidth + '/pix/clear.gif';}
   }


function watchHide(a,uin)
	{
	if (watchObj)
		{alert('Please wait...'); return false;}

	watchObj = a;
	while (watchObj.tagName.toUpperCase() != 'TR')
		{watchObj = watchObj.parentNode;}

	var table = a;
	while (table.tagName.toUpperCase() != 'TABLE')
		{table = table.parentNode;}

	var tr = watchObj.rowIndex;
	table.rows[tr++].style.display = 'none';
	while (table.rows[tr].className == 'even')
		{table.rows[tr++].style.display = 'none';}

	var url = "icq-journalwatch.pl?ajax=Y&uin=" + uin;
	document.body.style.cursor = 'wait';
	if (window.XMLHttpRequest)
		{
		// code for Mozilla, etc.
		jsHTTP=new XMLHttpRequest();
		jsHTTP.onreadystatechange=watchHideDone;
		jsHTTP.open("GET",url,true);
		jsHTTP.send(null);
		}
	else if (window.ActiveXObject)
		{
		// code for IE
		jsHTTP=new ActiveXObject("Microsoft.XMLHTTP");
		if (jsHTTP)
			{
			jsHTTP.onreadystatechange=watchHideDone;
			jsHTTP.open("GET",url,true);
			jsHTTP.send();
			}
		}
	}

function watchHideDone()
	{
	if (jsHTTP.readyState == 4)
		{
		if (jsHTTP.status == 200)
			{watchObj = null;}
		else
			{
			alert('AJAX Error: ' + jsHTTP.status);
			watchObj = null;
			}
		}
	document.body.style.cursor = 'default';
	}