/**
* Table Over
* js-funktionen
*
* @author heiko pfefferkorn
* @copyright 2005 heiko pfefferkorn
* @version $Id: table_over.js,v 1.2 2006/04/22 08:15:52 erik Exp $
*
*/


    /* CL_TB_get_attribute */
    function CL_TB_get_attribute(el,attribut){
        if( typeof el == 'object' )
            return ( this.$dom_detect ) ? el.getAttribute(attribut) : el[attribut];
    }


    /* CL_TB_set_option */
    function CL_TB_set_option(el,status){
        this["$"+el] = status;
    }


    /* CL_TB_set_color */
    function CL_TB_set_color(el){
        if( typeof el == 'object' ){ // > 1
            el.className = this.$new_color;
        }
    }


    /* CL_TB_set_linkcolor */
    function CL_TB_set_linkcolor(el){
        if( typeof el == 'object' ){ // > 1
            var id_el       = this.get_attribute(el,'id');
            var el_length   = id_el.length;
            var l_fpos      = id_el.lastIndexOf(this.$split_identlink_identid)+1;
            var id_number   = id_el.substring(l_fpos, el_length);
            link_id         = this.$ident_link+this.$split_identlink_identid+id_number;
        
            //el      = this.get_attribute(el_text,'id');
            //document.getElementById(link_id).style.color=this.$new_colortext;
            document.getElementById(link_id).className = this.$new_colortext;
        }
    }


    /* CL_TB_set_out
     *
     * 1 - el muss ein objekt sein
     * 2 - wird down-status gespeichert (true?) & ist eigenschaft 'id' des 'el' vorhanden
     * 3 - weise 'over'-farbe zu
     * 4 - weise 'el' die entsprechende farbe laut '2' zu
     */
    function CL_TB_set_out(el){
        if( typeof el == 'object' && this.get_attribute(el,'id') != '' && this.get_attribute(el,'id') != 'undefined' ){ // > 1
            if( this.$save_down ){ // > 2
                el_ident        = this.get_attribute(el,'id');

                if( this.$arr_marked_elements[el_ident] == true ){
                    this.$new_color     = this.$color_down;
                    this.$new_colortext = this.$color_down_text;
                }else{
                    this.$new_color     = this.$color_out;
                    this.$new_colortext = this.$color_out_text;
                }

            }else{ // > 3
                this.$new_color     = this.$color_out;
                this.$new_colortext = this.$color_out_text;
            }

            this.set_color(el); // > 4
            if( this.$use_text_over ) this.set_linkcolor(el);
        }
    }


    /* CL_TB_set_over
    *
     * 1 - el muss ein objekt sein
     * 2 - wird down-status wird gespeichert (true?) & ist eigenschaft 'id' des 'el' vorhanden
     * 3 - weise 'over'-farbe zu
    * 4 - weise 'el' die entsprechende farbe laut 'this.$new_color' zu
     */
    function CL_TB_set_over(el){
        if( typeof el == 'object' && this.get_attribute(el,'id') != '' && this.get_attribute(el,'id') != 'undefined' ){ // > 1
            if( this.$save_down ){ // > 2
                el_ident = this.get_attribute(el,'id');

                if( this.$arr_marked_elements[el_ident] == true ){
                    this.$new_color     = this.$color_down_over;
                    this.$new_colortext = this.$color_down_over_text;
                }else{
                    this.$new_color     = this.$color_over;
                    this.$new_colortext = this.$color_over_text;
                }

            }else{ // > 3
                this.$new_color     = this.$color_over;
                this.$new_colortext = this.$color_over_text;
            }

            this.set_color(el); // > 4
            if( this.$use_text_over ) this.set_linkcolor(el);
        }
    }


    /* CL_TB_set_up
     *
     * wenn die maus innerhalb eines bereiches gedrückt und wieder losgelassen wurde
     * dann soll sofort der vorherige status von 'el' wieder angezeigt werden,
     * status setzen ist eben identisch zu 'set_out()'
     */
    function CL_TB_set_up(el){
        if( typeof el == 'object' ) this.set_out(el);
    }


    /* CL_TB_set_down
     *
    * 1 - el muss ein objekt sein
     * 2 - wird down-status wird gespeichert (true?) & ist eigenschaft 'id' des 'el' vorhanden
     * 3 - weise 'over'-farbe zu
     * 4 - weise 'el' die entsprechende farbe laut '2' zu
     */
    function CL_TB_set_down(el){
        if( typeof el == 'object' ){ // > 1

            if( this.$save_down && this.get_attribute(el,'id') != '' && this.get_attribute(el,'id') != 'undefined' ){ // > 2
                var el_ident    = this.get_attribute(el,'id');

                if( this.$multiple_down ){

                    if( this.$arr_marked_elements[el_ident] ){
                        this.$arr_marked_elements[el_ident] = false;
                        this.$new_color     = this.$color_out;
                        this.$new_colortext = this.$color_out_text;
                    }else{
                        this.$arr_marked_elements[el_ident] = true;
                        this.$new_color     = this.$color_down;
                        this.$new_colortext = this.$color_down_text;
                    }

                }else{

                    if( this.$arr_marked_elements[el_ident] ){
                        this.$arr_marked_elements[el_ident] = false;
                        this.$new_color     = this.$color_out;
                        this.$new_colortext = this.$color_out_text;
                    }else{
                        for( var key in this.$arr_marked_elements ){
                            this.$arr_marked_elements[key]  = false;
                            this.set_out(document.getElementById(key));
                        }

                        this.$arr_marked_elements[el_ident] = true;
                        this.$new_color     = this.$color_down;
                        this.$new_colortext = this.$color_down_text;
                    }

                }
            }else{ // > 3
                this.$new_color     = this.$color_down;
                this.$new_colortext = this.$color_down_text;
            }

            this.set_color(el); // > 4
            if( this.$use_text_over ) this.set_linkcolor(el);

        }
    }



    /* CL_TB_over */
    function CL_TB_over(){
        this.$dom_detect            = ( document.getElementById ) ? true : false;
        this.$arr_marked_elements   = new Array();
        this.$new_color             = '';
        this.$color_over            = '';
        this.$color_out             = '';
        this.$color_down            = '';
        this.$color_down_over       = '';
        this.$save_down             = false;
        this.$multiple_down         = false;
        this.$use_text_over         = false;
    }


    new CL_TB_over();
    CL_TB_over.prototype.set_down       = CL_TB_set_down;
    CL_TB_over.prototype.set_up         = CL_TB_set_up;
    CL_TB_over.prototype.set_over       = CL_TB_set_over;
    CL_TB_over.prototype.set_out        = CL_TB_set_out;
    CL_TB_over.prototype.set_color      = CL_TB_set_color;
    CL_TB_over.prototype.set_linkcolor  = CL_TB_set_linkcolor;
    CL_TB_over.prototype.set_option     = CL_TB_set_option;
    CL_TB_over.prototype.get_attribute  = CL_TB_get_attribute;