function checkEmail(cMail) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.getElementById(cMail).value)){
		return (true)
	}
	return (false)
}
function clear_field(ifield,icontent) {
	if (document.getElementById(ifield).value == icontent) {
		document.getElementById(ifield).value = "";
	}
}

function fill_field(ifield,icontent) {
	if (document.getElementById(ifield).value.length <= 1 || document.getElementById(ifield).value == "") {
		document.getElementById(ifield).value = icontent;
	}
}
function charCounter(field,maxLength,countTarget) {
		field = document.getElementById(field);
		countTarget = document.getElementById(countTarget);
	var inputLength=field.value.length;
	if (inputLength >= maxLength) {
		field.value=field.value.substring(0,maxLength);
	}
		countTarget.value=maxLength-field.value.length;
}
function delLink(link,where,confirmID) {
	if (link != 'inactive') {
		Check = confirm(document.getElementById(confirmID).value);
		if (Check == true) {
			open(link, where);
		}
    }
}
function sendKontaktRequest() {
	var submit = checkEmail('actEM');
	if (submit) {
		document.getElementById('KontaktFormular').submit();
	} else {
		alert(document.getElementById('FailSubmit').value);
	}
}
function sendLocaRequest() {
	var submit = checkEmail('actEM');
	if (submit) {
		document.getElementById('LocationFormular').submit();
	} else {
		alert(document.getElementById('FailSubmit').value);
	}
}
function sendFoodRequest() {
	var submit = checkEmail('actEM');
	if (submit) {
		document.getElementById('FOODFormular').submit();
	} else {
		alert(document.getElementById('FailSubmit').value);
	}
}
function daysInMonth(iMonth, iYear) {
         return 32 - new Date(iYear, iMonth, 32).getDate();
}
function setDaysOfMonth(d_day,d_month,d_year) {
		var o_daySelect = document.getElementById(d_day);
		var o_monthSelect = document.getElementById(d_month);
		var o_yearSelect = document.getElementById(d_year);

         var y_selID = o_yearSelect.selectedIndex;
         var year = o_yearSelect.options[y_selID].value;

         var m_selID = o_monthSelect.selectedIndex;
         var month = o_monthSelect.options[m_selID].value;

         var d_selID = o_daySelect.selectedIndex;
         var day = o_daySelect.options[d_selID].value;

         var nd = daysInMonth(month-1, year);

         var myOptions = [];
         for (var loop=0; loop<nd; loop++) {
              var d_value = loop+1;
              var d_label = d_value;
              myOptions[loop] = { optText:d_label, optValue:d_value };
         }

         o_daySelect.options.length = 0;
         for (var loop=0; loop<myOptions.length; loop++) {
              var optObj = document.createElement('option');
              optObj.text = myOptions[loop].optText;
              optObj.value = myOptions[loop].optValue;
              o_daySelect.options.add(optObj);
              if (optObj.value == day) {
                  o_daySelect.options[loop].selected = true;
              }
         }
}