// JavaScript Document
$(document).ready(function() {
	
	$(".nav").click(function() {
		seitenwechsel($(this).attr("id"),false);
		});
	
	$(".unternav").click(function(){   
		seitenwechsel($(this).attr("id"),true);
  	});
	
	$(".nav3").click(function(){  
			$(".djmarwinun").hide('slow');
			$(".zumirun").hide('slow');
			$(".webprogun").hide('slow');
			$("."+$(this).attr("id")).show('slow');
		return false;
  	});	
	
	
	$(".nav2").click(function(){    
		seitenwechsel($(this).attr("id"),false);
  	});
	$("#showlogin").click(function(){ 
			$("#slogin").hide('slow'); 
			$("#login").show('slow');
			return false;
	});
	$("#hidelogin").click(function(){  
			$("#login").hide('slow');
			$("#slogin").show('slow');
			return false;
	});
	$("#startshow").click(function(){    
		$("#startblock").fadeOut('fast',function(){
				$("#body4").fadeIn('fast');
				$("#body5").fadeIn('fast');
				$("#cont").fadeIn('slow');
		});
		return false;
  	});
	$("#body6").click(function(){    
		window.open("http://www.mwieners.de/admin.php");
        return false;
  	});
	

});

function Cursortasten(event) 
{ 
	  if(event.keyCode == 13)
  {
    $("#startblock").fadeOut('fast',function(){
				$("#body4").fadeIn('fast');
				$("#body5").fadeIn('fast');
				$("#cont").fadeIn('slow');
	});
    
  }  
  	  if(event.keyCode == 27)
  {
    			$("#body4").fadeOut('fast');
				$("#body5").fadeOut('fast');
				$("#cont").fadeOut('slow',function(){
					$("#startblock").fadeIn('fast');
					
		});
    
  }  
} 
function seitenwechsel(id,untnav){

	 $.get("includes/"+id+".php", function(text){
		 	if(untnav==false){
			$(".djmarwinun").hide('slow');
			$(".zumirun").hide('slow');
			$(".webprogun").hide('slow');
			}
			$("#content").hide('slow', function(){
				
				$("#content").html(text).show('slow');
			});
			
   		});
		$("#url").html('URL zu der Seite: http://www.mwieners.de/?s='+id+'&i=n');
	return false;
}


function youtube(id){
	$("#content").hide('slow', function(){
				text = '<iframe class="youtube-player" type="text/html" width="560" height="420" src="http://www.youtube.com/embed/'+id+'" frameborder="0"></iframe>';
				$("#content").html(text).show('slow');
			});
		$("#url").html('&nbsp;');
	return false;
}

window.fbAsyncInit = function() {
    FB.init({appId: '113827398637172', status: true, cookie: true,
             xfbml: true});
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());
  
  
  function sendRequest() { 
			var name = document.form.name.value;
			if (document.form.name.value == "") {
    			alert("Bitte einen Namen angeben!");
    			document.form.name.focus();
				document.form.name.className = "feld2";
    			return false;
  			}
  			if (document.form.email.value == "") {
    			alert("Bitte eine E-Mail angeben!");
    			document.form.email.focus();
				document.form.email.className = "feld2";
    			return false;
  			}
  			if (MD5(document.form.captcha.value) != captcha) {
    			alert("Captcha Falsch, bitte editieren!");
    			document.form.captcha.focus();
				document.form.captcha.className = "feld2";
    			return false;
  			}
  			if (document.form.email.value.indexOf("@") == -1) {
    			alert("Keine E-Mail-Adresse!");
    			document.form.email.focus();
				document.form.email.className = "feld2";
    			return false;
  			}
  			if (document.form.text.value == "") {
    			alert("Bitte einen Text angeben!");
    			document.form.text.focus();
				document.form.text.className = "feld2";
    			return false;
  			}
			
			
			   var url = "send.php";
				var request =  new XMLHttpRequest()
				request.open('POST',url,true);
				request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				request.send("s=1&name="+document.form.name.value+"&email="+document.form.email.value+"&text="+document.form.text.value+"&captcha="+document.form.captcha.value);
			
			seitenwechsel('abgesendet',false);
			return false;
  		}
