/*******************************************************************************
* Datei :           links.js   ***JAVASCRIPT***                                *
*                                                                              *
* Projekt :         NC LinkList                                                *
* Version :         1.2                                                        *
* Datum :           21.02.2004                                                 *
* Letzte Änderung : 03.04.2005 (v1.2)                                          *
* Autor :           Manuel Rennecke <info@netconcept24.de>                     *
* Herausgeber :     (c) 2003-2005 - Net Concept 24                             *
*                                                                              *
* Funktionsbibliothek - Links, AdminCenter/Linkverzeichnis                     *
*******************************************************************************/ 

//#### Neu, Bearbeiten, Freischalten, Beschreibungslänge #######################
function count_chars(max_chars) {
	if (document.form.description.value.length > Number(max_chars)) {
		var text = document.form.description.value;
		document.form.description.value = text.substr(0,Number(max_chars));
	}
	document.form.chars.value = Number(max_chars) - document.form.description.value.length;
}
function Pcount_chars(max_chars) {
	if (document.LLneueintragenform.description.value.length > Number(max_chars)) {
		var text = document.LLneueintragenform.description.value;
		document.LLneueintragenform.description.value = text.substr(0,Number(max_chars));
	}
	document.LLneueintragenform.chars.value = Number(max_chars) - document.LLneueintragenform.description.value.length;
}

//#### Neu, Bearbeiten, Freischalten, Formularüberprüfung ######################
function checkform() {
	if (document.form.name.value == "") {
		alert("Bitte geben Sie den Titel der Webseite an!");
		document.form.name.focus();
		return false;
	}
	if (document.form.link.value == "" || document.form.link.value == "http://") {
		alert("Bitte geben Sie die URL/Adresse der Webseite an!");
		document.form.link.focus();
		return false;
	}
	if (document.form.category_id.value == 0) {
		alert("Bitte wählen Sie die Kategorie, in der der Link aufgeführt werden soll!");
		document.form.category_id.focus();
		return false;
	}
}

//#### Freischaltung, Navigationsfeldverwaltung ################################
function manage_fields() {
	if (document.navigation.t.options[4].selected == true) {
		document.navigation.s.disabled = true;
		document.navigation.l.disabled = true;
		if (document.all)  {
			document.all.field1.style.color = "#999999";
			document.all.field2.style.color = "#999999";
			document.all.s.style.backgroundColor = "#CCCCCC";
			document.all.l.style.backgroundColor = "#CCCCCC";
		} else {
			document.getElementById('field1').style.color = "#999999";
			document.getElementById('field2').style.color = "#999999";
			document.getElementById('s').style.backgroundColor = "#CCCCCC";
			document.getElementById('l').style.backgroundColor = "#CCCCCC";
		}
	} else {
		document.navigation.s.disabled = false;
		document.navigation.l.disabled = false;
		if (document.all) {
			document.all.field1.style.color = "#000000";
			document.all.field2.style.color = "#000000";
			document.all.s.style.backgroundColor = "";
			document.all.l.style.backgroundColor = "";
		} else {
			document.getElementById('field1').style.color = "#000000";
			document.getElementById('field2').style.color = "#000000";
			document.getElementById('s').style.backgroundColor = "";
			document.getElementById('l').style.backgroundColor = "";
		}
	}
}

//#### Vorschlag, Bearbeiten (öffentlich), Formularüberprüfung #################
function checkpublicform() {
	if (document.LLneueintragenform.name.value == '') {
		alert('Bitte geben Sie den Titel der Webseite an!');
		document.LLneueintragenform.name.focus();
		return false;
	}
	if (document.LLneueintragenform.link.value == '' || document.LLneueintragenform.link.value == 'http://') {
		alert('Bitte geben Sie die URL der Webseite an!');
		document.LLneueintragenform.link.focus();
		return false;
	}
	if (document.LLneueintragenform.category_id.value == '0') {
		alert('Bitte wählen Sie eine passende Kategorie aus!');
		document.LLneueintragenform.category_id.focus();
		return false;
	}
	if (document.LLneueintragenform.username.value == '') {
		alert('Bitte geben Sie einen Benutzernamen an (wird zum Ändern der Daten benötigt)!');
		document.LLneueintragenform.username.focus();
		return false;
	}
	if (document.LLneueintragenform.email.value == '') {
		alert('Bitte geben Sie Ihre E-mail Adresse an (wird zum Ändern der Daten benötigt)!');
		document.LLneueintragenform.email.focus();
		return false;
	}
	if (document.LLneueintragenform.email.value.indexOf('@') == -1 || document.LLneueintragenform.email.value.indexOf('.') == -1) {
		alert('Die angegebene E-Mail Adresse ist ungültig!');
		document.LLneueintragenform.email.focus();
		return false;
	}
	if (document.LLneueintragenform.password.value == '') {
		alert('Bitte geben Sie ein Passwort an (wird zum Ändern der Daten benötigt)!');
		document.LLneueintragenform.password.focus();
		return false;
	}
	if ((document.LLneueintragenform.password2) && (document.LLneueintragenform.password2.value != document.LLneueintragenform.password.value)) {
		alert('Passwort und Passwort-Wiederholung stimmen nicht überein!');
		document.LLneueintragenform.password.focus();
		return false;
	}
}
