/*

        Navi.js

        JavaScript functions classes for www.clubcola.de
        (c) 2008 Andreas Vent-Schmidt <a.vent@procommerz.de>

        This file is not intended for public use. If you do so
        nevertheless, please do not complain about any damage
        or disadvantage you may be subjected to.

        Please note that this code is copyright protected by law.

        If you're unable to create such simple code yourself,
        you shouldn't play with JavaScript at all (or read
        a beginner's book first)...

*/


        // die "Klassen"-Definiton für die Navi-Klasse
        function Navi(navName)
        {
            this.navName = navName;
            this.state = 0;
            this.bild = new Array();
            this.bild[0] = new Image();
            this.bild[0].src = '/standard/img/mainnav/' + this.navName + '_0.gif';
            this.bild[1] = new Image();
            this.bild[1].src = '/standard/img/mainnav/' + this.navName + '_1.gif';
        }


        // sowie einige Methoden
        Navi.prototype = {

            activate:   function()
                        {
                            // alle anderen deaktivieren
                            for ( i = 0; i < theNavis.length; i++ )
                            {
                                if ( this.navName != theNavis[i].navName )
                                {
                                    theNavis[i].set(0);
                                }

                            }
                            // dieses aktivieren
                            this.set(1);
                            this.out();
                        },
            set:        function(onoff)
                        {
                            this.state = onoff;

                            if ( onoff == 0 && $('div_' + this.navName).visible() )
                            {
                                eff = Effect.SwitchOff($('div_' + this.navName), {duration:0.4});
                            } else if ( onoff == 1 )
                            {
                                eff = Effect.Appear($('div_' + this.navName), {duration:0.5, to:1});
                                
                                var con_el = $('cu_' + this.navName);
                                var con_nav = $('cn_' + this.navName);
                                
                                if ( ! con_nav.empty() )
                                {
                                	var a_el = con_nav.down('p').down('a');
                                } else
                                {
                                	var a_el = null;
                                }
                                
                                // Inhalt holen, falls leer
                                if ( con_el.empty() )
                                {
                                	showDetail("/_" + this.navName + "/default.php", 'cu_' + this.navName, a_el);
                                }
                            }
                            // Navi-Bild aktualisieren
                            this.out();
                        },
            over:       function()
                        {
                        	if ( $('img_' + this.navName) )
                        	{
                            	$('img_' + this.navName).src = this.bild[1].src;
                            }
                        },
            out:        function()
                        {
                        	if ( $('img_' + this.navName) )
                        	{
                            	$('img_' + this.navName).src = this.bild[this.state].src;
                            }
                        }
        }

        var produkt = new Navi('produkt');
        var geschaefte = new Navi('geschaefte');
        var geschichte = new Navi('geschichte');
        var carlcowalski = new Navi('carlcowalski');
        var aktion = new Navi('aktion');
        var impressum = new Navi('impressum');

        //var theNavis = Array(produkt, geschaefte, geschichte, carlcowalski, impressum);
        var theNavis = Array(produkt, geschaefte, geschichte, carlcowalski, aktion, impressum);

        // Content-Fenster schließen
        function contentClose(divid)
        {
            eff = Effect.SwitchOff($('div_' + divid), {duration:0.4});
            for ( i = 0; i < theNavis.length; i++ )
            {
                if ( divid == theNavis[i].navName )
                {
                    theNavis[i].set(0);
                    break;
                }

            }
        }