﻿
eProject.Provide("eProject.Widgets.DropDownMenu");eProject.Require("eProject.Ajax");var DropDownMenu=function(){parentWindowMenu=null;if(eProject.Widgets.DropDownMenu.Hide!=null){parentWindowMenu=eProject.Widgets.DropDownMenu;}
eProject.Eventing.EventManager.Attach(window,"unload",function(){if(parentWindowMenu){parentWindowMenu=null;}
else{eProject.Widgets.DropDownMenu=null;}});return new DropDownMenuObj();}();if(!eProject.Widgets.DropDownMenu.Hide){eProject.Widgets.DropDownMenu=DropDownMenu;}
function DropDownMenuObj(){this.Obj=null;this.Caller=null;this.Options=null;this.Args=null;this.Cover=null;this.IsIE=eProject.Browser.IsIE;this.MenuLoadUrl=document.location.pathname;this.HiddenSelects=null;this.LoadPacket=null;this.IgnoreAnimation=false;this._method="POST";this.Cache={};this.onRender=fnOnRender;this.onMenuLoaded=null;this.mLoad=fnLoad;this.mIsCached=fnIsCached;this.mGetAll=fnGetAll;this.mGetXY=fnGetXY;this.mIsInside=fnIsInside;this.mLoadFromCache=fnLoadFromCache;this.mOutsideClick=fnOutsideClick;this.SetDisplayParameters=fnSetDisplayParameters;this.OutsideClick=fnOutsideClick;this.CreateMenu=fnCreateMenu;this.ClearMenu=fnClearMenu;this.ClearFromCache=fnClearFromCache;this.AddItem=fnAddItem;this.Init=fnInit;this.Show=fnShow;this.Load=fnLoad;this.onRender=fnOnRender;this.isCached=fnIsCached;this.getAll=fnGetAll;this.Hide=fnHide;this.getXY=fnGetXY;this.isInside=fnIsInside;this.outsideClick=fnOutsideClick;this.ProcessStateChange=fnProcessStateChange;this.Init();function fnInit(){if(!parentWindowMenu){eProject.Eventing.EventManager.Attach(window,'resize',this.Hide);}
eProject.Eventing.EventManager.Attach(document,"click",this.Hide);}
function fnCreateMenu(menuID,menuClassName){var newMenu=document.createElement("DIV");newMenu.className="ddm "+menuClassName;newMenu.id=menuID;newMenu.style.visibility="hidden";document.body.appendChild(newMenu);var items=document.createElement("UL");newMenu.appendChild(items);return this;}
function fnClearMenu(menuID){var menu=document.getElementById(menuID);if(!menu){return this;}
menu.removeChild(menu.firstChild);menu.appendChild(document.createElement("UL"));return this;}
function fnClearFromCache(oid){if(this.Cache[oid]){this.Cache[oid]=null;}}
function fnAddItem(menuID,item){var menu=document.getElementById(menuID);if(!menu){throw"Menu does not exist";}
var newItem=document.createElement("LI");if(typeof(item)=="string"){newItem.innerHTML=item;}else if(typeof(item)=="object"){newItem.appendChild(item);}
menu.firstChild.appendChild(newItem);return this;}
function fnShow(event,menuId,caller,options,arg1,arg2,arg3)
{event.cancelBubble=true;var s=caller||document.body;var o=document.getElementById(menuId);if(this.Caller)
{if(this.Caller==s)
{this.Hide();return;}
else
{this.Hide();}}
if(!options){if(this.IsIE){options={"animate":false};}
else{options={"animate":true};}}
if(options.animate==undefined||options.animate==null){if(this.IsIE){options.animate=false;}
else{options.animate=true;}}
this.Caller=s;this.Obj=document.getElementById(menuId);this.Options=options;if(o==null)
throw"Popup menu with a given ID not found: '"+menuId+"'";if(event!=null&&event.srcElement!=null&&event.srcElement!=s&&event.srcElement.tagName=="A"&&event.srcElement.href!=null&&event.srcElement.href!=""){return;}
this.SetDisplayParameters(o,s,options);var all=this.mGetAll(o);for(var i=0;i<all.length&&arguments.length>4;i++)
{if(all[i].tagName=="A")
{var a=all[i];if(a._href==undefined)
{a._href=a.href;a._title=a.title;a._innerHtml=a.innerHTML;}
else
{a.href=a._href;a.title=a._title;a.innerHTML=a._innerHtml;}
if(options.disablemask!=undefined)
{a.removeAttribute("disabled");}
for(var j=4;j<arguments.length;j++)
{a.href=a.getAttribute("href").replace("{"+(j-4)+"}",arguments[j]);a.title=a.title.replace("{"+(j-4)+"}",arguments[j]);a.innerHTML=a.innerHTML.replace("{"+(j-4)+"}",arguments[j]);}}}
if(options.disablemask!=undefined)
{var c=0;for(var i=0;i<all.length;i++)
if(all[i].tagName=="A")
if(options.disablemask.charAt(c++)=='0')
{all[i].removeAttribute("href");all[i].removeAttribute("title");all[i].removeAttribute("onclick");all[i].setAttribute("disabled","disabled");}}
o.style.visibility="visible";o.style.display="";o.style.zIndex=100;if(options.labelcssdown!=undefined)
{s.className=options.labelcssdown;}
s._onmouseover=s.onmouseover;s._onmouseout=s.onmouseout;s.onmouseover=null;s.onmouseout=null;s.parentNode._onmouseover=s.parentNode.onmouseover;s.parentNode._onmouseout=s.parentNode.onmouseout;s.parentNode.onmouseover=null;s.parentNode.onmouseout=null;}
function fnLoad(event,menuId,caller,oid,options,args)
{event.cancelBubble=true;if(options==undefined||options==null)
options={};if(options.animate==undefined||options.animate==null){if(this.IsIE){options.animate=false;}
else{options.animate=true;}}
if(this.Obj)
{if(this.Caller==caller)
{this.Hide();return;}
else
{this.Hide();}}
if(this.mIsCached(oid))
{this.mLoadFromCache(oid,caller,options);return;}
var o=document.getElementById(menuId);if(o==null)
throw"Popup menu with a given ID not found: '"+menuId+"'";this.Obj=o;this.Obj.innerHTML="<span class='ddm_loading'></span>";this.Caller=caller;this.Options=options;this.SetDisplayParameters(this.Obj,caller,options);if(event!=null&&event.srcElement!=null&&event.srcElement!=caller&&event.srcElement.tagName=="A"&&event.srcElement.href!=null&&event.srcElement.href!="")
return;if(this.LoadPacket!=null&&this.LoadPacket.RequestStatus!=0&&this.LoadPacket.RequestStatus!=4){eProject.Ajax.AjaxManager.AbortRequest(this.LoadPacket);}
var request={"onSuccess":function(xmlHttp){DropDownMenu.ProcessStateChange(xmlHttp,oid);},"onError":function(errorCode){alert('An unknown error occured\n'+errorCode);},"_callback":"ddmActions","_menuId":menuId,"_callerURL":document.location.href,"ShowLoading":false,"Method":this._method,"Url":this.MenuLoadUrl+"?oid="+oid};if(args){for(var arg in args){request[arg]=args[arg];}}
this.LoadPacket=new AjaxPacket(request);eProject.Ajax.AjaxManager.mSendRequest(this.LoadPacket);}
function fnProcessStateChange(xmlHttp,oid)
{var res=xmlHttp.responseText;var o=this.Obj;if(o==null){return;}
o.innerHTML=res;this.SetDisplayParameters(this.Obj,this.Caller,this.Options);this.onRender();this.Cache[oid]=o.cloneNode(true);if(this.onMenuLoaded)
this.onMenuLoaded();}
function fnSetDisplayParameters(o,s,options)
{document.body.appendChild(o);var oldEvent=o.onclick;o.onclick=function(e){if(!e)e=window.event;e.cancelBubble=true;if(oldEvent)oldEvent(e);};o.style.display="none";var bodySH=document.body.scrollHeight;o.style.position="absolute";o.style.visibility="hidden";var needToShowDiv=this.IsIE||options.dir=="l"||options.dir=="u"||options.autoresize;if(needToShowDiv)
{o.style.display="";}
o.style.top="0px";o.style.left="0px";var elem=s;for(elem=s.parentNode;elem!=null&&elem.nodeType!=9;elem=elem.parentNode)
{if(elem.style.overflow!=null&&elem.style.overflow.length>0)
{eProject.Eventing.EventManager.Attach(elem,'scroll',this.Hide);}}
var xy=this.mGetXY(s);if(options.xoffset==undefined)options.xoffset=0;if(options.yoffset==undefined)options.yoffset=0;o.style.pixelLeft=xy.left+options.xoffset;o.style.pixelTop=xy.top+options.yoffset;if(options.scroll)
{o.style.overflowY="auto";o.style.overflowX="hidden";if($(o).height()>options.height)
{o.style.height=options.height;}}
if(options.autoresize)
{o.style.overflow="auto";o.style.height="";o.style.width="";var availHeight;if(options.dir=="u")
availHeight=xy.top;else
availHeight=parseInt(bodySH,10)-xy.top;availHeight=availHeight*0.90;if(parseInt(o.offsetHeight,10)>availHeight)
{if(o.scrollHeight<=o.clientHeight)
o.style.width=(o.offsetWidth+30)+"px";o.style.height=availHeight+"px";}}
if(options.dir=="r")
{o.style.pixelLeft+=s.offsetWidth;}
else if(options.dir=="l")
{var pl=o.style.pixelLeft;o.style.pixelLeft=pl-o.offsetWidth;o.style.pixelLeft=pl-o.offsetWidth;}
else if(options.dir=="u")
{o.style.pixelTop-=o.offsetHeight;}
else
{o.style.pixelTop+=s.offsetHeight;}
o.style.left=o.style.pixelLeft+"px";o.style.top=o.style.pixelTop+"px";if(this.IsIE)
{this.HiddenSelects=new Array();var oXY=this.getXY(o);var selects=document.getElementsByTagName("SELECT");for(var i=0;i<selects.length;i++)
{var sel=selects[i];if(sel.style.display=="none"||sel.style.visibility=="hidden"||this.mIsInside(sel))
continue;var selXY=this.getXY(sel);if(selXY.left+sel.offsetWidth>=oXY.left&&selXY.top+sel.offsetHeight>=oXY.top&&selXY.left<=oXY.left+o.offsetWidth&&selXY.top<=oXY.top+o.offsetHeight)
{this.HiddenSelects.push(sel);sel.style.visibility="hidden";}}}
if(o.filters&&options.animate&&!this.IgnoreAnimation)
{switch(options.dir)
{case"r":o.style.filter="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=0.50,wipestyle=0,motion=forward,duration=0.10)";break;case"l":o.style.filter="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=0.50,wipestyle=0,motion=reverse,duration=0.10)";break;case"u":o.style.filter="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=0.50,wipestyle=1,motion=reverse,duration=0.10)";break;default:o.style.filter="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=0.50,wipestyle=1,motion=forward,duration=0.10)";break;}}
o.style.visibility="visible";o.style.display="";o.style.zIndex=100;if(o.filters&&options.animate&&!this.IgnoreAnimation)
o.filters[0].play();}
function fnOnRender()
{var options=this.Options;var s=this.Caller;if(options.labelcssdown!=undefined)
{s.className=options.labelcssdown;}
s._onmouseover=s.onmouseover;s._onmouseout=s.onmouseout;s.onmouseover=null;s.onmouseout=null;s.parentNode._onmouseover=s.parentNode.onmouseover;s.parentNode._onmouseout=s.parentNode.onmouseout;s.parentNode.onmouseover=null;s.parentNode.onmouseout=null;}
function fnIsCached(oid)
{var o=this.Cache[oid];return(o!=undefined&&o!=null);}
function fnLoadFromCache(oid,caller,options)
{var oCached=this.Cache[oid];if(oCached==undefined||oCached==null){return;}
this.Obj=oCached.cloneNode(true);this.Caller=caller;this.Options=options;this.SetDisplayParameters(this.Obj,caller,options);this.onRender();}
function fnGetAll(o)
{var a=new Array();fn_getAll(a,o);return a;}
function fn_getAll(a,o){for(var i=0;i<o.childNodes.length;i++)
{a.push(o.childNodes[i]);if(o.childNodes[i].hasChildNodes)
fn_getAll(a,o.childNodes[i]);}}
function fnOutsideClick()
{if(this.Obj==undefined||this.Obj==null)
return;if(this.Options.animate&&this.Obj.filters&&!this.IgnoreAnimation)
{switch(this.Options.dir)
{case"r":this.Obj.style.filter="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=0.50,wipestyle=0,motion=reverse,duration=0.10)";break;case"l":this.Obj.style.filter="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=0.50,wipestyle=0,motion=forward,duration=0.10)";break;case"u":this.Obj.style.filter="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=0.50,wipestyle=1,motion=forward,duration=0.10)";break;default:this.Obj.style.filter="progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=0.50,wipestyle=1,motion=reverse,duration=0.10)";break;}}
this.Obj.style.visibility="hidden";if(this.Cover)
this.Cover.parentNode.removeChild(this.Cover);if(this.Options.labelcss!=undefined)
{this.Caller.className=this.Options.labelcss;}
this.Caller.onmouseover=(this.Caller._onmouseover==undefined)?null:this.Caller._onmouseover;this.Caller.onmouseout=(this.Caller._onmouseout==undefined)?null:this.Caller._onmouseout;this.Caller.parentNode.onmouseover=(this.Caller.parentNode._onmouseover==undefined)?null:this.Caller.parentNode._onmouseover;this.Caller.parentNode.onmouseout=(this.Caller.parentNode._onmouseout==undefined)?null:this.Caller.parentNode._onmouseout;if(this.Caller.parentNode.onmouseout!=null&&this.Caller.parentNode.onmouseout!=undefined){this.Caller.parentNode.onmouseout()}
if(this.Options.disablemask!=undefined)
{var all=this.mGetAll(this.Obj);for(var i=0;i<all.length;i++)
if(all[i].tagName=="A")
all[i].disabled=false;}
if(this.IsIE)
{if(this.HiddenSelects){var o=undefined;while((o=this.HiddenSelects.pop())!=undefined)
o.style.visibility="visible";}}
this.Obj=null;this.Caller=null;}
function fnHide()
{if(parentWindowMenu){parentWindowMenu.OutsideClick();}
DropDownMenu.OutsideClick();}
function fnGetXY(Obj)
{for(var sumTop=0,sumLeft=0;Obj.offsetParent!=null;sumTop+=Obj.offsetTop,sumLeft+=Obj.offsetLeft,sumTop-=Obj.scrollTop,sumLeft-=Obj.scrollLeft,Obj=Obj.offsetParent);return{"left":sumLeft,"top":sumTop};}
function fnIsInside(o)
{while(o!=document&&o!=null)
{if(o==this.Obj)
return true;o=o.parentNode;}
return false;}}