﻿

function DropCombo()
{
    //=========================================
    // Structure to save the frame properties.
    //=========================================

    this.combo_button = null;
    this.state = 'hidden';
    this.attachedControl = null;
    this.layerName = "";
    this.left = 0;
    this.top = 0;
    
    
    
    
    if (typeof DropCombo._initialized == "undefined")
    {
        DropCombo.prototype.initValues = function(button, state, attachedControl)
        {           
             this.state = state;
            this.attachedControl = document.getElementById(attachedControl);
            this.combo_button = document.getElementById(button);
            this.layerName = attachedControl;
            this.getLeftPos();
            this.getTopPos(); 
           // alert(this.getTopPos());
            this.attachedControl.style.left =this.getLeftPos()+ "px";
            this.attachedControl.style.top = this.getTopPos() + "px";          
            this.showhide();
        };
        
        DropCombo.prototype.comboButton= function(but)
        {
            this.combo_button=but;
        }
        
        DropCombo.prototype.getLeftPos = function()
        {            
            var leftpos = 0;
            var mainTag = this.combo_button;
	        var tempTag = this.combo_button;
            do {
	            tempTag = tempTag.offsetParent;
	            //tempTag = tempTag.parentElement;
	            leftpos	+= tempTag.offsetLeft;
            } while(tempTag.tagName.toUpperCase()!="BODY" && tempTag.tagName.toUpperCase()!="HTML");
            leftpos += tempTag.offsetLeft;
	        return leftpos;               
        };  
        
        DropCombo.prototype.getTopPos = function()
        {
	        topPos=0;
	        var mainTag = this.combo_button;	        
	        var aTag = this.combo_button;
            do {
	            aTag = aTag.offsetParent;
	            topPos	+= aTag.offsetTop;
            } while(aTag.tagName.toUpperCase()!="BODY" && aTag.tagName.toUpperCase()!="HTML");
            topPos += mainTag.offsetTop + mainTag.offsetHeight;
	        return topPos;
        };
        
        DropCombo.prototype.showhide = function()
        {
            //this.attachedControl = document.getElementById(attachedControl);
            //this.combo_button = document.getElementById(button);
            //alert("alert");
            if (this.state == 'visible')
            {
                if(this.left==0)
                {
                    this.left=this.getLeftPos();
                    this.top=this.getTopPos();              
                }
                this.attachedControl.style.left = this.left + "px";
                this.attachedControl.style.top = this.getTopPos() + "px";
            }
            layer_ref = this.layerName;	        
            if (document.all) { //IS IE 4 or 5 (or 6 beta)
                eval( "document.all." + layer_ref + ".style.visibility = this.state");
            }
            if (document.layers) { //IS NETSCAPE 4 or below
                document.layers[layer_ref].visibility = this.state;
            }
            if (document.getElementById && !document.all) {
                maxwell_smart = document.getElementById(layer_ref);
                maxwell_smart.style.visibility = this.state;
            }
            if (this.state == 'visible') {
                this.state = 'hidden';
            }
            else {
                this.state = 'visible';
            }
        };
        
        DropCombo.prototype.hide = function()
        {            
            if (document.all) { //IS IE 4 or 5 (or 6 beta)
                eval( "document.all." + layer_ref + ".style.visibility = this.state");
            }
            if (document.layers) { //IS NETSCAPE 4 or below
                document.layers[layer_ref].visibility = this.state;
            }
            if (document.getElementById && !document.all) {
                maxwell_smart = document.getElementById(layer_ref);
                maxwell_smart.style.visibility = this.state;
            }  
            this.state = 'visible';         
        }
        
        DropCombo._initialized = true;
    }        

}

