﻿var gVid = new Array();
    function inArray(arr){
        for(i=0; i<gVid.length; i++){
            if(gVid[i] == arr ){
                return true;
            }
        }
        return false;
    }
    function sendEvent(swf,typ,prm) {
        thisMovie(swf).sendEvent('playpause');
    }
    function getUpdate(typ,pr1,pr2,swf) {
        if( typ == "time") {
            if( pr1 > 0.75) {
                if( inArray(swf) == false) {
                    gVid.push(swf);
                    window.setTimeout(sendEvent(swf,'playpause'),50);
                }
            }
        }
    }
    function thisMovie(swf) {
        if(navigator.appName.indexOf("Microsoft") != -1) {
            return window[swf];
        }else{
            return document[swf];
        }
    }

    function filterSoapResults(script, branch, term){
        document.location.href = script + "?data[term]=" + term + "&data[branch]=" + branch;
    }
 

var StockmeierFlyout = new Class({
    Implements:[Options, Events],
    options:{
        trigger:'#stage > img',
        flyout:'#stage div.flyout',
        closebtn: '#stage div.flyout a.close',
        wrapper:'#header',
        mouseoutdelay:500
        },
    initialize:function(options){
        this.setOptions(options);
        this.trigger = document.getElement(this.options.trigger);
        this.flyout = document.getElement(this.options.flyout);
        this.wrapper = document.getElement(this.options.wrapper);
        this.closebtn = document.getElement(this.options.closebtn);
        if(!this.flyout || !this.trigger){return}
        
        this.trigger.setStyle('cursor', 'pointer');
        this.flyout.setStyles({display: 'block', opacity: 0});
        this.setEvents()
    },
    setEvents:function(){
        this.trigger.addEvent('click', function(ev){
                this.show();
            }.bind(this));
        this.wrapper.addEvents({
            'mouseleave': function(ev){
                    this.flyout.store('mouseout', true);
                    this.hide.delay(this.options.mouseoutdelay, this, true)
                }.bind(this),
            'mouseenter': function(ev){
                    this.flyout.store('mouseout', false);
                }.bind(this)
            });
        this.closebtn.addEvent('click', function(ev){
            ev.stop(); this.hide()
        }.bind(this));
        
    },
    show:function(){
        this.flyout.morph({opacity:1, height:631});
    },
    hide:function(checkmouse){
        if(checkmouse && !this.flyout.retrieve('mouseout')){return;}
        this.flyout.morph({opacity:0, height:0});
    }
});
window.addEvent('domready', function(){
    var sf = new StockmeierFlyout();
});
