/*
 * jQuery hashchange event - v1.3 - 7/21/2010
 * http://benalman.com/projects/jquery-hashchange-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){r||l(a());n()}).attr("src",r||"javascript:0").insertAfter("body")[0].contentWindow;h.onpropertychange=function(){try{if(event.propertyName==="title"){q.document.title=h.title}}catch(s){}}}};j.stop=k;o=function(){return a(q.location.href)};l=function(v,s){var u=q.document,t=$.fn[c].domain;if(v!==s){u.title=h.title;u.open();t&&u.write('<script>document.domain="'+t+'"<\/script>');u.close();q.location.hash=v}}})();return j})()})(jQuery,this);

var hash = false; 
var hashnew = false; 
var c = 1;
var orgurl = location.href.split("#",2);
$(document).ready(function(){
	function processHash(hash){
		if (hashnew != hash) {
			hashnew = hash;
			var quelle = hash.split("#",2);
			if (quelle[1]) {
				$("#response").hide().load(quelle[1]+".html?art=print").fadeIn();
				$('#navi ul li').removeClass('act');
				$('#navi ul li#'+quelle[1]).addClass('act');
				$('html, body').animate({scrollTop:0}, 'slow');
			}
		}
	}
	$(window).hashchange( function(){
		if (location.hash) {
			processHash(location.hash);
		}
	})
	$(window).hashchange();
	function isURL(argvalue) {
	
	  if (argvalue.indexOf(" ") != -1)
		return false;
	  else if (argvalue.indexOf("http://") == -1)
		return false;
	  else if (argvalue == "http://")
		return false;
	  else if (argvalue.indexOf("http://") > 0)
		return false;
	
	  argvalue = argvalue.substring(7, argvalue.length);
	  if (argvalue.indexOf(".") == -1)
		return false;
	  else if (argvalue.indexOf(".") == 0)
		return false;
	  else if (argvalue.charAt(argvalue.length - 1) == ".")
		return false;
	
	  if (argvalue.indexOf("/") != -1) {
		argvalue = argvalue.substring(0, argvalue.indexOf("/"));
		if (argvalue.charAt(argvalue.length - 1) == ".")
		  return false;
	  }
	
	  if (argvalue.indexOf(":") != -1) {
		if (argvalue.indexOf(":") == (argvalue.length - 1))
		  return false;
		else if (argvalue.charAt(argvalue.indexOf(":") + 1) == ".")
		  return false;
		argvalue = argvalue.substring(0, argvalue.indexOf(":"));
		if (argvalue.charAt(argvalue.length - 1) == ".")
		  return false;
	  }
	
	  return true;
	
	}
	$("#navi ul a").each(function(){
		var new2 = $(this).attr("href");
		if (!isURL(new2)) {
			new2 = new2.split(".htm",2);
			$(this).attr("href",orgurl[0]+"#"+new2[0]);
		}
	});
	$("#subnav ul a").livequery(function(){
		$(this).each(function(){
			var new2 = $(this).attr("href");
			if (!isURL(new2)) {
				new2 = new2.split(".htm",2);
				$(this).attr("href",orgurl[0]+"#"+new2[0]);
			}
		});
	});
	$(".seo").livequery(function(){
		$(this).each(function(){
			var new2 = $(this).attr("href");
			if (!isURL(new2)) {
				new2 = new2.split(".htm",2);
				$(this).attr("href",orgurl[0]+"#"+new2[0]);
			}
		});
	});
	$("#navi ul a").click(function(){
		var quelle = $(this).attr("href");
		if (!isURL(quelle)) {
			quelle = quelle.split("#",2);
			hash = "#"+quelle[1];
			processHash(hash);
		}
	});
	$("#subnav ul a").livequery("click", function(){
		var quelle = $(this).attr("href");
		if (!isURL(quelle)) {
			quelle = quelle.split("#",2);
			hash = "#"+quelle[1];
			processHash(hash);
		}
	});
	$(".seo").livequery("click", function(){
		var quelle = $(this).attr("href");
		if (!isURL(quelle)) {
			quelle = quelle.split("#",2);
			hash = "#"+quelle[1];
			processHash(hash);
		}
	});
});
