
	/* DevForum.JS */

	/*
		routines added for IE5B2:
			window_load - call showSelected from load handler (persistence)
			document_keyup - kb handling when any key is released (accessibility)
			HandleKeyForHeading - kb handling when section heading has focus (accessibility)
			HandleKeyForItem - kb handling when article has focus (accessibility)
	*/

	// Accessibility key definitions
	var DHTML_ARROW_MIN = 37;
	var DHTML_ARROW_MAX = 40;
	var DHTML_LEFT_ARROW = 37; 	// left-arrow
	var DHTML_UP_ARROW = 38; 	// up-arrow
	var DHTML_RIGHT_ARROW = 39;  // right-arrow
	var DHTML_DOWN_ARROW = 40;   // down-arrow

	//-------------------------------------------------------------------------
	//	Declare necessary variables
	//	eSelected: the currently selected item in the TOC
	//	sCurrentDoc: the path of the document currently displayed in the
	//	content frame. This string is passed as a hash value
	//-------------------------------------------------------------------------

	var eSelected = null;
	//MATTO: change to lowercase since it may be entered in mixed case by the user or by some referring page
	var sCurrentDoc = window.location.hash.substring(1).toLowerCase();
	// MATTO: Special case to handle links to XML content that include /workshop vroot

	if (-1 != navigator.appVersion.indexOf("MSIE 5"))
	{
		var oRegXML = new RegExp("^/xml/", "i");
		sCurrentDoc = sCurrentDoc.replace(oRegXML, "/xml/");
	}

	//-------------------------------------------------------------------------
	//	getContainer()
	//	Purpose: finds the container element for a given child
	//	Called: from the viewElement function
	//-------------------------------------------------------------------------

	function getContainer(eSrc)
	{
		while ("BODY" != eSrc.tagName.toUpperCase())
		{
			if ("clsShowHide" != eSrc.className) return eSrc;
			eSrc = eSrc.parentElement;
		}
	}

	//-------------------------------------------------------------------------
	//	newToc()
	//	Purpose: takes a path to a contents page as input and
	//	returns a properly-formed c-frame URL which loads the contents page
	//	w/ the appropriate TOC.
	//	Called: in the onclick event of any TOC item that should load a new TOC
	//	(signified by the expNewTOC expando property).
	//-------------------------------------------------------------------------

	function newToc()
	{
		var sTargetPath = window.event.srcElement.pathname;
		var sFrameRoot = "/" + sTargetPath.substring(0,sTargetPath.substring(1).indexOf("/") + 2);
		return HackURL(sFrameRoot + "c-frame.htm#/" + sTargetPath);
	}

	//-------------------------------------------------------------------------
	//	HackURL()
	//	Purpose: Inserts a unique search value into a c-frame URL. This value
	//	is obtained by applying the getTime method to the Date object.
	//	Called: from the newToc() function
	//-------------------------------------------------------------------------

	function HackURL(sURL)
	{
		var iTime = new Date().getTime();
		var sFrameURL = sURL.substring(0,sURL.indexOf("#"));
		var sHash = sURL.substring(sURL.indexOf("#"));
		if ("" != sFrameURL)
		{
			if (location.protocol.indexOf("file:") > -1) return sHash.substring(1);
			return sFrameURL + "?" + iTime + sHash;
		}
	}

	//-------------------------------------------------------------------------
	//	contentsHeading_click()
	//
	//	Purpose:	For TOC items w/ no children
	//					1) Navigates content frame
	//					2) Highlights item as selected
	//					3) Shows stylesheet samples in new window, if necessary
	//
	//				For TOC items w/ children
	//					1) Shows/Hides children
	//					2) Swaps +/- list item icons
	//
	//	Called: from the global onclick event handler. All items that are
	//	classed as either "clsShowHide" or "clsTocHeading" will have this event
	//	handler defined.
	//-------------------------------------------------------------------------
//HACK

	function contentsHeading_click(eSrc) 
    {

//   alert("contentsHeading_click");
    	if ("noexpand" == eSrc.parentElement.className || "clsNoExpand" == eSrc.parentElement.className)
		{
			if (document.all["chkNewWin"])
			{
				if (document.all["chkNewWin"].checked) eSrc.target="_blank";
			}
			if ("" == eSrc.target) eSrc.target = "TEXT";
			if (null != eSelected)  eSelected.className = "clsTocItem";
			eSrc.className = "clsTocItemSelect";
			return eSelected = eSrc;
		}

		if ("A" == eSrc.tagName.toUpperCase()) eSrc = eSrc.parentElement;
		var sSrcClass = eSrc.className.toLowerCase();
		var iChildrenCount = eSrc.children.length;
		var oListContainer, oChildClass;
		for (var i = 0; i<iChildrenCount; i++)
		{
			oChildClass = eSrc.children[i].className.toLowerCase()
			if ("clsitemsshow" == oChildClass || "clsitemshide" == oChildClass)
                oListContainer = eSrc.children[i];
		}

		if (oListContainer) {
			eSrc.className = "clsshowhide" == sSrcClass ? "clsShowHideShowing" : "clsShowHide";
			oListContainer.className = "clsshowhide" == sSrcClass ? "clsItemsShow" : "clsItemsHide";
		}
			return false;
	}

	function contentsItem_click(eSrc)
	{
		if (document.all["styleView"]) eSrc.target = document.all["styleView"].checked ? "_blank" : "TEXT";
		else if ("" == eSrc.target) eSrc.target = "TEXT"
		if(null != eSelected) eSelected.className = "clsTocItem";
		eSrc.className = "clsTocItemSelect";
		eSelected = eSrc;
	}

	function bucketName_click(eSrc)
	{
		eSrc.target = "TEXT";
		if(null != eSelected) eSelected.className = "clsTocItem";
	}

	//-------------------------------------------------------------------------
	//	GLOBAL EVENT HANDLERS
	//-------------------------------------------------------------------------

	function document_mouseover()
	{
//	    alert("document_mouseover");
		var eSrc = window.event.srcElement;
		if ("clsTocHeading" == eSrc.className && "noexpand" != eSrc.parentElement.className && "clsNoExpand" != eSrc.parentElement.className) eSrc.style.color = "red";
	}

	function document_mouseout()
	{
		var eSrc = window.event.srcElement;
		if ("clsTocHeading" == eSrc.className && "noexpand" != eSrc.parentElement.className&& "clsNoExpand" != eSrc.parentElement.className) eSrc.style.color = "#F4A460";
	}

	function document_click()
	{
		var eSrc = window.event.srcElement;
        if ("INPUT" == eSrc.tagName.toUpperCase())
            return;
//	    alert("document_click"+eSrc.tagName);
		if(eSrc.id!=null && eSrc.id.length>0 && document.all("reply")!=null)
		{
			document.all("reply").show.value = eSrc.id;
//			alert("document_click"+document.all("reply").show.value);
		}
		window.event.cancelBubble = true;
		while ("BODY" != eSrc.tagName.toUpperCase())
		{
			if(null != eSrc.getAttribute("expResetToc"))
                return bucketName_click(eSrc);
			else if ("clsTocItem" == eSrc.className || "clsTocItemSelect" == eSrc.className)
                return contentsItem_click(eSrc);
			else if (null != eSrc.getAttribute("expNewToc"))
			{
				eSrc.target="_top";
				eSrc.href = newToc();
				return;
			}
			else if ("clsShowHide" == eSrc.className || "clsShowHideShowing" == eSrc.className || "clsTocHeading" == eSrc.className)
                return contentsHeading_click(eSrc);
			else if("showAll" == eSrc.id) 
                return eSrc.target = "TOC";
            else if ("clsItemsShow" == eSrc.className) //jm
                return "";
			eSrc = eSrc.parentElement;
		}
   		window.event.cancelBubble = false;

	}

	function showSelected()
	{
		if (null != eSelected)
		{
			if (eSelected.offsetTop > document.body.offsetHeight) getContainer(eSelected).scrollIntoView();
		}
	}

	function window_load()
	{
	   showSelected();
	}

	// --------------------------------------------------------------
	// Accessibility routines based on Windows Explorer functionality
	// --------------------------------------------------------------

	function document_keyup()
	{
		var iKey = window.event.keyCode;

		// only trap arrow keys
		if (iKey < DHTML_ARROW_MIN || iKey > DHTML_ARROW_MAX)
		{
			return;
		}

		// BUGBUG: IE4 returns BODY instead of element with the focus. Use event object instead
		//var oActive = document.activeElement;
		var oActive = window.event.srcElement;

		// Handle up/down regardless of the type of selected anchor
		// Handle right/left differently dependent on section / article level
		if (DHTML_UP_ARROW == iKey || DHTML_DOWN_ARROW == iKey)
		{
			//HandleUpDown(iKey, oActive); // disabled for IE5B2 because it conflicts with scrollbar
		}
		else if ('clsTocItem' == oActive.className || ('clsTocHeading' == oActive.className && "noexpand" == oActive.parentElement.className && "clsNoExpand" != oActive.parentElement.className))
		{
			// handle articles and headings that don't expand/collapse
			HandleKeyForItem(oActive, iKey);
		}
		else if ('clsTocHeading' == oActive.className)
		{
			// handle headings that expand/collapse
			HandleKeyForHeading(oActive, iKey);
		}

		return;
	}

	// handle up and down arrow keys
	function HandleUpDown(iKey, oActive)
	{
		var iIndex = oActive.sourceIndex;

		// Handling of down and up arrow is identical regardless of what type of element (section / article) has focus
		if (DHTML_UP_ARROW == iKey)
		{
			// handling is identical regardless of expand/collapse state of heading
			// assert(document.links.length > 0);
			while (iIndex >= document.links(0).sourceIndex)
			{
				var oTemp = document.all(--iIndex);
				// walk backwards until the next visible anchor is found
				if (oTemp.className == "clsTocItem" || oTemp.className == "clsTocHeading")
				{
					// make sure the element is part of a visible list
					// only necessary when navigating from section to article
					if (oTemp.parentElement.parentElement.className != "clsItemsHide")
					{
						oTemp.focus();
						break;
					}
				}

			}
		}
		else if (DHTML_DOWN_ARROW == iKey)
		{
			// Set focus to the next visible link or section
			while (iIndex <= document.links(document.links.length-1).sourceIndex)
			{
				var oTemp = document.all(++iIndex);
				if ((oTemp.className == "clsTocHeading" || oTemp.className == "clsTocItem") && oTemp.parentElement.parentElement.className != "clsItemsHide")
				{
					oTemp.focus();
					break;
				}
			}
		}
	}


	function HandleKeyForItem(oItem, iKey)
	{
		// left-arrow from a child node travels up to the parent node (not the sibling)
		if (iKey == DHTML_LEFT_ARROW)
		{
			// if the user hits the left arrow on an item, set the focus to the immediate parent
			// just like Windows Explorer
			oItem.parentElement.parentElement.parentElement.children(0).focus();
		}
	}

	// Handle keyboard action on a section
	function HandleKeyForHeading(oActive, iKey)
	{
		// Need to add code to handle
		// - up arrow: select previous item or section. Ensure that item is displayed
		// - down array: select next item or section. Ensure that item is displayed. Otherwise choose next section

		//window.event.cancelBubble = true;
		var oParent = oActive.parentElement;

		if (oParent.className=="clsShowHide" || oParent.className=="clsShowHideShowing")
		{
			if ('clsItemsHide' == oParent.children(1).className)
			{
				if (DHTML_RIGHT_ARROW == iKey)
				{
					contentsHeading_click(oActive);
				}
				else if (DHTML_LEFT_ARROW == iKey)
				{
					// navigate to the previous parent section heading if any
					if (oParent.parentElement.className != 'clsItemsShow')
					{
						return;
					}

					// A->LI->UL->LI->A
					var oParentHeading = oParent.parentElement.parentElement.children(0);
					oParentHeading.focus();
				}
			}
			else if ('clsItemsShow' == oParent.children(1).className)
			{
				if (DHTML_LEFT_ARROW == iKey)
				{
					contentsHeading_click(oActive);
				}
				else if (DHTML_RIGHT_ARROW == iKey)
				{
					// would be much simplified if I could simulate a tab key...
					// set focus to the next section or article
					// A->LI->UL->LI->A
					oParent.children(1).children(0).children(0).focus();
				}
			}
		}
	}

	document.onmouseover = document_mouseover;
	document.onmouseout = document_mouseout;
	document.onclick = document_click;
	document.onkeyup = document_keyup;
	window.onload = window_load;

	//---------------------------------------------------------
	// PRE-LOAD GRAPHICS
	//---------------------------------------------------------

	var aImg = new Array(2);
	var iNumImg = aImg.length
	for(var i=0;i<iNumImg;i++) aImg[i] = new Image();

	aImg[0].src = "/images/plus.gif";
	aImg[1].src = "/images/minus.gif";

	//-------------------------------------------------------------------------
	//	"SYNC" UP TOC WITH DOCUMENT
	//-------------------------------------------------------------------------

	var cLinks = document.links;
	var iNumLinks = cLinks.length;

	// MATTO: pulled this condition outside of inner loop since sCurrentDoc never changes. only test once
	if (""  != sCurrentDoc)
	{
		for (var i=0;i<iNumLinks;i++)
		{
			var eSrc = cLinks[i];

			// MATTO: convert toLower since no guarantees that URL is in the same case since TOCs are hand-authored
			var sTempHref = eSrc.href.toLowerCase();

			// MATTO: is clsBucketName ever used?? if articles always use clsTocItem test positive rather than negative
			if(sTempHref.indexOf(sCurrentDoc) > -1 && "clsBucketName" != eSrc.className)
			{
				eSrc.className = "clsTocItemSelect";
				// BUGBUG: eSrc.style.fontWeight = "bold";
				eSelected = eSrc;
				if("noexpand" != eSelected.parentElement.className && "clsNoExpand" != eSelected.parentElement.className)
				{
					for (var a=eSrc.sourceIndex-1;a>0;a--)
					{
						var eTemp = document.all[a];
						if ("clsItemsHide" == eTemp.className) eTemp.className = "clsItemsShow";
						if ("clsTocHeading" == eTemp.className) {
							eTemp.parentElement.className = "clsShowHideShowing";
							break;
						}
					}
				}
			  eSelected = eSrc;
			  break;
			}
		}
	}

function onReply(id)
{
    Topic.style.display = "none";
    reply.style.display = "block";
    reply.scrollIntoView();
    reply.id.value = id;
    var sub = document.all(id+"Tit").innerText;
    reply.sub.value = "Re: "+sub;
    reply.sub.focus();
//	MAPIObj.Logoff();
}

function onNewConv()
{
    window.event.srcElement.style.display = "none";
    Topic.style.display = "block";
    reply.style.display = "block";
    reply.scrollIntoView();
    reply.top.focus();
}

function onSendReply()
{
    if (reply.snd.value=="Update")
    {
         return true;
    }
    window.event.returnValue = false;
/*
    if (Topic.style.display == "block")
    {
        var str = reply.top.value;
        str = str.replace("\s","");
        if (str == "")
        {
            alert("Topic: field cannot be blank");
            reply.top.focus();
            return false;
        }

    }
*/

    var str = reply.usr.value;
    str = str.replace("\s","");
    if (str == "")
    {
        alert("From: field cannot be blank");
        reply.usr.focus();
        return false;
    }

    str = reply.sub.value;
    str = str.replace("\s","");
    if (str == "")
    {
        alert("Subject: field cannot be blank");
        reply.sub.focus();
        return false;
    }
    window.event.returnValue = true;

}

function onPageInit()
{
	if(window.navigator.userAgent.indexOf('MSIE')<0)
		return;
    var l = document["reply"].show.value;
//	alert("onPageInit"+l.tagName);
	if (l==""||l==null)
	{
		var a = window.location.toString().split("?");
		if (a.length>1)
		{
			a = a[1].split("=");
			for (i=0; i<a.length; i++)
			  if (a[i++]=="show")
				l=document.all.item(a[i]);
		}
	}
    if (l!=null&&l!=""&&l!="undefined")
	{
//        alert(l);
		var i = document.all.item(l);
		showItem(i);
        i.scrollIntoView();
	}
}

function showItem(l)
{
//    alert(l.parentElement.tagName);
	if ("BODY" != l.parentElement.tagName.toUpperCase())
        showItem(l.parentElement);
    if ("clsItemsHide" == l.className)
        l.className = "clsItemsShow";
    else if ("clsShowHide" == l.className)
        l.className = "clsShowHideShowing";
}

function onEditText(id)
{
    var sub = document.all(id+"Tit");
    var u = document.all(id+"Usr").innerText;
//    alert(id+"Usr");
    if (u==null)
        u = "";
//    alert(u);
    var v = reply.usr.value;
//    alert(v);
    u = u.replace(/\s/g, "");
    v = v.replace(/\s/g, "");
    if (u != v)
        return;
    reply.style.display = "block";
    reply.id.value = id;
    if (sub != null)
        reply.sub.value = sub.innerText;
    var t = document.all(id+"Txt");
    if (t != null)
    {
        var txt = t.innerHTML;
        txt =  txt.replace(/</g, "<<");
        txt =  txt.replace(/>/g, ">>");
        reply.txt.value = txt;
    }
    reply.snd.value = "Update";
    reply.scrollIntoView();
    reply.sub.focus();
}

function NoOp()
{
//    alert("NoOP");
}

//interval = window.setInterval("colorChange();", 100);
var dir=1;
var ch=1;
var cdir=1;
function SetGlow()
{
//  alert("SetGlow");
/*
  var gl=SubTit.filters.Glow.strength;
  
  SubTit.filters.Glow.strength += dir;
  alert(SubTit.filters.item(0).color);
  SubTit.filters[0].color += dir*2;
*/

  if (gl==7 || gl==1)
	dir *= -1;
}

var bkc=0, bki;
function colorChange()
{  
  col = Math.random()*0xffffff;
/*
  T1.style.color = col;
  T2.style.color = Math.random()*0xffffff;
  T3.style.color = Math.random()*0xffffff;
  T4.style.color = Math.random()*0xffffff;
  T5.style.color = Math.random()*0xffffff;
  T6.style.color = Math.random()*0xffffff;
  T7.style.color = Math.random()*0xffffff;
  T8.style.color = Math.random()*0xffffff;
*/
  var it = document.all.item("T"+ch);
  if (it != null)
  {
	if (bkc!=0)
	{
		bki.style.color = bkc;
		bki.filters.Glow.strength = 1;
	}
	bki = it;
	bkc = it.style.color;
	it.style.color = col;
	alert(it.filters.length);
	
//    it.filters.item(0).strength = 2;
//	alert(it.filters);

  }
 if (ch==str.length-1 || ch==0)
	cdir *= -1;
  do
	ch += cdir;
  while (ch<str.length && ch>=0 && str.charAt(ch)==" ");
  SetGlow();
}

