/* GuestBook */
function kg_isemail(chain) {
	var result = true;
	if (chain.length > 0) {
		if (chain.indexOf("@") > 0) {
			temp = chain.indexOf("@");
			tempchain = chain.substr(temp + 1,chain.length - temp);
			if (tempchain.indexOf("@") === -1 && tempchain.indexOf(".")  > 0) {
				/*ok*/
			} else {
				result = false;
			}
		} else {
			result = false;
		}
	} else {
		result = false;
	}
	if(chain!==escape(chain)){
		result = false;
	}
	return result;
}

function kg_addComment() {
	/*alert("ustawiam formularz dodawania tematu");*/
	document.getElementById('ksiega_gosci_form_container').style.display = "inline";
}

function kg_insertComment(autor,email,msg) {
	var blad = false;
	var errormsg = "";
	if (!kg_isemail(email)) {
		blad = true;
		errormsg = "Niepoprawny adres email !!!";
	}
	if (!msg.length > 0) {
		blad = true;
		errormsg = errormsg + "\nNie akceptujemy pustych komentarzy!!!\n" + msg;
	}
	if (!autor.length > 0) {
		blad = true;
		errormsg = errormsg + "\nProszę wpisać sygnaturę autora!";
	}
	if (!blad) {
		document.getElementById('ksiega_gosci_form').submit();
	} else {
		alert(errormsg);
	}
}

function kg_canceladdComment() {
	/*alert("ustawiam formularz dodawania tematu");*/
	document.getElementById('ksiega_gosci_form_container').style.display = "none";
}

function kg_deleteMsg(id,details) {
	if (confirm("Are you sure to delete Message " + id + " from:\n" + details)) {
		document.getElementById('kg_delete_form' + id).submit();
	}
}

function settoenabled(id) {
	/*alert(id+': wlaczone');*/
	document.getElementById('status_' + id).style.color = "#009900";
	document.getElementById('status_' + id).innerHTML = "Wpis został włączony!";
	document.getElementById('status_bt_' + id).value = "Wyłącz wpis";
}

function settodisabled(id) {
	/*alert(id+': wylaczone');*/
	document.getElementById('status_' + id).style.color = "#990000";
	document.getElementById('status_' + id).innerHTML = "Wpis został wyłączony!";
	document.getElementById('status_bt_' + id).value = "Włącz wpis";
}