
function openWindow(url)
{
	var parms = 'width=700,height=600,toolbar=0,resizable,scrollbars,location=0';

	var question = window.open(url,'question',parms);
	question.focus();
}


function openAnswers(question,pageLocation)
{
	var parms = 'width=500,height=400,toolbar=0,location=0,resizable,scrollbars';
	var url   = pageLocation + 'displayAnswers.php?question=' + question;

	var answer = window.open(url,'answer',parms);
	answer.focus();
}

function openReport(url)
{
//	var parms = 'width=700,height=600,resizable,scrollbars';
//	var parms = 'menubar=1,toolbar=1,resizable,scrollbars';
	var parms = 'width=800,height=600,menubar=1,toolbar=1,location=0,scrollbars';
//	var parms = '';

	var report = window.open(url,'report',parms);
	report.focus();
}

function populateAnswerBox(answerText)
{
	var el = document.getElementById("answerArea");

	var store = "";

	if (el.value)
		store = el.value;

	store += answerText;
	store += "\r\r";

	// alert(store + " " + el);

	el.value = store;

}

function newQuestion(location,blogID,cat,user)
{

	var parms = 'width=557,height=445,menubar=0,toolbar=0,location=0,resizable,Scrollbars';

	var url   = location + 'newQuestion.php?id=' + blogID + '&cat=' + cat + '&user=' + user;

	var report = window.open(url,'newQuestion',parms);
	report.focus();

}

function openReport(url)
{
//	var parms = 'width=700,height=600,resizable,scrollbars';
//	var parms = 'menubar=1,toolbar=1,resizable,scrollbars';
	var parms = 'menubar=1,toolbar=1,location=0,scrollbars';
//	var parms = '';

	var report = window.open(url,'report',parms);
	report.focus();
}

function populateAnswerBox(answerText)
{
	var el = document.getElementById("answerArea");

	var store = "";

	if (el.value)
		store = el.value;

	store += answerText;
	store += "\r\r";

	// alert(store + " " + el);

	el.value = store;

//	var parms = 'width=500,height=400,toolbar=0,location=0,resizable,scrollbars';
//	var url   = pageLocation + 'displayAnswers.php?question=' + question;

//	var answer = window.open(url,'answer',parms);
//	answer.focus();
}

function newReq(location,blogID,cat,user)
{

	var parms = 'width=557,height=445,menubar=0,toolbar=0,location=0,resizable,Scrollbars';

	var url   = location + 'newRequirement.php?id=' + blogID + '&cat=' + cat + '&user=' + user;

	var report = window.open(url,'newRequirement',parms);
	report.focus();

}

function launchupload(location)
{
//	window.open (location + "uploadAttachments.php", "b2upload", "width=380,height=360,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0");
	upload = window.open (location + "/admin/b2upload_requirement2.php", "b2upload", "width=380,height=360,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0");
	upload.focus();
}

function launchLinkAttachment(location,postID)
{
//	attach = window.open (location + "/admin/b2upload_linkAttachment.php", "b2link", "width=530,height=360,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0");
	attach = window.open (location + "/admin/b2upload_linkAttachmentThread.php?id="+postID, "b2link", "width=530,height=360,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0");
	attach.focus();
}
/*
function launchToDoLinkAttachment(location,postID)
{
//	attach = window.open (location + "/admin/b2upload_linkAttachment.php", "b2link", "width=530,height=360,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0");
	attach = window.open (location + "/admin/b2upload_linkToDoAttachmentThread.php?id="+postID, "b2link", "width=530,height=360,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0");
	attach.focus();
}
*/
function launchEntryList(location,blogID)
{
	url = location + "/admin/b2upload_listEntries.php?blog="+blogID;
//	window.open (location + "uploadAttachments.php", "b2upload", "width=380,height=360,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0");
	link = window.open (url, "b2linkList", "width=630,height=460,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0");
	link.focus();
}

function launchLinkSuggestions(location,blogID)
{
	url = location + "/admin/b2upload_linkSuggestions.php?blog="+blogID;
//	window.open (location + "uploadAttachments.php", "b2upload", "width=380,height=360,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0");
	link = window.open (url, "b2linkSuggestions", "width=630,height=460,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0");
	link.focus();
}

function leaveViewpoint(location,postID)
{
	var parms = 'width=530,height=400,toolbar=0,location=0,resizable,scrollbars';
	var url   = location + 'leaveViewpoint.php?id=' + postID;

	var viewpoint = window.open(url,'answer',parms);
	viewpoint.focus();
}

// insert your favorite sliding script here, just modify it
// to always return false.
function toggle(pDivId,pState,passedCSS,update,showEdit)
{
	// alert(passedCSS);

	if (pState==0)
	{ // hidden
 		var classStore = 'show '+passedCSS;
		document.getElementById(pDivId).className=classStore;
		document.getElementById('as'+pDivId).style.display='none';
		document.getElementById('ah'+pDivId).style.display='block';

		if (showEdit == 1)
			document.getElementById("edit" + pDivId).style.display='inline';

		if (update == 1)
		{
			var parms = 'id=' + pDivId + '&show=show';
			// alert("showing" + parms);
			makeRequest('updateComments.php',parms,'bottomcontent');
		}
//		alert("before call");
//		slidedown(pDivId);
		return false;
	}
	else
	{ // shown
 		var classStore = 'bury '+passedCSS;
		document.getElementById(pDivId).className=classStore;
		document.getElementById('as'+pDivId).style.display='block';
		document.getElementById('ah'+pDivId).style.display='none';

		if (showEdit == 1)
			document.getElementById("edit"+pDivId).style.display='none';

		if (update == 1)
		{
			var parms = 'id=' + pDivId + '&show=hide';
			// alert("hiding=" + parms);
			makeRequest('updateComments.php',parms,'bottomcontent');
		}
		return false;
	}
}

function uncheckOthers(passedCheck)
{
	// alert(passedCheck.id + "  " + passedCheck.checked);

	if ((passedCheck.checked == true) &&
		 (passedCheck.id   == 'typeCheckZ'))
	{
		document.getElementById('typeCheckF').checked = false;
		document.getElementById('typeCheckE').checked = false;
		document.getElementById('typeCheckI').checked = false;
	}

	if ((passedCheck.checked == true) &&
		 (passedCheck.id   == 'loeCheckA'))
	{
		document.getElementById('loeCheckS').checked = false;
		document.getElementById('loeCheckM').checked = false;
		document.getElementById('loeCheckL').checked = false;
		document.getElementById('loeCheckX').checked = false;
	}

	if ((passedCheck.checked == true) &&
		 (passedCheck.id   == 'applCheckW'))
	{
		document.getElementById('applCheckH').checked = false;
		document.getElementById('applCheckO').checked = false;
		document.getElementById('applCheckG').checked = false;
	}
}

function uncheckTypeAll(passedCheck)
{
	// alert(passedCheck.id + "  " + passedCheck.checked);

	if (passedCheck.checked == true)
	{
		document.getElementById('typeCheckZ').checked = false;
	}
}

function uncheckLOEAll(passedCheck)
{
	// alert(passedCheck.id + "  " + passedCheck.checked);

	if (passedCheck.checked == true)
	{
		document.getElementById('loeCheckA').checked = false;
	}
}

function uncheckApplAll(passedCheck)
{
	// alert(passedCheck.id + "  " + passedCheck.checked);

	if (passedCheck.checked == true)
	{
		document.getElementById('applCheckW').checked = false;
	}
}

var isEdit = 0;
var origComment = "";

function editComment(passedDiv, commentID)
{
	// alert("helllooooooo " + passedDiv);

	if (isEdit == 0)
	{
		// alert("content=" + document.getElementById(passedDiv).innerHTML);

		commField = document.getElementById("inline" + passedDiv);

		// alert("commField=" + commField + " id=" + commField.id);
		var commentStore = commField.innerHTML;
		origComment = commField.innerHTML;

		// alert("0xxx=" + commentStore);

		// change <br />'s into ascii line breaks
		commentStore = commentStore.replace(/<BR>/g,"\r");
		commentStore = commentStore.replace(/<br>/g,"\r");
		commentStore = commentStore.replace(/<br \/>/g,"\r");

		// alert("1xxx=" + commentStore);

		var updateForm  = "<form action='update.php' method='post' >\n";
			 updateForm += "<textarea name='comment' id='comment' rows='12'  cols='100' class='bComment'>\n";

			 updateForm += commentStore;

			 updateForm += "</textarea>\n";
			 updateForm += "<input type='submit' value='Save Changes'>\n";
			 updateForm += "<b><span class='dimmed'>Please note that subscribers will not be notified of any changes made to your post.</span></b>\n";
			 updateForm += "<input type='hidden' id='comment_ID' name='comment_ID' value=\"" + commentID + "\">\n";
			 updateForm += "</form>\n";

		document.getElementById("inline" + passedDiv).innerHTML = updateForm;

		isEdit = 1;
	}
	else
	{
		// alert("content=" + document.getElementById(passedDiv).innerHTML);

		commField = document.getElementById("inline" + passedDiv);
		commField.innerHTML = origComment;

		isEdit = 0;
		origComment = "";

	}
}

function getCookieVal (offset)
{
	var endstr = document.cookie.indexOf (";", offset);

	if (endstr == -1)
		endstr = document.cookie.length;

	return unescape(document.cookie.substring(offset, endstr));
}

function FixCookieDate (date)
{
	var base = new Date(0);
	var skew = base.getTime();
	// dawn of (Unix) time - should be 0  if (skew > 0)
	// Except on the Mac - ahead of its time
	date.setTime (date.getTime() - skew);
}

function GetCookie (name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;

		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);

		i = document.cookie.indexOf(" ", i) + 1;

		if (i == 0)
			break;
	}

	return null;
}

function SetCookie (name,value,expires,path,domain,secure)
{
	document.cookie = name + "=" + escape (value) + ((expires) ? ";expires=" + expires.toGMTString() : "") + ((path) ? ";path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}

function DeleteCookie (name,path,domain)
{
	if (GetCookie(name))
	{
		document.cookie = name + "=" + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ";	expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function LinkFR(location, postID)
{
	var theHeight = 460;
	var theWidth = 630;

	// position the window relative to where the mouse was clicked. This way we can hang it off (or at
	// least give the impression of hanging if off) the mouse click
	var theTop = yMouse + 15;
	var theLeft = xMouse - theWidth + 15;

	if (!IE)
	{
		// size of available space = window.innerHeight
		// position of link = 150px from top
		// height of link = 30px
		// status bar = 20px
		// height scrolled down = window.scrollY
		theHeight = window.innerHeight - 200 + window.scrollY;
	}
	else
	{
		// if IE then availHeight is screenHeight of PRIMARY SCREEN
		theHeight = document.documentElement.clientHeight - 230 + document.documentElement.scrollTop;
	}

	parms = "width="+theWidth+",height="+theHeight+",top="+theTop+",left="+theLeft+",location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0";

	url = location + "/admin/linkFR.php?post="+postID;
	link = window.open (url, "b2linkFR", parms);
	link.focus();
}

function LinkSuggestion(location, postID)
{
	var theHeight = 460;
	var theWidth = 630;

	// position the window relative to where the mouse was clicked. This way we can hang it off (or at
	// least give the impression of hanging if off) the mouse click
	var theTop = yMouse + 15;
	var theLeft = xMouse - theWidth + 15;

	if (!IE)
	{
		// size of available space = window.innerHeight
		// position of link = 150px from top
		// height of link = 30px
		// status bar = 20px
		// height scrolled down = window.scrollY
		theHeight = window.innerHeight - 200 + window.scrollY;
	}
	else
	{
		// if IE then availHeight is screenHeight of PRIMARY SCREEN
		theHeight = document.documentElement.clientHeight - 230 + document.documentElement.scrollTop;
	}

	parms = "width="+theWidth+",height="+theHeight+",top="+theTop+",left="+theLeft+",location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0";

	url = location + "/admin/linkSuggestion.php?post="+postID;
	link = window.open (url, "b2linkSugg", parms);
	link.focus();
}

function ListUserToDos(location)
{
	var theHeight = 460;
	var theWidth = 630;

	// position the window relative to where the mouse was clicked. This way we can hang it off (or at
	// least give the impression of hanging if off) the mouse click
	var theTop = yMouse + 15;
	var theLeft = xMouse - theWidth + 15;

	if (!IE)
	{
		// size of available space = window.innerHeight
		// position of link = 150px from top
		// height of link = 30px
		// status bar = 20px
		// height scrolled down = window.scrollY
		theHeight = window.innerHeight - 200 + window.scrollY;
	}
	else
	{
		// if IE then availHeight is screenHeight of PRIMARY SCREEN
		theHeight = document.documentElement.clientHeight - 230 + document.documentElement.scrollTop;
	}

	parms = "width="+theWidth+",height="+theHeight+",top="+theTop+",left="+theLeft+",location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0";

	url = location + "/admin/listUserToDos.php";
	link = window.open (url, "b2listUsers", parms);
	link.focus();
}


function ListCRUserToDos(location)
{
	var theHeight = 460;
	var theWidth = 630;

	// position the window relative to where the mouse was clicked. This way we can hang it off (or at
	// least give the impression of hanging if off) the mouse click
	var theTop = yMouse + 15;
	var theLeft = xMouse - theWidth + 15;

	if (!IE)
	{
		// size of available space = window.innerHeight
		// position of link = 150px from top
		// height of link = 30px
		// status bar = 20px
		// height scrolled down = window.scrollY
		theHeight = window.innerHeight - 200 + window.scrollY;
	}
	else
	{
		// if IE then availHeight is screenHeight of PRIMARY SCREEN
		theHeight = document.documentElement.clientHeight - 230 + document.documentElement.scrollTop;
	}

	parms = "width="+theWidth+",height="+theHeight+",top="+theTop+",left="+theLeft+",location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0";

	url = location + "/admin/listCRUserToDos.php";
	link = window.open (url, "b2listUsers", parms);
	link.focus();
}

function toggleRollout(id,width)
{
	// position the window relative to where the mouse was clicked. This way we can hang it off (or at
	// least give the impression of hanging if off) the mouse click
	var theTop = yMouseWin - 20;
	var theLeft = xMouseWin - width + 20;

	//	alert("coords=" + xMouseWin + "/" + yMouseWin + "width=" + width);

	// only toggle if click registered as valid otherwise we will do nothing and make them click again
	if (theTop > 0 && theLeft > 0)
	{
		var divID = document.getElementById(id);
	
		divID.style.top = theTop+"px";
		divID.style.left = theLeft+"px";
		divID.style.zindex = 2000;
	
		if (divID.style.display == 'none')
		{
			divID.style.display = 'block';
		}
		else
		{
			divID.style.display = 'none';
		}
	}
}

function hideRollout(id)
{
//	var divID = document.getElementById(id);

//	divID.style.display == 'none';

	document.getElementById(id).style.display == 'none';

//	alert(id + divID.style.display);
}


function mouseX(evt) 
{
	if (evt.pageX) 
		return evt.pageX;
	else if (evt.clientX)
   	return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
	else 
		return null;
}

function mouseY(evt) 
{
	if (evt.pageY)
		return evt.pageY;
	else if (evt.clientY)
   	return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	else 
		return null;
}

	// Detect if the browser is IE or not.
	// If it is not IE, we assume that the browser is NS.
	var IE = document.all?true:false
	
/* commented out cpature events hack. might break something */
	// If NS -- that is, !IE -- then set up for mouse capture
	if (!IE) document.captureEvents(Event.MOUSEMOVE)

	// Set-up to use getMouseXY function onMouseMove
//	document.onmousemove = getMouseXY;

	// Temporary variables to hold mouse x-y pos.s
	var tempX = 0
	var tempY = 0
	
	// Main function to retrieve mouse x-y pos.s

	function getMouseXY(e) 
	{
		if (IE)
		{ // grab the x-y pos.s if browser is IE
			tempX = event.clientX + document.body.scrollLeft;
			tempY = event.clientY + document.body.scrollTop;
		}
		else
		{  // grab the x-y pos.s if browser is NS
			tempX = e.pageX;
			tempY = e.pageY;
		}

	  return true;
	}




/*
function ChooseProjectFilter(location)
{
	var theHeight = 460;
	var theWidth = 630;

	// position the window relative to where the mouse was clicked. This way we can hang it off (or at
	// least give the impression of hanging if off) the mouse click
	var theTop = yMouse + 15;
	var theLeft = xMouse - theWidth + 15;

	if (!IE)
	{
		// size of available space = window.innerHeight
		// position of link = 150px from top
		// height of link = 30px
		// status bar = 20px
		// height scrolled down = window.scrollY
		theHeight = window.innerHeight - 200 + window.scrollY;
	}
	else
	{
		// if IE then availHeight is screenHeight of PRIMARY SCREEN
		theHeight = document.documentElement.clientHeight - 230 + document.documentElement.scrollTop;
	}

	parms = "width="+theWidth+",height="+theHeight+",top="+theTop+",left="+theLeft+",location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0";

	url = location + "/admin/chooseProjectFilter.php";
	link = window.open (url, "b2projectFilter", parms);
	link.focus();
}
*/

function refresh()
{
     location.reload(true);
}

function toggle2(pDivId,pState,passedCSS,update,showEdit)
{

	if (pState==0)
	{ // hidden

		var classStore = 'show';
		document.getElementById(pDivId).className=classStore;

		var classToggle = 'toggle';
		document.getElementById('toggle'+pDivId).className=classToggle;

		document.getElementById('divider'+pDivId).style.display='block';
		document.getElementById('abridged'+pDivId).style.display='none';

		if (passedCSS == 'resolved')
		{
			var commentCSS = 'individualCommentResolved';
		}
		else
		{
			var commentCSS = 'individualComment';
		}

		document.getElementById('comment'+pDivId).className = commentCSS;

		document.getElementById('as'+pDivId).style.display='none';
		document.getElementById('ah'+pDivId).style.display='block';

		if (showEdit == 1)
			document.getElementById("edit" + pDivId).style.display='inline';

		if (update == 1)
		{
			var parms = 'id=' + pDivId + '&show=show';
			// alert("showing" + parms);
			makeRequest('updateComments.php',parms,'bottomcontent');
		}
//		alert("before call");
//		slidedown(pDivId);
		return false;
	}
	else
	{ // shown
// 		var classStore = 'bury '+passedCSS;
 		var classStore = 'bury';
		document.getElementById(pDivId).className=classStore;

		var classToggle = 'toggleHidden';
		document.getElementById('toggle'+pDivId).className=classToggle;

		document.getElementById('divider'+pDivId).style.display='none';
		document.getElementById('abridged'+pDivId).style.display='block';

		if (passedCSS == 'resolved')
		{
			var commentCSS = 'individualCommentResolvedHidden';
		}
		else
		{
			var commentCSS = 'individualCommentHidden';
		}

		document.getElementById('comment'+pDivId).className = commentCSS;

		document.getElementById('as'+pDivId).style.display='block';
		document.getElementById('ah'+pDivId).style.display='none';

		if (showEdit == 1)
			document.getElementById("edit"+pDivId).style.display='none';

		if (update == 1)
		{
			var parms = 'id=' + pDivId + '&show=hide';
			// alert("hiding=" + parms);
			makeRequest('updateComments.php',parms,'bottomcontent');
		}
		return false;
	}

}

// function toggle3(pDivId,prevDivId,pState,passedCSS,update,showEdit)
function toggle3(commentCount,commentID,pState,passedCSS,update,showEdit)
{
	var previousComment    = commentCount - 1;
	var nextComment        = commentCount + 1;

	var nextCommentDiv     = document.getElementById('extraDivider'+nextComment);
	var previousCommentDiv = document.getElementById('extraDivider'+previousComment);

	if (pState==0)
	{ // hidden - setting to be shown

		var classStore = 'show';
		document.getElementById(commentCount).className=classStore;

		var classToggle = 'toggle';
		document.getElementById('toggle'+commentCount).className=classToggle;

		document.getElementById('divider'+commentCount).style.display='block';
		document.getElementById('abridged'+commentCount).style.display='none';

		// if we are setting the comment to be visible and the next comment is hidden then
		// we want to display a line before the hidden comment
		// alert("next=" + document.getElementById('divider'+nextComment).style.display + " count=" + commentCount + " next=" + nextComment);
		if (document.getElementById('divider'+nextComment).style.display == 'none')
		{
			nextCommentDiv.style.display = 'block';
		}

		// if we are setting the comment to be visible and the previous comment is also
		// visible then we want to make sure that the line above the current comment is
		// not visible
		// alert("prev=" + document.getElementById('divider'+previousComment).style.display + " count=" + commentCount + " next=" + nextComment);
		if (document.getElementById('divider'+previousComment).style.display == 'block')
		{
			document.getElementById('extraDivider'+commentCount).style.display = 'none';
		}

		if (passedCSS == 'resolved')
		{
			var commentCSS = 'individualCommentResolved';
		}
		else
		{
			var commentCSS = 'individualComment';
		}

		document.getElementById('comment'+commentCount).className = commentCSS;

		document.getElementById('as'+commentCount).style.display='none';
		document.getElementById('ah'+commentCount).style.display='block';

		if (showEdit == 1)
		{
			document.getElementById("edit" + commentCount).style.display='inline';
		}

		if (update == 1)
		{
			var parms = 'id=' + commentID + '&show=show';
			// alert("showing" + parms);
			makeRequest('updateComments.php',parms,'bottomcontent');
		}

		return false;
	}
	else
	{ // shown - set to be hidden

 		var classStore = 'bury';
		document.getElementById(commentCount).className=classStore;

		var classToggle = 'toggleHidden';
		document.getElementById('toggle'+commentCount).className=classToggle;

		document.getElementById('divider'+commentCount).style.display='none';
		document.getElementById('abridged'+commentCount).style.display='block';

		// if we are setting the comment to be hidden and the previous comment is
		// visible then we want to make sure that the line above the current comment is
		// visible
		// alert("prev=" + document.getElementById('divider'+previousComment).style.display + " count=" + commentCount + " next=" + nextComment);
		if (document.getElementById('divider'+previousComment).style.display == 'block')
		{
			// alert("poop");
			document.getElementById('extraDivider'+commentCount).style.display = 'block';
		}

		// if we are setting a comment to be hidden and the next comment is also hidden
		// we want to make sure that the line above the next comment is hidden
		if (document.getElementById('divider'+nextComment).style.display == 'none')
		{
			// alert("poop");
			document.getElementById('extraDivider'+nextComment).style.display = 'none';
		}

		if (passedCSS == 'resolved')
		{
			var commentCSS = 'individualCommentResolvedHidden';
		}
		else
		{
			var commentCSS = 'individualCommentHidden';
		}

		document.getElementById('comment'+commentCount).className = commentCSS;

		document.getElementById('as'+commentCount).style.display='block';
		document.getElementById('ah'+commentCount).style.display='none';

		if (showEdit == 1)
		{
			document.getElementById("edit"+commentCount).style.display='none';
		}

		if (update == 1)
		{
			var parms = 'id=' + commentID + '&show=hide';
			// alert("hiding=" + parms);
			makeRequest('updateComments.php',parms,'bottomcontent');
		}

		return false;
	}
}

function confirmDelete(attachID)
{
	var answer = confirm("Are you sure you want to delete this attachment?")
	if (answer)
	{
		var parms = 'id=' + attachID;
		var targetID = "attach"+attachID;
		// alert("hiding=" + parms);
		makeRequest('deleteAttachment.php',parms,targetID);
	}
	else
	{
	}

}

function deleteLink(topicID,linkedTopic)
{
	var answer = confirm("Are you sure you want to delete this link?")
	if (answer)
	{
		var parms = 'id=' + topicID + '&linked=' + linkedTopic;
//		var parms = 'id=' + topicID;
		var targetID = "linked"+topicID;
		// alert("hiding=" + parms);
		makeRequest('deleteLink.php',parms,targetID);
	}
	else
	{
	}

}



var newPostEditor = '';
var completeEditor = '';
var myNiceEditor = '';

//function displayStatusForm(divID)
function displayStatusForm(displayDiv,hideDiv,displayClass, hideClass)
{
/*
	var visibility = document.getElementById(divID).style.display;

	if (visibility == 'none')
	{
		document.getElementById(divID).style.display='block';
		document.getElementById("NewPostDropDown").setAttribute("class", "newPostOver");
		document.getElementById("NewPostDropDown").setAttribute("className", "newPostOver");
		document.getElementById("commentArea").focus();
	}
	else
	{
		document.getElementById(divID).style.display='none';
		document.getElementById("NewPostDropDown").setAttribute("class", "newPost");
		document.getElementById("NewPostDropDown").setAttribute("className", "newPost");
		window.scrollY -= 200;
	}
*/

	if (newPostEditor == '')
	{
		newPostEditor = new nicEditor(
			{buttonList : ['bold','italic','underline','strikeThrough','left','center','right',,'ol','ul','subscript','superscript','fontSize','hr','link','unlink'],
			 maxHeight : 220}).panelInstance('commentArea');

//		nicEditors.findEditor("newPostEditor").setContent("AAAaaargh");
	}

	// It is getting late and I cannot concentrate enough to think of an elegant solution to this, so...
	//
	// As I see it there are 6 possible permutations:
	//
	// None are showing and we want to display A
	// None are showing and we want to display B
	// A is showing and we want to hide A
	// B is showing and we want to hide B
	// A is showing and we want to hide B
	// B is showing and we want to hide A
	//
	// With that in mind, let's try and come up with a solution...
	var showVisibility = document.getElementById(displayDiv).style.display;
	var hideVisibility = document.getElementById(hideDiv).style.display;

//	var showClass = document.getElementById(displayDiv).className;
//	var hideClass = document.getElementById(hideDiv).className;

	// is the selected div showing???
	if (showVisibility == 'none')
	{
		// alert('show = none');
		// is the unselected div already showing?
		if (hideVisibility == 'block')
		{

			// alert('hiding current');
			document.getElementById(hideDiv).style.display = 'none';
			document.getElementById(hideClass).className = 'newPost';
		}

		// alert('showing');
		document.getElementById(displayDiv).style.display = 'block';
		document.getElementById(displayClass).className = "newPostOver";

	}
	else
	{
		// alert('hiding selected');

		// hide the current div
		document.getElementById(displayDiv).style.display = 'none';
		document.getElementById(displayClass).className = "newPost";
	}


	// if we are toggling the new post form this will be appearing off the bottom
	// of the page. To increase useability we will scroll the window down when the
	// button is clicked so that the form is immediately visible on the bottom of
	// the page
/*
	if (divID == "New Post")
	{
		if (window.scrollBy)
		{
//			window.scrollBy(0, 300);
		}
	}
*/

//	return false;
}

// insane date validation using regular expression is taken from:
// http://www.expertsrt.com/scripts/Rod/validate_date.php
// I offer them my thanks for the hours this saved me :)
function validateDate(fld) 
{
	var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
//	var errorMessage = 'Please enter valid date as month, day, and four digit year.\nYou may use a slash, hyphen or period to separate the values.\nThe date must be a real date. 2-30-2000 would not be accepted.\nFormat mm/dd/yyyy.';
	var errorMessage = 'Please enter valid date as month, day, and four digit year separated by a slash.\nFormat mm/dd/yyyy.';

	if ((fld.value.match(RegExPattern)) || (fld.value=='') || (fld.value=='mm/dd/yyyy'))
	{
		 // alert('Date is OK');
	}
	else
	{
		alert(errorMessage);
		fld.focus();
	}
}

function displayDate(fld)
{
	// Array of day number suffixes
	var daySuffix = new Array("", "st","nd","rd","th","th","th","th","th","th","th",
										"st","nd","rd","th","th","th","th","th","th","th",
										"st","nd","rd","th","th","th","th","th","th","th","st");
	// Array of day names
	var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday",
									 "Thursday","Friday","Saturday");

	// Array of month Names
	var monthNames = new Array("January","February","March","April","May","June","July",
										"August","September","October","November","December");

	// get todays date
	var now = new Date();

	var t_day = now.getDate();		// Returns the day of the month
	var t_mon = now.getMonth();		// Returns the month as a digit
	var t_year = now.getFullYear();	// Returns 4 digit year

	// add on passed number of days
//	if (parseInt(fld))
	if (fld && !isNaN(fld) && (fld != ' '))
	{
		var passedNumDays = parseInt(fld);

		now.setDate(now.getDate()+ passedNumDays);

		t_day = now.getDate();		// Returns the day of the month
		t_mon = now.getMonth();		// Returns the month as a digit
		t_year = now.getFullYear();	// Returns 4 digit year

		var newDate = dayNames[now.getDay()] + ", " + t_day + daySuffix[t_day]+ " " + monthNames[t_mon] + " " + t_year;

		//	alert("now, now=" + now);

		// display calculated final date
		document.getElementById('finalDate').innerHTML = newDate;

		if (fld > 360)
		{
			document.getElementById('finalDate').innerHTML = "Perhaps a closer target date would be more appropriate.";
		}

	}
	else if (fld != '')
	{
//		alert("Target number of days needs to be numeric. <" + document.getElementById('targetDate').value + ">");
		alert("Target number of days needs to be numeric.");
		document.getElementById('finalDate').innerHTML = " ";
	}
	else
	{
		document.getElementById('finalDate').innerHTML = " ";
	}
}

function clearField(fld)
{
	// clear the text if value is default
	if (fld.value == 'mm/dd/yyyy')
		fld.value = '';

	if (fld.value == 'num days')
		fld.value = '';

	if (fld.value == 'enter Title here')
		fld.value = '';

	if (fld.value == 'enter Description here')
		fld.value = '';

	// change the style
	fld.className = 'targetDark';

}


	var disableCheckboxes = function()
	{
		var als = document.getElementsByName('alertNames[]');
		var els = document.getElementsByName('notifyNames[]');
		var xls = document.getElementsByName('nameEntry');

		if (document.getElementById('Notify').checked)
		{
			document.getElementById('notifyLegend').className = 'inputEntry';
			// enable checkboxes
			// alert("checked");
			for(var i=0; el=els[i]; i++)
			{
				if (xls.length > 0)
				{
					if (el.checked)
						xls[i].className = 'nameEntry';
					else
						xls[i].className = 'nameEntryUnchecked';
				}

				el.disabled = false;
			}
			for(var i=0; al=als[i]; i++)
			{
				al.disabled = false;
			}
		}
		else
		{
			document.getElementById('notifyLegend').className = 'inputEntryUnchecked';
			// disable checkboxes
			// alert("unchecked");
			for(var i=0; el=els[i]; i++)
			{
				if (xls.length > 0)
				{
					xls[i].className = 'nameEntryUnchecked';
				}

				el.disabled = true;
			}

			for(var i=0; al=als[i]; i++)
			{
				al.disabled = true;
			}
		}
	}

	function toggleCheckStyle(fld, id, count)
	{

		var els = document.getElementsByName('notifyNames[]');
		var xls = document.getElementsByName('alertNames[]');

		if ((els[count].checked) ||
			 (xls[count].checked))
		{
			document.getElementById('name'+id).className = 'nameEntry';
		}
		else
			document.getElementById('name'+id).className = 'nameEntryUnchecked';

		if (els[count].checked)
		{
			els[count].className = 'check3';
		}
		else
		{
			els[count].className = 'check3a';
		}


		if (xls[count].checked)
		{
			xls[count].className = 'check2';
		}
		else
		{
			xls[count].className = 'check2a';
		}

/*
		if (fld.checked)
			document.getElementById('name'+id).className = 'nameEntry';
		else
			document.getElementById('name'+id).className = 'nameEntryUnchecked';
*/
	}


	function toggleCheckStyle2(fld, id)
	{
		if (fld.checked)
			document.getElementById('name'+id).className = 'nameEntry';
		else
			document.getElementById('name'+id).className = 'nameEntryUnchecked';
	}



//var IE = document.all?true:false;
//if (!IE) document.captureEvents(Event.MOUSEMOVE)
//document.onmousemove = getMouseXY;
var xMouse = 0;
var yMouse = 0;
var xMouseWin = 0;
var yMouseWin = 0;

function getMouseXY(e)
{
	if (IE)
	{ // grab the x-y pos.s if browser is IE
		xMouse = event.screenX //event.clientX + document.body.scrollLeft;
		yMouse = event.screenY //event.clientY + document.body.scrollTop;
	}
	else
	{ // grab the x-y pos.s if browser isn't IE
		xMouse = e.screenX;
		yMouse = e.screenY;
  	}

	xMouseWin = (parseInt(mouseX(e)));
	yMouseWin = (parseInt(mouseY(e)));

	return true;
}

function mouseX(evt) {if (!evt) evt = window.event; if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return 0;}
function mouseY(evt) {if (!evt) evt = window.event; if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return 0;}

//function follow(evt) {if (document.getElementById) {var obj = document.getElementById(divName).style; obj.visibility = 'visible';



/*
*/


