/**
* remoteCP 4
* ütf-8 release
*
* @package remoteCP
* @author hal.sascha
* @copyright (c) 2006-2008
*/
window.addEvent('domready', function()
{
	rcp_Actions = new Actions();
	rcp_Modal   = new Modal();
	rcp_Tabs    = new Tabs();
	(function(){ PeriodicalUpdate('ajax.php?plugin=Core', 'serverstatus', 'serverstatus', false ) }).periodical(10500);
	(function(){ PeriodicalUpdate('ajax.php?plugin=Core&op=challenge', 'currentchallenge', 'currentchallenge', false ) }).periodical(15250);
});

/*
 * Other functions
 */
function PeriodicalUpdate(url, loader, target, callback)
{
	new Ajax(url,
	{
		method: 'get', 
		update: $(target),
		onRequest: function()
		{
			$(loader).addClass('loading');
		},
		onComplete: function()
		{ 
			$(loader).removeClass('loading');
			if(callback) {
				if(typeof window[callback] == 'function') window[callback]();
			}
		},
		onFailure: function()
		{
			$(loader).removeClass('loading');
		}
	}).request();
}

function checkUncheckAll(theElement)
{
	var theForm = theElement.form, z = 0;
	for(z=0; z<theForm.length;z++)
	{
		if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall')
		{
			theForm[z].checked = theElement.checked;
			selrow(theForm[z], theElement.checked);
		}
	}
}

function selrow(obj, force)
{
	if(obj.parentNode.parentNode.className != 'bg-s' || force)
	{
		obj.parentNode.parentNode.className = 'bg-s';
	} else {
		obj.parentNode.parentNode.className = '';
	}
}
