﻿/*******************************************************/
function OrvisFlyOut(FlyOutObj) {
this.trigger = $(FlyOutObj.trigger);
// the menu is the div that contains all the menu options. 
this.menu = $(FlyOutObj.menuDiv);
// what is the open/close delay 
this.showDelay = 500;
if ($(FlyOutObj.OpenDelay) != null) { this.showDelay = $(FlyOutObj.OpenDelay); } //override the delay via the control (if set)
this.hideDelay = 50;
if ($(FlyOutObj.CloseDelay) != null) { this.hideDelay = $(FlyOutObj.CloseDelay); } //override the delay via the control (if set)
this.opendelay = null;
this.closedelay = null;

// if the menu div isn't valid, abort.
if (!this.menu) { return false; } 

// define the open and close functions.  We use the show() and hide() functions from Prototype.    
this.open = function() { 
    if (this.closedelay != null) { window.clearTimeout(this.closedelay); }
    if (this.showDelay > 0) {
        this.opendelay = window.setTimeout("$('" + this.menu.id + "').show();$('" + FlyOutObj.imageSrc + "').src = $('" + FlyOutObj.imgH + "').src;", this.showDelay);        
    } else { 
        eval("$('" + FlyOutObj.imageSrc + "').src = $('" + FlyOutObj.imgH + "').src;")
        this.menu.show(); 
        this.flonormal.id.hide();
        this.flohover.id.show();
    }
};
this.close = function() { 
    if (this.opendelay != null) { window.clearTimeout(this.opendelay); }
    if (this.hideDelay > 0) {
        this.closedelay = window.setTimeout("$('" + this.menu.id + "').hide();$('" + FlyOutObj.imageSrc + "').src = $('" + FlyOutObj.imgN + "').src;", this.hideDelay);
    } else { 
        eval("$('" + FlyOutObj.imageSrc + "').src = $('" + FlyOutObj.imgN + "').src;")
        this.menu.hide(); 
        this.flonormal.id.show();
        this.flohover.id.hide();
    }
};
// set up the events.  On mouseover of either trigger or menu, open.  On mouseout of either, close.
Event.observe(this.menu, 'mouseover', this.open.bindAsEventListener(this));
Event.observe(this.menu, 'mouseout', this.close.bindAsEventListener(this));
if (this.trigger) { 
    Event.observe(this.trigger, 'mouseover', this.open.bindAsEventListener(this)); 
    Event.observe(this.trigger, 'mouseout', this.close.bindAsEventListener(this)); 
    Event.observe(this.trigger, 'click', this.close.bindAsEventListener(this)); 
}
};

var OrvisFlyOutByClass = function (FlyOutObj) {
    this.trigger = FlyOutObj.trigger;
    this.menu = FlyOutObj.menu;
    this.className = FlyOutObj.className;
    this.showDelay = 500;
    if ($(FlyOutObj.OpenDelay) != null) { this.showDelay = $(FlyOutObj.OpenDelay); } //override the delay via the control (if set)
    this.hideDelay = 50;
    if ($(FlyOutObj.CloseDelay) != null) { this.hideDelay = $(FlyOutObj.CloseDelay); } //override the delay via the control (if set)
    this.openDelay = null;
    this.closeDelay = null;
    this.open = function () {
        if (this.closeDelay != null) { window.clearTimeout(this.closeDelay); }
        if (this.showDelay > 0) {
            this.openDelay = window.setTimeout("$('" + this.menu.id + "').addClassName('" + this.className + "');", this.showDelay);
        } else {
            $(this.menu).addClassName(this.className);
        }
    };
    this.close = function () {
        if (this.openDelay != null) { window.clearTimeout(this.openDelay); }
        if (this.hideDelay > 0) {
            this.closeDelay = window.setTimeout("$('" + this.menu.id + "').removeClassName('" + this.className + "');", this.hideDelay);
        } else {
            $(this.menu).removeClassName(this.className);
        }
    };

    Event.observe(this.menu, 'mouseover', this.open.bindAsEventListener(this));
    Event.observe(this.menu, 'mouseout', this.close.bindAsEventListener(this));
    if (this.trigger) {
        Event.observe(this.trigger, 'mouseover', this.open.bindAsEventListener(this));
        Event.observe(this.trigger, 'mouseout', this.close.bindAsEventListener(this));
        Event.observe(this.trigger, 'click', this.close.bindAsEventListener(this));
    }
};

