// Funktionssammlung
// sprite funktion mit active-state
$(function(){
  if ($.browser.msie && $.browser.version < 7) return;
  $('#mainnav li')
      .removeClass('highlight')
      .find('a')
      .append('<span class="hover" />').each(function () {
         var $span = $('> span.hover', this).css('opacity', 0);
         
      // aktive URL auslesen und aufsplitten
		  var path = window.location.toString().split("/");
		  var home = "/";
	  	var url = "/" + path[3] + "/";	 
		  	    
    	// element mit ausgelesener URL finden und manipulieren *hex hex*
		  $("#mainnav li a[href='" + [url || home] + "']").children("span").each(function() {   
		     	$(this).css('opacity', 1);
		     	$(this).parent().addClass("selected");
		  })
  	
  			// HAX um das aktive element nicht zu Šndern.
  			if($(this).hasClass("selected")) { } else {
          $(this).hover(function () {
              // on hover
              $span.stop().fadeTo(500, 1);
          }, function () {
              // off hover
              $span.stop().fadeTo(500, 0);
          });
          }
      });
});


$(function(){
	$(".anfahrt-open")
	.click(function(){
		$('#anfahrt').animate({opacity: "show", top: "175"}, "slow");
		}
	)	

	$(".anfahrt-close")
	.click(function(){
		$('#anfahrt').animate({opacity: "hide", top: "475"}, "slow");
		}
	)	

});




// referenzen title
$(function(){
	$("ul.refImage li").hover(
	function(){
		$(this).children().stop().animate({ opacity: 1 },600);
	},
	function(){
		$(this).children().stop().animate({ opacity: 0.6 },400);
	}
	)
});

// external links
$(function() {
	$(".weblink a").attr("target","_blank").attr("rel","bookmark");
	$(".external").attr("target","_blank").attr("rel","bookmark");
});


// input blur 		(c) Daniel Sokoll
function setfocus(obj)
{
  if(!obj.origsearchphrase)
  {
    obj.origsearchphrase = obj.value;
  }
  if(obj.value == obj.origsearchphrase)
  {
    obj.value = '';
  }
}

function leavefocus(obj)
{
  if(obj.value == '')
  {
    obj.value = obj.origsearchphrase;
  }
}

var cheatcode = "";

function checkCode(){
	if (cheatcode == "login"){
		window.location.href = '/wp-admin/';
	}else{

	}
	cheatcode = "";
}

$(document).bind('keydown', 'l', function (evt){cheatcode = cheatcode + "l";});
$(document).bind('keydown', 'o', function (evt){cheatcode = cheatcode + "o";});
$(document).bind('keydown', 'g', function (evt){cheatcode = cheatcode + "g";});
$(document).bind('keydown', 'i', function (evt){cheatcode = cheatcode + "i";});
$(document).bind('keydown', 'n', function (evt){cheatcode = cheatcode + "n";});
$(document).bind('keydown', 'return', function (evt){checkCode();});