function subscribe() {
	messageWnd.reset();
	if (!checkEmail(email.value)) {
		messageWnd.show('Invalid e-mail address',true);
		return false;
	}
	messageWnd.show(waitHTML,false);
	submitBtn.onclick = null;
	ajax = new Ajax();
	ajax.onreadystatechange = whenReady;
	ajax.onError = ajaxError;
	if (countryLabel.innerHTML == '&nbsp;') countryLabel.innerHTML = 'All';
	if (departmentLabel.innerHTML == '&nbsp;') departmentLabel.innerHTML = 'All';
	ajax.open('GET',getPath(type),true);
	ajax.send(null);
}
function getPath(type) {
	return 'saveSubscription-'+countryLabel.innerHTML+'-'+departmentLabel.innerHTML+'-'+email.value+'-'+type+'-'+(Math.random()*1000);
}
function ajaxError() {messageWnd.setText('Connection Error',true); ajax.remove(); ajax=null; submitBtn.onclick = subscribe;}
function whenReady() {
	if (ajax.readyState == 4 && ajax.status == 200) {
		messageWnd.setText(ajax.responseText,true);
		ajax.remove();
		ajax = null;
//		_gaq.push(['_trackEvent', 'Job Alert', countryLabel.innerHTML+' - '+departmentLabel.innerHTML]);
		submitBtn.onclick = subscribe;					
	}
}

