// Browser Flags ===================================================================================
var appVer = navigator.userAgent.toLowerCase();
var nn4= (document.layers);
var nn6= (document.getElementById && !document.all);
var ie4= (document.all && !document.getElementById);
var ie5= (document.all && document.getElementById);
var mac= (appVer.indexOf("mac") != -1);
var ie4Mac = (ie4 && mac);
var opera = (appVer.indexOf('opera') != -1);
if (mac) {ie4 = false; ie5 = false; nn4 = false;}

var imgPath = '/iweb/images/TreeView/';

function ShowHide(strId)
{
	//if ((ie4 || ie5) && (!mac))
	if ((document.getElementById || document.all))
	{
		var strSpan;
		var strTree;
		var strHead;
		
		if (document.getElementById)
		{
			strSpan = "document.getElementById('contents" + strId + "')";
			strTree = "document.getElementById('imgPlusMin" + strId + "')";
			strHead = "document.getElementById('msgHeader" + strId + "')";
		}
		else
		{
			strSpan = "document.all['contents" + strId + "']";
			strTree = "document.all['imgPlusMin" + strId + "']";
			strHead = "document.all['msgHeader" + strId + "']";
		}
		
		var treeItem = eval(strTree);
		if (treeItem)
		{
			strTreeImgSrc = treeItem.src.toString();
					
			//Change the folder and plus minus images
			if (strTreeImgSrc.search("plus.gif")>=0) treeItem.src=imgPath + "min.gif";
			if (strTreeImgSrc.search("min.gif")>=0) treeItem.src=imgPath + "plus.gif";
		}
			
		//Show or hide the span element if it exists
		spanItem = eval(strSpan);
		if (spanItem)
		{
			if (spanItem.style.display=='none') spanItem.style.display="";
			else spanItem.style.display="none";			
		}
		
		//Change the class of the message header
		var headItem = eval(strHead);
		if (headItem)
		{
			if (headItem.className=='MsgHeader') headItem.className='MsgHeaderExpanded';
			else headItem.className='MsgHeader';
		}
	}
	else
	{
		var strUrl= document.URL;
		var arUrl = strUrl.split("&");
		var bolFound = false;
		
		for (var i=0; i<arUrl.length; i++)
		{
			if (arUrl[i].substr(0, 8) == "post_id=") 
			{	
				arUrl[i] = "post_id=" + strId;
				bolFound = true;
			}
		}
		strUrl = arUrl.join("&");
		if (!bolFound) strUrl =+ "&post_id=" + strId;
		
		alert(strUrl);	
		document.location.href = strUrl;	
	}
		
}

function buildPostUrl(postId)
{
  var strNewHref = document.location.href;
  var qString = new PageQuery(document.location.search)
  qString.setValue("post_id", postId);
  
  strNewHref = strNewHref.split("?")[0] + "?" + qString.buildQueryString();
	
	document.location.href = strNewHref;
}

function confirmPostDelete(postId, forumId, assnId)
{
	var deleteType = "all";
	
	if (confirm("Are you sure you want to delete this Post and all related Posts?"))
	{
		document.location.href = "/Discussion/Discussion.asp?dis_action=delete&del_post_id=" + postId + "&forum_id=" + forumId + "&assn_id=" + assnId;
	}
}
