window.addEvent('domready', function() {
});
var login = function() {
	var req = new Request(
		{method:'post',url: '/javascript/login.php',onSuccess: function(text) {
			if( text == "1" ) {
				location.href = 'central.php';
			} else {
				alert( text );
			}
		}
	});
	req.send(Object2QueryStr({'username':$('username').value,'password':$('password').value}));
}
var logout = function() {
	var req = new Request(
		{method:'post',url: '/javascript/logout.php',onSuccess: function(text) {
			location.href = 'index.php';
		}
	});
	req.send();
}
var newsletter = function() {
	var req = new Request(
		{method:'post',url: '/javascript/newsletter.php',onSuccess: function(text) {
			alert( text );
		}
	});
	req.send(Object2QueryStr({'email':$('email').value}));	
}
function Object2QueryStr(obj) {
	obj = new Hash(obj);
	var ret = '';
	var tr = '';
	obj.each(function(d,n) {
			ret = ret + tr + encodeURIComponent(n) + '=' + encodeURIComponent(d);
		tr = '&';
	});
	return ret;
}
