var changeOrgWindow;

function getTimeZoneOffset() 
{ 
	var time = new Date();
	var offset = -(time.getTimezoneOffset());
	return offset; 
} 

function setTimeZoneCookie() 
{ 
	var cookies = document.cookie;
	if (cookies.indexOf("timezone=") == -1)	
	{
		document.cookie = 'timezone=' + getTimeZoneOffset() + ";path=/";
	}
} 

function AssignClickHooks()
{
	var arrayDivs = window.document.all["expandCollapseDiv"];
	var div = window.document.getElementById("expandCollapseDiv");
	if (null != arrayDivs && div != null)
	{
		var len = arrayDivs.length;
		var i =0;
		if (len > 1)
		{
			for(i=0; i < len ; i++)
			{
				arrayDivs[i].onclick = MonitorClicks;
			}
		}
		else
			div.onclick = MonitorClicks;		
	}
	ExpandFirstDyamicSpotGraphic();
}

function MonitorClicks()
{		
	CollapseExpand(this);	
}

function ExpandFirstDyamicSpotGraphic()
{	
	var arrayDivs = window.document.all["expandCollapseDiv"];
	if (null != arrayDivs)
	{
		var len = arrayDivs.length;
		var i =0;
		for(i=0; i < len ; i++)
		{
			if (i == 0)
			{
				arrayDivs[i].nextSibling.style.visibility = "visible";
				arrayDivs[i].nextSibling.style.display = "";
				var imageVisible = arrayDivs[i].firstChild.firstChild.firstChild.childNodes[1].firstChild;
				imageVisible.style.visibility = "visible";
				imageVisible.style.display = "";
				var imageHidden = arrayDivs[i].firstChild.firstChild.firstChild.childNodes[1].childNodes[1];
				imageHidden.style.visibility = "hidden";
				imageHidden.style.display = "none";	
			}
			else
			{		
				arrayDivs[i].nextSibling.style.visibility = "hidden";
				arrayDivs[i].nextSibling.style.display = "none";
				var imageVisible = arrayDivs[i].firstChild.firstChild.firstChild.childNodes[1].firstChild;				
				imageVisible.style.visibility = "hidden";
				imageVisible.style.display = "none";				
				var imageHidden = arrayDivs[i].firstChild.firstChild.firstChild.childNodes[1].childNodes[1];				
				imageHidden.style.visibility = "visible";
				imageHidden.style.display = "";	
			}	
		}
	}
	//var root = document.getElementById("rootDiv");
	/*var arrayDivs = window.document.all["expandCollapseDiv"];
	for
	if (null != arrayDivs && null != arrayDivs[0])
		InitiateVisibleState(arrayDivs[0]);	
		*/
	//var innerDiv = root.firstChild.firstChild.firstChild.firstChild.firstChild;
		
}
function CollapseExpand(control)
{		
	var nextSibling = control.nextSibling;			
	var state = nextSibling.style.visibility;
	if (state == "visible")
	{				
		nextSibling.style.visibility = "hidden";
		nextSibling.style.display = "none";
		var imageVisible = control.firstChild.firstChild.firstChild.childNodes[1].firstChild;				
		imageVisible.style.visibility = "hidden";
		imageVisible.style.display = "none";				
		var imageHidden = control.firstChild.firstChild.firstChild.childNodes[1].childNodes[1];				
		imageHidden.style.visibility = "visible";
		imageHidden.style.display = "";
	}
	else if (state == "hidden")
	{				
		nextSibling.style.visibility = "visible";
		nextSibling.style.display = "";
		var imageVisible = control.firstChild.firstChild.firstChild.childNodes[1].firstChild;
		imageVisible.style.visibility = "visible";
		imageVisible.style.display = "";
		var imageHidden = control.firstChild.firstChild.firstChild.childNodes[1].childNodes[1];
		imageHidden.style.visibility = "hidden";
		imageHidden.style.display = "none";		
	}			
}	
	

function setTimezoneCookie()
{
	document.cookie = 'timezone=' + getTimeZoneOffset() + ";path=/";
}

function submitEditPage(submitPageUrl)
{
	//does the URL contain the query string separator
	//if the URL doesn't contain the question mark then add it
	if( submitPageUrl.indexOf("?") == -1 )
	{
		submitPageUrl = submitPageUrl + "?";
	}

	if( submitPageUrl.lastIndexOf("&") != submitPageUrl.length - 1 && submitPageUrl.lastIndexOf("?") != submitPageUrl.length - 1 )
	{
		submitPageUrl = submitPageUrl + "&";
	}

	submitPageUrl = submitPageUrl + "timezone=" + getTimeZoneOffset();

	

	openWindow(submitPageUrl);
}

function openWindow(pageUrl)
{

	window.open(pageUrl, "editPageWindow");
}

function DoHover()
{
	var objTargetElement = event.srcElement.Competency;
	var objAction = event.srcElement;
	var targetElem = objTargetElement;
	
	var bCancelBubble = false;
	
	if ( ( ( event.srcElement.tagName == "A")||
			( event.srcElement.tagName == "IMG")
		  ) && 
		 (event.srcElement.parentElement.Competency != null))
	{
		bCancelBubble = true;
		targetElem = event.srcElement.parentElement.Competency;
	}
		 
	if ( null == objTargetElement )
	{
		 if (null == event.srcElement.parentElement.Competency)
			return;
	}
		
		if ( bCancelBubble == true)
			{
			objAction.parentElement.style.backgroundColor = "#FF9900";
			objAction.parentElement.style.color = "#FFFFFF";
			}		
		else
			{
			objAction.style.backgroundColor = "#FF9900";
			objAction.style.color = "#FFFFFF";
			
			var nLen = objAction.children.length;
			var i=0;
			for ( i=0; i < nLen; i++)
			{
				objAction.children[i].style.color = "#FFFFFF";
				objAction.children[i].backgroundColor = "#FF9900";
			}
			
				//objAction.lastChild.style.color = "#FFFFFF";
			}	
		
			if ( null != targetElem)
			{
				if ( null != document.all[targetElem].style)
				{
					document.all[targetElem].style.fontFamily = "verdana, sans-serif";
					document.all[targetElem].style.fontSize	= ".7em";		
					document.all[targetElem].style.color = "#FFFFFF";
					document.all[targetElem].style.display = "";
				}
			}
		
		
		if ( bCancelBubble == true)
		{
			event.returnValue = false;
			event.cancelBubble = true;
		}
		
	//event.cancelBubble = false;	
	
	return true;
}

function UndoHover()
{
	var objTargetElement = event.srcElement.Competency;
	var objAction = event.srcElement;
	var targetElem = objTargetElement;
	
	//var objParentElement = event.srcElement.parentElement.Competency;

	var bCancelBubble = false;
	
	if ( ( ( event.srcElement.tagName == "A")||
			( event.srcElement.tagName == "IMG")
		  ) && 
		 (event.srcElement.parentElement.Competency != null))
	{
		bCancelBubble = true;
		targetElem = event.srcElement.parentElement.Competency;
	}
		 
	if ( null == objTargetElement )
	{
		 if (null == event.srcElement.parentElement.Competency)
			return;
	}
		
	if ( bCancelBubble == true)
		{
			objAction.parentElement.style.backgroundColor = "";
		}	
	else
		{
			objAction.style.backgroundColor = "";
			objAction.style.color = "";	
			
			var nLen = objAction.children.length;
			var i=0;
			for ( i=0; i < nLen; i++)
			{
				objAction.children[i].style.color = "";
				objAction.children[i].backgroundColor = "";
			}
			
			//objAction.lastChild.style.color = "";
		}	
			
	if ( null != targetElem)
	{	
		if ( null != document.all[targetElem].style)
		{
			document.all[targetElem].style.display = "none";

		}
	}
			
	if ( bCancelBubble == true)
		{
			event.returnValue = false;
			event.cancelBubble = true;
		}

	return true;
}

function openChangeLocation()
{
	if (changeOrgWindow != null)
		changeOrgWindow = null;
   
    changeOrgWindow = window.open(baseVsName, "ChangeOrgWindow", "width=320,height=320");
   
    if(event != null)
    {
        event.returnValue = false;
    }

    return false;
}

function updateOrganization(orgId)
{
    if(changeOrgWindow != null)
    {
        changeOrgWindow.close();

        changeOrgWindow = null;
    }

    if(orgId != null)
    {
		var currentURL = window.location.href;
		var lastIndex = currentURL.length;
		if(lastIndex > 1 && currentURL.charAt(lastIndex-1) == '#')
		{
			currentURL = currentURL.substring(0, lastIndex-1);
		}
		var url = currentURL.replace('?mode=refresh','');
		window.location = url; 	
    }
}

//change background image of competency home page header by graphic widget
function AssignBaseURL_CompetencyHomePage()
{
	var table_el = document.getElementById("changeBackground_table");
	if (table_el != null)
	{
		var resourceattr = table_el.getAttribute("backgroundNew");
		if (resourceattr != null && resourceattr.length > 0)
			table_el.setAttribute("background",baseURL+"/binary/"+resourceattr);
			//table_el.setAttribute("background",baseURL+"/REData/getbinary?RID="+resourceattr);		
	}	
}

//This function is called to toggle the disable and enable of combo box in portal search
function toggleCategoryCombo(toggle)
{
	var catDropDown = window.document.getElementById("CategoryComboBox");
	if (catDropDown != null)
	{
		if (toggle == true)
			catDropDown.disabled = false;
		else if (toggle == false)
			catDropDown.disabled = true;
	}
}

// Top header nav code
function mhHover(tbl,idx,cls)
{
	var t,d;
	if(document.getElementById)
		t=document.getElementById(tbl);
	else 
		t=document.all(tbl);
	if(t==null)
		return;
	if(t.getElementsByTagName)
		d=t.getElementsByTagName("TD");
	else 
		d=t.all.tags("TD");
	if(d==null)
		return;
	if(d.length<=idx)
		return;
	d[idx].className=cls;
}



var menuKill;
var menuCreate;
var openedSubMenuId;
var menuTimeout = 300;

	function MenuDrawBackground(subchildmenu)
	{
	/*
		var x = subchildmenu.parentElement.scrollWidth;
		
		subchildmenu.style.width = x - 5;
		subchildmenu.style.background = "#CCCCCC";
		subchildmenu.style.borderColor = "#999999";
		subchildmenu.style.borderWidth = "1px";	
		subchildmenu.style.borderStyle = "solid";
		
		subchildmenu.style.paddingTop  = "2px";
		subchildmenu.style.paddingBottom = "2px"; 
		subchildmenu.style.marginRight = "2px";
	*/
		HighlightCell(subchildmenu);
	}
	
	function ClearBackground(subchildmenu)
	{
		ResetCell(subchildmenu);
	}

	function sendToTarget(url, isPopUp)
	{
		if(url != null)
		{
			if(isPopUp)
			{
				window.open(url);			
			}
			else
			{		
				document.location = url;
			}
		}		
		event.cancelBubble=true;
	}

//******************************************************************************
//
//  Show sub menu functions
//
//******************************************************************************

	function MenuEnter(submenu)
	{
		elementLeft = event.fromElement;
		elementEntered = event.srcElement;
		if (openedSubMenuId != null && submenu.id == openedSubMenuId)
		{
			if (menuKill != null)
			{
				window.clearTimeout(menuKill);
				menuKill = null;
			}
			return;
		}
		if( elementLeft != undefined && elementEntered != undefined )
		{
			if( ShouldShowMenu(submenu, elementEntered, elementLeft) )
			{
//				if(menuKill)
//				{
					//HighlightMultiCellRow(submenu.parentElement.parentElement);
					//window.clearTimeout(menuKill);
			
//					menuKill = null;
//				}
			}
		}
	}

	function showMenu(submenu)
	{
		elementLeft = event.fromElement;
		elementEntered = event.srcElement;

		if( elementLeft != undefined && elementEntered != undefined )
		{
			if( ShouldShowMenu(submenu, elementEntered, elementLeft) )
			{
				var ParentMenuItem = window.document.all["LeftNavMenu"];	
			
				submenu.style.position = 'absolute';
//				submenu.style.position = 'relative';				
				containingRow = submenu.parentElement.parentElement;
					
				containingRow.isActive = true;
		
				//if the menu being shown is a child of a first level element
				// calculate the absolute 
//				alert(submenu.parentElement.id.indexOf("parent_"));
				if(submenu.parentElement.id.indexOf("parent_") != -1)
				{
					if ((ParentMenuItem.clientWidth) != null)
						submenu.style.left = parseInt(ParentMenuItem.clientWidth) +1;
					// Counting the height of the site header and calculating top value
					submenu.style.top = getAbsoluteXOffset(submenu.parentElement) - 125;
				}
				else
				{
					var x = submenu.parentElement.parentElement.scrollWidth;
		
					submenu.style.left = x;
			
					submenu.style.top = submenu.parentElement.parentElement.offsetTop - 2;
				}
				
				var el = submenu.parentElement.parentElement;
				while (el != null && el.className != "MenuRow")
				{
					if (el.id.indexOf("row") != -1)
					{
						HighlightMultiCellRow(el);
					}
					el = el.parentElement;
				}

				if (openedSubMenuId != null && submenu.id == openedSubMenuId)
				{
					if (menuKill != null)
					{
						window.clearTimeout(menuKill);
						menuKill = null;
					}
					return;
				}
		
				menuCreate = window.setTimeout("drawSubMenu(" + submenu.id + ");", menuTimeout);
			}
		}
	}

	function ShouldShowMenu(submenu, toElement, fromElement)
	{
		if( submenu != undefined && toElement != undefined && fromElement != undefined )
		{
			if( IsRowRelative(submenu, toElement)  && !IsParentRowActive(submenu))
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		return false;
	}

	function drawSubMenu(submenu)
	{
//		if(submenu.style.display == "none")
		if(submenu.style.display == "none" && (openedSubMenuId == null || openedSubMenuId.indexOf('parent') != -1))
		{
			showHideMenu(submenu, true);
			if(submenu.style.width == "")
			{
				submenu.style.width = submenu.scrollWidth + 8;
			}
		}
		menuCreate = null;
	}

//******************************************************************************
//
//  Kill sub menu functions
//
//******************************************************************************

	function MenuLeave(submenu)
	{
		elementLeft = event.srcElement;
		elementEntered = event.toElement;
		if( elementLeft != undefined) // && elementEntered != undefined)
		{
			if( ShouldKillMenu(submenu, elementEntered, elementLeft) )
			{
				if(menuCreate)
				{
					window.clearTimeout(menuCreate);
					menuCreate = null;
				}
				
				ResetMultiCellRow(submenu.parentElement.parentElement);
			
				submenu.parentElement.parentElement.isActive = false;
		
				menuKill = window.setTimeout("killsubmenu(" + submenu.id + ");", menuTimeout);
			}
		}
	}

	function getContainer(node)
	{
		var pNode = node.parentNode;
		if (node.tagName=="TR" && node.id != '')
			return node;
		
		while(true)
		{	
			if (pNode == undefined)
				return node;
			if (pNode.tagName=="TR" && pNode.id != '')
				return pNode;
			pNode = pNode.parentNode;
		}
		return node;
	}

	function ShouldKillMenu(submenu, toElement, fromElement)
	{
		if( submenu != undefined && toElement != undefined && fromElement != undefined )
		{
			// if the toElement is an anchor and the from
			// element is a table cell and a parent of the anchor
                	// and the submenu is active
                	// then return true
			var toNode = getContainer(toElement);
			var fromNode = getContainer(fromElement);
			
			if (toNode.tagName != 'TR' || toNode.id=='')
				return true;
			if (toNode.parentElement.parentElement.id == 'LeftNavMenu'
			&& fromNode.parentElement.parentElement.id != 'LeftNavMenu'
			&& submenu.id.indexOf('parent') ==-1)
				return true;			

			var s1, s2;
			s1 = toNode.id.split('_')[0];
			s2 = fromNode.id.split('_')[0];
			//alert(s1 + ' ' + s2);
			//alert(fromNode.children[0].className + ' ' + toNode.children[0].className);
			if (toNode.outerHTML.indexOf(fromNode.id) != -1
			|| fromNode.outerHTML.indexOf(toNode.id) != -1	)
				return false;
			else if (s1 == s2 
			&& (toNode.parentElement.parentElement.id == submenu.id )
			&& toNode.parentElement.parentElement.id != 'LeftNavMenu')
				{
					return false;
					// How do I know if I'm at the end menu;
				}
			else if (toNode.children[0].id.indexOf('sub') != -1)
				return false;
			else if (toNode.parentElement.parentElement.id == submenu.id)
				return false;
			else			
				return true;
			//return !IsParentRowActive(submenu);
		}

		return true;
	}
	
	function killsubmenu(submenu)
	{
		if( submenu != null && menuKill != null )
		{
			submenu.style.background  = "#F1F1F1";
			submenu.style.borderColor = "#999999";

			showHideMenu(submenu, false);
			
		if ((submenu.id.indexOf('child') == -1) )
			showHideAllElements("SELECT", true);
		
		}
	}

//******************************************************************************
//
//  Navigation overlap functions
//
//******************************************************************************

function showHideMenu(menu, show)
{
	if (null == menu) return;

	if (show && menu.style.display == "none")
//>	if (show && menu.style.visibility == "hidden")
	{
		menu.style.display = "";
	}

	var el = menu;
	var posLeft = 0;
	var posTop = 0;
	while (el)
	{
		posLeft += el.offsetLeft;
		posTop += el.offsetTop;
		el = el.offsetParent;
	}
	var posRight = posLeft + menu.offsetWidth;
	var posBottom = posTop + menu.offsetHeight;
	if (show)
	{
		showHideElements("SELECT", false, posLeft, posTop, posRight, posBottom);
		openedSubMenuId = menu.id;
	}
	else
	{
		showHideElements("SELECT", true, posLeft, posTop, posRight, posBottom);
		if (menu.id.indexOf("child") != -1)
		{
			openedSubMenuId = menu.parentElement.parentElement.parentElement.parentElement.id;
		}
		else
		{
			openedSubMenuId = null;
		}

		if (menu.style.display != "none")
//>		if (menu.style.visibility != "hidden")
		{
			menu.releaseCapture();

			menu.style.display = "none";
		}
		if (menu.id != "LeftNavMenu")
		{
			var mainMenu = window.document.all["LeftNavMenu"];
			
			if ( null == mainMenu) return;
			
			el = mainMenu;
			posLeft = 0;
			posTop = 0;
			while (el)
			{
				posLeft += el.offsetLeft;
				posTop += el.offsetTop;
				el = el.offsetParent;
			}
			posRight = posLeft + mainMenu.offsetWidth;
			var posBottom = posTop + mainMenu.offsetHeight;
			showHideElements("SELECT", false, posLeft, posTop, posRight, posBottom);

		}

	}
}

function showHideAllElements(elementName, show)
{
	var allElements = window.document.all.tags(elementName);
	if (allElements != null)
	{
		for (i = 0; i < allElements.length; i++)
		{
			if (show && allElements[i].style.visibility == "hidden")
			{
				allElements[i].style.visibility = "inherit";
			}
			else if (!show && allElements[i].style.visibility != "hidden")
			{
				allElements[i].style.visibility = "hidden";
			}
		}
	}
}

function showHideElements(elementName, show, areaLeft, areaTop, areaRight, areaBottom)
{
	var allElements = window.document.all.tags(elementName);
	if (allElements != null)
	{
		for (i = 0; i < allElements.length; i++)
		{
			var el = allElements[i];
			var selectLeft = 0;
			var selectTop = 0;
			while (el)
			{
				selectLeft += el.offsetLeft;
				selectTop += el.offsetTop;
				el = el.offsetParent;
			}
			var selectRight = selectLeft + allElements[i].offsetWidth;
			var selectBottom = selectTop + allElements[i].offsetHeight;
			if (show && allElements[i].style.visibility == "hidden"
				&& areOverlappingRectangles(areaLeft, areaTop, areaRight, areaBottom, selectLeft, selectTop, selectRight, selectBottom) )
			{
				allElements[i].style.visibility = "inherit";
			}
			else if (!show && allElements[i].style.visibility != "hidden"
				&& areOverlappingRectangles(areaLeft, areaTop, areaRight, areaBottom, selectLeft, selectTop, selectRight, selectBottom) )
			{
				allElements[i].style.visibility = "hidden";
			}
		}
	}
}

function areOverlappingRectangles(
	rect1Left, rect1Top, rect1Right, rect1Bottom, 
	rect2Left, rect2Top, rect2Right, rect2Bottom)
	{
		var maxLeft = Math.max(rect1Left, rect2Left);
		var minRight = Math.min(rect1Right, rect2Right);
		var maxTop = Math.max(rect1Top, rect2Top);
		var minBottom = Math.min(rect1Bottom, rect2Bottom);
		if (maxLeft >= minRight || maxTop >= minBottom)
		{
			return false;	// rectangles do not overlap
		}
		else
		{
			return true;	// rectangles overlap
		}
	}	

//******************************************************************************
//
// Absolute positioning functions
//
//******************************************************************************
	function getAbsoluteXOffset(element)
	{
		offset = 0;
		
		if(element != null)
		{
			sacSub = element;
			
			while(sacSub.parentElement.nodeName != "BODY")
			{
				if(sacSub.parentElement.currentStyle.position == 'absolute')
				{
					break;
				}
				
				offset += sacSub.parentElement.offsetTop;
				
				sacSub = sacSub.parentElement;
			}

			offset += element.offsetParent.offsetTop;
		}

		return offset;
	}

	function getAbsoluteYOffset(element)
	{
		offset = 0;
		
		if(element != null)
		{
			sacSub = element;
			
			while(sacSub.parentElement.nodeName != element.offsetParent.nodeName)
			{
				if(sacSub.parentElement.style.position == 'absolute')
				{
					break;
				}
				
				offset += sacSub.parentElement.offsetLeft;
				
				sacSub = sacSub.parentElement;
			}
			
			offset += element.offsetParent.offsetLeft;
		}
		
		return offset;
	}

//******************************************************************************
//
// Element coloring functions
//
//******************************************************************************
	function borderize_on(e)
	{
		if (document.all)
		{
			source3=event.srcElement;
		}
		else if (document.getElementById)
		{
			source3=e.target;
		}
		
		if (source3.className=="menulines")
		{
			borderize(source3,"black");
		}
		else
		{
			while(source3.tagName!="TABLE")
			{
				source3=document.getElementById? source3.parentNode : source3.parentElement;
				if (source3.className=="menulines");
				borderize(source3,"black");
			
			}
		}
	}

	function borderize_off(e)
	{
		if (document.all)
		{
			source4=event.srcElement;
		}
		else if (document.getElementById)
		{
			source4=e.target;
		}
		
		if (source4.className=="menulines")
		{
			borderize(source4,"#E6E6E6");
		}
		else
		{
			while(source4.tagName!="TABLE")
			{
				source4=document.getElementById? source4.parentNode : source4.parentElement;
				if (source4.className=="menulines");
				borderize(source4,"#E6E6E6");
			}
		}
	}

	function borderize(what,color)
	{
		what.style.borderColor=color
	}

	function HighlightMultiCellRow(parentTr)
	{
		var borderTop = "solid #F1F1F1 1px";
		var borderRight;
		var borderBottom = borderTop;
		var borderLeft;
		
		if(parentTr != null  && parentTr.children.length > 0 &&
		   parentTr.children[0].style.background  != "#cccccc"  )
		{
			for(childIndex = 0 ; childIndex < parentTr.children.length ; childIndex++)
			{
				parentTr.children[childIndex].style.background = "#cccccc";
				parentTr.children[childIndex].style.border = "0";
				
				if(childIndex == 0)
				{
					borderLeft = "solid #F1F1F1 1px";
					borderRight = "solid #cccccc 1px";
				}
				else if(childIndex == parentTr.children.length - 1)
				{
					borderLeft = "solid #cccccc 1px";
					borderRight = "solid #F1F1F1 1px";
					
					parentTr.children[childIndex].style.backgroundRepeat    = "no-repeat";
					parentTr.children[childIndex].style.backgroundPositionX = "center";
					parentTr.children[childIndex].style.backgroundPositionY = "center";
					//parentTr.children[childIndex].style.backgroundImage     = "url(arrowLTR.gif)";
				}
				else
				{
					borderRight = "solid #cccccc 1px";
					borderLeft = "solid #cccccc 1px";
				}
				
				parentTr.children[childIndex].style.borderTop    = borderTop;
				// parentTr.children[childIndex].style.borderRight  = borderRight;
				parentTr.children[childIndex].style.borderBottom = borderBottom;
				// parentTr.children[childIndex].style.borderLeft   = borderLeft;
			}
		}
	}

	function ResetMultiCellRow(parentTr)
	{
		resetBorder = "solid #F1F1F1 1px";
		
		if(parentTr != null)
		{
			for(childIndex = 0 ; childIndex < parentTr.children.length ; childIndex++)
			{
				parentTr.children[childIndex].style.background = "#F1F1F1";
				
				// add the child image background image
				if(childIndex == parentTr.children.length - 1)
				{
					parentTr.children[childIndex].style.backgroundRepeat    = "no-repeat";
					parentTr.children[childIndex].style.backgroundPositionX = "center";
					parentTr.children[childIndex].style.backgroundPositionY = "center";
					//parentTr.children[childIndex].style.backgroundImage     = "url(arrowLTR.gif)";
				}
				
				parentTr.children[childIndex].style.borderTop    = resetBorder;
				// parentTr.children[childIndex].style.borderRight  = resetBorder;
				parentTr.children[childIndex].style.borderBottom = resetBorder;
				// parentTr.children[childIndex].style.borderLeft   = resetBorder;
			}
		}
	}

	function HighlightCell(targetTd)
	{
		var highlightBorder = "solid #F1F1F1 1px";
		
		if(targetTd != null)
		{
			targetTd.style.background   = "#cccccc";				
			targetTd.style.borderTop    = highlightBorder;
			targetTd.style.borderRight  = highlightBorder;
			targetTd.style.borderBottom = highlightBorder;
			targetTd.style.borderLeft   = highlightBorder;
			var el = targetTd.parentElement;
			while (el != null && el.className != "MenuRow")
			{
				if (el.id.indexOf("row") != -1)
				{
					HighlightMultiCellRow(el);
					var sibl = el.nextSibling;
					while (sibl != null)
					{
						if (sibl.id.indexOf("row") != -1)
						{
							ResetMultiCellRow(sibl);
						}
						sibl = sibl.nextSibling;
					}
				}
				el = el.parentElement;
			}
		}
	}
	
	function ResetCell(targetTd)
	{
		resetBorder = "solid #F1F1F1 1px";
		
		if(targetTd != null)
		{
			targetTd.style.background   = "#F1F1F1";
			targetTd.style.borderTop    = resetBorder;
			targetTd.style.borderRight  = resetBorder;
			targetTd.style.borderBottom = resetBorder;
			targetTd.style.borderLeft   = resetBorder;
		}
	}

//******************************************************************************
//
//  Display management functions
//
//******************************************************************************
	function IsSubmenuActive(submenu)
	{
		if( submenu != undefined)
		{
			return submenu.style.display.toUpperCase() != "NONE";
		}
		else
		{
			return false;
		}
	}

	function IsParentRowActive(submenu)
	{
		// If the TR is not active, which is defined by the following colors, then
		// hide the menu
		if( submenu != null)
		{
			parentTr = submenu.parentElement.parentElement;

			return parentTr.isActive;
		}
		else
		{
			return false;
		}
	}

	// a row relative is an element that is a decendent of the same row.
        // 
	function IsRowRelative(submenu, element)
	{
		if(submenu != undefined && element != undefined)
		{
			parentTr = submenu.parentElement.parentElement;

			var parentElement = null;

			if(element.nodeName == "TD")
			{
				parentElement = element.parentElement;
			}
			else if(element.nodeName == "A")
			{
				parentElement = element.parentElement.parentElement;
			}

			if(parentElement != undefined)
			{
				return parentTr.id == parentElement.id; 
			}

		}

		return false;
	}

	function IsCellParentOfElement(tdElement, element)
	{
		if(tdElement != undefined && element != undefined)
		{
			elementParent = element.parentElement;
			
			return tdElement.id == elementParent.id;
		}
		else
		{
			return false;
		}
	}
	
	/* Show category full title as a tool tip */
	
	function ShowFullTitle(current, fullTitle)
	{
		if (current != null)
			current.title =  fullTitle;			
	}


function mhHover(tbl,idx,cls) { 
	var t,d; 
	if(document.getElementById) t=document.getElementById(tbl); else t=document.all(tbl); 
	if(t==null) return; 
	if(t.getElementsByTagName) d=t.getElementsByTagName("TD"); else d=t.all.tags("TD"); 
	if(d==null) return; if(d.length<=idx) return; d[idx].className=cls; 
} 

function ShowFullTitle(current, fullTitle) { 
	if (current != null) current.title = fullTitle; 
} 


function sendToTarget(url, isPopUp) { 
	if(url != null) { 
		if(isPopUp) { 
			window.open(url); 
		} else { 
//			document.location = url; 
		    parent.location.href = url;
		} 
	} 
	event.cancelBubble=true; 
}


function popupPrint (url)
{
	strURL = url;
	var win=window.open(strURL,'printPop','toolbar=0,location=0,directories=0,menubar=1,toolbar=0,resizable=1,status=0,scrollbars=1,width=640,height=480,screenX=100,screenY=100,left=100,top=100'); if (window.focus)win.focus();
}

function printClose(){
	self.print();
//	setTimeout("self.close()",500);
}

function calendarPicker(strField){
	window.open('/Secure/DatePicker.aspx?field=' + strField,'calendarPopup','width=250,height=190,resizable=yes');
}


function do_what()
{
	var what_do= confirm("Are you sure you want to cancel and miss out on the benefits of enrolling in the ISV Community Initiative?");
	if (what_do== true)
	{
		window.location="/Cancel.aspx";
	}else{
		
	}
}
