var g_CurrentJumpPopup = null;
var g_HandleDocumentBodyClick = null;
function kwiz_pl_MSOWebPartPage_OpenMenu(MenuToOpen,SourceElement)
{
    kwiz_pl_MenuHtc_hide();
	g_HandleDocumentBodyClick = HandleDocumentBodyClick;
	HandleDocumentBodyClick = null;
	MSOWebPartPage_OpenMenu(MenuToOpen,SourceElement);
	
	window.setTimeout(function(){HandleDocumentBodyClick = g_HandleDocumentBodyClick;SetBodyEventHandlers(HandleDocumentBodyClick);}, 500);
}
function kwiz_pl_FindFieldValue(fname, xmlObj)
{
	this.caption = "";
	this.value = "";
	for(var i = 0; i < xmlObj.childNodes.length; i++)
	{
		if(xmlObj.childNodes[i].getAttribute("internalname") == fname)
		{
			this.caption = xmlObj.childNodes[i].getAttribute("fieldname");
			this.value = xmlObj.childNodes[i].getAttribute("fieldvalue");
			break;
		}
	}
}

function kwiz_pl_MakeID(oMaster, nLevel, nIndex)
{
	return oMaster._wzPrefixID+"_"+nLevel+"_"+nIndex;
}
function kwiz_pl_CreateMenuOption(oMaster, oRow, oNode, wzID, wzHtml, isMenuStructure)
{
	var oIcon=document.createElement("td");
	var oLabel=document.createElement("td");
	var oAccKey=document.createElement("td");
	var oArrow=document.createElement("td");
	if(isMenuStructure != false)
		oRow.appendChild(oIcon);
	oRow.appendChild(oLabel);
	if(isMenuStructure != false)
		oRow.appendChild(oAccKey);
	if(isMenuStructure != false)
		oRow.appendChild(oArrow);
	if (oMaster._fLargeIconMode)
		oIcon.className=!oMaster._fIsRtL ? "ms-MenuUIIconLarge" : "ms-MenuUIIconRtlLarge";
	else
		oIcon.className=!oMaster._fIsRtL ? "ms-MenuUIIcon" : "ms-MenuUIIconRtL";
	oIcon.align="center";
	if(isMenuStructure != false)
	{
		if (oMaster._fCompactItemsWithoutIcons && !oNode.getAttribute("iconSrc"))
			oLabel.className=!oMaster._fIsRtL ? "ms-MenuUILabelCompact" : "ms-MenuUILabelCompactRtl";
		else
			oLabel.className=!oMaster._fIsRtL ? "ms-MenuUILabel" : "ms-MenuUILabelRtL";
		oAccKey.className="ms-MenuUIAccessKey";
		oArrow.className="ms-MenuUISubmenuArrow";
		if (!oMaster._fLargeIconMode)
		{
//			oLabel.noWrap=true;
		}
		oIcon.noWrap=true;
		oAccKey.noWrap=true;
		oArrow.noWrap=true;
		oLabel.id=oNode.id;
		if (!wzHtml) wzHtml=oNode.innerHTML;
		if (oNode.getAttribute("enabled")=="false")
		{
			oRow.disabled=true;
			oLabel.className+=" ms-MenuUIItemTableCellDisabled";
		}
		var wzIconSrc=null, wzIconAlt=null;
		if (oNode.getAttribute("checked")=="true")
			{
			wzIconSrc=oMaster._wzChkMrkPath;
			wzIconAlt="*";
			}
		else
			{
			wzIconSrc=kwiz_pl_EvalAttributeValue(oNode, "iconSrc", "iconScript");
			wzIconAlt=oNode.getAttribute("iconAltText");
			}
		var innerHtml=wzHtml;
		var sText=kwiz_pl_EvalAttributeValue(oNode, "text", "textScript");
		var sDescription=kwiz_pl_EvalAttributeValue(oNode, "description", "descriptionScript");
		var oMenuItemBody=document.createElement("div");
		if (sDescription !=null && oMaster._fLargeIconMode)
		{
			var oBold=document.createElement("B");
			var oTextSpan=document.createElement("SPAN");
			var oTextNode=document.createTextNode(sText);
			var oBr=document.createElement("BR");
			var oDescSpan=document.createElement("SPAN");
			var oDescNode=document.createTextNode(sDescription);
			//oTextSpan.setAttribute("style","white-space: nowrap;");
			oDescSpan.className="ms-menuitemdescription";
			oMenuItemBody.appendChild(oBold);
			oBold.appendChild(oTextSpan);
			oTextSpan.appendChild(oTextNode);
			oMenuItemBody.appendChild(oBr);
			oMenuItemBody.appendChild(oDescSpan);
			oDescSpan.appendChild(oDescNode);
		}
		else if (sText !=null)
		{
			var oTextSpan=document.createElement("SPAN");
			var oTextNode=document.createTextNode(sText);
//			oTextSpan.setAttribute("style","white-space: nowrap;");
			oMenuItemBody.appendChild(oTextSpan);
			oTextSpan.appendChild(oTextNode);
		}
		var htmlSpan=document.createElement("SPAN");
		htmlSpan.innerHTML=innerHtml;
		oMenuItemBody.appendChild(htmlSpan);
		if (wzIconSrc)
		{
			var oImg=document.createElement("IMG");
			SetImageSize(oMaster, oImg);
			var oImgLbl=document.createElement("LABEL");
			oIcon.appendChild(oImg);
			oLabel.appendChild(oImgLbl);
			var wzIconId=wzID+"_"+"ICON";
			oImg.id=wzIconId;
			oImg.src=wzIconSrc;
			if (wzIconAlt)
			{
				oImg.alt="";
				oImg.title="";
			}
			oImgLbl.htmlFor=wzIconId;
			oImgLbl.appendChild(oMenuItemBody);
		}
		else
		{
			if (browseris.nav || oMaster._fLargeIconMode)
			{
				var oImg=document.createElement("IMG");
				SetImageSize(oMaster, oImg);
				var oImgLbl=document.createElement("LABEL");
				oIcon.appendChild(oImg);
				oLabel.appendChild(oImgLbl);
				var wzIconId=wzID+"_"+"ICON";
				oImg.id=wzIconId;
				oImg.src="/_layouts/images/blank.gif";
				oImg.alt="";
				oImg.title="";
				oImgLbl.htmlFor=wzIconId;
				oImgLbl.appendChild(oMenuItemBody);
				if (oMaster._fLargeIconMode)
				{
					oImg.width=32;
					oImg.height=16;
				}
				else
				{
					oImg.width=16;
				}
			}
			else
			{
				oIcon.innerHTML="&nbsp;";
				oLabel.appendChild(oMenuItemBody);
			}
		}
		var wzAccKey=oNode.getAttribute("accessKeyText");
		if (wzAccKey) oAccKey.innerHTML=wzAccKey;
		kwiz_pl_SetIType(oRow, "option");
	}
	else
	{
		oLabel.innerHTML = oNode.innerHTML;
	}
}

function kwiz_pl_GetChildByTagAndId(parent, tagName, id)
{
	var elms = parent.getElementsByTagName(tagName);
	for(var i = 0; i < elms.length; i++)
	{
		if(elms[i].id == id)
			return elms[i];
	}
	return null;
}
function kwiz_pl_CreateHtmlMenuItem(menu, html)
{
	var mi=kwiz_pl_CAMOpt(menu, "", "", "");
	mi.onMenuClick = null;
	mi.innerHTML = html;
}
function  kwiz_pl_GoToLink(elm)
{
	var href = elm.forhref;
	if(href == null)
		href = elm.href;
	if(href == null)
	{
		var tds = elm.getElementsByTagName("td");
		for(var i = 0; i < tds.length, href == null; i++)
		{
			href = tds[i].getAttribute("href");;
		}
	}
	if(href == null)
        return;
  	var win = window.open(href, elm.getAttribute("target"));
}

g_CurrentTooltipTimeout = null;
function  kwiz_pl_ItemMouseOver(elm)
{
    var bClassName = elm.getAttribute("bclassname");
    if(bClassName != null)
	    elm.className = bClassName + "sel";
	if((elm != document.body.calttel) && (document.body.calttel != null))
		document.body.calttel.popup = null;
	document.body.calttel = elm;
	g_CurrentTooltipTimeout = window.setTimeout(kwiz_pl_ShowTooltip, 500);
}
function  kwiz_pl_ItemMouseOut(elm)
{
	
    var bClassName = elm.getAttribute("bclassname");
    if(bClassName != null)
	    elm.className = bClassName;
	elm.toElement = window.event.toElement;
    window.clearTimeout(g_CurrentTooltipTimeout);
    g_CurrentTooltipTimeout = null;
	kwiz_pl_SetTimeOutToHideMenu()
}

function kwiz_pl_CMenu(wzID)
{
	var m=document.getElementById(wzID);
	if (m)
	{
		m._initialized=false;
		m._oContents=null;
		m.innerHTML="";
		return m;
	}
	m=document.createElement("MENU");
	if(!m)return null;
	if(wzID)m.id=wzID;
	m.className="ms-SrvMenuUI";
	AChld(document.body,m);
	return m;
}
function kwiz_pl_CAMOpt(p,wzText,wzAct,wzISrc,wzIAlt,wzISeq,wzDesc)
{
	var mo=kwiz_pl_CMOpt(wzText,wzAct,wzISrc,wzIAlt,wzISeq,wzDesc);
	if(!mo)return null;
	kwiz_pl_AChld(p,mo);
	return mo;
}
function kwiz_pl_CMOpt(wzText,wzAct,wzISrc,wzIAlt,wzISeq,wzDesc)
{
	var mo=kwiz_pl_CMItm("option");
	if(!mo)return null;
	mo.setAttribute("text", wzText);
	mo.setAttribute("onMenuClick", wzAct);
	if (wzDesc)mo.setAttribute("description", wzDesc);
	kwiz_pl_AImg(mo,wzISrc,wzIAlt);
	if(kwiz_pl_FNEmpWz(wzISeq))mo.setAttribute("sequence",wzISeq);
	return mo;
}
function kwiz_pl_CMItm(wzType)
{
	var mi=document.createElement("SPAN");
	if(!mi)return null;
	mi.setAttribute("type",wzType);
	return mi;
}
function kwiz_pl_AImg(mi,wzISrc,wzIAlt)
{
	if(!mi)return;
	if(kwiz_pl_FNEmpWz(wzISrc))mi.setAttribute("iconSrc",wzISrc);
	if(kwiz_pl_FNEmpWz(wzIAlt))
		mi.setAttribute("iconAltText",wzIAlt);
	else
		mi.setAttribute("iconAltText","");
}
function kwiz_pl_FNEmpWz(wz)
{
	return (wz&&wz!="");
}
function kwiz_pl_AChld(p,c)
{
	if(p&&c)p.appendChild(c);
}
function kwiz_pl_OMenu(m,r,fr,ft,yoff, isMenuStructure)
{
	if(typeof(m)=="string")m=document.getElementById(m);
	if(m)
		{
			kwiz_pl_OMenuInt(m,r,fr,ft,yoff, isMenuStructure);
		}
	return false;
}
function kwiz_pl_OMenuInt(m,r,fr,ft,yoff, isMenuStructure)
{
	if(m&&!kwiz_pl_MenuHtc_isOpen(m)) kwiz_pl_MenuHtc_show(m,r,fr,ft,yoff, isMenuStructure);
}
function kwiz_pl_MenuHtc_isOpen(oMaster)
{
	if (!oMaster || !oMaster._initialized)
		return false;
	var result=kwiz_pl_IsOpen(oMaster);
	return result;
}
function kwiz_pl_MenuHtc_show(oMaster, oParent, fForceRefresh, fFlipTop, yOffset, isMenuStructure)
{
	if (!(browseris.ie55up || browseris.nav6up || browseris.safari125up))
		return false;
	kwiz_pl_MenuHtc_hide();
	g_CurrentShownElement = oParent;
	kwiz_pl_MenuHtc_init(oMaster);
	oMaster._oParent=oParent;
	oMaster._fIsRtL=kwiz_pl_IsElementRtl(oMaster._oParent);
	kwiz_pl_SetBodyEventHandlers(null);
	kwiz_pl_AssureId(oParent);
	var result=kwiz_pl_ShowRoot(oMaster, oParent, fForceRefresh, fFlipTop, yOffset, isMenuStructure);
	kwiz_pl_NavigateToMenu(oMaster);
	g_kwiz_pl_menuHtc_lastMenu=oMaster;
	if (browseris.ie)
	{
		if (window.event !=null)
			window.event.cancelBubble=true;
	}
	return false;
}
function kwiz_pl_GetIType(oItem)
{
	return oItem ? oItem.getAttribute("type") : null;
}
function kwiz_pl_NavigateToMenu(oMaster)
{
	var oMenu=oMaster._arrPopup[oMaster._nLevel].firstChild;
	kwiz_pl_AssureId(oMenu);
	try
	{		
		var oFirstItem=oMenu.firstChild.firstChild.firstChild;		
		oFirstItem.tabIndex=0;
		if (oFirstItem.setActive !=null)
			oFirstItem.setActive();
		else if (oFirstItem.focus !=null)
			oFirstItem.focus();
	}
	catch (e)
	{
	}
}
function kwiz_pl_ShowRoot(oMaster, oParent, fForceRefresh, fFlipTop, yOffset, isMenuStructure)
{
	kwiz_pl_UpdateLevel(oMaster, 0);
	if (fForceRefresh)
		{
		oMaster._oContents=null;
		oMaster._oRoot=null;
		oMaster._nLevel=0;
		oMaster._arrPopup=new Array();
		oMaster._arrSelected=new Array();
		}
	else
		{
		oMaster._oRoot=oMaster._oContents;
		}
	var y=0;
	if (oParent) y+=oParent.offsetHeight;
	if (browseris.safari)
	{
		if (oParent.tagName=="TR" && oParent.childNodes.length > 0)
		{
			y+=(oParent.childNodes[0].offsetTop+oParent.childNodes[0].offsetHeight
				- oParent.offsetTop);
		}
	}
	if (yOffset) y+=yOffset;
	fFlipTop=fFlipTop !=false;
	kwiz_pl_MenuHtcInternal_Show(oMaster, oParent, y, fFlipTop, isMenuStructure);
}
function kwiz_pl_AssureId(obj)
{
	if (obj.id==null || obj.id=="")
		obj.id="msomenuid"+kwiz_pl_GetUniqueNumber();
	return obj.id;
}
function kwiz_pl_FIsIType(oItem, wzType)
{
	return kwiz_pl_FIStringEquals(kwiz_pl_GetIType(oItem), wzType);
}
function kwiz_pl_FIStringEquals(wzX, wzY)
{
	return wzX !=null && wzY !=null && wzX.toLowerCase()==wzY.toLowerCase();
}
function kwiz_pl_FIsIHidden(oItem)
{
	if (oItem)
	{
		var hiddenFunc=oItem.getAttribute("hidden");
		if (!hiddenFunc) return false;
		return eval(hiddenFunc);
	}
	else
		return false;
}
function kwiz_pl_FixUpMenuStructure(oMaster)
{
	var menuNodes=oMaster._oRoot.childNodes;
	var lastGroupId=null;
	var lastMenuSeparatorRow=null;
	for (var nIndex=0; nIndex < menuNodes.length; nIndex++)
	{
		var menuRow=menuNodes[nIndex];
		if (menuRow.nodeType !=1)
			continue;
		var deleteRow=false;
		var displayNone=menuRow.style !=null && menuRow.style.display=='none';
		var jsHidden=kwiz_pl_FIsIHidden(menuRow);
		if (displayNone || jsHidden)
		{
			deleteRow=true;
		}
		else if (kwiz_pl_FIsIType(menuRow, "separator"))
		{
			if (lastMenuSeparatorRow !=null || nIndex==0)
				deleteRow=true;
			else
				lastMenuSeparatorRow=menuRow;
		}
		else
		{
			var cGroupId=menuRow.getAttribute("menuGroupId");
			if (cGroupId !=lastGroupId &&
				lastMenuSeparatorRow==null &&
				nIndex !=0)
			{
				var lastMenuSeparatorRow=document.createElement("ie:menuitem");
				lastMenuSeparatorRow.setAttribute("type","separator");
				oMaster._oRoot.insertBefore(lastMenuSeparatorRow,menuRow);
			}
			else if (kwiz_pl_FIsIType(menuRow, "submenu") && lastMenuSeparatorRow !=null)
			{
				menuRow.parentNode.removeChild(lastMenuSeparatorRow);
				lastMenuSeparatorRow=null;
			}
			else
			{
				lastMenuSeparatorRow=null;
			}
			lastGroupId=cGroupId;
		}
		if (deleteRow)
		{
			menuRow.parentNode.removeChild(menuRow);
			nIndex--;
		}
	}
	if(lastMenuSeparatorRow !=null)
		lastMenuSeparatorRow.parentNode.removeChild(lastMenuSeparatorRow);
}
function kwiz_pl_PrepContents(oMaster, isMenuStructure)
{
	oMaster._fLargeIconMode=(oMaster.getAttribute("largeIconMode")=="true");
	oMaster._fCompactItemsWithoutIcons=(oMaster.getAttribute("CompactMode")=="true");
	if (!browseris.safari)
	{
		oMaster._oContents=document.createElement("span");
		oMaster._oContents.style.display="none";
		oMaster._oContents.innerHTML=oMaster.innerHTML;
	}
	else
	{
		oMaster._oContents=oMaster.cloneNode(true);
		oMaster._oContents.style.display="none";
	}
	if(isMenuStructure != false)
	{
		if (oMaster._fLargeIconMode)
		{
			if (oMaster._fIsRtL)
				oMaster._wzMenuStyle="ms-MenuUILargeRtL";
			else
				oMaster._wzMenuStyle="ms-MenuUILarge";
		}
		else
		{
			if (oMaster._fIsRtL)
				oMaster._wzMenuStyle="ms-MenuUIRtL";
			else
				oMaster._wzMenuStyle="ms-MenuUI";
		}
		oMaster._wzChkMrkPath="/_layouts/images/ChkMrk.gif";
		oMaster._wzMArrPath="/_layouts/images/MArr.gif";
		oMaster._wzMArrPathRtL="/_layouts/images/MArrRtL.gif";
	}
}
function kwiz_pl_MenuHtc_hide(e)
{
	kwiz_pl_ClearTimeOutToHideMenu();
	var e = document.body.calttel;
	if(e == null)
		return;
	var oMaster=g_kwiz_pl_menuHtc_lastMenu;
	if (oMaster !=null)
	{
	     kwiz_pl_HideMenu(oMaster);
	}
	g_kwiz_pl_menuHtc_lastMenu=null;
}
function kwiz_pl_ClearTimeOutToHideMenu()
{
	if (document.body.getAttribute("HideMenuTimeOut") !=null)
	{
		 kwiz_pl_ClearTimeOut("HideMenuTimeOut");
	}
}
function kwiz_pl_SetTimeOutToHideMenu()
{
	ClearTimeOut("HideMenuTimeOut"); 
	document.body.setAttribute("HideMenuTimeOut", window.setTimeout(kwiz_pl_MenuHtc_hide, 1500));
}
var kwiz_pl_kfnDisableEvent=new Function("return false");
var g_kwiz_pl_menuHtc_lastMenu=null;
var g_kwiz_pl_uniqueNumber= 0;
function kwiz_pl_GetUniqueNumber()
{
	g_kwiz_pl_uniqueNumber++;
	return "KSCP" + g_kwiz_pl_uniqueNumber;
}
function kwiz_pl_HideMenu(oMaster, nPhase)
{
	 kwiz_pl_ClearTimeOutToHideMenu();
	if (nPhase==null)
		nPhase=0;
	if (nPhase==2)
	{
		if (oMaster._onDestroy !=null)
		{
			oMaster._onDestroy();
			oMaster._onDestroy=null;
		}
		return;
	}
	if (kwiz_pl_IsOpen(oMaster))
	{
		if (oMaster._oParent !=null)
		{
			oMaster._oParent.onclick=oMaster._oParent._onclick;
			oMaster._oParent.onmouseover=oMaster._oParent._onmouseover;
			oMaster._oParent.onmouseout=oMaster._oParent._onmouseout;
			oMaster._oParent.onmousedown=oMaster._oParent._onmousedown;
		}
		kwiz_pl_SetBodyEventHandlers(null);
		kwiz_pl_UpdateLevel(oMaster, 0);
		var oPopup=oMaster._arrPopup[0];
		if (oPopup !=null)
		{
			var oBackFrame=document.getElementById(oPopup._backgroundFrameId);
			if (oBackFrame !=null)
				oBackFrame.parentNode.removeChild(oBackFrame);
			var res = oPopup.parentNode.removeChild(oPopup);
			oMaster._arrPopup[0]=null;
			if (nPhase==0)
			{
				if (oMaster._onDestroy !=null)
				{
					oMaster._onDestroy(); 
					oMaster._onDestroy=null;
				}
			}
		}
		g_CurrentShownElement = null;
		g_kwiz_pl_menuHtc_lastMenu=null;
	}
}
function kwiz_pl_IsOpen(oMaster)
{
	if (!oMaster._arrPopup)
		return false;
	var oPopup=oMaster._arrPopup[oMaster._nLevel];
	return oPopup;
}
function kwiz_pl_SetBodyEventHandlers(h)
{
	document.body.onclick=h;
}
function kwiz_pl_UpdateLevel(oMaster, nLevel)
{
	var oPopup;
	while (oMaster._nLevel > nLevel)
		{
		oPopup=oMaster._arrPopup[oMaster._nLevel];
		if (oPopup)
			{
			kwiz_pl_ClearShowSubMenuEvnt(oPopup);
			var oBackFrame=document.getElementById(oPopup._backgroundFrameId);
			if (oBackFrame !=null)
				oBackFrame.parentNode.removeChild(oBackFrame);
			oPopup.parentNode.removeChild(oPopup);
			}
		oMaster._arrPopup[oMaster._nLevel]=null;
		oMaster._arrSelected[oMaster._nLevel]=null;
		oMaster._oRoot=oMaster._oRoot.parentNode;
		oMaster._nLevel--;
		}
	oPopup=oMaster._arrPopup[oMaster._nLevel];
	if (oPopup) kwiz_pl_ClearShowSubMenuEvnt(oPopup);
}
function kwiz_pl_ClearShowSubMenuEvnt(oPopup)
{
	kwiz_pl_ClearTimeOut("timeoutID");
}
function kwiz_pl_ClearTimeOut(oAttribute)
{
	var id=document.body.getAttribute(oAttribute);
	if (id !=null)
	{
		window.clearTimeout(id);
	}
	document.body.removeAttribute(oAttribute);
}
function kwiz_pl_MenuHtc_init(oMaster)
{
	if (oMaster._initialized)
		return;
	oMaster._initialized=true;
	oMaster._wzPrefixID="mp"+kwiz_pl_GetUniqueNumber();
	if (oMaster.id==null)
		oMaster.id=oMaster._wzPrefixID+"_id";
	oMaster._nLevel=0;
	oMaster._arrPopup=new Array();
	oMaster._arrSelected=new Array();
	if (typeof(oMaster._onDestroy)=="undefined")
		oMaster._onDestroy=null;
	oMaster._fLargeIconMode=false;
	oMaster._fCompactItemsWithoutIcons=false;
}
function kwiz_pl_IsElementRtl(oCurrent)
{
	while (oCurrent !=null && oCurrent.tagName !=null)
	{
		var dir=oCurrent.getAttribute("dir");
		if ((dir==null || dir=="") && oCurrent.style !=null)
		{
			dir=oCurrent.style.direction;
		}
		if (dir=="rtl")
			return true;
		else if (dir=="ltr")
			return false;
		oCurrent=oCurrent.parentNode;
	}
	return false;
}
function kwiz_pl_MenuHtcInternal_Show(oMaster, oParent, y, fFlipTop, isMenuStructure)
{
	var oPopup=oMaster._arrPopup[oMaster._nLevel];	
	var nIndex;							
	var fTopLevel;							
	var oInnerDiv;
	if (!oMaster._oContents) kwiz_pl_PrepContents(oMaster, isMenuStructure);
	if (!oMaster._oContents || kwiz_pl_IsOpen(oMaster)) return;
	if (!oPopup && !oMaster._oRoot)
		{
		oMaster._nLevel=0;
		oMaster._oRoot=oMaster._oContents;
		}
	fTopLevel=oMaster._nLevel==0;
	fFlipTop=fFlipTop && fTopLevel;
	if (!oPopup)
	{
		oMaster._arrPopup[oMaster._nLevel]=document.createElement("DIV");
		if(isMenuStructure == false)
		{
			oMaster._arrPopup[oMaster._nLevel].onclick = oMaster._oParent.onclick;
		}
		oPopup=oMaster._arrPopup[oMaster._nLevel];
		oPopup.isMenu=true;
		oPopup.master=oMaster;
		oPopup.level=oMaster._nLevel;
		oInnerDiv=document.createElement("DIV");
		var oTable=document.createElement("table");
		var oTBody=document.createElement("tbody");
		oInnerDiv.isInner=true;
		oPopup.style.position="absolute";
		oInnerDiv.style.overflow="visible";
		oTable.appendChild(oTBody);
		oInnerDiv.appendChild(oTable);
		oPopup.appendChild(oInnerDiv);
		if (oMaster._fIsRtL)
			oPopup.setAttribute("dir", "rtl");
		else
			oPopup.setAttribute("dir", "ltr");
		document.body.appendChild(oPopup);
		if(isMenuStructure != false)
		{
			kwiz_pl_FixUpMenuStructure(oMaster);
		}
		var id=0;
		var childNodeLength=oMaster._oRoot.childNodes.length;
		for (nIndex=0; nIndex < childNodeLength; nIndex++)
		{
			var oNode=oMaster._oRoot.childNodes[nIndex];
			if (oNode.nodeType !=1)
				continue;
			if (!kwiz_pl_FIsIType(oNode, "label"))
			{
				var oItem=kwiz_pl_CreateMenuItem(oMaster, oNode, kwiz_pl_MakeID(oMaster, oMaster._nLevel, id), "", isMenuStructure);
				if (oItem) oTBody.appendChild(oItem);
				id++;
			}
		}
		if(isMenuStructure != false)
		{
			oPopup.className="ms-MenuUIPopupBody";
			oTable.className=oMaster._wzMenuStyle;
		}
		else
		{
			oTable.className="ms_cal_tooltipmaintable";
		}
		oTable.cellSpacing=0;
		oTable.cellPadding=0;
		if(isMenuStructure != false)
		{
			oTable.style.width = "230px";
		}
		oTable.style.height = "100%";
		oPopup.oncontextmenu=kwiz_pl_kfnDisableEvent;
		oPopup.ondragstart=kwiz_pl_kfnDisableEvent;
		oPopup.onselectstart=kwiz_pl_kfnDisableEvent;
		if (oParent._onmouseover==null)
			oParent._onmouseover=oParent.onmouseover;
		if (oParent._onmouseout==null)
			oParent._onmouseout=oParent.onmouseout;
		if (oParent._onmousedown==null)
			oParent._onmousedown=oParent.onmousedown;
		if (oParent._onclick==null)
			oParent._onclick=oParent.onclick;
		if (fTopLevel)
		{
			var wzOnUnload=oMaster.getAttribute("onunloadtext");
			if (wzOnUnload) oPopup.onunload=new Function(wzOnUnload);
		}
	}
	else
	{
		var oOld=oMaster._arrSelected[oMaster._nLevel];
		if (oOld) UnselectItem(oOld);
	}
	oMaster._arrSelected[oMaster._nLevel]=null;
	var oBackFrame;
	if (browseris.ie)
	{
		var originalScrollLeft=document.body.scrollLeft;
		oBackFrame=document.createElement("iframe");
		kwiz_pl_AssureId(oBackFrame);
		oBackFrame.src="/_layouts/blank.htm";
		oBackFrame.style.position="absolute";
		oBackFrame.style.display="none";
		oBackFrame.scrolling="no";
		oBackFrame.frameBorder="0";
		document.body.appendChild(oBackFrame);
		oPopup.style.zIndex=103;
		oPopup._backgroundFrameId=oBackFrame.id;
		if (originalScrollLeft !=document.body.scrollLeft)
		{
			document.body.scrollLeft=originalScrollLeft;
		}
	}
	kwiz_pl_SetMenuPosition(oMaster, oParent, oPopup, oInnerDiv, fFlipTop, fTopLevel, isMenuStructure);
	if (browseris.ie)
	{
		kwiz_pl_SetBackFrameSize(null, oPopup);
		oPopup.onresize=new Function("kwiz_pl_SetBackFrameSize(event, null);");
		oBackFrame.style.display="block";
		oBackFrame.style.zIndex=101;
	}
}
function kwiz_pl_SetBackFrameSize(e, oPopup)
{
	if (oPopup==null)
		oPopup=GetEventSrcElement(e);
	var nRealWidth=oPopup.scrollWidth+oPopup.offsetWidth - oPopup.clientWidth;
	var nRealHeight=oPopup.scrollHeight+oPopup.offsetHeight - oPopup.clientHeight;
	var oBackFrame=document.getElementById(oPopup._backgroundFrameId);
	oBackFrame.style.left=oPopup.offsetLeft+"px";
	oBackFrame.style.top=oPopup.offsetTop+"px";
	oBackFrame.style.width=nRealWidth+"px";
	oBackFrame.style.height=nRealHeight+"px";
}
function kwiz_pl_MergeAttributes(oTarget, oSource)
{
	if (browseris.nav || oTarget.kwiz_pl_MergeAttributes==null)
	{
		var oAttributes=oSource.attributes;
		for (var i=0; i < oAttributes.length; i++)
		{
			var oAttrib=oAttributes[i];
			if (oAttrib !=null &&
				oAttrib.specified &&
				oAttrib.nodeName !="id" &&
				oAttrib.nodeName !="ID" &&
				oAttrib.nodeName !="name")
			{
				oTarget.setAttribute(oAttrib.nodeName, oAttrib.nodeValue);
			}
		}
		if (oSource.getAttribute("type") !=null)
			oTarget.setAttribute("type", oSource.getAttribute("type"));
		if (oSource.submenuRoot !=null)
			oTarget.submenuRoot=oSource.submenuRoot;
	}
	else
	{
		oTarget.kwiz_pl_MergeAttributes(oSource);
	}
}
function kwiz_pl_CreateMenuItem(oMaster, oNode, wzID, wzHtml, isMenuStructure)
{
	if (kwiz_pl_FIsIType(oNode, "label")) return;
	var oRow=document.createElement("tr");
	kwiz_pl_MergeAttributes(oRow, oNode);
	oRow.setAttribute("onMenuClick", oNode.getAttribute("onMenuClick"));
	if (kwiz_pl_FIsIType(oNode, "separator"))
	{
		CreateMenuSeparator(oMaster, oRow);
		return oRow;
	}
	if (!kwiz_pl_GetIType(oNode)) kwiz_pl_SetIType(oNode, "option");
	var oFmtTableRow=document.createElement("tr");
	var oFmtTableCell=document.createElement("td");
	var oFmtTable=document.createElement("table");
	var oFmtTableBody=document.createElement("tbody");
	oFmtTableRow.appendChild(oFmtTableCell);
	oFmtTableCell.appendChild(oFmtTable);
	oFmtTable.appendChild(oFmtTableBody);
	oFmtTableBody.appendChild(oRow);
	if(isMenuStructure != false)
	{
		if (oMaster._fCompactItemsWithoutIcons && !oNode.getAttribute("iconSrc"))
			oFmtTableCell.className="ms-MenuUIItemTableCellCompact";
		else
			oFmtTableCell.className="ms-MenuUIItemTableCell";
		oFmtTable.className="ms-MenuUIItemTable";
	}
	oFmtTable.width="100%";
	oFmtTable.cellSpacing=0;
	oFmtTable.cellPadding=0;
	if (kwiz_pl_FIsIType(oNode, "submenu"))
		CreateSubmenu(oMaster, oRow, oNode, wzID);
	else if (kwiz_pl_FIsIType(oNode, "option"))
		kwiz_pl_CreateMenuOption(oMaster, oRow, oNode, wzID, wzHtml, isMenuStructure);
	if (oRow.disabled ||
		oRow.getAttribute("enabled")=="false")
	{
		oRow.disabled=false;
		oRow.className="ms-MenuUIDisabled";
		oRow.disabled=false;
		for (var nIndex=0; nIndex < oRow.childNodes.length; nIndex++)
		{
			if (oRow.childNodes[nIndex].nodeType !=1)
				continue;
			oRow.childNodes[nIndex].disabled=true;
			oFmtTableCell.className+=" ms-MenuUIItemTableCellDisabled";
		}
		oRow.optionDisabled=true;
	}
	kwiz_pl_MergeAttributes(oFmtTableRow, oRow);
	if (oRow.optionDisabled !=null)
	{
		oFmtTableRow.optionDisabled=oRow.optionDisabled;
	}
	oFmtTableRow.id=wzID;
	kwiz_pl_SetIType(oFmtTableRow, kwiz_pl_GetIType(oRow));
	return oFmtTableRow;
}
function kwiz_pl_SetIType(oItem, wzType)
{
	if (oItem) oItem.setAttribute("type", wzType);
}

function kwiz_pl_EvalAttributeValue(oNode, sAttribute1, sAttribute2)
{
	var result=oNode.getAttribute(sAttribute2);
	if (result !=null &&
		result.toLowerCase().indexOf("javascript:")==0)
	{
		result=eval(result.substring(11));
		if (result !=null && result !="")
			return result;
	}
	var result=oNode.getAttribute(sAttribute1);
	if (result==null)
		return "";
	return result;
}

function kwiz_pl_HandleDocumentBodyClick(e)
{
	if (g_kwiz_pl_menuHtc_lastMenu !=null)
	{
		var oMaster=g_kwiz_pl_menuHtc_lastMenu;
		if (oMaster !=null)
		{
			kwiz_pl_HideMenu(oMaster);
		}
	}
}
function kwiz_pl_SetMenuPosition(oMaster, oParent, oPopup, oInnerDiv, fFlipTop, fTopLevel, isMenuStructure)
{
	var maxWidth=window.screen.width;
	var maxHeight=window.screen.height;
	if (browseris.nav)
	{
		maxWidth=document.body.clientWidth;
		maxHeight=document.body.clientHeight;
	}
	else if (self.innerHeight)
	{
		maxWidth=self.innerWidth;
		maxHeight=self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		maxWidth=document.documentElement.clientWidth;
		maxHeight=document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		maxWidth=document.body.clientWidth;
		maxHeight=document.body.clientHeight;
	}
	var nRealWidth=oPopup.scrollWidth+oPopup.offsetWidth - oPopup.clientWidth;
	var nRealHeight=oPopup.scrollHeight+oPopup.offsetHeight - oPopup.clientHeight;
	var widthTooBig=false;
	var heightTooBig=false;
	if (nRealWidth > maxWidth - 50)
	{
		widthTooBig=true;
		nRealWidth=maxWidth - 50;
	}
	if (oMaster._fCompactItemsWithoutIcons && nRealHeight >=600)
	{
		heightTooBig=true;
		nRealHeight=600;
	}
	if (nRealHeight >=maxHeight - 50)
	{
		heightTooBig=true;
		nRealHeight=maxHeight - 50;
	}
	if (!widthTooBig && !heightTooBig)
	{
		oInnerDiv.style.overflow="visible";
	}
	else
	{
		if (browseris.ie)
		{
			if (widthTooBig)
			{
				oPopup.style.width=nRealWidth+"px";
				oInnerDiv.style.width=nRealWidth+"px";
				oInnerDiv.style.overflowX="scroll";
			}
			else
			{
				oInnerDiv.style.width=nRealWidth+"px";
				oInnerDiv.style.overflowX="visible";
			}
			if (heightTooBig)
			{
				oPopup.style.height=nRealHeight+"px";
				oInnerDiv.style.height=nRealHeight+"px";
				oInnerDiv.style.overflowY="scroll";
			}
			else
			{
				oInnerDiv.style.height=nRealHeight+"px";
				oInnerDiv.style.overflowY="visible";
			}
		}
		else
		{
			oPopup.style.height=nRealHeight+"px";
			oInnerDiv.style.height=nRealHeight+"px";
			oPopup.style.width=nRealWidth+"px";
			oInnerDiv.style.width=nRealWidth+"px";
			oInnerDiv.style.overflow="auto";
		}
	}
	nRealWidth=oPopup.scrollWidth+oPopup.offsetWidth - oPopup.clientWidth;
	nRealHeight=oPopup.scrollHeight+oPopup.offsetHeight - oPopup.clientHeight;
	var EdgeLeft=0;
	var EdgeRight=maxWidth;
	var ParentLeft=0;
	var EdgeTop=0;
	var ParentTop=0;
	var oCurrent=oParent;
	if (browseris.safari)
	{
		if (oCurrent.tagName=="TR" && oCurrent.childNodes.length > 0)
			oCurrent=oCurrent.childNodes[0];
	}
	var p=kwiz_pl_MenuHtc_GetElementPosition(oCurrent);
	ParentLeft=p.x;
	ParentTop=p.y;
	var nParentWidth;
	if (fTopLevel)
	{
		nParentWidth=p.width;
		ParentTop+=p.height;
		ParentTop -=1;
	}
	else
	{
		nParentWidth=p.width+1;
	}
	var fTryGoDefault=!fFlipTop && !document.body.getAttribute("flipped");
	var fFlippedDefault, fFlippedNonDefault;
	var xDefault, xFlipped;
	if (!oMaster._fIsRtL)
	{
		var MenuRightDefault;
		var MenuLeftFlipped;
		if (fTopLevel)
		{
			xDefault=ParentLeft;
			MenuRightDefault=ParentLeft+nRealWidth;
			MenuLeftFlipped=ParentLeft+nParentWidth - nRealWidth;
		}
		else
		{
			xDefault=ParentLeft+nParentWidth;
			MenuRightDefault=ParentLeft+nParentWidth+nRealWidth;
			MenuLeftFlipped=ParentLeft - nRealWidth;
		}
		xFlipped=MenuLeftFlipped;
		fFlippedDefault=MenuRightDefault > EdgeRight && MenuLeftFlipped > EdgeLeft;
		fFlippedNonDefault=!(MenuLeftFlipped < EdgeLeft && MenuRightDefault < EdgeRight);
	}
	else
	{
		var MenuLeftDefault;
		var MenuRightFlipped;
		if (fTopLevel)
		{
			MenuLeftDefault=ParentLeft+nParentWidth - nRealWidth;
			MenuRightFlipped=ParentLeft+nRealWidth;
			xFlipped=ParentLeft;
		}
		else
		{
			MenuLeftDefault=ParentLeft - nRealWidth;
			MenuRightFlipped=ParentLeft+nParentWidth+nRealWidth;
			xFlipped=ParentLeft+nParentWidth;
		}
		xDefault=MenuLeftDefault;
		fFlippedDefault=MenuLeftDefault < EdgeLeft && MenuRightFlipped < EdgeRight;
		fFlippedNonDefault=!(MenuRightFlipped > EdgeRight && MenuLeftDefault > EdgeLeft);
	}
	var fFlipped=fTryGoDefault ? fFlippedDefault : fFlippedNonDefault;
	var x=fFlipped ? xFlipped : xDefault;
	var xOffset;
	var yOffset;
	if (browseris.nav)
	{
		xOffset=window.pageXOffset;
		yOffset=window.pageYOffset;
	}
	else
	{
		var htmlElement=document.body.parentElement;
		if (!kwiz_pl_IsElementRtl(document.body))
		{
			xOffset=document.body.scrollLeft;
			xOffset+=htmlElement.scrollLeft;
		}
		else
		{
			xOffset=-document.body.scrollWidth+document.body.offsetWidth+document.body.scrollLeft;
			xOffset+=-htmlElement.scrollWidth+htmlElement.offsetWidth+htmlElement.scrollLeft;
		}
		yOffset=document.body.scrollTop;
		yOffset+=htmlElement.scrollTop;
	}
	if (nRealWidth >=maxWidth)
	{
		x=xOffset;
	}
	else if (x - xOffset+nRealWidth >=maxWidth)
	{
		x=xOffset+maxWidth - nRealWidth;
	}
	var y;
	if (nRealHeight >=maxHeight)
	{
		y=yOffset;
	}
	else if (ParentTop+nRealHeight - yOffset >=maxHeight)
	{
		y=yOffset+maxHeight - nRealHeight;
	}
	else
	{
		y=ParentTop;
	}
	oPopup.setAttribute("flipped", fFlipTop ? fFlipped && fFlippedDefault : fFlipped);
	var posLeft=Math.max(x,xOffset);
	var posTop=Math.max(y,yOffset);
	oPopup.style.left=posLeft+"px";
	oPopup.style.top=posTop+"px";
}
function kwiz_pl_AdjustScrollPosition(element, relativeToElement, result)
{
	var oCurrent=element;
	while (oCurrent !=null &&
		oCurrent !=relativeToElement &&
		oCurrent !=element.offsetParent &&
		oCurrent.tagName !=null &&
		oCurrent.tagName.toLowerCase() !="body" &&
		oCurrent.tagName.toLowerCase() !="html")
	{
		if (oCurrent.scrollWidth > oCurrent.clientWidth &&
			oCurrent.offsetWidth >=oCurrent.clientWidth &&
			oCurrent.clientWidth !=0)
		{
			if (!IsElementRtl(oCurrent))
			{
				if (oCurrent.scrollLeft > 0)
					result.x -=oCurrent.scrollLeft;
			}
			else
			{
				result.x+=(oCurrent.scrollWidth - oCurrent.offsetWidth - oCurrent.scrollLeft);
			}
		}
		if (oCurrent.scrollTop > 0)
			result.y -=oCurrent.scrollTop;
		oCurrent=oCurrent.parentNode;
	}
}
function kwiz_pl_MenuHtc_GetElementPosition(element, relativeToElement)
{
	var result=new Object();
	result.x=0;
	result.y=0;
	result.width=0;
	result.height=0;
	if (element.offsetParent) {
		var parent=element;
		while (parent !=null &&
			parent !=relativeToElement)
		{
			result.x+=parent.offsetLeft;
			result.y+=parent.offsetTop;
			kwiz_pl_AdjustScrollPosition(parent, relativeToElement, result);
			var parentTagName=parent.tagName.toLowerCase();
			if (parentTagName !="table" &&
				parentTagName !="body" &&
				parentTagName !="html" &&
				parentTagName !="div" &&
				parent.clientTop &&
				parent.clientLeft) {
				result.x+=parent.clientLeft;
				result.y+=parent.clientTop;
			}
			if (browseris.ie && parentTagName=="td")
			{
				if (parent.runtimeStyle.borderTopStyle !="none" ||
				    parent.currentStyle.borderTopStyle !="none")
				{
					var shift;
					if (parent.runtimeStyle.borderTopWidth !="")
					{
						shift=parseInt(parent.runtimeStyle.borderTopWidth);
					}
					else
					{
						shift=parseInt(parent.currentStyle.borderTopWidth);
					}
					if (!isNaN(shift))
					{
						result.y+=shift;
					}
				}
				if (parent.runtimeStyle.borderLeftStyle !="none" ||
				    parent.currentStyle.borderLeftStyle !="none")
				{
					var shift;
					if (parent.runtimeStyle.borderLeftWidth !="")
					{
						shift=parseInt(parent.runtimeStyle.borderLeftWidth);
					}
					else
					{
						shift=parseInt(parent.currentStyle.borderLeftWidth);
					}
					if (!isNaN(shift))
					{
						result.x+=shift;
					}
				}
			}
			parent=parent.offsetParent;
		}
	}
	else if (element.left && element.top) {
		result.x=element.left;
		result.y=element.top;
	}
	else {
		if (element.x) {
			result.x=element.x;
		}
		if (element.y) {
			result.y=element.y;
		}
	}
	if (element.offsetWidth && element.offsetHeight) {
		result.width=element.offsetWidth;
		result.height=element.offsetHeight;
	}
	else if (element.style && element.style.pixelWidth && element.style.pixelHeight) {
		result.width=element.style.pixelWidth;
		result.height=element.style.pixelHeight;
	}
	return result;
}
var g_CurrentTooltipPopup = null;
var g_CurrentShownElement = null
function kwiz_pl_CreateTooltip(elm, tootltip)
{
	if(g_CurrentShownElement == elm)
		return;
    if(g_CurrentTooltipTimeout == null)
        return;
	g_CurrentTooltipPopup = CMenu("calendartooltip");
	g_CurrentTooltipPopup.setAttribute("CompactMode", "true");
	kwiz_pl_CreateTooltipItem(elm, g_CurrentTooltipPopup, tootltip);

	kwiz_pl_OMenu(g_CurrentTooltipPopup, elm, null, null, -1, false);
    
	setTimeout(kwiz_pl_ClearTimeOutToHideMenu, 100);
	setTimeout(function(){kwiz_pl_SetBodyEventHandlers(kwiz_pl_HandleDocumentBodyClick);}, 300);

}
function kwiz_pl_CreateTooltipItem(elm, obj, html)
{
	var mo=document.createElement("SPAN");
	if(elm.popupclick != null)
	{
	    elm.onclick = function() {elm.popupclick(elm);};
	}
	else
	{
	    elm.onclick = function() {kwiz_pl_GoToLink(elm);};
	}
	AChld(obj,mo);
	mo.innerHTML = html;
}



function kwiz_pl_ShowTooltip()
{
	var e = document.body.calttel;
    var bClassName = e.getAttribute("bclassname");
	if((bClassName != null) && (e.className != bClassName + "sel"))
		return;
	if((e.popup != null) && (e.popup.isOpen == true))
		return;
	kwiz_pl_LocateToottip(e);
}

function kwiz_pl_LocateToottip(elm, dir)
{
	try
	{
        var tooltiptext = elm.tooltipcontent;
        if(tooltiptext  == null)
            tooltiptext  = elm.getAttribute("tooltipcontent");
	    if((tooltiptext != null) && (tooltiptext.length > 0))
		    kwiz_pl_CreateTooltip(elm, tooltiptext, dir)
	}
	catch(e)
	{
	}
}



