//Ajax
var req = null;
function ajaxstart() {
         try{
                 req = new XMLHttpRequest();
         }
         catch(ms){
                 try{
                         req = new ActiveXObject("Msxml2.XMLHTTP");
                 }
                 catch(nonms){
                         try{
                                 req = new ActiveXObject("Microsoft.XMLHTTP");
                         }
                         catch(failed){
                                 req = null;
                         }
                 }
         }
         if(req == null)
                 alert("Ajax-Fehler");
}
function ajaxhandler(method, get, send){
         ajaxstart();
        if(method == "get")
                 req.open("GET", "/ajax.php?" + get, true);
         else
                 req.open("POST", "/ajax.php?"+ get, true)
         req.onreadystatechange = function(){
                 if(req.readyState == 4){
                         if(req.status == 200){
                                 eval(req.responseText);
                         }
                         /*else{
                                 alert('Ajax-Status-Fehler: ' + req.status);
                         }*/
                }
                 /*else{
                         alert('Ajax-Open-Fehler');
                 }*/
         }
         req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
         req.send(send);
}
function update_positions(cat_id){
         document.getElementById('subpages_list').innerHTML = '<img src="./images/loading2.gif" width="43" height="11">';
         document.getElementById('position_list').innerHTML = '<img src="./images/loading2.gif" width="43" height="11">';
         ajaxhandler('get', 'action=get_site_list&cat_id=' + cat_id);
}
function update_positions2(cat_id){
         document.getElementById('subpages_list').innerHTML = '<img src="./images/loading2.gif" width="43" height="11">';
         ajaxhandler('get', 'action=get_site_list3&cat_id=' + cat_id);
}
function update_positions_subpage(page_id){
         document.getElementById('position_list').innerHTML = '<img src="./images/loading2.gif" width="43" height="11">';
         ajaxhandler('get', 'action=get_site_list2&page_id=' + page_id);
}
function guestbook_add_smilie(symbol){
         var input = document.getElementById('neueintrag');
         var start = input.selectionStart;
         var end = input.selectionEnd;
         input.value = input.value.substring(0, start) + symbol + input.value.substring(end);
         input.focus();
         input.selectionStart = start + symbol.length;
         input.selectionEnd = start + symbol.length;
}
