function openLoginform() {
	var opt = 'width=820px, height=600px, menubar=no, toolbar=no, location=no, status=no, resizable=yes, scrollbars=yes'
	window.open('/sys/en/loginform', 'loginform', opt);
	return false;	
}

function openSignupform() {
	var opt = 'width=820px, height=600px, menubar=no, toolbar=no, location=no, status=no, resizable=yes, scrollbars=yes'
	window.open('/sys/en/signup', 'signup', opt);
	return false;	
}

function openNewWindow(url) {
	var opt = 'width=820px, height=600px, menubar=no, toolbar=no, location=no, status=no, resizable=yes, scrollbars=yes'
	window.open(url, null, opt);
	return false;	
}

function $$(id) {
	var e = document.getElementById(id);
	e.submitTo = function(action) {
		this.action = action;
		this.submit();
	};
	return e;
}

function alertOnLoad(msg) {
	$(function() {
		if (typeof(msg) == 'string') {
			alert(msg);
		} else if (typeof(msg) == 'object') {
			alert(msg.join('\n'));
		}
	});
}

var createDateSelector;
var createMonthSelector;
var createYearSelector;

(function() {
	
	var MONTH = [
		'Jan',
		'Feb',
		'Mar',
		'Apr',
		'May',
		'Jun',
		'Jul',
		'Aug',
		'Sep',
		'Oct',
		'Nov',
		'Dec'
	];

	createDateSelector = function (name, selectedValue) {
		var select = $('<select name="' + name + '" />');
		select.append($('<option value="">-Day-</option>'));
		for (var i=1; i<=31; i++) {
			var s = (i<10) ? '0'+i : ''+i;
			var option = $('<option value="' + s + '">' + s + '</option>');
			if (selectedValue == s) {
				option.attr('selected', 'selected');
			}
			select.append(option);
		}
		return select;
	}

	createMonthSelector = function (name, selectedValue) {
		var select = $('<select name="' + name + '" />');
		select.append($('<option value="">-Month-</option>'));
		for (var i=1; i<=12; i++) {
			var s = (i<10) ? '0'+i : ''+i;
			var option = $('<option value="' + s + '">' + s + ' (' + MONTH[i-1] + ')</option>');
			if (selectedValue == s) {
				option.attr('selected', 'selected');
			}
			select.append(option);
		}
		return select;
	}

	createYearSelector = function (name, selectedValue, from, to) {
		var select = $('<select name="' + name + '" />');
		select.append($('<option value="">-Year-</option>'));
		for (var i=from; i<=to; i++) {
			var option = $('<option value="' + i + '">' + i + '</option>');
			if (selectedValue == i) {
				option.attr('selected', 'selected');
			}
			select.append(option);
		}
		return select;
	}
	
})();

