    function blockError() {
        return true;
    }

    theHost = window.location.hostname;
    if (theHost.search(/dev-media.aberratio.de/) >= 0) {
        // on preview do nothing
        // window.onerror = blockError;
    } else {
        window.onerror = blockError;
    }

    var BASE_URL = 'http://'+window.location.hostname+'/';


    function get_albumUid(url_obj){
        url = ""+url_obj; /* convert OBJ to String*/
        startpos       = url.indexOf("albumUid");
        albumUid       = url.substr(startpos);
        albumUid_tmp   = albumUid.substr(9);
        endpos         = albumUid_tmp.indexOf('/');
        albumUid       = albumUid.substr(0, (9+endpos+1))
        return albumUid;
    }

    $(document).ready(function()
    {

        // Client is Safari
        if (navigator.userAgent.match(/Safari/i) != null) {
            $('#mainnavi').addClass("safari");
        }
        if (navigator.userAgent.match(/iPad/i) != null) {
            // Show footer for other browsers
            $('#mainnavi').addClass("ipad");
        }

        // Watermarks
        // if ($('.dms-outer-wrapper .sign-in .input').length > 0) {
            // $('.dms-outer-wrapper .sign-in .input').watermark('Ihre E-Mail Adresse');
        // }

        // Browser bookmarks
        if ($('#bookmarks-browser').length > 0) {
            $('#bookmarks-browser').jFav();
        }

        // Hide event teaser without events
        if ($('.ae_mini').length > 0) {

            if ($('.ae_mini .ae_title').html() == 'Keine Termine') {
//                $('.spalte3-2').css('display','none');
                //bugfix, Sascha, 15.07.11
                $('.ae_mini .ae_title').parent().parent().parent().parent().parent().css('display','none');
            }
        }

        // Hide first level of sitemap
        if ($('.csc-sitemap').length > 0) {
            $('.csc-sitemap > ul').css('list-style-type','none');
            $('.csc-sitemap > ul > li > a').css('display','none');
        }

//        $("ul.sf-menu").supersubs({
//            minWidth:    12,   // minimum width of sub-menus in em units
//            maxWidth:    27,   // maximum width of sub-menus in em units
//            extraWidth:  1     // extra width can ensure lines don't sometimes turn over
//                               // due to slight rounding differences and font-family
//        }).superfish().find('ul').bgIframe({opacity:true});


//        $("ul.sf-main-menu").supersubs({
//            minWidth:    12,   // minimum width of sub-menus in em units
//            maxWidth:    27,   // maximum width of sub-menus in em units
//            extraWidth:  1     // extra width can ensure lines don't sometimes turn over
//                               // due to slight rounding differences and font-family
//        }).superfish().find('ul').bgIframe({opacity:true});

            $("ul.sf-menu").superfish({
                pathClass:  'mainnavi_active',
                animation:   {opacity:'show', height:'show'},
                speed:       'fast',
                pathLevels: 1
            });


        $("div.jm-gallery-image-entry a").attr("rel","lightbox");
        $("div.jm-gallery-image-entry a").lightBox({fixedNavigation:false});

        // $('.news-list-twin .news-list-item').each(function(counter){
            // className = $(this).attr('class');
            // $(this).addClass('list-item-'+counter)
        // });

        nrElements = $('.csc-frame-ap').size();
        $('.csc-frame-ap').each(function(counter){
            if ((counter+1) != nrElements) {
                $(this).after('<div class="ap-line-wrapper"><div class="ap-line"></div></div>');
            }
        });

        nrElements = $('.dateiliste-li').size();
        $('.dateiliste-li').each(function(counter){
            if ((counter+1) != nrElements) {
                $(this).after('<li class="ap-line-wrapper"><span class="ap-line"></span></li>');
            }
        });

        // ####################################################################
        // GALLERY ACCORDION ##################################################

//        var cPosAct = getJsCookie('lastActive');

        // border bottom
//        if(cPosAct == 1) {
//            $("#abergallacc-last").css("border-bottom","2px solid #CCCCCC");
//        } else {
//            $("#abergallacc-last").css("border-bottom","none");
//        }

//        $('.accHeaderDiv').click(function()
//        {
//            var pos = $(this).attr("rel");
//            var lastId = $(this).attr("id");

//             setJsCookie('galaccpos',pos,'');


//             if (getJsCookie('galaccpos') == pos) {
//                 setJsCookie('galaccpos',9999,'');
//             } else {
//                 setJsCookie('galaccpos',pos,'');
//             }

//            if(lastId == 'abergallacc-last') {
//                $("#abergallacc-last").css("border-bottom","2px solid #CCCCCC");
//                setJsCookie('lastActive',1,'');
//            } else {
//                $("#abergallacc-last").css("border-bottom","none");
//                setJsCookie('lastActive',0,'');
//            }
            // console.log(lastId);
//        });

//        var cPos = getJsCookie('galaccpos');
//        if (cPos) {
//            activePos = parseInt(cPos);
//        } else {
//            activePos = 9999;
//        }

//        $('.partsWrapper a').click(function()
//        {
//            url = ($(this).attr("href"));
//            setJsCookie('galaccurl',url,'');
//        });


        //Nur ausführen wenn galleryacc auch vorhanden ist
        if($('div.tx-abergalleryacc-pi1').length > 0 )
        {

            $('#abergallacc').find('.parts:last-child').css("border-bottom","none");

             // ACTIVE?
                current_url = document.URL;
                current_albumUid = get_albumUid(current_url);
                links = $('#abergallacc .partsWrapper a');
                i=0;
                headpos = false;
                $.each(links, function(key, value) {
                    link_albumUid = get_albumUid(value);
                    if(current_albumUid.indexOf(link_albumUid) >-1){
                        $(links[i]).addClass("active");
                        headpos = parseInt($(links[i]).parent().parent().prev().attr("rel"));
        //                $(links[i]).parent().parent().prev().addClass("selected");
                    }
                    i++;
                });


                $('#abergallacc').accordion({
                    autoheight: false,
                    active: headpos,
                    collapsible: true,
                    header: '.accHeaderDiv'
                });

        }


       // ####################################################################
       // ####################################################################
       // Subnavigation Presse

        if($('div.static_subnavigation').length > 0 ){

         // ACTIVE?
            current_url = document.URL;
            links = $('div.static_subnavigation a');
            i=0;
            headpos = false;
            $.each(links, function(key, value) {
                link_url = value;
                if(current_url.indexOf(link_url) >-1){
                    $(links[i]).addClass("active");
                    headpos = parseInt($(links[i]).parent().parent().prev().attr("rel"));
    //                $(links[i]).parent().parent().prev().addClass("selected");
                }
                i++;
            });
        }

        // ####################################################################
        // ####################################################################



//    console.log(activePos);

        // ao-dateiliste

        $('.ao-dateiliste').each(function() {
            $('> div', this).each(function(counter) {

                // Add href link to image
                href = $('div.extWrapper a', this).attr('href');
                $('span.scDL_IMG', this).after('<a class="link'+counter+'" target="_blank" href="'+href+'"></a>');
                $('a.link'+counter, this).html($('span.scDL_IMG', this));

                // Add border to second image in row
                if (counter%2 == 0) {
                    $(this).css('border-right', '1px dotted #CCCCCC');
                    $(this).css('margin-right', '25px');
                } else {
                    $(this).after('<div class="ap-line-wrapper"></div>');
                }
            });
        });

        // $('.ao-dateiliste > div').each(function(counter) {
            // moduloVal = (counter%2);
            // //console.log(moduloVal);
            // if(moduloVal == 0) {
                // $(this).css("border-right","1px dotted #CCCCCC");
                // $(this).css("margin-right","25px");
            // } else {
                // $(this).after('<div class="ap-line-wrapper"></div>');
            // }
        // });

        $('.tx-rspflvplayer-pi1 object').each(function(counter){
            var theObj = this;
            var theWidth = $(theObj).attr('width');
            $(theObj).wrap("<div class='autoWrapper' style='width:"+theWidth+"px'></div>")
        });

        $("input:submit").addClass("dmSubmit");

        // Newsletter text Footer>Newsletter
        $('#bodyID_10 .text-dummy').html('<div><strong>Montags ist Newslettertag.</strong> Einmal wöchentlich verschickt Hamburg@work gebündelt alle News zu Themen rund um Hamburgs Digitale Wirtschaft. Bleiben Sie informiert.</div>');
        $('#bodyID_10 .text-dummy').css('margin-bottom', '10px');
        $('#bodyID_10 .text-dummy').css('margin-left', '5px');

        // Newsletter Button Startseite
        $('#bodyID_31 .dms-outer-wrapper .button').css('position', 'absolute');
        $('#bodyID_31 .dms-outer-wrapper .button').css('bottom', '8px');
        $('#bodyID_31 .dms-outer-wrapper .button').css('right', '10px');

        // STARTSEITE BUTTONS
        $(".spalte1-1 .spalte1InnerDiv .csc-frame-invisible").append('<div id="spalte1-1-button"><a href="service-news/rubrik/4/" title="Aktuelles">mehr Aktuelles</a></div>');
        $(".spalte1-2 .spalte1InnerDiv .csc-frame-invisible").append('<div id="spalte1-2-button"><a href="service-news/rubrik/3/" title="Aus den Unternehmen">mehr Unternehmensnews</a></div>');
        $(".spalte1-3 .spalte1InnerDiv .csc-frame-rulerBefore").append('<div id="spalte1-3-button"><a href="mediathek-videos/" title="Videos">zu den Videos</a></div>');
        // $(".spalte2-1 .spalte2InnerDiv .csc-frame-invisible").append('<div id="spalte2-1-button"><a href="#" title="Diverses">zu Diverses</a></div>');
        $(".spalte3-2 .spalte3InnerDiv .csc-frame-rulerBefore").append('<div id="spalte3-2-button" style="z-index: 100;"><a href="mediathek-galerien/" title="Galerien">zu den Galerien</a></div>');
        $(".spalte3-2 .spalte3InnerDiv .csc-frame-rulerBefore").append('<div id="spalte3-2-cover" style="z-index: 50;"></div>');

        // Edititere News Archiv
        if ($('.news-amenu-container').length > 0) {
            var counter = 0;

            $('.news-amenu-container ul li').each(function()
            {
                if ($(this).hasClass('news-amenu-item-year')) {
                    counter++;
                    $(this).addClass('list-'+counter);
                    $(this).append('<ul class="news-amenu-item-list list-item-'+counter+'"></ul>');
                } else {
                    $('.list-item-'+counter).append(this);
                }
            });

            $('.news-amenu-item-year').click(function()
            {
                for (var i=1; i<=$('.news-amenu-item-year').length; i++) {
                    if ($(this).hasClass('list-'+i)) {
                        $('.list-item-'+i).show('slow');
                    } else {
                        $('.list-item-'+i).hide('hide');
                    }
                }
            });
        }

        // Edititere Sponsor Download
        if ($('ul.dateiliste').length > 0) {
            for (var i=0; i<$('li.dateiliste-li').length; i++) {
                var url = $('li.dateiliste-li div.extWrapper a').eq(i).attr('href');
                $('li.dateiliste-li span.scDL_IMG img').eq(i).wrap('<a target="_blank" href="'+url+'"></a>');
            }
        }

        // Auf-/Zuklappen der Subnavi / rechts
        if ($('li.serviceSubNavi').length > 0) {

            // Aktuelle URL ermitteln und Subnavi ggf. aufklappen
            var curSite = window.location.href;
            var index = -1;

            // Iteration ueber alle HREF Elemente in der Navigation
            $('li.serviceSubNavi ul').each(function(count) {

                // Pruefen ob aktueller Ueberpunkt aktiv
                if (curSite.indexOf($(this).parent().find('div').find('a').attr('href')) >= 0) {
                    index = count;

                // Pruefen ob Unterpunkt in aktuellem Ueberpunkt aktiv
                } else {
                    $($(this).find('a')).each(function() {
                        if (curSite.indexOf($(this).attr('href')) >= 0) {
                            index = count;
                        }
                    });
                }
            });

            // Subnavi ggf. aufklappen
            if (index != -1) {
                $('li.serviceSubNavi ul').eq(index).show();
            }

            $('li.serviceSubNavi div').click(function()
            {
                // Index des angeklickten Elements ermitteln
                var index = $('li.serviceSubNavi div').index(this);

                // Iteration ueber alle entsprechenden Elemente
                for (var i=0; i<$('li.serviceSubNavi div').length; i++) {

                    // Aktuelles Element auf-/zuklappen
                    if (index == i) {
                        if ($('li.serviceSubNavi ul').eq(i).css('display') == 'none') {
                            $('li.serviceSubNavi ul').eq(i).show('fast');
                        } else {
                            // $('li.serviceSubNavi ul').eq(i).hide('fast');
                        }

                    // Alle anderen Elemente zuklappen
                    } else {
                        $('li.serviceSubNavi ul').eq(i).hide('fast');
                    }
                }
            });

        }

        // mediathek - audio
        //markiere alle DIVs mit Player
        $('#bodyID_131 .spalte1 .csc-default object').parent().addClass("media_player");
        $('#bodyID_131 .spalte1 .csc-default a.download').parent().parent().parent().addClass("media");
        $('<div class="listen">Anhören</div>').appendTo('#bodyID_131 .media_player');

        // Liste der Termine ausblenden, wenn kein Termin vorhanden ist
        if ($('.spalte1 .ae_list').length > 0) {
            if ($('.spalte1 .ae_list .title').html() == 'Keine Termine') {
                $('.spalte1 .ae_list').parent().parent().parent().css('display','none');
            }
        }

        $('.ae_facts a').attr('target', '_blank');

    });
