 // cufón 

Cufon.replace 
('h4')
('h6')
('ul#slider li a')
('blockquote')
; 
jQuery('h2').each(function(){
	if(jQuery(this).children('strong').length == 0){
		Cufon.replace(jQuery(this));
	};
});
 

function toggle(){
	if($(window).width() < 1024 && $('#image').css('opacity') == 1){
		$('#image').animate({opacity: 0},1000,'linear');
	}
	
	if($(window).width() > 1024 && $('#image').css('opacity') == 0){
		$('#image').animate({opacity:1},1000,'linear');
	}
}


// tooltip

(function($) {
	$.fn.easyTooltip = function(options){
		// default configuration properties
		var defaults = {	
			xOffset: -5,		
			yOffset: 37,
			tooltipId: "easyTooltip",
			clickRemove: false,
			content: "",
			useElement: ""
		}; 
			
		var options = $.extend(defaults, options);  
		var content;
				
		this.each(function() {  				
			var title = $(this).attr("title");
			$(this).hover(function(e){						 							   
				content = (options.content != "") ? options.content : title;
				content = (options.useElement != "") ? $("#" + options.useElement).html() : content;
				$(this).attr("title","");									  				
				if (content != "" && content != undefined){			
					$("body").append("<div id='"+ options.tooltipId +"'>"+ content +"</div>");
					$("#" + options.tooltipId)
						.css("position","absolute")
						.css("top",(e.pageY - options.yOffset) + "px")
						.css("left",(e.pageX + options.xOffset) + "px")				
						.css("display","none")
						.fadeIn("normal")
				}
			},
			function(){	
				$("#" + options.tooltipId).remove();
				$(this).attr("title",title);
			});	
			$(this).mousemove(function(e){
				$("#" + options.tooltipId)
					.css("top",(e.pageY - options.yOffset) + "px")
					.css("left",(e.pageX + options.xOffset) + "px")					
			});	
			if(options.clickRemove){
				$(this).mousedown(function(e){
					$("#" + options.tooltipId).remove();
					$(this).attr("title",title);
				});				
			}
		});
	};
})(jQuery);


// hover images

  $(".hover").fadeTo("slow", 1); // This sets the opacity of the thumbs to fade down to 30% when the page loads
						   $(".hover").hover(function(){
						   $(this).fadeTo("slow", 0.4); // This should set the opacity to 100% on hover
						   },function(){
						   $(this).fadeTo("slow", 1); // This should set the opacity back to 30% on mouseout
						   });


// flyout navi 


$(document).ready(
	function(){
		$('#reifen').hover(
 				function(){
						$(this).children('ul').css('display', 'block');
						$(this).children('ul').stop(true, true).animate({top: '100px',  height: '95px'}, 200)
				},
				function(){
					$(this).children('ul').stop(true, true).animate({top: '100px', left: '4px',  height: '0'}, 130, function(){$(this).css('display', 'none')})
				}
		)
	}
);


// mailmask

$.fn.noSpam = function() {
	at = '@';
	return this.each(function(){
		e = null;
		$(this).find('span').replaceWith(at);
		e = $(this).text();
		$(this).attr('href', 'mailto:' + e);
	});
};


// go to top

$.fn.topLink = function(settings) {
	settings = jQuery.extend({fadeSpeed: 200}, settings);
		var scroll_timer;
		var displayed = false;
		var $message = $(this);
		var $window = $(window);
		var top = $(document.body).children(0).position().top;
		$window.scroll(function () {
			window.clearTimeout(scroll_timer);
			scroll_timer = window.setTimeout(function () {
				if($window.scrollTop() <= top)
				{
					displayed = false;
					$message.fadeOut(settings.fadeSpeed);
				}
					else if(displayed == false) 
				{
					displayed = true;
					$message.stop(true, true).fadeIn(settings.fadeSpeed).click(function () { $message.fadeOut(settings.fadeSpeed); });
				}
			}, 100);
		});
};



 $(document).ready(function(){
	toggle();
	$(window).resize(function(){toggle();});
    
	$('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                $('html,body').animate({scrollTop: targetOffset}, 1000);
                return false;
            }
        }
    });

	
								
							
	$('a.escape').noSpam();
	$('.goToTop').topLink({fadeSpeed: 500});
	$('a#link0').easyTooltip({useElement: 'item0' });
	$('a#link1').easyTooltip({useElement: 'item1' });
	$('a#link2').easyTooltip({useElement: 'item2' });
	$('a#link3').easyTooltip({useElement: 'item3' });
	$('a#link4').easyTooltip({useElement: 'item4' });
	$('a#link5').easyTooltip({useElement: 'item5' });
	$('a#link6').easyTooltip({useElement: 'item6' });
	$('a#link7').easyTooltip({useElement: 'item7' });
	$('a#link8').easyTooltip({useElement: 'item8' });
	$('a#link9').easyTooltip({useElement: 'item9' });
	$('a#link10').easyTooltip({useElement: 'item10' });
	$('a#link11').easyTooltip({useElement: 'item11' });
	$('a#link12').easyTooltip({useElement: 'item12' });
	$('a#link13').easyTooltip({useElement: 'item13' });
	$('a#link14').easyTooltip({useElement: 'item14' });
	$('a#link15').easyTooltip({useElement: 'item15' });
	$('a#link16').easyTooltip({useElement: 'item16' });
	$('a#link17').easyTooltip({useElement: 'item17' });
	$('a#link18').easyTooltip({useElement: 'item18' });
	$('a#link19').easyTooltip({useElement: 'item19' });
	$('a#link20').easyTooltip({useElement: 'item20' });
	$('a#link21').easyTooltip({useElement: 'item21' });
	$('a#link22').easyTooltip({useElement: 'item22' });
	$('a#link23').easyTooltip({useElement: 'item23' });
	$('a#link24').easyTooltip({useElement: 'item24' });
	$('a#link25').easyTooltip({useElement: 'item25' });
	$('a#link26').easyTooltip({useElement: 'item26' });
	$('a#link27').easyTooltip({useElement: 'item27' });
	$('#slider').cycle({fx: 'fade',speed: 500, timeout: 0, 	next: '#featuredBtnNext', prev:   '#featuredBtnPrev', pause:   1 });
	$('#sliderFelgen').cycle({fx: 'fade',speed: 500, timeout: 0, 	next: '#featuredBtnNext', prev:   '#featuredBtnPrev', pause:   1 });
	$('#sliderIndex').cycle({fx: 'slideX', speed: 900});
	$("a[rel='lightbox']").colorbox({maxHeight:"90%"});
 });
 
