$(document).ready(function() {
    if($("#player").length > 0) {
    
    flowplayer("player", "/public/flowplayer-3.2.7.swf", {
clip: {
autoPlay: false,
autoBuffering: false
}
});
    flowplayer("player2", "/public/flowplayer-3.2.7.swf", {
clip: {
autoPlay: false,
autoBuffering: false
}
});
    flowplayer("player3", "/public/flowplayer-3.2.7.swf", {
clip: {
autoPlay: false,
autoBuffering: false
}
});
}
    
    function replaceHeading(mode, el) {
        
        if(mode == 'hover') {
            var img = el.attr('class') + '_active';
        } else {
            var el = $(this);
            var img = el.attr('class').split(' ').join('_');
        }
        el.text('').css({
            'background-image' : 'url(public/images/headings/' + img + '.gif)',
            'background-position' : 'top left',
            'background-repeat' : 'no-repeat'
        });
    }
    
    $('#content h1, .content_menu li a').each(replaceHeading);
    $('.content_menu li a').hover(
        function() {replaceHeading('hover', $(this))},
        replaceHeading
    );
    
    $(".replace").focus(function() {
        var el = $(this);
        if(el.val() == el.attr('rel'))
            el.val('');
    }).blur(function() {
        var el = $(this);
        if(el.val() == '')
            el.val(el.attr('rel'));
    });

    $("img[title='galerie']").each(function() {
        var obj = $(this);
        //var w = obj.width();
        //var h = obj.height();
        var newwidth = 100;
        obj.removeAttr('height').removeAttr('width').removeAttr('style').width(newwidth);
        var aobj = obj.wrap('<a></a>').parent();
        aobj.attr('href',obj.attr('src')).attr('rel','lytebox[galerie]');
    });
    initLytebox();
    
    // Maps
    if (GBrowserIsCompatible()) {
        if($("#map_kirchhellen").length > 0) {
            var point = new GLatLng(51.6043838, 6.9244150);
            var map = new GMap2(document.getElementById("map_kirchhellen"));
            map.setCenter(point, 13);
            map.addOverlay(new GMarker(point));
            //map.openInfoWindow(point,document.createTextNode("Hauptstraße 66, 46244 Bottrop-Kirchhellen"));
            map.setUIToDefault();
        }
        
        if($("#map_gladbeck").length > 0) {
            var point = new GLatLng(51.5745924, 6.9906759);
            var map = new GMap2(document.getElementById("map_gladbeck"));
            map.setCenter(point, 13);
            map.addOverlay(new GMarker(point));
            //map.openInfoWindow(point,document.createTextNode("Humboldtstraße 15, 45964 Gladbeck"));
            map.setUIToDefault();
        }
        
        if($("#map_bottrop").length > 0) {
            var point = new GLatLng(51.5240541, 6.9248853);
            var map = new GMap2(document.getElementById("map_bottrop"));
            map.setCenter(point, 13);
            map.addOverlay(new GMarker(point));
            //map.openInfoWindow(point,document.createTextNode("Kirchhellener Straße 18, 46236 Bottrop"));
            map.setUIToDefault();
        }
        
    }
});

