function saveCategory()
{
    xajax_saveCategory(xajax.getFormValues("newCategory"));
    return false;
}

function uploadFileTo()
{
    xajax_selectCat(xajax.getFormValues("selectCat"));
    return false;
}

function showUserOnline(ID)
{
    xajax_showUserOnline(ID);
    return false;
}

function showUserOptions() 
{
    xajax_showUserOptions();
    return false;
}

function showAdminMenu() 
{
    xajax_showAdminMenu();
    return false;
}

function newSponsor()
{
    xajax_newSponsor();
    return false;
}

function editSponsor(ID)
{
    xajax_newSponsor(ID);
    return false;
} 

function saveSponsor(ID)
{
    xajax_saveSponsor(ID, xajax.getFormValues("sponsor"));
    return false;
}

function showSponsor()
{
    xajax.$('loading').style.visibility = "visible";
    xajax_showSponsor(xajax.getFormValues("choose"));
    return false;
}

function popUpHide()
{
    var the_style = getStyleObject('popup');
        the_style.display="none";
        the_style.background="#242424";
        the_style.width="200px";
        the_style.minHeight="100px";
        document.getElementById('popup').innerHTML="";
}

function popUpMove(ereignis)
{
    var the_style = getStyleObject('popup');
    if (document.getElementById) {
        x = ereignis.clientX + "px";
        y = ereignis.clientY+20 + "px";
    }else if (document.all) {
        x = ereignis.clientX;
        y = ereignis.clientY+20;
    }
    the_style.display="block";
    the_style.left = x;
    the_style.top = y;
}

function registerForm()
{
    xajax_register(xajax.getFormValues("registerForm"));
    return false;
}

function popUpDates(date) 
{
    document.getElementById('popup').innerHTML="";
    xajax_popUpDates(date);
    return false;
}

function tabBrowsing(tabID)
{
    xajax.$('loading').style.visibility = "visible";
	xajax_tabBrowsing(tabID);
	return false;
}

function imageVote(ID, vote)
{
    imageTop = document.getElementById("imageTop");
    imageFlop = getStyleObject("imageFlop");
    if(vote == "5") {
        document.getElementById("imageTop").style.background.url = "templates/motto/images/image_vote_top_voted.png"
    }
    xajax_imageVote(ID, vote);
    return false;
}

function showCommentForm(type, ID) 
{
    xajax_showCommentForm(type, ID);
    return false;
}

function newgBookPost() 
{
    xajax_newgBookPost();
    return false;
}

function submitNewgBookPost()
{
    tinyMCE.triggerSave(false, false);
    xajax.$('save').disabled=true;
	xajax.$('save').value="bitte warten...";
    //xajax.$('loading').style.visibility = "visible";
	xajax_submitNewgBookPost(xajax.getFormValues("gBookPost"));
	xajax.$('save').disabled=false;
	return false;
}

function newPost(ID)
{
    xajax_newPost(ID);
    return false;
}

function submitNewPost(ID)
{
    tinyMCE.triggerSave(false, false);
    xajax.$('save').disabled=true;
	xajax.$('save').value="bitte warten...";
    //xajax.$('loading').style.visibility = "visible";
	xajax_submitNewPost(xajax.getFormValues("newPostForm"), ID);
	xajax.$('save').disabled=false;
	return false;
}

function newTopic(ID)
{
	xajax_newTopic(ID);
	return false;
}

function submitNewTopic(ID)
{
    tinyMCE.triggerSave(false, false);
    xajax.$('save').disabled=true;
	xajax.$('save').value="bitte warten...";
    //xajax.$('loading').style.visibility = "visible";
	xajax_submitNewTopic(xajax.getFormValues("newTopicForm"), ID);
	xajax.$('save').disabled=false;
	return false;
}

function submitComment()
{
    tinyMCE.triggerSave(false, false);
    xajax.$('save').disabled=true;
	xajax.$('save').value="bitte warten...";
	xajax_saveComments(xajax.getFormValues("commentsForm"));
	xajax.$('save').disabled=false;
	return false;
}

function browsertest()  
{
  var browser;
  if(document.all) return browser="iex";
  if(document.layers) return browser="nav";
  if(navigator.appName=="Netscape" && !document.layers && !document.getElementById) return browser="old";
  if(window.sidebar) return browser="n_6";
}

//ansprechart von elementen
function get_element(id)
{
  var skin;
  browser = browsertest();
  if(browser == "nav") return skin=document.id;
  if(browser == "iex") return skin=id.style;
  if(browser == "n_6") return skin=document.getElementById(id).style;
}


// write content & display
function popup(id)
{
  browser = browsertest();
  skin = get_element(id);
  
  if (document.getElementById) {
    skin.left  = window.event.clientX + 20 + "px";
    skin.top = window.event.clientY - 20 + "px";
  } else if (document.all) {
    skin.left = window.event.clientX + 20;
    skin.top = window.event.clientY - 20;
  }
  skin.visibility="visible";
  
  
}


// park content box
function popup_kill(id)
{
  browser = browsertest();
  if(browser != "old")
  {
    skin = get_element(id);
    skin.visibility="hidden";
  }
  
}

var the_timeout;

function show_scrollbox(divID)
{
  // get the stylesheet
  //
  var the_style = getStyleObject(divID);
  if (the_style)
  {
    the_style.visibility = "visible";
    if(the_style.top == "")
      the_style.top = 215-document.getElementById(divID).offsetHeight;
    // get the current coordinate and add 5
    //
    
    var current_top = parseInt(the_style.top);
    var new_top = current_top + 5;

  //alert(the_style.top);
    // set the left property of the DIV, add px at the
    // end unless this is NN4
    //
    if (document.layers) 
    {
      the_style.top = new_top;
    }
    else 
    {  
      the_style.top = new_top + "px";
    }
    
    // if we haven't gone to far, call moveDiv() again in a bit
    // 
    if (current_top < 215)
    {
       the_timeout = setTimeout("show_scrollbox('" + divID + "');",5);
    }
  }
}


function hide_scrollbox(divID)
{
  // get the stylesheet
  //
  var the_style = getStyleObject(divID);
  if (the_style)
  {
    if(the_style.top == "")
      the_style.top = 215;
    // get the current coordinate and add 5
    //
    
    var current_top = parseInt(the_style.top);
    var new_top = current_top - 5;

  //alert(the_style.top);
    // set the left property of the DIV, add px at the
    // end unless this is NN4
    //
    if (document.layers) 
    {
      the_style.top = new_top;
    }
    else 
    {  
      the_style.top = new_top + "px";
    }
    
    // if we haven't gone to far, call moveDiv() again in a bit
    // 
    if (current_top > 215-document.getElementById(divID).offsetHeight)
    {
       the_timeout = setTimeout("hide_scrollbox('" + divID + "');",10);
    }else 
    {
      the_style.visibility = "hidden";
    }
  }
}


function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject


function scroll_to(speed) 
{
    if(speed<0) {
        window.scrollTo(0, 0);
    }else {
        if(document.body.clientHeight) {
            window.scrollTo(0, document.body.clientHeight);
        }else {
            window.scrollTo(0, window.innerHeight);
        }
    }
    //alert(document.body.clientHeight+"-"+window.pageYOffset+"-"+screen.availHeight);
}

function reload_captcha() 
{
    document.getElementById('captcha').src = "index.php?captcha&" + (new Date()).getTime();
}

function addDescriptionBox(fileID, title) {
    document.getElementById(fileID+"_settingsForm").innerHTML = "<table> \n" +
                                                                "   <tr><td>Titel</td><td><input type='text' id='"+fileID+"_title' value='"+title+"' /></td></tr> \n" +
                                                                "   <tr><td>Beschreibung</td><td><textarea id='"+fileID+"_description' ></textarea></td></tr> \n"
                                                                "</table>\n"  ;
}

