/***********************************************
* AnyLink Drop Down Menu-  Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/


// Usage: <a onmouseover='mDropDown(this,event,"contentDivId")'>Link Text</a> 
 
 
 
/***
 *** These are values that will determine the size, css, position & sliding effects of the menu.
 *** Defaults & expanations are here.  You can override these for any one menu by passing in the 
 *** hash obj hPassedOptions or for your document by setting MgicDropDown.defaults.xxx = ?
 ***/
MgicDropDown.defaults = {

        hideMenuOnClick:false,      //Does a click (anywhere) close the menu?
        noIframe:false,         //Forces no iframe to be generated (for pages without select fields beneith the menus; otherwise, will make a blocking iFrame in IE only
    
        extraClasses:'',           //Add extra classes to a menu
        replaceParamsArray:[],     //You can replace anything in the HTML in your content div [[findstr1,replacestr1],[findstr2,replacestr2]]

        addedWidthToMenu:0,        //Menus by default will use the width of the parent element.  You can add (or subtract) to that here (only affects right side)
        offsetX:0,                 //Horizantal Offset of menu
        offsetY:0,                 //Vertical Offset
        minWidth:'parent',         //Menu will be this width (if > 0) unless an item is longer, in which case the menu will be the item width.
                                    //{minWidth:'parent'} will make the minwidth the width of the parent element.  
        
        openRight:false,       //Menu opens on right of parent
        
        dropDownTime:1,          //How long (in milliseconds) does the slide take to finish?  Put in 1 here for no slide
        disappearDelay:250         //The menu will hang around for this amount of time (in milliseconds) after it's been told to hide

};

MgicDropDown.ie5=document.all;
MgicDropDown.ns6=document.getElementById&&!document.all;
MgicDropDown.dropdownIsSupported = (MgicDropDown.ie5||MgicDropDown.ns6);

MgicDropDown.instances = [];
MgicDropDown.hInnerIdToInstance = new Object;



/***
 *** Accessor Functions:  These functions create/handle instances of the menu behind the scenes.  Use 
 ***/
var mDrop = null;
var mDropHash = new Object;
var iNumHashes = 0;
var hParentToTrigger = new Object;


/*
 * Will call mDropDownActivate, plus set onmouseout if you're so inclined/lazy
 * 
 *  To Be called onclick or onmouseover by activating element
 *  Parameters
 *   oMenuParent: the element (object or id) to be used for the menu (usually 'this');
 *   e: event
 *   oMenuContents: the div element (object or id) to be used for menu content
 *   Options (optional): see "defaults" above for available options
 *   oThis (not needed): The calling object. Used in behind-the-scenes calls 
 */
function mDropDown(oMenuParent, e, oMenuContents, hPassedOptions,oThis) {

    if (!oThis) {
        if(e.srcElement) oThis = e.srcElement;
        else if(e.target) oThis = e.target;
        else return true;
    }

    if(oThis.id == null || oThis.id == "")  { oThis.id = "mgicDropDownMenuButton"+iNumHashes; } 

    try {
    if(!mDropHash[oThis.id]) {

        addEvent(oThis,'mouseout',mDropDelayHide);
        addEvent(oThis,'mouseover',mDropClearHide);
        addEvent(oThis,'click',mDropClearHide);


        //oThis.onmouseout = setEvent(oThis.onmouseout,mDropDelayHide);
        //oThis.onmouseover = setEvent(oThis.onmouseover,mDropClearHide);
        //oThis.onclick = setEvent(oThis.onclick,mDropClearHide);
    }

    
    if(typeof(oMenuParent) == "string") oMenuParent=document.getElementById? document.getElementById(oMenuParent) : eval(oMenuParent); //
    
    if(oThis != oMenuParent) {
        if(oMenuParent.id == null || oMenuParent.id == "")  { oMenuParent.id = "mgicDropDownMenuParent"+iNumHashes; } 
        hParentToTrigger[oMenuParent.id] = oThis.id; 
        if(!mDropHash[oThis.id]) {
            addEvent(oMenuParent,'mouseout',mDropDelayHide);
            addEvent(oMenuParent,'mouseover',mDropClearHide);
            addEvent(oMenuParent,'click',mDropClearHide);

            //oMenuParent.onmouseout = setEvent(oMenuParent.onmouseout,mDropDelayHide);
            //oMenuParent.onmouseover = setEvent(oMenuParent.onmouseover,mDropClearHide);
            //oMenuParent.onclick = setEvent(oMenuParent.onclick,mDropClearHide);
        }
    }
} catch (e) { alert(e.message+e.stack);
}

    //Set default click behavior: click on button does nothing, unless function is called onclick
    if(e.type=="click" && (hPassedOptions == null || hPassedOptions.hideMenuOnClick == null)) {
        if(hPassedOptions == null) hPassedOptions = {hideMenuOnClick:true}
        hPassedOptions.hideMenuOnClick = true;
    }

    return mDropDownActivate(oMenuParent, e, oMenuContents, hPassedOptions,oThis);

}



/*
 * Easy-to-use call/shortcut for Related Links
 */
function mDropDownRelatedLinks(e,sTargetId) {
     
    var oThis;
    if(e.srcElement) oThis = e.srcElement;
    else if(e.target) oThis = e.target;
    else return true;

    return mDropDown(oThis, e, sTargetId, {minWidth:0,dropDownTime:1,hideMenuOnClick:false},oThis);

}


/*
 * Easy-to-use call/shortcut for Related Links
 */
function mDropDownTabs(e,sTargetId) {
     
    var oThis;
    if(e.srcElement) oThis = e.srcElement;
    else if(e.target) oThis = e.target;
    else return true;

    var oThisParent = oThis.parentNode;
    return mDropDown(oThisParent, e, sTargetId, {dropDownTime:1,hideMenuOnClick:false,offsetX:1,addedWidthToMenu:-5},oThis);

}














/*
 * mDropDownActivate: Initiates Object (if necessary) & shows the menu according to the parameters
 *
 */
function mDropDownActivate(oMenuParent, e, oMenuContents, hPassedOptions,oThis) {
    
    if (!oThis) {
        if(e.srcElement) oThis = e.srcElement;
        else if(e.target) oThis = e.target;
        else return true;
    }
    if(!oMenuParent || oMenuParent==window) {
        oMenuParent = oThis;
    }
    if(oThis.id == null || oThis.id == "")  { oThis.id = "mgicDropDownMenuButton"+iNumHashes; } 

    if(!mDropHash[oThis.id]) { mDropHash[oThis.id] = new MgicDropDown(); }
    if(!(mDropHash[oThis.id].menuIsOn())) return mDropHash[oThis.id].showDD(oMenuParent, e, oMenuContents, hPassedOptions);

}



/*
 * mDropDelayHide: for onmouseout: will hide menu, if the cursor isn't over our menu object
 * Will be set automatically if you use mDropDown
 */
function mDropDelayHide(e,trigger_id) {


    if(typeof(trigger_id) == 'string') {
        oThis = document.getElementById(trigger_id);
    } else if(typeof(trigger_id) == 'object') {
        oThis = trigger_id;
    } else {
        if(e.srcElement) oThis = e.srcElement;
        else if(e.target) oThis = e.target;
    }

    var mDropObj = (mDropHash[oThis.id])? mDropHash[oThis.id] : (hParentToTrigger[oThis.id] && mDropHash[hParentToTrigger[oThis.id]])? mDropHash[hParentToTrigger[oThis.id]] : null;
    if(mDropObj) mDropObj.delayHideMenu(e);

}


/*
 * mDropClearHide: for onmouseover: will stop hiding of menu
 * Will be set automaticallyif you use mDropDown
 */

function mDropClearHide(e,trigger_id) {
    
    if(typeof(trigger_id) == 'string') {
        oThis = document.getElementById(trigger_id);
    } else if(typeof(trigger_id) == 'object') {
        oThis = trigger_id;
    } else {
        if(e.srcElement) oThis = e.srcElement;
        else if(e.target) oThis = e.target;
    }

    
    var mDropObj = (mDropHash[oThis.id])? mDropHash[oThis.id] : (hParentToTrigger[oThis.id] && mDropHash[hParentToTrigger[oThis.id]])? mDropHash[hParentToTrigger[oThis.id]] : null;
    if(mDropObj) mDropObj.clearHideMenu(e);
    
}


/*
 * mDropClick: Not much to this; for on click (optional);  Will return whether this script is supported
 */
function mDropClick(e) {
    
    if(e.srcElement) oThis = e.srcElement;
    else if(e.target) oThis = e.target;
    
    var mDropObj = (mDropHash[oThis.id])? mDropHash[oThis.id] : (hParentToTrigger[oThis.id] && mDropHash[hParentToTrigger[oThis.id]])? mDropHash[hParentToTrigger[oThis.id]] : null;
    
    if(mDropObj) return mDropObj.clickReturnValue();
    return !MgicDropDown.dropdownIsSupported;
}


function mHideAllMenus() {

    for (var i in mDropHash) {
        mDropHash[i].hideMenu();
    }
}



/*
 * setEvent: helper function to not overwrite old function calls old 
 */
function addEvent(element,name,observer) {
    if (element.addEventListener) {
      element.addEventListener(name, observer,false);
    } else if (element.attachEvent) {
      element.attachEvent('on' + name, observer);
    }
}


/***
 *** Backward compatibility with old UtilityDropDown.js.
 ***/


function dropdownMouseover(e,sTargetId) {
     
    var oThis;
    if(e.srcElement) oThis = e.srcElement;
    else if(e.target) oThis = e.target;
    else return true;

    var sBtnOnclick = oThis.onclick + " ";
    var bHideClick = !(sBtnOnclick.match(/dropdownClick/));

    return mDropDown(oThis, e, sTargetId, {minWidth:0,dropDownTime:1,hideMenuOnClick:bHideClick},oThis);

}

function dropdownClick(e,sTargetId,sDirection) {
    
    var oThis;
    if(e.srcElement) oThis = e.srcElement;
    else if(e.target) oThis = e.target;
    else return true;

    if(!mDropHash[oThis.id] || (mDropHash[oThis.id] && !mDropHash[oThis.id].menuIsOn()))  dropdownMouseover(e,sTargetId);
    
    return false;

}



/***
 *** MgicDropDown Object: creates a div structure.  Function showDD will show that object.
 ***/
function MgicDropDown() {

      var currentInstance = MgicDropDown.instances.length;
      this.currentInstance = currentInstance;
      MgicDropDown.instances[currentInstance] = this;

      var oAccel = null;
      var delayHide = null;
      var options = {};

      var iInstance = iNumHashes;
      iNumHashes++;

      this.iInstance = iInstance;

      var oDivOuter = null;
      var oDivInner = null;
      var oIframe = null;
      var oTargetDiv = null;
      var isReversedY;
      var isReversedX;
      var bMenuIsOn;

      this.showDD = showDD;
      this.hideMenu=hideMenu;
      this.delayHideMenu=delayHideMenu;
      this.clearHideMenu=clearHideMenu;
      this.dynamicHide=dynamicHide;
      this.clickReturnValue=clickReturnValue;
      this.menuIsOn=menuIsOn;

      this.populatemenu=populatemenu;

      var iParentNodeNumber = '17'; 

      this.clearHideMenu=clearHideMenu;

      createDiv();
      function createDiv() {

          var top_div = document.createElement('DIV');
          top_div.style.overflow = "hidden";
          top_div.style.backgroundColor = 'transparent';
          top_div.style.display = 'none';
          top_div.style.position = 'absolute';

          top_div.onmouseover = clearHideMenu;

          var inner_div = document.createElement('DIV');
          inner_div.style.display = 'none';
          inner_div.style.overflow = 'visible';
          top_div.style.overflow = "hidden";
          inner_div.style.position = 'relative';
          inner_div.onmouseover = clearHideMenu;
          inner_div.onmouseout  = dynamicHide;
          inner_div.onclick  = mHideAllMenus;
          inner_div.style.top = '10px';
          inner_div.id = 'mgicdropinnerdiv_'+currentInstance;
          
          MgicDropDown.hInnerIdToInstance[inner_div.id] = currentInstance;

          var iframe_block = null;
          if(!options.noIframe && MgicDropDown.ie5) {
               iframe_block = document.createElement('IFRAME');
               iframe_block.style.allowTransparency = 'true';
                iframe_block.style.backgroundColor = 'transparent';
                iframe_block.style.display = 'none';
                iframe_block.style.position = 'absolute';
                iframe_block.frameBorder = 0;
                iframe_block.border = 0;
                iframe_block.style.filter = 'Alpha(opacity=0)';
                iframe_block.src = "/web_common/blank.html";
          }


          //top_div.appendChild(iframe_block);
          top_div.appendChild(inner_div);

          if(!document.getElementById('mgicdropdown_holder')) {
              var droparea = document.createElement('DIV');
              droparea.style.width="1px";
              droparea.style.height="1px";
              droparea.id ='mgicdropdown_holder';
          
              if(document.getElementById('mgic_container')) {
                  document.getElementById('mgic_container').appendChild(droparea);
              } else {
                  document.getElementsByTagName('body')[0].appendChild(droparea);
              }
          }

          if(iframe_block != null) document.getElementById('mgicdropdown_holder').appendChild(iframe_block);
          document.getElementById('mgicdropdown_holder').appendChild(top_div);
      
          oDivOuter = top_div;
          oDivInner = inner_div;
          oIframe = iframe_block;

      }

        function showDD(oMenuParent, e, oMenuContents, hPassedOptions){
        
        	if (window.event) event.cancelBubble=true
        	else if (e.stopPropagation) e.stopPropagation();
        
            if(e.type=="click" && options.hideMenuOnClick && menuIsOn()) {
                showhide(oDivOuter, oDivInner, oIframe, e, menuwidth);
                return false;
            }

            if(typeof(oMenuParent) == "string") oMenuParent=document.getElementById? document.getElementById(oMenuParent) : eval(oMenuParent);
            if(typeof(oMenuContents) == "string") oMenuContents=document.getElementById? document.getElementById(oMenuContents) : eval(oMenuContents);

            if(!oMenuParent || !oMenuContents) return true;			

			var oldTargetDiv = oTargetDiv;
            oTargetDiv = oMenuParent;

            iParentNodeNumber = null;
            if(oMenuParent.parentNode.id &&  typeof(MgicDropDown.hInnerIdToInstance[oMenuParent.parentNode.id]) != "undefined") {
                 iParentNodeNumber =  MgicDropDown.hInnerIdToInstance[oMenuParent.parentNode.id];
            }

            if(!hPassedOptions) hPassedOptions = {};

            for (var i in MgicDropDown.defaults) {
                options[i] = MgicDropDown.defaults[i];
                if(typeof(hPassedOptions[i]) != "undefined") options[i] = hPassedOptions[i];
            }

            //From earlier dev.. abondoned in favor of minWidth.  Still used?
            if(typeof(hPassedOptions['collapseWidth']) != "undefined" && hPassedOptions['collapseWidth']) options['minWidth'] = 0;

            if (options.hideMenuOnClick) {
                document.onclick = mHideAllMenus;
            } else {
                document.onclick = function() { };
            }
            


        	
        	if(delayHide && oldTargetDiv == oTargetDiv) {
        	
        		clearHideMenu(); 

        	} else {

				clearHideMenu(); 
	
				populatemenu(oMenuContents,options.extraClasses,options.replaceParamsArray);	
				
				if (MgicDropDown.dropdownIsSupported){
					
					if (oAccel != null) oAccel.stop();
					
					var menuwidth = oMenuParent.offsetWidth;
	
					menuwidth = showhide(oDivOuter, oDivInner, oIframe, e, menuwidth);
					
                    if(!options.openRight) {
                        oDivInner.style.top = -oDivInner.offsetHeight+"px";
                    } else {
                        oDivInner.style.left = -oDivInner.offsetWidth+"px";
                        oDivInner.style.top = "0px";
                    }
					//oIframe.style.top = -oDivInner.offsetHeight+"px";

					oDivOuter.x = getposOffset(oMenuParent,"left") + options.offsetX;
					oDivOuter.y = getposOffset(oMenuParent,"top")  + options.offsetY;

                    if(options.openRight) {
                        oDivOuter.style.left = setOuterPositionRight(oMenuParent.offsetWidth,menuwidth,oDivOuter.x) + "px";
                        oDivOuter.style.top  = setOuterPositionTop(0,oDivInner.offsetHeight,oDivOuter.y,oMenuParent.offsetHeight) + "px";
                    } else {
                        oDivOuter.style.left = setOuterPositionRight(0,menuwidth,oDivOuter.x) + "px";
                        oDivOuter.style.top  = setOuterPositionTop(oMenuParent.offsetHeight,oDivInner.offsetHeight,oDivOuter.y) + "px";
                    }
			
                    if(oIframe != null) {
                        oIframe.style.left =  oDivOuter.style.left;
                        oIframe.style.top =  oDivOuter.style.top;
                    }


                    var x0;
                    var x1;


			        if(!options.openRight) {

                        x0 = parseInt(oDivInner.style.top);
                        x1 = 0;

                        if(isReversedY) {
                            x0 = parseInt(oDivOuter.offsetHeight);
                            x1 = 0;
                        }
                    } else {

                        x0 = parseInt(oDivInner.style.left);
                        x1 = 0;

                        if(isReversedX) {
                            var x0 = parseInt(oDivOuter.offsetWidth);
                            x1 = 0;
                        }
                    }


                    oAccel = new Accelimation(x0, x1, options.dropDownTime, -1);
			
					oAccel.onframe = (options.openRight)? slideFrameX : slideFrameY;
					oAccel.onend = slideEnd;
			
                    bMenuIsOn = true;
					oAccel.start();
			
				}
				
			}
			        	
        	return clickReturnValue();
        }

        function setOuterPositionRight(iMenuParentWidth,iMenuWidth,iOuterDivLeft) {
            
            var oDoc = (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
        
            var iCorrectLeft = iOuterDivLeft + iMenuParentWidth;
            isReversedX = false;

            var iRightEdge = MgicDropDown.ie5 && !window.opera ? oDoc.scrollLeft + oDoc.clientWidth-5 : window.pageXOffset + window.innerWidth-5;
            var iLeftEdge = MgicDropDown.ie5 && !window.opera ? oDoc.scrollLeft : window.pageXOffset;

            if (iMenuWidth + iOuterDivLeft + iMenuParentWidth > iRightEdge) { //Move left?
                iCorrectLeft = (options.openRight)? iOuterDivLeft - iMenuWidth : iRightEdge - iMenuWidth;
                isReversedX = true;

                if(iCorrectLeft < iLeftEdge) {  //left no good either?
                    iCorrectLeft = iRightEdge-iMenuWidth;
                    isReversedX = false;
                }

            }
            return iCorrectLeft;

        }

        function setOuterPositionTop(iMenuParentHeight,iMenuHeight,iOuterDivTop,iRealParentHeight) {
            
            var oDoc = (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body

            var iTopEdge =oDoc.scrollTop;
            var iRightEdge = MgicDropDown.ie5 && !window.opera ? oDoc.scrollTop + oDoc.clientHeight-15 : window.pageXOffset + window.innerWidth-15
            var iBottomEdge = oDoc.scrollTop + oDoc.clientHeight-15;

            var iCorrectTop = iOuterDivTop + iMenuParentHeight;
            isReversedY = false;

            if (iBottomEdge - iOuterDivTop < iMenuHeight){  //move up?                 btm of window - top of btn < height of menu
                iCorrectTop = iOuterDivTop - iMenuHeight + ((options.openRight)? iRealParentHeight : 0);   // menu height + item height
                isReversedY = true;
                if ((iOuterDivTop - iTopEdge) < iMenuHeight) { // up no good either?      top of btn - top of window < height of btn
                    iCorrectTop = iTopEdge; // top of btn + height of menu - top of window
                    isReversedY = false;
                }
            }
            return iCorrectTop;

        }
        
        function populatemenu(content_obj,classextra,replace_params){
        		var content_html = content_obj.innerHTML;
        		if(replace_params && replace_params.length) {
        			for(var i=0; i<replace_params.length; i++) {
        				var myregexp = new RegExp(replace_params[i][0], "g")
        				content_html = content_html.replace(myregexp,replace_params[i][1]);
        			}
        		}
        		oDivInner.innerHTML = content_html;
                if(classextra != "") classextra = " " + classextra;
        		oDivInner.className = content_obj.className + classextra;
                oDivInner.style.positioning = 'relative';
                //oIframe.style.positioning = 'relative';
        }
        
        function showhide(oParent, oMenuDisplay, oIframeBlocker, e, menuwidth){
        	if (MgicDropDown.dropdownIsSupported) {
        		
                //alerted(menuwidth);
                if (e.type=="click" && oParent.style.display=="none" || e.type=="mouseover") {
                    oParent.style.left=oParent.style.top="-500px";
        			
                    oMenuDisplay.style.visibility="visible";
        			//oIframeBlocker.style.visibility="visible";
        			
        			oParent.style.display="block";
                    oMenuDisplay.style.display="block";
        			
                    if(oIframeBlocker != null) {
                        oIframeBlocker.style.left=oIframeBlocker.style.top="-500px";
                        oIframeBlocker.style.display="inline";
                    }
                    
                    var addwidth = true;

                    if (options.minWidth || options.minWidth==0) {
                        
                        var collapse_menuwidth = 0;
                        var all = oMenuDisplay.all ? oMenuDisplay.all : oMenuDisplay.getElementsByTagName("*");
                        
                        var oDoc = (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body ;

                        oMenuDisplay.style.width = "1px";
                        

                        if(MgicDropDown.ns6 || all[0].offsetWidth <= 5) {

                            oMenuDisplay.style.width = 0;
                            oParent.style.width = 0;

                            oMenuDisplay.style.width = "";
                            oParent.style.width = "";
                        
                        }

                       for (var i = 0;i<all.length;i++) {
                            if(all[i].offsetWidth > collapse_menuwidth) {
                                collapse_menuwidth = all[i].offsetWidth;
                            }
                       }


                        if(options.minWidth == 'parent' && menuwidth + options.addedWidthToMenu >= collapse_menuwidth) {
                            oMenuDisplay.style.width = menuwidth + "px";
                        
                        } else if(options.minWidth + options.addedWidthToMenu >= collapse_menuwidth) {
                            oMenuDisplay.style.width = options.minWidth + "px";
                        
                        } else {
                            oMenuDisplay.style.width=collapse_menuwidth + "px";
                            addwidth = false;
                        }



                    } else if(menuwidth!="") {
                        
                        oMenuDisplay.style.width=menuwidth+"px";
                    
                    }

                    var addedwidth = (addwidth)? options.addedWidthToMenu : 0;
                    //alerted((addedwidth) + "px");
                    oMenuDisplay.style.width = (parseInt(oMenuDisplay.offsetWidth) + addedwidth) + "px";

                    oParent.style.width=oMenuDisplay.offsetWidth+"px";
                    oParent.style.height=oMenuDisplay.offsetHeight+"px";
                    
                    if(oIframe != null) {
                        oIframe.style.height = oMenuDisplay.offsetHeight + "px";
                        oIframeBlocker.style.width=oMenuDisplay.offsetWidth+"px";
                    }


        		} else if (e.type=="click") {
                    hideMenu();
        		}
        	}
            return oMenuDisplay.offsetWidth;
        }
        
        function menuIsOn() {
            if(oDivInner && oDivOuter.style.display != 'none' && bMenuIsOn) return true;
            return false;
        }

        function getposOffset(element, offsettype){

            var valueT = 0, valueL = 0;
            do {
                valueT += element.offsetTop  || 0;
                valueL += element.offsetLeft || 0;
                element = element.offsetParent;
            } while (element);
            return (offsettype=="left"? valueL : valueT);

        }
        
        function clickReturnValue(){ return !MgicDropDown.dropdownIsSupported; }
        
        function contains_ns6(a, b) {
        	if(!a||!b) return false;
        	while (b=b.parentNode)
        		if (b == a) return true;
        			return false;
        }
        
        function dynamicHide(e){

            if(!e) e = window.event;
        	if (MgicDropDown.ie5 && !(oDivInner.contains(e.toElement))) { // || oTargetDiv.contains(e.toElement)
        		delayHideMenu();
            } else if (MgicDropDown.ns6 && e.currentTarget != e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget)) {  //e.currentTarget != oTargetDiv && 
                delayHideMenu();
            }
        }
        
        function hideMenu(e){ 
            if (typeof oDivOuter!="undefined" && MgicDropDown.dropdownIsSupported){ 
                

                if (oAccel!= null) oAccel.stop();
             	delayHide = null;
        
                var x0;
                var x1;

                if(!options.openRight) {

                    x0 = parseInt(oDivInner.style.top);
                    x1 = -oDivInner.offsetHeight;

                    if(isReversedY) {
                        x0 = 0;
                        x1 = oDivOuter.offsetHeight;
                    }

                } else {

                    x0 = parseInt(oDivInner.style.left);
                    x1 = -oDivInner.offsetWidth;

                    if(isReversedX) {
                        x0 = 0;
                        x1 = oDivOuter.offsetWidth;
                    }
                }

                xer = 0;
                oAccel = new Accelimation(x0, x1, options.dropDownTime, -1);
        

                oAccel.onframe = (options.openRight)? slideFrameX : slideFrameY;
                oAccel.onend = finishhidemenu;
        
                oAccel.start();
                
            } 
        }
        
        function finishhidemenu(){ 
            oDivOuter.style.display="none"; 
            oDivInner.style.display="none"; 
            if(oIframe != null) oIframe.style.display="none";
            bMenuIsOn = false;
        }
        
        function delayHideMenu(){ 

            if(!menuIsOn()) return;
            if (MgicDropDown.dropdownIsSupported) {
                eval("window.hideMenu" + iInstance + " = hideMenu");
                if(typeof delayHide == "undefined" || delayHide == null) delayHide = setTimeout("window.hideMenu" + iInstance + "()",options.disappearDelay);

                if (iParentNodeNumber != null) {
                    MgicDropDown.instances[iParentNodeNumber].delayHideMenu();
                }
            }
        }
        
        function clearHideMenu(){
            if (typeof delayHide != "undefined") {
                clearTimeout(delayHide);
                delayHide = null;
            }

            if (iParentNodeNumber != null && MgicDropDown.instances[iParentNodeNumber]) {
                MgicDropDown.instances[iParentNodeNumber].clearHideMenu();
            }

        }
        
        function slideFrameY(x) {
                oDivInner.style.top = x + "px";
                if(oIframe != null && isReversedY && x + oDivInner.offsetHeight > 0) oIframe.style.height = x + oDivInner.offsetHeight + "px";
        }


        function slideFrameX(x) {
            oDivInner.style.left = x + "px";
            if(oIframe != null && !isReversedX && x + oDivInner.offsetWidth > 0) oIframe.style.width = x + oDivInner.offsetWidth + "px";
        }

        function slideEnd() { }
}




/* 
 * This part is:
 * Copyright 2003-2004, Aaron Boodman (www.youngpup.net)
 * =================================================================================================
 * 
 * Use of this library is governed by the Creative Commons Attribution 2.0 License. You can check it 
 * out at: http://creativecommons.org/licenses/by/2.0/
 */

//=====================================================================
// Accel[erated] [an]imation object
// change a property of an object over time in an accelerated fashion
//=====================================================================
// obj  : reference to the object whose property you'd like to animate
// to   : final value of prop
// time : time the animation should take to run
// zip	: optional. specify the zippiness of the acceleration. pick a 
//		  number between -1 and 1 where -1 is full decelerated, 1 is 
//		  full accelerated, and 0 is linear (no acceleration). default
//		  is 0.
//=====================================================================
// bezier functions lifted from the lib_animation.js file in the 
// 13th Parallel API. www.13thparallel.org
//=====================================================================

function Accelimation(from, to, time, zip) {
	if (typeof zip  == "undefined") zip  = 0;
	if (typeof unit == "undefined") unit = "px";

        this.x0         = from;
        this.x1		= to;
	this.dt		= time;
	this.zip	= -zip;
	this.unit	= unit;
	this.timer	= null;
	this.onend	= new Function();
        this.onframe    = new Function();
}



//=====================================================================
// public methods
//=====================================================================

// after you create an accelimation, you call this to start it-a runnin'
Accelimation.prototype.start = function() {
	this.t0 = new Date().getTime();
	this.t1 = this.t0 + this.dt;
	var dx	= this.x1 - this.x0;
	this.c1 = this.x0 + ((1 + this.zip) * dx / 3);
	this.c2 = this.x0 + ((2 + this.zip) * dx / 3);
	Accelimation._add(this);
}

// and if you need to stop it early for some reason...
Accelimation.prototype.stop = function() {
	Accelimation._remove(this);
}



//=====================================================================
// private methods
//=====================================================================

// paints one frame. gets called by Accelimation._paintAll.
Accelimation.prototype._paint = function(time) {
	if (time < this.t1) {
		var elapsed = time - this.t0;
	        this.onframe(Accelimation._getBezier(elapsed/this.dt,this.x0,this.x1,this.c1,this.c2));
        }
	else this._end();
}

// ends the animation
Accelimation.prototype._end = function() {
	Accelimation._remove(this);
        this.onframe(this.x1);
	this.onend();
}




//=====================================================================
// static methods (all private)
//=====================================================================

// add a function to the list of ones to call periodically
Accelimation._add = function(o) {
	var index = this.instances.length;
	this.instances[index] = o;
	// if this is the first one, start the engine
	if (this.instances.length == 1) {
		this.timerID = window.setInterval("Accelimation._paintAll()", this.targetRes);
	}
}

// remove a function from the list
Accelimation._remove = function(o) {
	for (var i = 0; i < this.instances.length; i++) {
		if (o == this.instances[i]) {
			this.instances = this.instances.slice(0,i).concat( this.instances.slice(i+1) );
			break;
		}
	}
	// if that was the last one, stop the engine
	if (this.instances.length == 0) {
		window.clearInterval(this.timerID);
		this.timerID = null;
	}
}

// "engine" - call each function in the list every so often
Accelimation._paintAll = function() {
	var now = new Date().getTime();
	for (var i = 0; i < this.instances.length; i++) {
		this.instances[i]._paint(now);
	}

}


// Bezier functions:
Accelimation._B1 = function(t) { return t*t*t }
Accelimation._B2 = function(t) { return 3*t*t*(1-t) }
Accelimation._B3 = function(t) { return 3*t*(1-t)*(1-t) }
Accelimation._B4 = function(t) { return (1-t)*(1-t)*(1-t) }


//Finds the coordinates of a point at a certain stage through a bezier curve
Accelimation._getBezier = function(percent,startPos,endPos,control1,control2) {
	return endPos * this._B1(percent) + control2 * this._B2(percent) + control1 * this._B3(percent) + startPos * this._B4(percent);
}


//=====================================================================
// static properties
//=====================================================================

Accelimation.instances = [];
Accelimation.targetRes = 10;
Accelimation.timerID = null;



var alerted_done = false;
function alerted(string) {
    if(!alerted_done) {
        alerted_done = true;
        alert(string);
    }
}
var num_alerts = 0;
function alert10(string) {
    if(num_alerts++ < 10) alert(string);
}

