
function ReadCookie(cookieName) {
	var theCookie = '' + document.cookie;
	var ind = theCookie.indexOf(cookieName);
	if (ind == -1 || cookieName == '') return ''; 
	var ind1 = theCookie.indexOf(';', ind);
	if (ind1 == -1) ind1 = theCookie.length;
	var data = unescape(theCookie.substring(ind + cookieName.length + 1, ind1));
	data = data.replace(/\+/g, ' ');
	return data;
}

function getCookie() {
	var user_name  = ReadCookie(_CookieUserName);
	var user_email = ReadCookie(_CookieUserEmail);
	
	document.getElementsByName(_InputUserName) [0].value = user_name;
	document.getElementsByName(_InputUserEmail)[0].value = user_email;
	
	//extra fields also (if existing):
	var n = document.getElementsByName(_InputUserName).length;
	for (i=1; i<n; i++) { 
		document.getElementsByName(_InputUserName) [i].value = user_name;
		document.getElementsByName(_InputUserEmail)[i].value = user_email;
	}
	
	//replace in `antwoordForm` also (if existing):
	if (typeof antwoordForm === 'undefined') {
		// variable/form is undefined  
	} else {
		antwoordForm  = antwoordForm .replace('name=\"naam\"', 'name=\"naam\" value=\"'+user_name+'\" ');
		antwoordForm  = antwoordForm .replace('name=\"email\"', 'name=\"email\" value=\"'+user_email+'\" ');
	} 
}

function getYearMonth(x) {
	var selectYear = document.getElementById(x+"_year");
	var year = selectYear[selectYear.selectedIndex].value;
	var selectMonth = document.getElementById(x+"_month");
	var month = selectMonth[selectMonth.selectedIndex].value;
	if (month == "0")
		month = "";
	else
		month = " " + selectMonth[selectMonth.selectedIndex].text;
	document.getElementById(x).value = year + month;
}

