
$(document).ready(function(){
	
	$("#container").hide();
	$("#rightContent").empty();
	$("#homeIntro").clone().appendTo("#rightContent");
	$("#rightContent>#homeIntro").hide();
	$("#rightContent>#homeIntro").slideDown("fast");
	setMainDiv();
	
	/*Top Links*/
	$("#logo").click(function(){
		$("#rightContent").empty();
		$("#homeIntro").clone().appendTo("#rightContent");
		$("#rightContent>#homeIntro").hide();
		$("#rightContent>#homeIntro").slideDown("normal");
		setMainDiv();
	});
	$("#topLink1").click(function(){
		$("#rightContent").empty();
		$("#homeIntro").clone().appendTo("#rightContent");
		$("#rightContent>#homeIntro").hide();
		$("#rightContent>#homeIntro").slideDown("normal");
		setMainDiv();
	});
	
	$("#topLink2").click(function(){
		$("#rightContent").empty();
		$("#uberuns").clone().appendTo("#rightContent");
		$("#rightContent>#uberuns").hide();
		$("#rightContent>#uberuns").slideDown("normal");
		setMainDiv();
	});
	$("#topLink3").click(function(){
		$("#rightContent").empty();
		$("#speisekarte").clone().appendTo("#rightContent");
		$("#rightContent>#speisekarte>#lists").empty();
		$("#container>#speisekarte>#lists>#list20").clone().appendTo("#rightContent>#speisekarte>#lists");
		$("#rightContent>#speisekarte").slideDown("normal");
		
		$(".listItem").mouseover(function(){
			$(this).css({"backgroundColor":"#cc0f0f"});
		});
		$(".listItem").mouseout(function(){
			$(this).css({"backgroundColor":"8c0222"});
		});
		
		$("#mainDiv").css({"margin":"50px 0px 50px 50px"});
		$("body").css({"text-align":"left"});
		$("#menuContext").css({"visibility":"visible"});
		$("#menuContext").show();
	});
	$("#topLink4").click(function(){
		$("#rightContent").empty();
		$("#bilder").clone().appendTo("#rightContent");
		$("#rightContent>#bilder").hide();
		$("#rightContent>#bilder").slideDown("normal");
		setMainDiv();
	});
	$("#topLink5").click(function(){
		$("#rightContent").empty();
		$("#impressum").clone().appendTo("#rightContent");
		$("#rightContent>#impressum").hide();
		$("#rightContent>#impressum").slideDown("normal");
		setMainDiv();
	});
	$("#topLink6").click(function(){
		$("#rightContent").empty();
		$("#kontakt").clone().appendTo("#rightContent");
		$("#rightContent>#kontakt").hide();
		$("#rightContent>#kontakt").slideDown("normal");
		setMainDiv();
	});
	$("#topLink7").click(function(){
		$("#rightContent").empty();
		$("#guestBook").clone().appendTo("#rightContent");
		$("#rightContent>#guestBook").hide();
		$("#contentIframe").attr("height=600px");
		$("#rightContent>#guestBook").append("<iframe src='gbook/gbook.php' id='contentIframe' height='800px' width='500px' name='contentIframe' allowtransparency='true' frameborder='0' onload='resize_ifrm();check_src();refreshSize();'></iframe>");
		$("#rightContent>#guestBook").slideDown("normal");
		setMainDiv();
	});
	/*Speisekarte List*/
	
	$("#rightContent>#item").click(function(){
		alert("asdasd");
	});
});

function setMainDiv(){
	$("#mainDiv").css({"margin":"50px auto"});
	$("body").css({"text-align":"center"});
	$("#menuContext").css({"visibility":"hidden"});
	$("#menuContext").hide();
}

/*Show List*/
function showList(listId){
	id="#container>#speisekarte>#lists>"+"#"+listId+"";
	$("#rightContent>#speisekarte>#lists").empty();	
	$(id).clone().appendTo("#rightContent>#speisekarte>#lists");
	$("#rightContent>#speisekarte>#lists").hide();
	$("#rightContent>#speisekarte>#lists").slideDown("slow");
	
}

/*Resize The Frame.*/
  URL = 'gbook/gbook.php';
  var dec = (typeof decodeURIComponent == 'function') ? decodeURIComponent : decode;
  function resize_ifrm() {
    if(navigator.userAgent.indexOf("Opera")==-1){
	var ifrm = document.getElementById('contentIframe');
    if(window.frames['contentIframe'] && window.frames['contentIframe'].document) {
	  try
	{
	  window.frames['contentIframe'].window.scroll(0,0);
	}
	catch(error)
	{
	
	}
      var body = window.frames['contentIframe'].document.body;
      if(body) {
        ifrm.style.height = (body.scrollHeight || body.offsetHeight)+30 + 'px';
      }
    }
	}
  }
  src_checked = false;
  function check_src() {
	if(navigator.userAgent.indexOf("Opera")==-1){
    if(src_checked) return;
    src_checked = true;
    var ifrm = document.getElementById('contentIframe');
    var urlPos = location.search.indexOf("iframeUrl=");
    if(urlPos > -1) {
      var src = dec(location.search.substring(urlPos+10));
    } else {
      var src = URL;
    }
    if(src != ifrm.src) ifrm.src = src;
	}
  }
  function refreshSize(){
	setInterval('resize_ifrm()', 100);
  }