$(document).ready(function() {
	
	$('li > a').hover(function() {
		$(this).parent().addClass('hover');
		return true;
	} ,function() {
    	$(this).parent().removeClass('hover');
    	return true;
    })
	
	$('li > * > a').hover(function() {
		$(this).parent().parent().addClass('hover');
		return true;
	} ,function() {
    	$(this).parent().parent().removeClass('hover');
    	return true;
    })
	
	// Empty text fields when the user focuses it
	$("input.text").focus(function () {
		if($(this).val() == this.defaultValue) $(this).val('');
    });
    // But fill it again if no input was made
	$("input.text").blur(function () {
        if($(this).val() == '') $(this).val(this.defaultValue);
    });
    // But empty them again if they are still having the default value on submit
	$("form").submit(function () {
        $(this).find("input.text").each(function () {
        	if($(this).val() == this.defaultValue) $(this).val('');
        });
    });
    
    $('a.backlink').click(function() {
    	history.back();
    	return false;
    })
    
    // Popboxes
    $(".popin").livequery('click',function() {
    	$(this).addClass("popout");
    	$(this).removeClass("popin");
    	popcut = $(this).parent().parent().parent().find('.popcut');
    	popcut.slideUp('slow');
    	popcut.addClass('hidden');
    	return false;
    });
    
    $(".popout").livequery('click',function() {
    	$(this).addClass("popin");
    	$(this).removeClass("popout");
    	popcut = $(this).parent().parent().parent().find('.popcut');
    	popcut.slideDown('slow');
    	popcut.removeClass('hidden');
    	return false;
    });
    
    $("#projectbutton").click(function() {
    	$('#startprojekte').removeClass('hidden');
    	return true;
    });
    
    $("#startprojekte").hover(function() {return true;} ,function() {
    	$(this).addClass('hidden');
    	return true;
    });
  

    $(".leistungen").click(function() {
   		$('#org').css('background',"transparent url('" + $(this).attr('href') + "') no-repeat center center");
    	$('#org').removeClass('hidden');
   		$('#lightbox').removeClass('hidden');
   		document.location.href='#';
    	return false;
    });
    

    $(".leistungen1").click(function() {
    	$('#org').removeClass('hidden');
   		$('#org').addClass('orgA');
   		$('#lightbox').removeClass('hidden');
    	return true;
    });

    $(".leistungen2").click(function() {
    	$('#org').removeClass('hidden');
   		$('#org').addClass('orgB');
   		$('#lightbox').removeClass('hidden');
    	return true;
    });
    

    $(".leistungen3").click(function() {
    	$('#org').removeClass('hidden');
   		$('#org').addClass('orgC');
   		$('#lightbox').removeClass('hidden');
    	return true;
    });
    

    $(".leistungen4").click(function() {
    	$('#org').removeClass('hidden');
   		$('#org').addClass('orgD');
   		$('#lightbox').removeClass('hidden');
    	return true;
    });
 
    
    $("#org").click(function() {
     	$(this).addClass('hidden');
     	$(this).removeClass('orgA');
     	$(this).removeClass('orgB');
     	$(this).removeClass('orgC');
     	$(this).removeClass('orgD');
   		$('#lightbox').addClass('hidden');
     	return false;
    });
        
    $(".zoom").hover(function() {
     	$(this).addClass('zoomed');
    	return false;
    } ,function() {
    	$(this).removeClass('zoomed');
    	return false;
    });
    
    // Postal code box
    $(".postal_code").click(function() {
    	var pc = $(".postal_codes");
    	if(pc.css("display") == "none")
    	{ 
    		$(".postal_codes").fadeIn();
    	}
    	else
    	{
    		$(".postal_codes").fadeOut();
    	}
		return false; 
    });
    
    $(".postal_codes").find("a").click(function() {
    	$(".postal_codes").fadeOut();
    	return true; // REUTAX Änderung von false auf true    		
    });
    
    // Tab navigation
    $("li.tab1 a").click(function() {
	    $(this).blur();
    	$("li.tab1").addClass('active');
    	$("li.tab2").removeClass('active');
    	$("div.tab1").removeClass('hidden');
    	$("div.tab2").addClass('hidden');
    	return false;
    });

    $("li.tab2 a").click(function() {
	    $(this).blur();
    	$("li.tab2").addClass('active');
    	$("li.tab1").removeClass('active');
    	$("div.tab2").removeClass('hidden');
    	$("div.tab1").addClass('hidden');
    	return false;
    });
/*
    $("span:last-child.datum").after('<span class="info">i</span>');
    $("span:last-child.ort").after('<span class="info">i</span>');
    
    $("span.info").hover(function () {
    	$(this).parent().addClass('info');
    }, function () {
    	$(this).parent().removeClass('info');
    });
*/
/*
    $(".tab.news a").click(function() {
    	$(this).blur();
    	$(".tabtop").css("background-position","0px 0px");
    	$(".section.news").show();
    	$(".section.jobtab").hide();
    	return false;
    });

    $(".tab.jobtab a").click(function() {
    	$(this).blur();
    	$(".tabtop").css("background-position","0px -39px");
    	$(".section.jobtab").show();
    	$(".section.news").hide();
    	return false;
    });*/
});

