/**
 * @author Falko Zander, www.falko-zander.de
 */

var CONFIG = null;
var EDIT = null;

function on_load() {
    CONFIG = document.forms.config;
    if (CONFIG == null) error('document.forms.config is missing!!');
    
    new cMenu('mainmenu');
    
    EDIT = new cEdit('frm_edit', 'globalframe');
    
    if (window.location.href.search(/login/) != -1) {
        window.location.href = CONFIG.script.value + '?name=start&lang=' + document.forms[0].lang.value;
    }

    addScrollObject('news', 'news_inner_scroll', 'news_scroll', 'news_scroll_up', 'news_scroll_down', 5, false, true, 25);
	addScrollObject('content', 'content_inner_scroll', 'content_scroll', 'content_scroll_up', 'content_scroll_down', 5, false, true, 25);
	
	//show_ads();
}

function chg_lang(lang) {
    window.location.href = CONFIG.script.value + '?name=' + CONFIG.content.value + '&lang=' + lang;
}

function show_ads(response) {
    if (CONFIG == null || CONFIG.content.value != 'start' || $('SAB_info') != null) return;
    
    if (typeof response == 'undefined') {
        var THIS = this;
        var xhr = new cXHR();
        var cb = function(resp) { THIS.show_ads(resp); };
        xhr.get('../SAB_info/' + CONFIG.lang.value + '.html', cb, 1, function() {});
        return;
    } else if (response != '') {
        var div = $$('div');
        document.body.appendChild(div);
        div.id = 'SAB_info';
        
        div.onmouseover = function() { div.className = 'hover'; };
        div.onmouseout = function() { div.className = ''; };
        div.onclick = function() { document.body.removeChild(div); };
        
        div.innerHTML = response;
        
        var gf = $('globalframe');
        if (gf != null) {
            var pos = getAbsoluteDimensions(gf);
            div.style.left = (pos.offsetLeft + ((pos.offsetWidth - div.offsetWidth) >> 1)) + 'px';
            div.style.top = pos.offsetTop + 100 + 'px';
        }
    }
}



//function Numsort(a, b) {
//    return parseInt(a) - parseInt(b);
//}
//
//Array.prototype.mix = function() {
//    if (this.length < 2) return;
//    var r, t, j;
//    for (j = this.length - 1; j > 0; j--) {
//        r = Math.floor(Math.random() * (j + 1));
//        t = this[j];
//        this[j] = this[r];
//        this[r] = t;
//    }
//}
