$(document).ready(function(){
	
	/*----------- Colorbox ------------*/
	$("a.colorbox").colorbox({
		transition:'fade', 
		returnFocus:true
	});
	
	$('#Projekte a').html('Referenzen <br />zum Stöbern');
	$('#NavigationReferenzen').append('<div class="botpag"></div><div class="botstoeb bot"><a href="#">Übersicht Stöbern</a></div><div class="botkunde bot"><a href="#">Übersicht Kunden</a></div>');
	
	if($("div.sended-card").length){
		$('#PageContent').addClass('opacity');
		$('#Navspecialinner').append('<div id="Closebutton"><a href="#"></a></div>');
		$('#PageContent').append('<div id="Close"></div>');
		
	}
	
	$('.opacity #Navspecial a').click(function() {
  		$('#Close, .opacity #Navspecial a').hide();
  		return false
	});
	
	$('.menuebottom.last').css('display', 'none');
	
	/*$('.menuebottom li').hover(
	function(){ //mouse over
		var $this=$(this);
		$this.stop().fadeTo("slow", 1);
	},
	function(){ //mouse out
		var $this=$(this);
		$this.stop().fadeTo("slow", 0.5);
	});
	*/
	//$('.listItem.kunde ul').wrap('<div class="sub" />');
	$('#NavigationReferenzen').prepend('<div class="projektfunktion"><div class="kunden">Kunde:</div><div class="kundenname"></div><div class="projekt">Projekt:</div><div class="text">Projektbeschreibung fehlt</div></div>');
	$('.listItem.kunde').click(function() {
  	
  		$(this).children().clone().wrap('<div class="sub" />').prependTo('.menuebottom.last .listmenue').wrap('<div class="remove" />');
  		$(this).clone().wrap('<div class="titelkunde" />').prependTo('.kundenname').wrap('<div class="remove" />');
  		$('.kundenname .sub').remove();
  		$('.listItem.kunde, .projektfunktion .projekt, .projektfunktion .text').hide();
  		$('.projektfunktion').show();
  		$(".remove .sub a").append('<span class="toolpro"></span>');
 		
 		$(".remove .sub a").hover(function() {
  		$this = $(this);
  		hoverText = $.data(this, 'title', $this.attr('title'));                             
  		$(this).find("span").animate({opacity: "show"}, "slow");
  		$(this).find("span").text(hoverText);       
	
  		$this.attr("title", "");       


			}, function() {             

  			$(this).find("span").animate({opacity: "hide"}, "fast");     
  			$(this).attr("title", hoverText);

		});
 		
	});
	
	
	
	
	$('#Projekte a').addClass('active');
	$('#Projekte a, .botstoeb a').click(function() {
  		$('#Projekte a').addClass('active');
  		$('#Kunden a').removeClass('active');
  		$('.menuebottom.first').show();
  		$('.menuebottom.last').hide();
  		return false
	});
	$('#Kunden a, .botkunde a').click(function() {
  		$('#Kunden a').addClass('active');
  		$('#Projekte a').removeClass('active');
  		$('.menuebottom.last').show();
  		$('.menuebottom.first').hide();
  		return false
	});

	$('.close, #Projekte a, #Kunden a, .botstoeb a, .botkunde a').click(function() {
  	
  		$('.remove').remove();
  		$('.listItem.kunde').show();
  		$('.projektfunktion').hide();
  		$('#firstk').addClass('active');
		$('#secondk').removeClass('active');
  		
	});
	
	
	if($('.menuebottom.last .active').length){
		//alert('der wird geladen!');
		$('#Projekte a').removeClass('active');
		$('#Kunden a').addClass('active');
		$('.menuebottom.last').show();
  		$('.menuebottom.first').hide();
  		$('.projektfunktion, .projektfunktion .projekt, .projektfunktion .text').show();
  		$('.listItem.kunde').hide();
  		$('.listItem.kunde.active').children().clone().wrap('<div class="sub" />').prependTo('.menuebottom.last .listmenue').wrap('<div class="remove" />');
  		$('.listItem.kunde.active').clone().wrap('<div class="titelkunde" />').prependTo('.kundenname').wrap('<div class="remove" />');
  		$('.kundenname .sub').remove();
  		$('.projektfunktion .text').html($('.remove .listItem.sub.active a:first').attr('title'));
	}
	
	
	

$(".menuebottom.first a").append('<span class="toolpro"></span>');
$(".listItem.sub a").append('<span class="toolpro"></span>');
	
	var hoverText = '';
	$(".menuebottom.first li a, .listItem.sub a").hover(function() {
  $this = $(this);
  hoverText = $.data(this, 'title', $this.attr('title'));                             
  $(this).find("span").animate({opacity: "show"}, "slow");
  $(this).find("span").text(hoverText);       

  $this.attr("title", "");       


}, function() {             

  $(this).find("span").animate({opacity: "hide"}, "fast");     
  $(this).attr("title", hoverText);

});





	


	
	//error meldung bei formhandler
	$('.errornote').css({
		'position'			: 'absolute', 
		'z-index'			: '10000'
		});
	$('.errornote').addClass('errornoteposition');	
	$('.closebutton').css('display', 'block');
	$('.errorhide').click(function() {
  		$('.errornote').hide('fast', function() {
  		});
	});

});


/*--------------------- E-Mail Programm -------------------------*/
function blurLink(theObject){if(msie4){theObject.blur();}}function decryptCharcode(n,start,end,offset){n=n+offset;if(offset>0&&n>end){n=start+(n-end-1);}else if(offset<0&&n<start){n=end-(start-n-1);}return String.fromCharCode(n);}function decryptString(enc,offset){var dec="";var len=enc.length;for(var i=0;i<len;i++){var n=enc.charCodeAt(i);if(n>=0x2B&&n<=0x3A){dec+=decryptCharcode(n,0x2B,0x3A,offset);}else if(n>=0x40&&n<=0x5A){dec+=decryptCharcode(n,0x40,0x5A,offset);}else if(n>=0x61&&n<=0x7A){dec+=decryptCharcode(n,0x61,0x7A,offset);}else{dec+=enc.charAt(i);}}return dec;}function linkTo_UnCryptMailto(s){location.href=decryptString(s,-5);}
