﻿/* mocktabs */
var mocktabs = Class.create();
mocktabs.prototype = {
    initialize: function(divId, exId, def, hparam, externalVar) {
        this.divId = divId;
        this.def = def;
        this.hparam = hparam;
        this.exId = exId;
        this.external = externalVar;
    },
    build: function() {
        var i = 0;
        var res = '';
        var selIdx = getHashParameter(this.hparam, getURLParameter('type', 0));
        for (i = 0; i < this.def.length; i++) {
            res += '<li><a href="javascript:void(0)" onclick="setHashParameter(\'' + this.hparam + '\', ' + i + ');' + this.external + '.build();"';
            if (selIdx == i) {
                res += ' class="selected"';
                document.getElementById(this.exId).innerHTML = this.def[i].Example;
            }
            res += '>' + this.def[i].Title + '</a></li>';

        }
        document.getElementById(this.divId).innerHTML = res;
    }
};


/* menu.js */
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;

function mcancelclosetime() {
    if (closetimer) {
        window.clearTimeout(closetimer);
        closetimer = null;
    }
}

// open hidden layer

function mopen(sender, id) {
    // cancel close timer
    mcancelclosetime();

    // close old layer
    if (ddmenuitem) {
        ddmenuitem.style.visibility = 'hidden';
    }

    // get new layer and show it
    ddmenuitem = document.getElementById(id);
    ddmenuitem.style.visibility = 'visible';
    ddmenuitem.style.left = ajaxTooltip_getLeftPos(sender) + 'px';
    ddmenuitem.style.top = (ajaxTooltip_getTopPos(sender) + 30) + 'px';

}
// close showed layer

function mclose() {
    if (ddmenuitem) {
        ddmenuitem.style.visibility = 'hidden';
    }
}

// go close timer

function mclosetime() {
    closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
// close layer when click-out
document.onclick = mclose;

/* dropdown.js */

function at_show_aux(parent, child) {
    var p = document.getElementById(parent);
    var c = document.getElementById(child);

    var height = c.offsetHeight;

    var maxheight = c.max_height;

    if (maxheight > 0 && height > maxheight) {
        c.style.height = maxheight + 'px';
        c.style.overflowX = "hidden";
        c.style.overflowY = "scroll";
        c.style.width = (c.offsetWidth + 10) + 'px';
    }

    var top = (c.at_position == "y") ? p.offsetHeight + 2 : 0;
    var left = (c.at_position == "x") ? p.offsetWidth + 2 : 0;

    for (; p; p = p.offsetParent) {
        top += p.offsetTop;
        left += p.offsetLeft;
    }

    c.style.position = "absolute";
    c.style.top = top + 'px';
    c.style.left = left + 'px';
    c.style.visibility = "visible";

}

// ***** at_show *****

function at_show() {
    var p = document.getElementById(this.at_parent);
    var c = document.getElementById(this.at_child);

    at_show_aux(p.id, c.id);
    clearTimeout(c.at_timeout);
}

// ***** at_hide *****

function at_hide() {
    var c = document.getElementById(this.at_child);

    c.at_timeout = setTimeout("document.getElementById('" + c.id + "').style.visibility = 'hidden'", 333);
}

// ***** at_click *****

function at_click() {
    var p = document.getElementById(this.at_parent);
    var c = document.getElementById(this.at_child);

    if (c.style.visibility != "visible") {
        at_show_aux(p.id, c.id);
    } else {
        c.style.visibility = "hidden";
    }
    return false;
}

// ***** at_attach *****
// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name

function at_attach(parent, child, showtype, position, cursor, maxheight) {
    var p = document.getElementById(parent);
    var c = document.getElementById(child);

    c.max_height = maxheight;
    p.at_parent = p.id;
    c.at_parent = p.id;
    p.at_child = c.id;
    c.at_child = c.id;
    p.at_position = position;
    c.at_position = position;

    c.style.position = "absolute";
    c.style.visibility = "hidden";

    if (cursor !== undefined) {
        p.style.cursor = cursor;
    }

    switch (showtype) {
        case "click":
            p.onclick = at_show;

            c.onmouseover = at_show;
            c.onmouseout = at_hide;
            break;
        case "hover":
            p.onmouseover = at_show;
            p.onmouseout = at_hide;
            c.onmouseover = at_show;
            c.onmouseout = at_hide;
            break;
    }
}
/* tabcontent */

function ddtabcontent(tabinterfaceid) {
    this.tabinterfaceid = tabinterfaceid; //ID of Tab Menu main container
    this.tabs = document.getElementById(tabinterfaceid).getElementsByTagName("a"); //Get all tab links within container
    this.enabletabpersistence = true;
    this.hottabspositions = []; //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container
    this.currentTabIndex = 0; //Index of currently selected hot tab (tab with sub content) within hottabspositions[] array
    this.subcontentids = []; //Array to store ids of the sub contents ("rel" attr values)
    this.revcontentids = []; //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)
    this.selectedClassTarget = "link"; //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")	
}

ddtabcontent.getCookie = function(Name) {
    var re = new RegExp(Name + "=[^;]+", "i"); //construct RE to search for target name/value pair
    if (document.cookie.match(re)) //if cookie found
    {
        return document.cookie.match(re)[0].split("=")[1];
    } //return its value
    return "";
};

ddtabcontent.setCookie = function(name, value) {
    document.cookie = name + "=" + value + ";path=/"; //cookie value is domain wide (path=/)
};

ddtabcontent.prototype = {

    expandit: function(tabid_or_position) { //PUBLIC function to select a tab either by its ID or position(int) within its peers
        this.cancelautorun(); //stop auto cycling of tabs (if running)
        var tabref = "";
        try {
            if (typeof tabid_or_position == "string" && document.getElementById(tabid_or_position).getAttribute("rel")) //if specified tab contains "rel" attr
            {
                tabref = document.getElementById(tabid_or_position);
            }
            else if ((!parseInt(tabid_or_position, 10).isNaN) && this.tabs[tabid_or_position].getAttribute("rel")) //if specified tab contains "rel" attr
            {
                tabref = this.tabs[tabid_or_position];
            }
        }
        catch (err) {
            alert("Invalid Tab ID or position entered!");
        }
        if (tabref != "") //if a valid tab is found based on function parameter
        {
            this.expandtab(tabref);
        } //expand this tab
    },

    cycleit: function(dir, autorun) { //PUBLIC function to move foward or backwards through each hot tab (tabinstance.cycleit('foward/back') )
        var currentTabIndex;
        if (dir == "next") {
            currentTabIndex = (this.currentTabIndex < this.hottabspositions.length - 1) ? this.currentTabIndex + 1 : 0;
        } else if (dir == "prev") {
            currentTabIndex = (this.currentTabIndex > 0) ? this.currentTabIndex - 1 : this.hottabspositions.length - 1;
        }
        if (typeof autorun == "undefined") //if cycleit() is being called by user, versus autorun() function
        {
            this.cancelautorun();
        } //stop auto cycling of tabs (if running)
        this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]]);
    },

    setpersist: function(bool) { //PUBLIC function to toggle persistence feature
        this.enabletabpersistence = bool;
    },

    setdisplayelement: function(id) { //PUBLIC function to toggle persistence feature
        this.displayElement = document.getElementById(id);
    },

    setselectedClassTarget: function(objstr) { //PUBLIC function to set which target element to assign "selected" CSS class ("linkparent" or "link")
        this.selectedClassTarget = objstr || "link";
    },

    getselectedClassTarget: function(tabref) { //Returns target element to assign "selected" CSS class to
        return (this.selectedClassTarget == ("linkparent".toLowerCase())) ? tabref.parentNode : tabref;
    },

    urlparamselect: function(tabinterfaceid) {
        var result = window.location.search.match(new RegExp(tabinterfaceid + "=(\\d+)", "i")); //check for "?tabinterfaceid=2" in URL
        return (result === null) ? null : parseInt(RegExp.$1, 10); //returns null or index, where index (int) is the selected tab's index
    },

    expandtab: function(tabref) {
        if (typeof this.displayElement != "undefined") {
            this.displayElement.innerHTML = tabref.innerHTML;
        }
        var subcontentid = tabref.getAttribute("rel"); //Get id of subcontent to expand
        //Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easily search through
        var associatedrevids = (tabref.getAttribute("rev")) ? "," + tabref.getAttribute("rev").replace(/\s+/, "") + "," : "";
        this.expandsubcontent(subcontentid);
        this.expandrevcontent(associatedrevids);
        for (var i = 0; i < this.tabs.length; i++) { //Loop through all tabs, and assign only the selected tab the CSS class "selected"
            this.getselectedClassTarget(this.tabs[i]).className = (this.tabs[i].getAttribute("rel") == subcontentid) ? "selected" : "";
        }
        if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
        {
            ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition);
        }
        this.setcurrenttabindex(tabref.tabposition); //remember position of selected tab within hottabspositions[] array
    },

    expandsubcontent: function(subcontentid) {
        for (var i = 0; i < this.subcontentids.length; i++) {
            var subcontent = document.getElementById(this.subcontentids[i]); //cache current subcontent obj (in for loop)
            subcontent.style.display = (subcontent.id == subcontentid) ? "block" : "none"; //"show" or hide sub content based on matching id attr value
        }
    },

    expandrevcontent: function(associatedrevids) {
        var allrevids = this.revcontentids;
        for (var i = 0; i < allrevids.length; i++) { //Loop through rev attributes for all tabs in this tab interface
            //if any values stored within associatedrevids matches one within allrevids, expand that DIV, otherwise, contract it
            document.getElementById(allrevids[i]).style.display = (associatedrevids.indexOf("," + allrevids[i] + ",") != -1) ? "block" : "none";
        }
    },

    setcurrenttabindex: function(tabposition) { //store current position of tab (within hottabspositions[] array)
        for (var i = 0; i < this.hottabspositions.length; i++) {
            if (tabposition == this.hottabspositions[i]) {
                this.currentTabIndex = i;
                break;
            }
        }
    },

    autorun: function() { //function to auto cycle through and select tabs based on a set interval
        this.cycleit('next', true);
    },

    cancelautorun: function() {
        if (typeof this.autoruntimer != "undefined") {
            clearInterval(this.autoruntimer);
        }
    },

    init: function(automodeperiod) {
        var persistedtab = ddtabcontent.getCookie(this.tabinterfaceid); //get position of persisted tab (applicable if persistence is enabled)
        var selectedtab = -1; //Currently selected tab index (-1 meaning none)
        var selectedtabfromurl = this.urlparamselect(this.tabinterfaceid); //returns null or index from: tabcontent.htm?tabinterfaceid=index
        this.automodeperiod = automodeperiod || 0;
        for (var i = 0; i < this.tabs.length; i++) {
            this.tabs[i].tabposition = i; //remember position of tab relative to its peers
            if (this.tabs[i].getAttribute("rel")) {
                var tabinstance = this;
                this.hottabspositions[this.hottabspositions.length] = i; //store position of "hot" tab ("rel" attr defined) relative to its peers
                this.subcontentids[this.subcontentids.length] = this.tabs[i].getAttribute("rel"); //store id of sub content ("rel" attr value)
                this.tabs[i].onclick = function() {
                    tabinstance.expandtab(this);
                    tabinstance.cancelautorun(); //stop auto cycling of tabs (if running)
                    return false;
                };
                if (this.tabs[i].getAttribute("rev")) { //if "rev" attr defined, store each value within "rev" as an array element
                    this.revcontentids = this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/));
                }
                if (selectedtabfromurl == i || this.enabletabpersistence && selectedtab == -1 && parseInt(persistedtab, 10) == i || !this.enabletabpersistence && selectedtab == -1 && this.getselectedClassTarget(this.tabs[i]).className == "selected") {
                    selectedtab = i; //Selected tab index, if found
                }
            }
        } //END for loop
        if (selectedtab != -1) //if a valid default selected tab index is found
        {
            this.expandtab(this.tabs[selectedtab]);
        } //expand selected tab (either from URL parameter, persistent feature, or class="selected" class)
        else //if no valid default selected index found
        {
            this.expandtab(this.tabs[this.hottabspositions[0]]);
        } //Just select first tab that contains a "rel" attr
        if (parseInt(this.automodeperiod, 10) > 500 && this.hottabspositions.length > 1) {
            this.autoruntimer = setInterval(function() {
                tabinstance.autorun();
            }, this.automodeperiod);
        }
    } //END int() function
}; //END Prototype assignment
/* tabextender.js */

var TabExtender = function(tabid, externalVariable) {
    this.lastTab = -1;
    this.targetId = tabid;
    this.tabActions = false;
    this.externalVariable = externalVariable;
};

TabExtender.prototype.runShowTab = function(index) {
    if (typeof this.tabActions[index].Variable != 'undefined') {
        if (typeof this.tabActions[index].Inited == 'undefined') {
            waitfor(this.tabActions[index].Variable, this.tabActions[index].OnInit);
            this.tabActions[index].Inited = true;
        }
    } else {
        if (typeof this.tabActions[index].Inited == 'undefined') {
            altEval(this.tabActions[index].OnInit);
            this.tabActions[index].Inited = true;
        }
    }
    if (typeof (this.tabActions[index].OnShow) != 'undefined') {
        if (typeof this.tabActions[index].Variable != 'undefined') {
            waitfor(this.tabActions[index].Variable, this.tabActions[index].OnShow);
        }
    } else {
        altEval(this.tabActions[index].OnShow);
    }
    if (typeof (this.tabActions[index].PageTitle) != 'undefined') {
        document.title = this.tabActions[index].PageTitle;
    }
    if ((typeof window.pageTracker != 'undefined') && (typeof this.tabActions[index].TrackingKey != 'undefined')) {
        window.pageTracker._trackPageview(this.tabActions[index].TrackingKey);
    }
};

TabExtender.prototype.runHideTab = function(index) {
    if (typeof this.tabActions[index].OnHide != 'undefined') {
        altEval(this.tabActions[index].OnHide);
    }
};

TabExtender.prototype.showTab = function(idx) {
    if (this.lastTab != -1) {
        this.runHideTab(lastTab);
    }
    this.lastTab = idx;
    if (typeof (this.tabActions[idx].Variable) != 'undefined') {
        waitfor(this.tabActions[idx].Variable, this.tabActions[idx].OnInit);
        this.tabActions[idx].Inited = true;
    } else {
        altEval(this.tabActions[idx].OnInit);
        this.tabActions[idx].Inited = true;
    }

    this.runShowTab(idx);
};

TabExtender.prototype.tabInit = function(sender, e) {
    var tabc = $find(this.targetId);
    var value = getHashParameter(this.externalVariable, tabc.get_activeTabIndex());
    setTimeout('$find(\'' + this.targetId + '\').set_activeTabIndex(' + value + ');', 100);
    this.showTab(value);
};

TabExtender.prototype.changeTab = function(sender, e) {

    var newIndex = sender.get_activeTab().get_tabIndex();
    this.setTabIndex(newIndex);
};

TabExtender.prototype.setTabIndex = function(newIndex) {
    setHashParameter(this.externalVariable, newIndex);
    if (this.lastTab != -1) {
        this.runHideTab(this.lastTab);
    }
    this.lastTab = newIndex;
    this.runShowTab(newIndex);
};

TabExtender.prototype.doChangeTab = function(index) {
    setTimeout('$find(\'' + this.targetId + '\').set_activeTabIndex(' + index + ');', 100);
};


/* anylinkcssmenu.js */
var anylinkcssmenu = {

    menusmap: {},
    divmap: {},
    preloadimages: [],
    effects: {
        delayhide: 1200,
        shadow: {
            enabled: false,
            opacity: 0.3,
            depth: [5, 5]
        },
        fade: {
            enabled: true,
            duration: 200
        }
    },
    //customize menu effects
    dimensions: {},

    getoffset: function(what, offsettype) {
        return (what.offsetParent) ? what[offsettype] + this.getoffset(what.offsetParent, offsettype) : what[offsettype];
    },

    getoffsetof: function(el) {
        el._offsets = {
            left: this.getoffset(el, "offsetLeft"),
            top: this.getoffset(el, "offsetTop"),
            h: el.offsetHeight
        };
    },

    getdimensions: function(menu) {
        this.dimensions = {
            anchorw: menu.anchorobj.offsetWidth,
            anchorh: menu.anchorobj.offsetHeight,
            docwidth: (window.innerWidth || this.standardbody.clientWidth) - 20,
            docheight: (window.innerHeight || this.standardbody.clientHeight) - 15,
            docscrollx: window.pageXOffset || this.standardbody.scrollLeft,
            docscrolly: window.pageYOffset || this.standardbody.scrollTop
        };
        if (!this.dimensions.dropmenuw) {
            this.dimensions.dropmenuw = menu.dropmenu.offsetWidth;
            this.dimensions.dropmenuh = menu.dropmenu.offsetHeight;
        }
    },

    isContained: function(m, e) {
        e = window.event || e;
        var c = e.relatedTarget || ((e.type == "mouseover") ? e.fromElement : e.toElement);
        while (c && c != m) {
            try {
                c = c.parentNode;
            } catch (ee) {
                c = m;
            }
        }
        if ((typeof c === 'undefined') || (c == m)) {
            return true;
        } else {
            return false;
        }
    },

    setopacity: function(el, value) {
        el.style.opacity = value;
        if (typeof el.style.opacity != "string") { //if it's not a string (ie: number instead), it means property not supported
            el.style.MozOpacity = value;
            if (el.filters) {
                el.style.filter = "progid:DXImageTransform.Microsoft.alpha(opacity=" + value * 100 + ")";
            }
        }
    },

    showmenu: function(menuid) {
        var menu = anylinkcssmenu.menusmap[menuid];
        clearTimeout(menu.hidetimer);
        this.getoffsetof(menu.anchorobj);
        this.getdimensions(menu);
        var posx = menu.anchorobj._offsets.left + (menu.orientation == "lr" ? this.dimensions.anchorw : 0); //base x pos
        var posy = menu.anchorobj._offsets.top + this.dimensions.anchorh - (menu.orientation == "lr" ? this.dimensions.anchorh : 0); //base y pos
        if (posx + this.dimensions.dropmenuw + this.effects.shadow.depth[0] > this.dimensions.docscrollx + this.dimensions.docwidth) { //drop left instead?
            posx = posx - this.dimensions.dropmenuw + (menu.orientation == "lr" ? -this.dimensions.anchorw : this.dimensions.anchorw);
        }
        if (posy + this.dimensions.dropmenuh > this.dimensions.docscrolly + this.dimensions.docheight) { //drop up instead?
            posy = Math.max(posy - this.dimensions.dropmenuh - (menu.orientation == "lr" ? -this.dimensions.anchorh : this.dimensions.anchorh), this.dimensions.docscrolly); //position above anchor or window's top edge
        }
        if (this.effects.fade.enabled) {
            this.setopacity(menu.dropmenu, 0); //set opacity to 0 so menu appears hidden initially
            if (this.effects.shadow.enabled) {
                this.setopacity(menu.shadow, 0);
            } //set opacity to 0 so shadow appears hidden initially
        }
        menu.dropmenu.setcss({
            left: posx + 'px',
            top: posy + 'px',
            visibility: 'visible'
        });
        if (this.effects.shadow.enabled) {
            menu.shadow.setcss({
                left: posx + anylinkcssmenu.effects.shadow.depth[0] + 'px',
                top: posy + anylinkcssmenu.effects.shadow.depth[1] + 'px',
                visibility: 'visible'
            });
        }
        if (this.effects.fade.enabled) {
            clearInterval(menu.animatetimer);
            menu.curanimatedegree = 0;
            menu.starttime = new Date().getTime(); //get time just before animation is run
            menu.animatetimer = setInterval(function() {
                anylinkcssmenu.revealmenu(menuid);
            }, 20);
        }
    },

    revealmenu: function(menuid) {
        var menu = anylinkcssmenu.menusmap[menuid];
        var elapsed = new Date().getTime() - menu.starttime; //get time animation has run
        if (elapsed < this.effects.fade.duration) {
            this.setopacity(menu.dropmenu, menu.curanimatedegree);
            if (this.effects.shadow.enabled) {
                this.setopacity(menu.shadow, menu.curanimatedegree * this.effects.shadow.opacity);
            }
        } else {
            clearInterval(menu.animatetimer);
            this.setopacity(menu.dropmenu, 1);
            menu.dropmenu.style.filter = "";
        }
        menu.curanimatedegree = (1 - Math.cos((elapsed / this.effects.fade.duration) * Math.PI)) / 2;
    },

    hidedivmenu: function(cssclass, divid) {
        var rightpos = 0;
        for (pos = 0; pos < this.divmap.length; pos++) {
            if (divid == this.divmap[pos]) {
                rightpos = pos;
            }
        }
        anylinkcssmenu.hidemenu(cssclass + rightpos);
    },

    setcss: function(param) {
        var prop;
        for (prop in param) {
            this.style[prop] = param[prop];
        }
    },

    setcssclass: function(el, targetclass, action) {
        var needle = new RegExp("(^|\\s+)" + targetclass + "($|\\s+)", "ig");
        if (action == "check") {
            return needle.test(el.className);
        } else if (action == "remove") {
            el.className = el.className.replace(needle, "");
        } else if (action == "add" && !needle.test(el.className)) {
            el.className += " " + targetclass;
        }
    },

    hidemenu: function(menuid) {
        var menu = anylinkcssmenu.menusmap[menuid];
        clearInterval(menu.animatetimer);
        menu.dropmenu.setcss({
            visibility: 'hidden',
            left: 0,
            top: 0
        });
        menu.shadow.setcss({
            visibility: 'hidden',
            left: 0,
            top: 0
        });
    },

    getElementsByClass: function(targetclass) {
        if (document.querySelectorAll) {
            return document.querySelectorAll("." + targetclass);
        } else {
            var classnameRE = new RegExp("(^|\\s+)" + targetclass + "($|\\s+)", "i"); //regular expression to screen for classname
            var pieces = [];
            var alltags = document.all ? document.all : document.getElementsByTagName("*");
            for (var i = 0; i < alltags.length; i++) {
                if (typeof alltags[i].className == "string" && alltags[i].className.search(classnameRE) != -1) {
                    pieces[pieces.length] = alltags[i];
                }
            }
            return pieces;
        }
    },

    addEvent: function(targetarr, functionref, tasktype) {
        if (targetarr.length > 0) {
            var target = targetarr.shift();
            if (target.addEventListener) {
                target.addEventListener(tasktype, functionref, false);
            } else if (target.attachEvent) {
                target.attachEvent('on' + tasktype, function() {
                    return functionref.call(target, window.event);
                });
            }
            this.addEvent(targetarr, functionref, tasktype);
        }
    },

    addState: function(anchorobj, state) {
        if (anchorobj.getAttribute('data-image')) {
            var imgobj = (anchorobj.tagName == "IMG") ? anchorobj : anchorobj.getElementsByTagName('img')[0];
            if (imgobj) {
                imgobj.src = (state == "add") ? anchorobj.getAttribute('data-overimage') : anchorobj.getAttribute('data-image');
            }
        } else {
            anylinkcssmenu.setcssclass(anchorobj, "selectedanchor", state);
        }
    },


    setupmenu: function(targetclass, anchorobj, pos) {
        this.standardbody = (document.compatMode == "CSS1Compat") ? document.documentElement : document.body;
        var relattr = anchorobj.getAttribute("rel");
        var dropmenuid = relattr.replace(/\[(\w+)\]/, '');
        anylinkcssmenu.divmap[pos] = dropmenuid;
        var menu = this.menusmap[targetclass + pos] = {
            id: targetclass + pos,
            anchorobj: anchorobj,
            dropmenu: document.getElementById(dropmenuid),
            revealtype: (relattr.length != dropmenuid.length && RegExp.$1 == "click") ? "click" : "mouseover",
            orientation: anchorobj.getAttribute("rev") == "lr" ? "lr" : "ud",
            shadow: document.createElement("div")
        };
        menu.anchorobj._internalID = targetclass + pos;
        menu.anchorobj._isanchor = true;
        menu.dropmenu._internalID = targetclass + pos;
        menu.shadow._internalID = targetclass + pos;
        menu.shadow.className = "anylinkshadow";
        document.body.appendChild(menu.dropmenu); //move drop down div to end of page
        document.body.appendChild(menu.shadow);
        menu.dropmenu.setcss = this.setcss;
        menu.shadow.setcss = this.setcss;
        menu.shadow.setcss({
            width: menu.dropmenu.offsetWidth + "px",
            height: menu.dropmenu.offsetHeight + "px"
        });
        this.setopacity(menu.shadow, this.effects.shadow.opacity);
        this.addEvent([menu.anchorobj, menu.dropmenu, menu.shadow], function(e) { //MOUSEOVER event for anchor, dropmenu, shadow
            var menu = anylinkcssmenu.menusmap[this._internalID];
            if (this._isanchor && menu.revealtype == "mouseover" && !anylinkcssmenu.isContained(this, e)) { //event for anchor
                anylinkcssmenu.showmenu(menu.id);
                anylinkcssmenu.addState(this, "add");
            } else if (typeof this._isanchor == "undefined") { //event for drop down menu and shadow
                clearTimeout(menu.hidetimer);
            }
        }, "mouseover");
        this.addEvent([menu.anchorobj, menu.dropmenu, menu.shadow], function(e) { //MOUSEOUT event for anchor, dropmenu, shadow                
            if (!anylinkcssmenu.isContained(this, e)) {
                var menu = anylinkcssmenu.menusmap[this._internalID];
                menu.hidetimer = setTimeout(function() {
                    anylinkcssmenu.addState(menu.anchorobj, "remove");
                    anylinkcssmenu.hidemenu(menu.id);
                }, anylinkcssmenu.effects.delayhide);
            }
        }, "mouseout");
        this.addEvent([menu.anchorobj], function(e) { //CLICK event for anchor, dropmenu
            var menu = anylinkcssmenu.menusmap[this._internalID];
            if (this._isanchor && menu.revealtype == "click") {
                if (menu.dropmenu.style.visibility == "visible") {
                    anylinkcssmenu.hidemenu(menu.id);
                } else {
                    anylinkcssmenu.addState(this, "add");
                    anylinkcssmenu.showmenu(menu.id);
                }
                if (e.preventDefault) {
                    e.preventDefault();
                }
                return false;
            } else {
                menu.hidetimer = setTimeout(function() {
                    anylinkcssmenu.hidemenu(menu.id);
                }, anylinkcssmenu.effects.delayhide);
            }
        }, "click");
    },
    init: function(targetclass) {
        var anchors = this.getElementsByClass(targetclass);
        var preloadimages = this.preloadimages;
        for (var i = 0; i < anchors.length; i++) {
            if (anchors[i].getAttribute('data-image')) { //preload anchor image?
                preloadimages[preloadimages.length] = new Image();
                preloadimages[preloadimages.length - 1].src = anchors[i].getAttribute('data-image');
            }
            if (anchors[i].getAttribute('data-overimage')) { //preload anchor image?
                preloadimages[preloadimages.length] = new Image();
                preloadimages[preloadimages.length - 1].src = anchors[i].getAttribute('data-overimage');
            }
            this.setupmenu(targetclass, anchors[i], i);
        }
    }

};