
function hoverIn()
{

    $(this).find('ul').css({'display' : 'block'});
    $(this).addClass('hover');
}

function hoverOut()
{
    $(this).find('ul').css({'display' : 'none'});
    $(this).removeClass('hover');
}

// JavaScript Document

$(document).ready(function()
{		
	/* actions */
	
    $("a.youtube").click(function(){
    
        $.fancybox({
                  'type' : 'iframe',
                    // hide the related video suggestions and autoplay the video
                    'href' : this.href.replace(new RegExp('watch\\?v=', 'i'), 'embed/') + '?rel=0&autoplay=1',
                    'overlayShow' : true,
                    'centerOnScroll' : true,
                    'speedIn' : 100,
                    'speedOut' : 50,
                    'width' : 640,
                    'height' : 480

                  });
                  return false;
    });
    
	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 = "#aa3377";
	
	$(".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;							   
	});
	
    $('#slider').after('<div id="nav" class="nav">').cycle({
        fx: 'fade',
        speed: 1000,
        timeout: 7000,
        pager: '#nav'
    });
    
    var config = {    
     over: hoverIn, // function = onMouseOver callback (REQUIRED)    
     timeout: 250, // number = milliseconds delay before onMouseOut    
     out: hoverOut // function = onMouseOut callback (REQUIRED)    
    };
    
    $('.has_sub').hoverIntent(config);
    
    
    $(' .menu_container li:nth-child(4) .flyout').css({'left' : '14.25em', 'max-height' : '425px', 'width' : '400px', 'background' : '#9c9e9f'});
    $('.menu_container li:nth-child(4) .flyout li.submenu').css({'clear' : 'none'});        
     
    
    
    
});
