backend_is_active = 1;

/**
 * Output formated file size
 *
 * @category   Functions
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2009-10-15
 */

var size_format = function(filesize) {
	var iec = ["Byte(s)", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
	
	var i = 0;
	while((filesize / 1024) > 1) {
		filesize = filesize / 1024;
		i++;
	}
	
	filesize = String(filesize);
	return filesize.substr(0, filesize.indexOf('.') + 3) + ' ' + iec[i];
};

/**
 * Insert date
 *
 * @category   Functions
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2009-10-15
 */

var insertDate = function() {
	var todayDate = new Date();
	var todayDay = (todayDate.getDate() < 10 ? '0' : '') + todayDate.getDate();
	var todayMonth = (todayDate.getMonth() + 1 < 10 ? '0' : '') + (todayDate.getMonth() + 1);
	var todayYear = todayDate.getFullYear();
	var todayHours = (todayDate.getHours() < 10 ? '0' : '') + todayDate.getHours();
	var todayMinutes = (todayDate.getMinutes() < 10 ? '0' : '') + todayDate.getMinutes();
	var todaySeconds = (todayDate.getSeconds() < 10 ? '0' : '') + todayDate.getSeconds();
	
	document.getElementById('timestamp').value = todayDay + '.' + todayMonth + '.' + todayYear + ' ' + todayHours + ':' + todayMinutes + ':' + todaySeconds;
};

/**
 * Disable browser cache for AJAX loading
 *
 * @category   Functions
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2009-10-15
 */

var noCache = function(uri) {
    return uri.concat(/\?/.test(uri) ? "&" : "?", "noCache=", (new Date).getTime(), ".", Math.random() * 1234567);
};

/**
 * date() function from PHP
 *
 * @category   Functions
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2009-10-15
 */

eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([59pqvxCEJKQRVX]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('p 17=9(j,h){p m,c=((18(h)==\'undefined\')?x E():(18(h)==\'number\')?x E(h*J):x E(h));p f=9(a,d){q((a=a+"").R<d){5 x Array(++d-a.R).join("0")+a}C{5 a}};p k=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];p i={1:"st",2:"nd",3:"rd",21:"st",22:"nd",23:"rd",31:"st"};p l=["","January","February","March","April","May","June","July","August","September","October","November","December"];p b={d:9(){5 f(b.j(),2)},D:9(){p a=b.l();5 a.V(0,3)},j:9(){5 c.getDate()},l:9(){5 k[b.w()]},N:9(){5 b.w()+1},S:9(){5 i[b.j()]?i[b.j()]:\'th\'},w:9(){5 c.16()},z:9(){5(c-x E(c.v()+"/1/1"))/864e5>>0},W:9(){p a=b.z(),d=364+b.L()-a;p e,g=(x E(c.v()+"/1/1").16()||7)-1;q(d<=2&&((c.16()||7)-1)<=2-d){5 1}C{q(a<=2&&g>=4&&a>=(6-g)){e=x E(c.v()-1+"/12/31");5 17("W",X.1b(e.1c()/J))}C{5(1+(g<=3?((a+g)/7):(a-(7-g))/7)>>0)}}},F:9(){5 l[b.n()]},m:9(){5 f(b.n(),2)},M:9(){t=b.F();5 t.V(0,3)},n:9(){5 c.1d()+1},t:9(){p a;q((a=c.1d()+1)==2){5 28+b.L()}C{q(a&1&&a<8||!(a&1)&&a>7){5 31}C{5 30}}},L:9(){p a=b.Y();5(!(a&3)&&(a%1e2||!(a%4e2)))?1:0},o:9(){q(b.n()===12&&b.W()===1){5 c.v()+1}q(b.n()===1&&b.W()>=52){5 c.v()-1}5 c.v()},Y:9(){5 c.v()},y:9(){5(c.v()+"").slice(2)},a:9(){5 c.K()>11?"pm":"am"},A:9(){5 b.a().toUpperCase()},B:9(){p a=(c.10()+Q)*Q;p d=(c.K()*3600)+(c.1e()*Q)+c.1f()+a;p e=X.floor(d/86.4);q(e>J)e-=J;q(e<0)e+=J;q((1g(e)).R==1)e="00"+e;q((1g(e)).R==2)e="0"+e;5 e},g:9(){5 c.K()%12||12},G:9(){5 c.K()},h:9(){5 f(b.g(),2)},H:9(){5 f(c.K(),2)},i:9(){5 f(c.1e(),2)},s:9(){5 f(c.1f(),2)},u:9(){5 f(c.getMilliseconds()*J,6)},I:9(){p a=(x E(c.v(),6,1,0,0,0));a=a.K()-a.1h();p d=c.K()-c.1h();5 d!=a?1:0},O:9(){p a=f(X.abs(c.10()/Q*100),4);q(c.10()>0)a="-"+a;C a="+"+a;5 a},P:9(){p a=b.O();5(a.V(0,3)+":"+a.V(3,2))},Z:9(){p a=-c.10()*Q;5 a},c:9(){5 b.Y()+"-"+b.m()+"-"+b.d()+"T"+b.h()+":"+b.i()+":"+b.s()+b.P()},r:9(){5 b.D()+\', \'+b.d()+\' \'+b.M()+\' \'+b.Y()+\' \'+b.H()+\':\'+b.i()+\':\'+b.s()+\' \'+b.O()},U:9(){5 X.1b(c.1c()/J)}};5 j.replace(/[\\\\]?([a-zA-Z])/g,9(a,d){q(a!=d){13=d}C q(b[d]){13=b[d]()}C{13=d}5 13})};',[],80,'|||||return||||function||||||||||||||||var|if|||||getFullYear||new|||||else||Date|||||1000|getHours||||||60|length||||substr||Math|||getTimezoneOffset|||ret|||getDay|date|typeof|||round|getTime|getMonth|getMinutes|getSeconds|String|getUTCHours'.split('|'),0,{}));

/*'/*
 * Save WMEP status (AJAX action)
 *
 * @category   Functions
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2009-10-15
 */

var toggleWMEPstatus = function(mode, name, status) {
	var actionsFile = 'index.php?backend&actions=save-wmep-status.php&mode=' + mode + '&name=' + name + '&status=' + (status == true ? 1 : 0);
	var WMEPstatus = MoreCSS.createXMLHttpRequest();
	WMEPstatus.open('get', noCache(actionsFile), true);
	WMEPstatus.send(null);
};

/**
 * stripshlashes() function from PHP
 *
 * @category   Functions
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2009-10-15
 */

var stripslashes = function(str) {
    return str.replace(/\0/g, "0").replace(/\\([\\'"])/g, "$1");
};

/**
 * addslashes() funtion from PHP
 *
 * @category   Functions
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2009-10-15
 */

var addslashes = function(str) {
    return str.replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0");
};

/**
 * htmlspecialchars() function from PHP
 *
 * @category   Functions
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2009-10-15
 */

var htmlspecialchars = function(string) {
	string = string.replace(/&/g, '&amp;');
	string = string.replace(/</g, '&lt;');
	string = string.replace(/>/g, '&gt;');
	string = string.replace(/"/g, '&quot;');
	string = string.replace(/'/g, '&#039;');
	return string;
};

/**
 * Toggle visual feedback and attribute "disabled" for input fields via checkbox
 *
 * @category   Functions
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2009-11-24
 */

var toggleFieldStatusByCheckbox = function(checkboxID, inputID, disableField) {
	var checkboxElement = document.getElementById(checkboxID);
	var inputElement = document.getElementById(inputID);
	
	if(disableField && disableField == true) inputElement.disabled = checkboxElement.checked == true ? 'disabled' : false;
	inputElement.className = checkboxElement.checked == true ? 'disabled' : '';
};

/**
 * Disable submit button on click and change value
 *
 * @category   Functions
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2009-12-27
 */

var waitSubmit = function(form, button, value) {
	button.disabled = true;
	button.value = value;
	document.getElementById(form).submit();
};