//---------------------------------------------------------------//
//
// EE Dropdown Library
//
// Author: Erwin Eggenberger
// Copyright: 2004 Erwin Eggenberger
//
// Use and modification only with the author's
// explicit permission !
//
//---------------------------------------------------------------//



function ee_pulldowncontrol( myname ) {

    //methods
    this.addPulldown = ee_addPulldown;
    this.over = ee_PulldownCOver;
    this.out = ee_PulldownCOut;
    this.update = ee_PulldownCUpdate;
    this.init = ee_PulldownInit;
    this.pdabs = ee_pdabs;

    //properties
    this.pulldowns=new Array();
    this.nbpulldowns = 0;
    this.myname = myname;
    this.timeout = 40;
    this.step = 5;
    this.enabled = true;
    
    this.init();
    
    
    function ee_PulldownInit(){
    
        //alert(navigator.userAgent);
        var useragent = String(navigator.userAgent);
        //var re = /(Netscape\/7\.1)/;
        var re = /Netscape\/7\.1/;
        if (useragent.search(re) != -1){
            this.enabled=false;
            //alert("Netscape 7.1");
        }
    }

    function ee_pdabs() {
    
        var ddowncontainer=document.getElementById("ddowncontainer");
        ddowncontainer.style.position="static";
        ddowncontainer.style.position="absolute";
    }


    function ee_addPulldown( maskid, menuid, height ) {
    
        this.pulldowns[this.nbpulldowns] = new ee_pulldown( maskid, menuid, height );
        this.nbpulldowns++;
    }
    
    function ee_PulldownCOver( nid ) {
        if( this.enabled && this.pulldowns[nid]) {
            this.pulldowns[nid].direction = 1;
            this.pulldowns[nid].visible(1);
            this.update(nid);
        }
    }
    
    function ee_PulldownCOut( nid ) {
        if( this.enabled && this.pulldowns[nid]) {
            this.pulldowns[nid].direction = -1;
            this.update(nid);
        }
    }
    
    function ee_PulldownCUpdate( nid ) {
    
        var status=0;
        status = this.pulldowns[nid].update();
        if(status)
            window.setTimeout( this.myname+".update("+nid+")", this.timeout );
    }
}


function ee_pulldown( maskid, menuid, height ) {

    //methods
    this.update = ee_PulldownUpdate;
    this.visible = ee_PulldownVisible;
    
    this.direction = 0;
    this.currentSize = 0;
    this.step = 20;
    
    this.height=height;
  //  alert(height);
    
    this.mask = document.getElementById(maskid);
    this.menu = document.getElementById(menuid);
    
    this.mask.style.visibility="hidden";


    function ee_PulldownUpdate() {
    
        this.currentSize= Math.max(0,Math.min(this.currentSize+(this.direction*this.step), this.height));
        this.mask.style.height=this.currentSize;
        this.menu.style.top=-this.height+this.currentSize;
        
        if( this.currentSize < this.height && this.currentSize > 0 )
            return true;
        else
            return false;
    
    }
    
    function ee_PulldownVisible(value) {
    
        this.mask.style.visibility="visible";
    }
    
}

