function enterBirthDate() {
	var elem = document.getElementsByName("birthdate")[0];
	if (elem.value == "tt.mm.jjjj") {
		elem.value = "";
	}
}	

function leaveBirthDate() {
	var elem = document.getElementsByName("birthdate")[0];
	if (elem.value == "") {
		elem.value = "tt.mm.jjjj";
	}
}

function checkPrivacyAgreement() {
	var checked = document.getElementsByName("privacy_agreement")[0].checked;
	if (!checked) {
		alert("\n\n\n Bitte stimmen Sie den Datenschutzbestimmungen auf dieser Seite zu. \n\n\n");
	}
	return true;
}

function showLinkAsPopup(link) {
	var features = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=400,height=300';
	var win = window.open(link.href, '', features);
	win.focus();
	return false;
}
function showLinkAsPopupBIG(link) {
	var features = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=550,height=450';
	var win = window.open(link.href, '', features);
	win.focus();
	return false;
}

function ProfessionDecorator() {
	
	this.elemProfessionSelect = null;
	this.elemIncomeSelect = null;
	this.elemIncomeLabel = null;
	
	this.init = init;
	this.update = update;
	
	function init() {
		this.elemProfessionSelect = document.getElementById('profession');
		this.elemIncomeSelect = document.getElementById('income');		
		this.elemIncomeLabel = $('label[for=income]')[0];		
		if (!this.elemProfessionSelect) return;
		if (!this.elemIncomeSelect) return;		
		if (!this.elemIncomeLabel) return;		
		this.update();
		var self = this;
		$('#profession').bind('change', function() { return self.update(); });
		$('#profession').bind('keypress', function() { return self.update(); });
	}
	
	function update() {
		var selected = this.elemProfessionSelect.options[this.elemProfessionSelect.selectedIndex].value;
		var visibility = selected == 'Arbeitnehmer' ? 'visible' : 'hidden';
		this.elemIncomeSelect.style.visibility = visibility;
		this.elemIncomeLabel.style.visibility = visibility;
		if (visibility == 'hidden') {
			this.elemIncomeSelect.selectedIndex = 0;
		}
	}
}

$(document).ready(function() {
	new ProfessionDecorator().init();
});

