/*
 $Id: modcms.js 30 2011-09-21 07:09:40Z rschwarz $
 $HeadURL: svn+ssh://svnserver/svn/modcms/trunk/media/js/modcms.js $
*/
var image_list = ['parken', 'rathaus', 'solar', 'wasser'];
var prev_image = 'kran';

function update_image_list(num, last_image) {
    prev_image = image_list.splice(num, 1, last_image);
    image_list.sort();
}

function get_image_name(last_image) {
    if (last_image == null) {
        last_image = prev_image;
    }
    var rand_num = Math.floor(Math.random()*image_list.length);
    var image = image_list[rand_num];
    update_image_list(rand_num, last_image);
    return image;
}

$(function(){
    // ----- mouseover-event for menutree -----
    $("#sidebar li").mouseover(function() {
        if ($(this).hasClass("selected") != true) {
            $(this).addClass("mouseover");
            $(this).addClass("selected");
            $(this).removeClass("notselected");
        }
    });
    $("#sidebar li").mouseout(function() {
        if ($(this).hasClass("mouseover") == true && $(this).hasClass("ancestor") == false) {
            $(this).removeClass("mouseover");
            $(this).removeClass("selected");
            $(this).addClass("notselected");
        }
    });
    $("#sidebar li").click(function() {
        if ($(this).hasClass("mouseover") == true) {
            $(this).removeClass("selected");
            $(this).addClass("notselected");
        }
    });
    // end - mouseover-event for menutree -----
    $(document).each(function(){
        // ----- change head-pictures -----
        var path = $(location).attr('pathname').split('/');
        if (path.length == 2) {
            var name = 'buero';
        } else {
            var name = get_image_name();
        }
        var path = $("#head_pictures").css("background-image");
        $("#head_pictures").css("background-image", path.replace(new RegExp('grafik_\\w+'), 'grafik_' + name));
        $("#head_pictures").hide().fadeIn('slow');
        $("#head_pictures").css("display", ""); // zum Ausblenden in Druckanzeige noetig
        $("#horizontal_pictures").css("background-image",
            path.replace(new RegExp('grafik_\\w+'), 'grafik_lang_' + name));
        // end - change head-pictures -----
        // ----- add background-color for d-system -----
        if (document.URL.match(/workepdevel/)) {
            $("body").css("background-color", "#123456");
        }
        // end - add background-color for d-system -----
    });
    $(document).ready(function(){
      $(".colorbox").colorbox();
      });

});


