﻿/*******************************************************/
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;
this.hideDelay = 50;
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 { 
        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 { 
        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)); 
}
};