var fcms_js_included = new Array();

function fcms_include(params, key) {
    if (!params) {
        return false;
    }

    var arr = new Array();
    var jsindex = 0;

    var arr = params.split(',');

    var inline, js;
    for (jsindex=0; jsindex<arr.length; jsindex++) {
        inline = false;
        js = "";
        switch (arr[jsindex]) {
            case "js":    js = "/_/scripts/js.js";
                break;
            case "md5":   js = "/_/scripts/md5.js";   
                break;
            case "nav":   js = "/_/scripts/navi.js";   
                break;
            case "aj_po": js = "/_/scripts/ajax/prototype.js";
                break;
            case "aj_sc": js = "/_/scripts/ajax/scriptaculous.js";
                break;
            case "aj_sc_gl": js = "/_/scripts/ajax/glider.js";
              break;
            case "aj_sc_sl":
                js = "/_/scripts/fcmsslideshow.js";
              break;
            case "sndmngr": js = "/_/scripts/fsndmngr1.js";
                break;
            case "swfup":
                js = '/_/scripts/swfupload/swfupload.js';
            break;
            case "swfupobj":
                js = '/_/scripts/swfupload/swfupload.swfobject.js';
            break;
            case "fswfupqu":
                js = '/_/scripts/swfupload/fcmsswfupload.queue.js';
            break;
            case "fswffile":
                js = '/_/scripts/swfupload/fcmsfileprogress.js';
            break;
            case "fswfhand":
                js = '/_/scripts/swfupload/fcmshandlers.js';
            break;
            case "google":
                if (key) {
                    js = "http://www.google.com/jsapi?key="+key;
                }
                break;
            case "gmaps":
                google.load("maps", "2");
                break;
            case "fcms": 
                js = "/_/scripts/fcms.js";
                break;
            case "fcmsmaps":
                js = "/_/scripts/fcmsmap.js";
                break;
            case "fcmspie":
                js = "/_/scripts/fcmspicedit.js";
                break;
            case "fcmscompn":
                js = "/_/scripts/fcmscompn.js";
                break;
            case "fcmsshoutbox":
                js = "/_/scripts/fcmsshoutbox.js";
                break;
            case "ltbox":
                js = "/_/scripts/ltbox.js";
                break;
            case "stat":
                js = "/_/scripts/ajax/stathandler.js";
                break;
            case 'swf':
                js = "/_/scripts/swfobject.js";
                break;
            case 'antzrubriksuche':
                js = "/_/scripts/fcmsuser/antzrubriksuche.js";
                break;
            case 'aj_epaper':
                js = '/_/scripts/ajax/epaper.js';
                break;
            case 'fcmscust':
                js = "/_/scripts/fcmscustomer.js";
            case 'fcmsorte':
                js = "/_/scripts/fcmsOrte.js";
            break;
    }
    if (js && !fcms_js_included[arr[jsindex]]) {
        fcms_js_included[arr[jsindex]] = arr[jsindex];
        if (inline) {
            document.writeln("<script type=\"text\/javascript\">"+js+"<\/script>");
        } else {
            document.writeln('<script type=\"text/javascript\" language=\"javascript\" src=\"'+js+'\"></script>');
        }
    }
  }
}


function check_popup_messages() {

    var handler = "/_/tools/ajax_handler.html";
    setTimeout("check_sound()", 2000);
    var myAjax = new Ajax.Request(
        handler, {
            method:
                'post',
            parameters:
                "type=com_popup_messages",
            onComplete:
                function(transport) {
                    var data = eval(transport.responseText);
                    if (data[1]) {
                        mw = window.open('/_/tools/disp_popup_messages.html'+data[0],'fCMSPopup','width=300,height=400,scrollbars=yes,resizable=no');
                        mw.focus();
                    }
                }
        }
    );
    setTimeout("check_popup_messages()", 60000);
}


function check_sound() {

    var handler = "/_/tools/ajax_handler.html";
    var myAjax = new Ajax.Request(
        handler, {
            method:
                'post',
            parameters:
                "type=com_sounds",
            onComplete:
                function(transport) {
                    snddata_string = transport.responseText;
                    aSoundIDs = null;
                    aSoundIDs = snddata_string.split(",");
                    fsndSetStartUpInterval(1500, 200);
                    fsndSetStartUpSounds(aSoundIDs);
                }
        }
    );
}
