// JavaScript Document

$(document).ready(function(){
			   
	var ref_images = new Array();
	var ref_counter = 0;
    
    $(".fancy").fancybox({
				'width'				: '50%',
				'height'			: '50%',
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'

    });
    
	$(".header .changer_thumb .image_box").each(function(i){
		$(this).css({zIndex: 0});
		ref_images[ref_counter] = $(this);
		ref_counter = ref_counter + 1;
	});
    
	$(".header .changer_thumb").click(function(){
		$(".header .changer_thumb .image_box").not($(this)).css({zIndex:0});
		$(this).find(".image_box").css({zIndex: 10});
		$(this).css({borderColor: "#808080"});
	}, function() {
		$(this).css({backgroundColor: ""});
		//$(this).find(".image_box").css({zIndex: 0});
	});	

	/* actions */
	
	var mailformplus = $("#kontaktformular").validate({
		rules: {
			Vorname: "required",
			Nachname: "required",
			"E-Mail-Adresse": "required email",
			Nachricht: "required",
			"Telefon-Nr": "number"
		},
		messages: {
			Vorname: "Bitte geben Sie Ihren Vornamen ein.",
			Nachname: "Bitte geben Sie Ihren Nachnamen ein.",
			"E-Mail-Adresse": {
				required: "Bitte geben Sie Ihre E-Mail-Adresse ein.",
				email: "Ihre Eingabe muss vom Format name@meinedomain.de sein."
			},
			Nachricht: "Bitte geben Sie eine Nachricht ein.",
			"Telefon-Nr": {
				number: "Sie d&uuml;rfen nur Zahlen eingeben."	
			}
		},
		//errorLabelContainer: "#messageBox",
		//wrapper: "li",
		errorPlacement: function(error, element) {
     		error.appendTo(element.parent("td").find(".messageBox"));
		},
		errorClass: "invalid"
	});
	
	var oldColor = "#9c9d9d";
	var highlightColor = "#3A2D27";
	
	$(".contact_text, .contact_textarea").focus(function(){
		$(this).css({borderColor: highlightColor});													 
	});
	
	$(".contact_text, .contact_textarea").blur(function(){
		$(this).css({borderColor: oldColor});													
	});
	
	$(".printlink").click(function(){
		var target = $(this).attr("href");
		var myWindow = window.open(target, "Druckversion", "width=600, height=400, scrollbars=yes");
			
		return false;							   
	});
    
    $(".ausklappen_link").click(function(){
        $(this).parent().find('.expandable').animate({'height' : 'toggle'});
    });

});
