if (!window.console || !console.firebug) {
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
    window.console = {};
    for (var i = 0; i < names.length; ++i) {
        window.console[names[i]] = function () {};
    }
}

var scase;
var scase2;
var scase3;
var scase4;

var menu;
var miniGalleryOptions1 = {
    thumbnailId: 'thumb1'
}

function go(Category, Content, Title) {

    if (Title == "Home") {
        Title = "Willkommen bei";
    }

    $('captionbox').innerHTML = Title + ' ';

    ShowCases.each(function (elm) {
        $(elm).hide();
    });


    if (Category == 'bissanzeiger') {



        if (Content != 'index') {
            test('bissanzeiger');
        } else {
            $('bissanzeiger').show();
            scase.next();
            scase.animate();
        }

        new Ajax.Updater('descriptionbox', 'doc/bissanzeiger/' + Content + '.htm');
        $('descriptionbox').appear();
        new Ajax.Request('doc/bissanzeiger/det_' + Content + '.htm', {
            method: 'get',
            asynchronous: true,
            evalScripts: true,
            onSuccess: ShowContent
        });

    } else {

        if (Category == 'zelt_funkboxen') {


            if (Content != 'index') {
                test('funkboxen');
            } else {
                $('funkboxen').show();
                scase2.next();
                scase2.animate();
            }

            new Ajax.Updater('descriptionbox', 'doc/zelt_funkboxen/' + Content + '.htm');
            $('descriptionbox').appear();
            new Ajax.Request('doc/zelt_funkboxen/det_' + Content + '.htm', {
                method: 'get',
                asynchronous: true,
                evalScripts: true,
                onSuccess: ShowContent
            });

        } else {

            if (Category == 'news') {


                if (Content != 'index') {
                    test('news');
                } else {
                    $('news').show();
                    scase3.next();
                    scase3.animate();
                }

                new Ajax.Updater('descriptionbox', 'doc/news/' + Content + '.htm');
                $('descriptionbox').appear();
                
                new Ajax.Request('doc/news/det_' + Content + '.htm', {
                    method: 'get',
                    asynchronous: true,
                    evalScripts: true,
                    onSuccess: ShowContent
                });

            } else {


                if (Category == 'werbung') {


                    if (Content != 'index') {
                        test('werbung');
                    } else {
                        $('werbung').show();
                        scase4.next();
                        scase4.animate();
                    }

                    new Ajax.Updater('descriptionbox', 'doc/werbung/' + Content + '.htm');
                    $('descriptionbox').appear();
                    new Ajax.Request('doc/werbung/det_' + Content + '.htm', {
                        method: 'get',
                        asynchronous: true,
                        evalScripts: true,
                        onSuccess: ShowContent
                    });
    
                } else {

                    $('detailsbox').setStyle('margin-top:20px;');

                    $('descriptionbox').hide();

                    $('detailsbox').innerHTML = '';

                    $('detailsbox').hide();
                    sleep(200);
                    new Ajax.Request('doc/' + Category + '/' + Content + '.htm', {
                        method: 'get',
                        asynchronous: true,
                        evalScripts: true,
                        onSuccess: function (req) {

                            $('detailsbox').innerHTML = req.responseText;

                            /* execute code javascript */
                            var sCodeJavascript = document.getElementsByTagName("script");
                            for (var i = 0; i < sCodeJavascript.length; i++) {
                                var contentScript = sCodeJavascript[i];
                                if (contentScript.src && contentScript.src != "") z = 1;
                                else {
                                    window.eval(contentScript.innerHTML);
                                    console.info('window.eval : %d', contentScript.innerHTML);
                                }

                            }

                            Util.RewriteLinks();

                            $('detailsbox').appear();
                        }

                    });
                }
            }
        }
    }
    Util.RewriteLinks();
    window.setTimeout('addReflections();', 250);
}
//------------------------------------------------------------------------------------

function test(id) {

    ShowCases.each(function (elm) {
        $(elm).hide();
    });

    $(id).show();
    $('detailsbox').setStyle('margin-top:-260px;');
    new Effect.Morph(id, {
        duration: 1,
        style: 'margin-top:0px;width:250px;margin-left:650px;'
    });

    $A($$('#' + id + ' ul')).each(function (elm) {
        elm.morph('height:50px;width:100px;top:0px;margin-top:0px;margin-left:-1px;');
    });

    $A($$('#' + id + ' ul li')).each(function (elm) {
        elm.morph('height:50px;width:50px;margin-top:-45px;top:0px;opacity:0.4;margin-left:50px; position:relative;');
    });

    $A($$('#' + id + ' a.controls')).each(function (elm) {
        elm.morph(' margin-top:-220px;opacity:0.5;');
    });

    $('detailsbox').appear();

    $('descriptionbox').fade();
    $$('#' + id + ' .morelink').each(function (elm) {
        elm.hide();
    });

}
//-------------------------------------------------

function runInit() {

    Util.RewriteLinks();

    ShowCases.each(function (elm) {
        $(elm).removeClassName('hidden');
    });

    //$('horizontal').removeClassName('hidden');
    //$('funkboxen').removeClassName('hidden');
    $('loading').hide();

    hs.graphicsDir = 'highslide/graphics/';
    hs.transitions = ['expand', 'crossfade'];
    hs.restoreCursor = null;
    hs.lang.restoreTitle = 'Click for next image';
    hs.showCredits = false;

    hs.lang = {
        cssDirection: 'ltr',
        loadingText: 'Lade...',
        loadingTitle: 'Klick zum Abbrechen',
        focusTitle: 'Klick um nach vorn zu bringen',
        fullExpandTitle: 'Zur Originalgröße erweitern',
        fullExpandText: 'Vollbild',
        creditsText: 'Powered by <i>Highslide JS</i>',
        creditsTitle: 'Gehe zur Highslide JS Homepage',
        previousText: 'Voriges',
        previousTitle: 'Voriges (Pfeiltaste links)',
        nextText: 'Nächstes',
        nextTitle: 'Nächstes (Pfeiltaste rechts)',
        moveTitle: 'Verschieben',
        moveText: 'Verschieben',
        closeText: 'Schließen',
        closeTitle: 'Schließen (Esc)',
        resizeTitle: 'Größe wiederherstellen',
        playText: 'Abspielen',
        playTitle: 'Slideshow abspielen (Leertaste)',
        pauseText: 'Pause',
        pauseTitle: 'Pausiere Slideshow (Leertaste)',
        number: 'Bild %1/%2',
        restoreTitle: ''
    };

    window.setTimeout('Effect.Appear(\'rlogo\', {duration:1})', 100);
    window.setTimeout('Effect.BlindRight(\'header\', {duration:2})', 500);
    window.setTimeout('Effect.Phase(\'contentwrapper\', {duration:2})', 2500);
    window.setTimeout('Effect.Phase(\'footer\', {duration:1})', 4500);
    window.setTimeout('Effect.SlideUpIn(\'menu\', {duration:1})', 2000);

    go('site', 'start', "Willkommen bei");
    window.setTimeout('addReflections();', 250);

}

Event.observe(window, "load", runInit);

document.observe('dom:loaded', function () {
    $('loading').removeClassName('hidden');



    scase = new Showcase.Horizontal($$('#bissanzeiger ul li'), $$('#bissanzeiger a.controls'), {
        duration: 0.3,
        size: 7,
        ratio: 0.3,
        scid: 'bissanzeiger',
        contents: 'bissanzeiger',
        initialDelay: 0
    });

    scase2 = new Showcase.Horizontal($$('#funkboxen ul li'), $$('#funkboxen a.controls'), {
        duration: 0.3,
        size: 5,
        ratio: 0.3,
        scid: 'funkboxen',
        contents: 'zelt_funkboxen',
        initialDelay: 0
    });

    scase3 = new Showcase.Horizontal($$('#news ul li'), $$('#news a.controls'), {
        duration: 0.3,
        size: 3,
        ratio: 0.6,
        scid: 'news',
        contents: 'news',
        initialDelay: 0
    });
    
    scase4 = new Showcase.Horizontal($$('#werbung ul li'), $$('#werbung a.controls'), {
        duration: 0.3,
        size: 3,
        ratio: 0.6,
        scid: 'werbung',
        contents: 'werbung',
        initialDelay: 0
    });
    
    menu = new menu.dd("menu");
    menu.init("menu", "menuhover");
    $('rlogo').hide();
    $('header').hide();
    $('contentwrapper').hide();
    $('footer').hide();
    $('menu').hide();
    $('detailsbox').hide();


    ShowCases.each(function (elm) {
        $(elm).hide();
    });

    $('descriptionbox').hide();
});

var Util = {
    RewriteLinks: function () {
        var LinkList = document.getElementsByTagName('a');
        var Links = $A(LinkList);

        Links.each(function (Link) {

            var path = Link.href.split("/");
            path.reverse();
            var filename = path[0].substring(0, path[0].lastIndexOf("."));
            var category = path[1];
            var title = Link.innerHTML.stripTags();

            if (Link.getAttribute("href") && Link.getAttribute("rel") == "external") {
                if (Link.target != "_blank") {
                    Link.target = "_blank";
                    Link.title = "(Neues Fenster) " + Link.title;
                }
            }

            if (Link.getAttribute("href") && Link.getAttribute("rel") == "gallery") {
                var Content = Link.href;
                if (Content.indexOf('javascript')) {
                    Link.href = "javascript:$('ifrmgallery').setAttribute('src','doc/multimedia/gallery/" + filename + ".htm');";
                    if (Link.onclick) {} else {
                        Link.onclick = "$('ifrmgallery').setAttribute('src','doc/multimedia/gallery/" + filename + ".htm');return false;";
                    }
                }
            }

            if (Link.getAttribute("href") && Link.getAttribute("rel") == "internal") {
                var Content = Link.href;
                if (Content.indexOf('javascript')) {
                    Link.href = "javascript:go(\'" + category + '\',\'' + filename + "\',\'" + title + "\');";
                    if (Link.onclick) {} else {
                        Link.onclick = "go(\'" + category + '\',\'' + filename + "\',\'" + title + "\');";
                    }
                }
            }
        });
    }
};