

var NavCSS = "welcome"

function loader(e) {
	var link = e.target || e.srcElement;
	NavCSS = link.rel;
	$("#content").load(link.rel+".txt", "", LoadDone);
	return false;
}


function LoadDone() {
	$(".loader").unbind("click");
	$(".loader").bind("click", loader);
	$(".lightbox").lightbox();
	$("#contact .send").unbind();
	$("#contact .send").bind("click", SendContact);
	$("#contactdone .reset").unbind();
	$("#contactdone .reset").bind("click", SendContactReset);
	$("#nav ul").attr("class", NavCSS);
}

/*== Neon-Animation==*/
var Show=0;
function Toggle(){
	if(Show==0){
		Show=1;
		$("#nav").addClass("act");
	}else{
		Show=0;
		$("#nav").removeClass("act");
	}
	var tim = Math.round(Math.random()*1500) + 10;
	window.setTimeout(Toggle,tim);
}



/*== Newsletter Registrieren ==*/
function SignIn() {

	CheckSignIn();

	if ($("#nl .missing").size() != 0) { return }
	
	var Email = $("#subs").val();
	if (Email != "") {
		var data = {
			"name": "",
			"email": Email,
			"body": "Subscribe Newsletter"
		}


		$.post("sender.php", data, SignInDone);
		//alert("send disabled.");
	}
}
function SignInDone(erg) {
	if (erg == "OK") {
		$("#subs").val("");
		$("#newsletterdone").show();
		$("#newsletterdone .reset").unbind();
		$("#newsletterdone .reset").bind("click", function() { $("#newsletterdone").hide(); });

	} else {
		alert(erg);
	}
}
function CheckSignIn() {
	var tbxEmail = $("#subs");
	if (tbxEmail.val() == "") {
		tbxEmail.addClass("missing");
		tbxEmail.focus();
	} else {
		tbxEmail.removeClass("missing");
	}
}



/*== Reiter ==*/
function ShowReiter1() {
	$("#reiter1").show();
	$("#reiter2").hide();
}
function ShowReiter2() {
	$("#reiter1").hide();
	$("#reiter2").show();
}



/*== Contactform ==*/
function CheckForm() {

	var tbxName = $("#tbxName");
	var tbxEmail = $("#tbxEmail");
	var tbxBody = $("#tbxBody");

	var SetFocus;
	
	if (tbxBody.val() == "") {
		tbxBody.addClass("missing");
		SetFocus = tbxBody;
	} else {
	tbxBody.removeClass("missing");
	}

	if (tbxEmail.val() == "") {
		tbxEmail.addClass("missing");
		SetFocus = tbxEmail;
	} else {
	tbxEmail.removeClass("missing");
	}

	if (tbxName.val() == "") {
		tbxName.addClass("missing");
		SetFocus = tbxName;
	} else {
		tbxName.removeClass("missing");
	}

	try {SetFocus.focus();}	catch (Error) { }
}

function SendContact() {

	CheckForm();

	$("#contact .tbx").bind("blur", CheckForm);

	if ($("#contact .missing").size() != 0) {return}


	var name = $("#tbxName").val();
	var email = $("#tbxEmail").val();
	var body = $("#tbxBody").val();

	var data = {
		"name" : name,
		"email" : email,
		"body" : body
	}
	
	$.post("sender.php", data, SendContactDone);
	//alert("send disabled.");
}
function SendContactDone(erg) {
	if (erg == "OK") {
		$("#contact").hide();
		$("#contactdone").show();
		$("#tbxName").val("");
		$("#tbxEmail").val("");
		$("#tbxBody").val("");
	} else {
	alert(erg);
	}
}
function SendContactReset() {
	$("#contact").show();
	$("#contactdone").hide();
}




$(document).ready(function() {
	//$("#news").load("news.txt");
	//$("#content").load("welcome.txt","",LoadDone);
	Toggle();

	$(".loader").unbind("click");
	$(".loader").bind("click", loader);

	$("#nav ul").attr("class", NavCSS);
});


