// Copyright 2003, 2004 Peter L. Blum, All Rights Reserved, www.PeterBlum.com
// Peter's Date Package Release 1.1.7

function PM_OnPopupIE(pTglCId, pPUCId){gPBC_PM_CancelEvent = false;var vSrcObj = pTglCId != "" ? PDP_GetById(pTglCId) : document.body;var vButtonType = vSrcObj.getAttribute("PM_BT");if ((vButtonType == null) ||((vButtonType == "left") && (window.event.button != 1)) ||((vButtonType == "right") && (window.event.button != 2)))return;window.event.cancelBubble = true;PM_InitSize(PDP_GetById(pPUCId));if ((window.event.button == 2) || (vSrcObj == document.body)) 
PDP_OpenPopupAtMousePoint(pPUCId, window.event);elsePDP_OpenPopup(vSrcObj.id, pPUCId, true);} 

function PM_OnPopupNS(pE){var vSrcObj = pE.currentTarget;var vPUCId = vSrcObj.getAttribute("PM_PUCId"); if (vPUCId == null)return;var vButtonType = vSrcObj.getAttribute("PM_BT");var vBtn = pE.button;if (gIsSafari && vBtn == 1)vBtn = 0;if ((vButtonType == null) ||((vButtonType == "left") && (vBtn != 0)) ||((vButtonType == "right") && (vBtn != 2)))return;pE.stopPropagation();PM_InitSize(PDP_GetById(vPUCId));if ((pE.button == 2) || (vSrcObj == document.body)) 
PDP_OpenPopupAtMousePoint(vPUCId, pE);elsePDP_OpenPopup(vSrcObj.id, vPUCId, true);} 

function PM_Initialize(){
if (!this.gPBC_PUCId)return;for (var vI = 0; vI < gPBC_PUCId.length; vI++){PM_InitBody(vI);} 
} 

function PM_InitializeOne(pTglCId){if (!this.gPBC_PUCId)return;for (var vI = 0; vI < gPBC_PUCId.length; vI++){if (gPBC_TglCId[vI] == pTglCId) 
{PM_InitBody(vI);return;}} 
} 
function PM_InitBody(pPos){var vOwnerElement = null;if (gPBC_TglCId[pPos] == "")vOwnerElement = document.body;elsevOwnerElement = PDP_GetById(gPBC_TglCId[pPos]);vOwnerElement.setAttribute("PM_PUCId", gPBC_PUCId[pPos], 0);vOwnerElement.setAttribute("PM_BT", gPBC_PUBT[pPos], 0);var vPUC = PDP_GetById(gPBC_PUCId[pPos]);if (vOwnerElement.attachEvent){vOwnerElement.attachEvent("onmousedown", new Function("PM_OnPopupIE('" + gPBC_TglCId[pPos] + "', '" + gPBC_PUCId[pPos] + "');"));if (gPBC_PUBT[pPos] == "right"){if (gPBC_TglCId[pPos] == "")vOwnerElement.oncontextmenu = new Function("return false;");elsedocument.attachEvent("oncontextmenu", PM_TestContextIE);}}else if (vOwnerElement.addEventListener){
if (OS == "Mac")vOwnerElement.addEventListener("mousedown", PM_OnPopupNS, false);elsevOwnerElement.addEventListener("mouseup", PM_OnPopupNS, false);if (gPBC_PUBT[pPos] == "right"){document.oncontextmenu = PM_TestContextNS;}}
else if (gIsIEMac && (vOwnerElement != document.body) && (gPBC_PUBT[pPos] == "left")){vOwnerElement.onclick = new Function("PDP_OpenPopup('" +gPBC_TglCId[pPos]+"','"+ gPBC_PUCId[pPos] + "',true);");}elsereturn;PDP_RelocatePopup(vPUC);} 

function PM_InitSize(pFld){var vInit = eval(PDP_GetAtt(pFld, "Inited", false));if (vInit)return;var vInnerTable = PDP_GetById(pFld.id + "_MenuTable");if (vInnerTable.offsetWidth + 4 > pFld.offsetWidth) 
pFld.style.width = vInnerTable.offsetWidth + 4;PDP_SetAtt(pFld, "Inited", true);}
function PM_TestContextIE(){for (var vSrcElement = window.event.srcElement;(vSrcElement != document) && (vSrcElement != null);vSrcElement = vSrcElement.parentNode){if (vSrcElement.getAttribute){if (vSrcElement.getAttribute("PM_PUCId") != null)return false;if ((vSrcElement.getAttribute("IsPopup") != null) &&(eval(vSrcElement.getAttribute("IsPopup"))))return false;}}return true;}
function PM_TestContextNS(pE){for (var vSrcElement = pE.target;(vSrcElement != document) && (vSrcElement != null);vSrcElement = vSrcElement.parentNode){if (vSrcElement.getAttribute != null){if (vSrcElement.getAttribute("PM_PUCId") != "")return false;if ((vSrcElement.getAttribute("IsPopup") != "") &&(eval(vSrcElement.getAttribute("IsPopup"))))return false;}}return true;} 