﻿GNgui.FooterItem = Class.create();
GNgui.FooterItem.prototype = 
{
	initialize : function (Id, Left, Width, Text, Expandable, ClickEventFunc)
	{
        if (Id == null) {alert('PleaseWait: Id not specified' );}
		if (Left == null) {alert('PleaseWait: Left not specified' );}
		if (Width == null) {alert('PleaseWait: Width not specified' );}
		if (Text == null) {alert('PleaseWait: Text not specified' );}
        
        this.newelement = $ce('div');
        this.newelement.setAttribute('id', Id);
        this.newelement.Expandable = Expandable;

        this.newelement.style.textAlign = "center";
        this.newelement.style.position = "absolute";
        this.newelement.style.left = Left;
        this.newelement.style.top = 0;
        this.newelement.style.width = Width;
	    this.newelement.style.height = 18;
	    this.newelement.style.color = "#000000";
	    this.newelement.style.fontWeight = "bold";
        
	    this.newelement.style.backgroundImage = "url(./" + TARGET + "/Images/button_s_c.gif)";

        this.newelement.cText = $ce('span');
        $ac(this.newelement, this.newelement.cText);
        this.newelement.cText.innerText = Text;
        this.newelement.cText.style.position = "absolute";
        this.newelement.cText.style.left = 0;
        this.newelement.cText.style.top = 2;
        this.newelement.cText.style.textAlign = "center";
	    this.newelement.cText.style.width = Width;
        this.newelement.cText.style.cursor = "hand";

        this.newelement.leftImg = $ce('img');
        $ac(this.newelement, this.newelement.leftImg);
        this.newelement.leftImg.src = "./" + TARGET + "/images/button_s_l.gif";
        this.newelement.leftImg.style.position = "absolute";
        this.newelement.leftImg.style.left = 0;
        this.newelement.leftImg.style.cursor = "hand";

        this.newelement.rightImg = $ce('img');
        $ac(this.newelement, this.newelement.rightImg);
        if (Expandable == true)
            this.newelement.rightImg.src = "./" + TARGET + "/images/button_s_r_e.gif";
        else
            this.newelement.rightImg.src = "./" + TARGET + "/images/button_s_r.gif";
        this.newelement.rightImg.style.position = "absolute";
        this.newelement.rightImg.style.left = Width - (Expandable == true?18:6);
        this.newelement.rightImg.style.cursor = "hand";

        Event.observe ( this.newelement, 'mouseover', GNgui.FooterItem.prototype.MouseOver.bindAsEventListener(this));    
        Event.observe ( this.newelement, 'mouseout',  GNgui.FooterItem.prototype.MouseOut.bindAsEventListener(this));    
        Event.observe ( this.newelement, 'mousedown', GNgui.FooterItem.prototype.MouseDown.bindAsEventListener(this));
        Event.observe ( this.newelement, 'mouseup',   GNgui.FooterItem.prototype.MouseUp.bindAsEventListener(this));
        
        this.newelement.ClickEventFunc = ClickEventFunc;
        Event.observe ( this.newelement, 'click' , GNgui.FooterItem.prototype.MouseClick.bindAsEventListener(this));
    },
    
	ID : function() { return this.newelement.id; },
	
	Show : function() { this.newelement.style.visibility = 'inherit'; },
	Hide : function() { this.newelement.style.visibility = 'hidden'; },
	
	MouseClick : function()
	{
        if (this.newelement.ClickEventFunc != null)
            this.newelement.ClickEventFunc();
	},
	
	MouseOver : function()
	{
	    this.newelement.style.backgroundImage = "url(./" + TARGET + "/Images/button_h_c.gif)";
        this.newelement.leftImg.src = "./" + TARGET + "/images/button_h_l.gif";
        if (this.newelement.Expandable == true)
            this.newelement.rightImg.src = "./" + TARGET + "/images/button_h_r_e.gif";
	    else
            this.newelement.rightImg.src = "./" + TARGET + "/images/button_h_r.gif";
	},
	
	MouseOut : function()
	{
	    this.newelement.style.backgroundImage = "url(./" + TARGET + "/Images/button_s_c.gif)";
        this.newelement.leftImg.src = "./" + TARGET + "/images/button_s_l.gif";
        if (this.newelement.Expandable == true)
            this.newelement.rightImg.src = "./" + TARGET + "/images/button_s_r_e.gif";
	    else
            this.newelement.rightImg.src = "./" + TARGET + "/images/button_s_r.gif";
	},

	MouseDown : function()
	{
	    this.newelement.style.backgroundImage = "url(./" + TARGET + "/Images/button_o_c.gif)";
        this.newelement.leftImg.src = "./" + TARGET + "/images/button_o_l.gif";
        if (this.newelement.Expandable == true)
            this.newelement.rightImg.src = "./" + TARGET + "/images/button_o_r_e.gif";
	    else
            this.newelement.rightImg.src = "./" + TARGET + "/images/button_o_r.gif";
	},

	MouseUp : function ()
	{
        this.newelement.style.backgroundImage = "url(./" + TARGET + "/Images/button_s_c.gif)";
        this.newelement.leftImg.src = "./" + TARGET + "/images/button_s_l.gif";
        if (this.newelement.Expandable == true)
            this.newelement.rightImg.src = "./" + TARGET + "/images/button_s_r_e.gif";
        else
            this.newelement.rightImg.src = "./" + TARGET + "/images/button_s_r.gif";

	}
}