/* Navigation */
$(document).ready(function(){
$(".page_item").mouseenter(function() {
    var className = $(this).attr("class");
    if(className.indexOf("current") == -1) {
      $(this).animate({"top": "-=5px"}, 50);
    }
});
$(".page_item").mouseleave(function() {
    var className = $(this).attr("class");
    if(className.indexOf("current") == -1) {
        $(this).animate({"top": "+=5px"}, 100);
    }
});
});


/* Klassen oberhalb in der Navigation einfügen */
$(document).ready(function(){
$('#pages-3 ul li a').each(function(index) {
    $(this).attr('class','square-blue');
    // Titel bestimmen
    var title = $(this).html();
    // Inneres setzen
    $(this).html('<span class="square-shade">&nbsp;</span><span class="square-inner">'+title+'</span>');
    // Sichtbar machen
    $(this).css('visibility','visible');
});
});


// Fokus im Kontaktformular
$(document).ready(function(){
if($('.your-name')) {
    $('.your-name input').focus();
}
});



/* Referenzen */
var positions = new Array();
$(document).ready(function(){
	var totHeight=0;

	$('#slides .slide').each(function(i){
		/* Loop through all the slides and store their accumulative widths in totWidth */
		positions[i]= totHeight;
		totHeight += $(this).height();
		if(!$(this).height())
		{
			alert("Please, fill in width & height for all your images!");
			return false;
		}
	});

	$('#slides').height(totHeight);


    // Bei Klick scrollen
	$('#menu ul li a').click(function(e){
        clearInterval ( aScroll );
        scrollTo( $(this) );
        return false;
	});

	$('#menu ul li.menuItem:first').addClass('act').siblings().addClass('inact');
	/* On page load, mark the first thumbnail as active */
    
    
    
    
    /* Am Anfang automatisch durchscrollen */
    aScroll = setInterval ( "autoScroll()", 3500 );   
});
function autoScroll() {

    if( $('#menu ul li.act').next('.inact').length > 0 ) {
        scrollTo( $('#menu ul li.act').next('.inact').children('a') );
    }
    else {
        scrollTo( $('#menu ul li:first-child a') );
    }


}
function scrollTo(t) {
        
		/* On a thumbnail click */
		$('li.menuItem.act').removeClass('act').addClass('inact');
		t.parent().addClass('act');
		t.parent().removeClass('inact');

		var pos = t.parent().prevAll('.menuItem').length;

		$('#slides').stop().animate({marginTop:-positions[pos]+'px'},500);
		/* Start the sliding animation */
        
}
