// CHECKBOX AKTIVIEREN/DEAKTIVIEREN
function check_box(id, group, checkedvalue, checktype) {

	boxID		= group + '_' + id + checktype;
	descID		= group + '_' + id + 'desc';

	fieldID		= group + '_' + id;
	group		= group + '_';
	form_name	= document.getElementById(fieldID).form.id;

	if (checktype == "radio") {

			// WERT DES HIDDEN FIELD SETZEN
			document.forms[form_name][fieldID].checked						= true;

	} else if (checktype == "checkbox") {

		// DEAKTIVIEREN WENN AKTIVIERT
		if (document.forms[form_name][fieldID].checked == true) {

			// WERT DES HIDDEN FIELD SETZEN
			document.forms[form_name][fieldID].checked						= false;

		// AKTIVIEREN WENN DEAKTIVIERT
		} else if (document.forms[form_name][fieldID].checked == false) {

			// WERT DES HIDDEN FIELD SETZEN
			document.forms[form_name][fieldID].checked						= true;

		}

	}

	num_of_fields = document.forms[form_name].length;

	for (i = 0; i < num_of_fields; i++) {

		currentFieldID	= document.forms[form_name][i].id;
		currentBoxID	= currentFieldID + checktype;
		currentDescID	= currentFieldID + 'desc';

		if (currentFieldID.search(group) != -1) {

			if (document.forms[form_name][i].getAttribute("type", "false") == checktype) {

				if (document.forms[form_name][currentFieldID].checked == false) {

					// CLASS DER CHECKBOX SETZEN
					document.getElementById(currentBoxID).className		= checktype;

					// CLASS DER BESCHREIBUNG SETZEN
					document.getElementById(currentDescID).className	= 'desc';

				// AKTIVIEREN WENN DEAKTIVIERT
				} else if (document.forms[form_name][currentFieldID].checked == true) {

					// CLASS DER CHECKBOX SETZEN
					document.getElementById(currentBoxID).className		= checkedvalue + checktype;

					// CLASS DER BESCHREIBUNG SETZEN
					document.getElementById(currentDescID).className	= checkedvalue + 'desc';

				}

			}

		}

	}

}

// GROESSE DER TEXTAREA AENDERN -----------------------------------------------------------------------------------------------------------
function resize_formfield (id, resize_value) {

	var textarea = document.getElementById(id);

	var current_height = textarea.rows;

	textarea.rows = parseInt(current_height) + parseInt(resize_value);

}

// EINBLENDEN/AUSBLENDEN
function showhide(id) {

	if (document.getElementById(id).style.display == 'block') {
		document.getElementById(id).style.display = 'none';
	} else {
		document.getElementById(id).style.display = 'block';
	}

}

// EINBLENDEN/AUSBLENDEN
function switchClass(id, classname) {

	var currentClassName = document.getElementById(id).className;

	if (currentClassName.indexOf(classname) != -1) {
		var reExp = new RegExp(classname);
		document.getElementById(id).className = document.getElementById(id).className.replace(reExp, "");
	} else {
		document.getElementById(id).className = document.getElementById(id).className + ' ' + classname;
	}

}

// FOCUS AUF ERSTES FORMULARFELD IM DOKUMENT
function focus_first_formfield () {

	if (typeof document.forms[0] == 'object') {

		var focusform = document.forms[0];
		var num_of_fields = focusform.elements.length;

		for (var i = 0; i <= num_of_fields; i++) {

			if (focusform.elements[i].type == 'text' || focusform.elements[i].type == 'textarea' || focusform.elements[i].type == 'password') {

				if (focusform.elements[i].value) {
					break;
				}

				focusform.elements[i].focus();
				break;

			}

		}

	}

}

// POPUP
function popup(url, name, popupWidth, popupHeight) {
	window.open(url, name, 'width=' + popupWidth + ', height=' + popupHeight + ', toolbar=0, menubar=0, status=0, resizable=0, scrollbars=0, directories=0, location=0');
}

// LINK
function hrefDo(url) {
	window.location.href = url;
}
