jQuery(document).ready(function() {  

	// Leiste oben und unten  ausblenden
	//jQuery("#metaTop").animate({top: "-100"}, 0 );	
	//jQuery("#bottomBar").animate({ bottom: "-100"}, 0 );
	

	// Startseite Portfolio Arbeiten leicht drehen.
    var maximal = 3;
    var minimal = -3;

    for( var i=0; i<=jQuery("#portfolioLatest li").size(); i++ )
    {

      var random = 'rotate('+Math.floor(Math.random() * (maximal-minimal) + minimal)+'deg)';
      //alert(random);

      jQuery( '#portfolioLatest li:nth-child('+i+') img' ).css({
          '-moz-transform': random,
          '-webkit-transform': random,
          'transform': random
      }).parent().attr( 'randomtransform', random ).hover(
        function(){
          jQuery( this ).find('img').css({
              '-moz-transform':'rotate(0deg)',
              '-webkit-transform':'rotate(0deg)',
              'transform':'rotate(0deg)'
          });
        },
        function(){
          jQuery( this ).find('img').css({
              '-moz-transform': jQuery( this ).attr( 'randomtransform' ),
              '-webkit-transform': jQuery( this ).attr( 'randomtransform' ),
              'transform': jQuery( this ).attr( 'randomtransform' )
          });
        }
      );
    }
        
/* ================================================================================
   
   Tooltip
   
================================================================================ */


    jQuery('a.tooltip').append('<div id="tooltip"></div>');

	jQuery('a.tooltip').hover(function() {
		jQuery(this).find("#tooltip").stop(true,true).animate({
			opacity: "show",
			top: "55"
		}, 0);
		var hoverText = jQuery(this).attr("title");
	    jQuery(this).find("#tooltip").text(hoverText);
	}, function() {
		jQuery(this).find("#tooltip").animate({
			opacity: "hide", 
			top: "30"
		}, 300);
	});
    
/* ================================================================================
      
   Top Button Transparenz
      
================================================================================ */
   
      
	jQuery(function() {
		jQuery('.topButton').hover(function(){
			jQuery(this).animate({top:'0px', opacity: 0.9},{queue:false,duration:250});
		}, function(){
			jQuery(this).animate({top:'11px', opacity: 1.0},{queue:false,duration:1000});
		});
	});


/* ================================================================================
   
   Leiste oben und unten Tranparent machen
   
================================================================================ */


	jQuery("#metaTop").animate({ opacity: 0.9 }, 750 );
	
	
	
/* ================================================================================
     
   Scroll Top -100px
     
================================================================================ */
  
    
   jQuery('#wrapper a[href^=#]').bind("click", function(event) {
        event.preventDefault();
        var ziel = jQuery(this).attr("href");

        jQuery('html,body').animate({
                scrollTop: jQuery(ziel).offset().top -100
        }, 1000);
        return false;
    });
    

/* ================================================================================
      
   Scroll Top      
      
================================================================================ */
   
      
    jQuery('a[href^=#top]').bind("click", function(event) {
        event.preventDefault();
        var ziel = jQuery(this).attr("href");

        jQuery('html,body').animate({
                scrollTop: jQuery(ziel).offset().top
        }, 1000);
        return false;
    });
	
/* !portfolio preview ================================================== */

	jQuery(".portfolio-preview li span").fadeTo("fast", 0.0);

	jQuery(".portfolio-preview li a").hover(function(){
		jQuery(this).next("span").fadeTo("fast", 1.0);
	},function(){
		jQuery(this).next("span").fadeTo("slow", 0.0);
	});

/* !functionsBar ================================================== */

if (jQuery.cookie('balkensichtbar') == null)
	var balkensichtbar = "ja";
else
	var balkensichtbar = jQuery.cookie('balkensichtbar');

if (balkensichtbar == 'nein'){
	jQuery('#functionsBar').animate({ opacity:0.6, bottom: "-32"}, 1000);
	jQuery('#functionsBar a.hide').text("open");
} else if (balkensichtbar == 'ja'){
	jQuery('#functionsBar').animate({ opacity:0.9, bottom: "0"}, 400);
};     

jQuery('#functionsBar a.hide').click(function(){
	if (balkensichtbar == 'ja'){
		jQuery('#functionsBar').animate({ opacity:0.6, bottom: "-32"}, 1000);
		jQuery(this).text("open");
		balkensichtbar = "nein";
		jQuery.cookie('balkensichtbar', 'nein', { expires: 2 });       
	} else if (balkensichtbar == 'nein'){
		jQuery('#functionsBar').animate({ opacity:0.9, bottom: "0"}, 400);
		jQuery(this).text("close");
		balkensichtbar = "ja";
		jQuery.cookie('balkensichtbar', null);
	}; 
	return false; 
});    


        
});


