/* RWL-HP - JavaScript-FILE (c) PSP */

RWL = { timer: null };

RWL.load = function (url, target) {
    $(target).update('<div align="center"><img src="bilder/layout/rwl_spinner.gif" alt="spinner"></div>');
    
    var myAjax = new Ajax.Updater(
        target,
        url,
        {
            method: 'get'
        });  
};

RWL.loadContent = function (typeid, params, ser, formname) {
    var url = "content/content.php";
    var i;
    var param = 'cid=0_0';
    var target = 'content';
    
    if ($('bildgrosscon')) {
        $('bildgrosscon').setStyle({display: 'none'});
    }
    
    RWL.stopShow();
  
    switch (typeid) {
    case '0_0':
        param = 'cid=0_0';
        target = 'content';
        break;
      
    case '1_0':
        param = 'cid=1_0';
        target = 'content';
        break;
      
    case '2_0':
        param = 'cid=2_0';
        target = 'content';
        break;
    
    case '3_0':
        param = 'cid=3_0';
        target = 'content';
        break;
      
    case '4_0':
        param = 'cid=4_0';
        target = 'content';
        break;
      
    case '5_0':
        param = 'cid=5_0';
        target = 'content';
        break;
    
    case '5_1':
        param = 'cid=5_1';
        target = 'show';
        break;
    
    case '5_6_1':
        param = 'cid=5_6_1';
        target = 'bildgrosstext';
        break;
    
    case '6_0':
        param = 'cid=6_0';
        target = 'content';
        break;
      
    case '7_0':
        param = 'cid=7_0';
        target = 'content';
        break;
      
    case '8_0':
        param = 'cid=8_0';
        target = 'content';
        break;
      
    case '9_0':
        param = 'cid=9_0';
        target = 'content';
        break;
    
    case '10_0':
        param = 'cid=10_0';
        target = 'content';
        break;
    
    case '11_0':
        param = 'cid=11_0';
        target = 'content';
        break;
        
    case '11_1':
        param = 'cid=11_1';
        target = 'showthumbs';
        break;
    case '11_2':
        param = 'cid=11_2';
        target = 'interface';
        break;
    case '11_3':
        param = 'cid=11_3';
        target = 'showimg';
        break;
    
    case '12_0':
        param = 'cid=12_0';
        target = 'content';
        break;
    
    case '13_0':
        param = 'cid=13_0';
        target = 'content';
        break;
    
    case '15_0':
        param = 'cid=15_0';
        target = 'content';
        break;
    
    case '14_0':
        param = 'cid=14_0';
        target = 'nextmatch';
        break;
        
    case '14_1':
        param = 'cid=14_1';
        target = 'lastmatch';
        break;
    case '14_2':
        param = 'cid=14_2';
        target = 'tabelle';
        break;
        
    case '14_3':
        param = 'cid=14_3';
        target = 'stats';
        break;
        
    case '17_0':
        param = 'cid=17_0';
        target = 'voting';
        break;
        
    case '16_0':
        param = 'cid=16_0';
        target = 'content';
        break;
        
    case '16_1':
        param = 'cid=16_1';
        target = 'content';
        break;
      
    default:
        param = 'cid=0_0';
        target = 'content';
        break;
    }
  
    if (typeof ser !== 'undefined' && typeof formname !== 'undefined') {
        if (ser === true && $(formname)) {
            params += '&' + $(formname).serialize();
        }
    }
  
    $(target).update('<div align="center"><img src="bilder/layout/rwl_spinner.gif" alt="spinner"></div>');
    
    var myAjax = new Ajax.Updater(
        target,
        url,
        {
            method: 'post',
            parameters: param + params
        });
};

RWL.loadRest = function () {
    RWL.loadContent('14_0', '');
    RWL.loadContent('14_1', '');
    RWL.loadContent('14_2', '');
    RWL.loadContent('14_3', '');
    //voting
    //RWL.loadContent('17_0', '');
};

RWL.setImgSelected = function (bildnr) {
    var nr = bildnr - 1;
    if (nr >= 0 && nr <= $('selectbild').length) {
        if ($('selectbild')) {
            $('selectbild').selectedIndex = nr;
        }
        if ($('imglargeview')) {
            $('imglargeview').src = 'inc/bild.inc.php?path=../' + $('selectbild').value + '&width=300';
        }
    }
};

RWL.showImg = function () {
    if ($('selectbild')) {
        if ($('imglargeview')) {
            $('imglargeview').src = 'inc/bild.inc.php?path=../' + $('selectbild').value + '&width=300';
        }
    }
};

RWL.nextBild = function () {
    var next = 0;
    
    if (RWL.timer !== null) {
        RWL.stopShow();
    }
    var nr = $('selectbild').selectedIndex;
    if (nr >= 0 && nr <= $('selectbild').length) {
        if ($('selectbild')) {
            next = nr + 1;
            
            if (next >= $('selectbild').length) {
                next = 0;
            }
            $('selectbild').selectedIndex = next;
            
            if ($('imglargeview')) {
                $('imglargeview').src = 'inc/bild.inc.php?path=../' + $('selectbild').value + '&width=300';
            }
        }
    }
};


RWL.previousBild = function () {
    var nr;
    var prev;
    
    if (RWL.timer !== null) {
        RWL.stopShow();
    }
    
    nr = $('selectbild').selectedIndex;
    if (nr >= 0 && nr <= $('selectbild').length) {
        if ($('selectbild')) {
            prev = nr - 1;
            
            if (prev < 0) {
                prev = $('selectbild').length - 1;
            }
            
            $('selectbild').selectedIndex = prev;
            
            if ($('imglargeview')) {
                $('imglargeview').src = 'inc/bild.inc.php?path=../' + $('selectbild').value + '&width=300';
            }
        }
    }
};

RWL.startShow = function startShow() {
    if ($('secs')) {
        if ($('secs').value > 0 && $('secs').value <= 10) {
            RWL.nextBild();
            RWL.timer = setTimeout('RWL.startShow()', (Math.ceil($('secs').value)) * 1000);
        }
    }
};

RWL.stopShow = function () {
    if (RWL.timer !== null) {
        clearTimeout(RWL.timer);
    }
};

RWL.reloadCap = function (sid) {
    var url = "content/content.php";
    var myAjax = new Ajax.Request(
        url,
        {
            method: 'post',
            parameters: 'cid=12_1' + sid,
            onSuccess: function (req) {
                if ($('capbild')) {
                    $('capbild').src = req.responseText + sid;
                }
            }
        });
};

RWL.setSmiley = function (smileystring) {
    var smiley = '{:)01}';
    
    switch (smileystring) {
    case '01':
        smiley = '{:)01}';
        break;
    case '02':
        smiley = '{:)02}';
        break;
    case '03':
        smiley = '{:)03}';
        break;
    case '04':
        smiley = '{:)04}';
        break;
    case '05':
        smiley = '{:)05}';
        break;
    case '06':
        smiley = '{:)06}';
        break;
    case '07':
        smiley = '{:)07}';
        break;
    case '08':
        smiley = '{:)08}';
        break;
    case '09':
        smiley = '{:)09}';
        break;
    case '10':
        smiley = '{:)10}';
        break;
    case '11':
        smiley = '{:)11}';
        break;
    case '12':
        smiley = '{:)12}';
        break;
    case '13':
        smiley = '{:)13}';
        break;
    case '14':
        smiley = '{:)14}';
        break;
    case '15':
        smiley = '{:)15}';
        break;
    case '16':
        smiley = '{:)16}';
        break;
    case '17':
        smiley = '{:)17}';
        break;
    case '18':
        smiley = '{:)18}';
        break;
    default:
        smiley = '{:)01}';
        break;
    }
  
    if ($('txtbeitraggbook')) {
        $('txtbeitraggbook').value += smiley;
    }
    else if ($('txtbeitragakt')) {
        $('txtbeitragakt').value += smiley;
    }
};

RWL.showGalName = function (event, name) {
    var offsetobject;
    var event = event || window.event;
    
    if ($('showgalname')) {
        $('showgalname').update(name);
        
        offsetobject = $('showgalname').viewportOffset();
        
        $('showgalname').setStyle({'top': Event.pointerY(event) + "px"});
        $('showgalname').setStyle({'left': (Event.pointerX(event) + 10) + "px"});
        
        $('showgalname').setStyle({'display': 'block'});
    }
};

RWL.hideGalName = function () {
    if ($('showgalname')) {
        $('showgalname').update();
        $('showgalname').setStyle({'display': 'none'});
    }
};

RWL.showBildgross = function (path, id) {
    if ($('bildgross') && $('bildgrosscon') && $('bildgrosstext')) {
        
        $('bildgross').src = path;
        RWL.loadContent('5_6_1', '&id=' + id);
        $('bildgrosscon').setStyle({'display': 'block'});
        
    }
};

RWL.showBildgross2 = function () {
    if ($('bildgross') && $('bildgrosscon') && $('bildgrosstext') && $('selectbild')) {
        if ($('selectbild')) {
            //damit im IE nicht das Dropdownfeld mitten im Bild ist
            $('selectbild').setStyle({'display': 'none'});
        }
        $('bildgross').src = "./admin/" + $('selectbild').value;
        $('bildgrosstext').update();
        $('bildgrosscon').setStyle({'display': 'block'});
    }
};

RWL.hideBildgross = function () {
    if ($('bildgross') && $('bildgrosscon')) {
        if ($('selectbild')) {
            //damit im IE nicht das Dropdownfeld mitten im Bild ist
            $('selectbild').setStyle({'display': 'inline'});
            $('bildgross').src = "";
        }
        $('bildgrosscon').setStyle({'display': 'none'});
    }
};



RWL.showBildgrossNew = function (path, textAsHtml) {

    if ($('bildgross') && $('bildgrosscon') && $('bildgrosstext')) {
        
        $('bildgross').src = path;
        $('bildgrosstext').update(textAsHtml); 
        $('bildgrosscon').setStyle({'display': 'block'});
        
    }

};