Cufon.replace('#naviMain a, #footerNavi a', {hover : '#232323'} , { fontFamily: 'Titillium' });
Cufon.replace('h1, h2, h3, #footerNavi, .back a, .label', { fontFamily: 'Titillium' });

function slider_init(id, control, list, height, interval, duration, max) 
{
	max = max-1;
	if(!interval) 
	{
		interval = false;
	}
	$('#' + control + ' li:first-child a').addClass('select');
	$('#' + list).css( {height: $('#' + list + ' li').length * height + 'px' } )
	$('#' + id).serialScroll({
		lock: true,
		cycle: false,
		jump: true,
		items: 'li',
		duration:duration,
		force:true,
		stop:true,
		constant:false,
		interval: interval,
		axis:'y',
		onBefore: function(e, elem, $pane, $items, pos) 
		{
			$('#' + control + ' a.select').removeClass('select');
			$('#' + control + ' a#slide_' + pos + '').addClass('select');
			if($('#' + control + ' a.slide.select').length == 0) {
				$('#' + control + ' a#slide_' + 0 + '').addClass('select');
			}
			$('#featureSliderBtn').css('display','block');
			if(pos==0) { $('#prevBtn').hide(); } else { $('#prevBtn').show(); }
			if(pos==max) { $('#nextBtn').hide(); } else { $('#nextBtn').show(); }
			
		}
	});
}

function slider_goto(slide, id, control) {
	$('#' + id).trigger('goto', [ slide ] );
	if(slide==0) {
		$('#prevBtn').hide();
	}
	else {
		$('#prevBtn').show();
	}
}

function slider_back(id, control) {
	$('#' + id).trigger('prev');
	$('#' + id).trigger('start');
	
}

function slider_next(id, control) {
	$('#' + id).trigger('next');
	$('#' + id).trigger('start');
}

(function ($) {

    $.fn.tooltip = function (opts) {
        $(this).each(function (index, el) {
            var self = this;
            this.element = $(el);
            this.options = jQuery.extend({
                'pattern': '',
                'speed': 500,
                'delay': 500,
                'offsetX': function (obj) {
                    return obj.tooltip.width();
                },
                'offsetY': function (obj) {
                    return obj.tooltip.height();
                }
            }, opts || {});
            this.tooltip = $(this.options.pattern.replace(/\%s/g, this.element.attr('title'))).appendTo($('body'));
            this.element.data('title', this.element.attr('title'));
            this.element.removeAttr('title');
            this.element.mouseenter(function (ev) {
                ev.preventDefault();
                self.tooltip.delay(self.options.delay).fadeIn(self.options.speed);
                $('body').mousemove(function (ev) {
                    self.tooltip.css({
                        'left': ev.pageX - self.options.offsetX(self),
                        'top': ev.pageY - self.options.offsetY(self)
                    });
                });
            });
            this.element.mouseleave(function (ev) {
                ev.preventDefault();
                if (self.tooltip.is(':visible') || self.tooltip.is(':animated')) self.tooltip.stop(true, true).fadeOut(self.options.speed);
                else self.tooltip.stop(true, true);
                $('body').unbind('mousemove');
            });
            var destrFns = this.element.data('destroy') ? this.element.data('destroy') : [];
            if (destrFns[destrFns.length] = function () {
                self.tooltip.fadeOut(self.options.speed);
            }) this.element.data('destroy', destrFns);
        });
        return this;
    }
    $.fn.destroy = function () {
        $(this).each(function (index, el) {
            if ($(el).data('destroy')) for (i = 0; i < $(el).data('destroy').length; ++i) $(el).data('destroy')[i]();
        });
        return this;
    }


})(jQuery);





$(document).ready(function() {
	
	// startseite
	$('.startseite .teaser img.hover').css('display', 'none').css('top', '-170px');
	$('.startseite .teaser').hover(
		function() {
			$(this).find('img.hover').fadeTo(200,1);
		},
		function() {
			$(this).find('img.hover').fadeTo(200,0);
		}
	)
	
	// expertise
	$('.expertise .teaser img.hover').css('top', '-170px');
	$('.expertise .teaser').hover(
		function() {
			$(this).find('img.hover').fadeTo(200,0);
		},
		function() {
			$(this).find('img.hover').fadeTo(200,1);
		}
	)
		
	
	// neues
	$('.neues .teaser img.hover').css('top', '-170px');
	$('.neues .teaser').hover(
		function() {
			$(this).find('img.hover').fadeTo(200,0);
		},
		function() {
			$(this).find('img.hover').fadeTo(200,1);
		}
	)
	
	// kreation
	$('.kreation .teaser img.hover').css('top', '-170px');
	$('.kreation .teaser').hover(
		function() {
			$(this).find('img.hover').fadeTo(200,0);
		},
		function() {
			$(this).find('img.hover').fadeTo(200,1);
		}
	)
	
	//extLink 
	$('.extLink').click(function() {
		window.open($(this).attr('href'));
		return false;
	})
	
	// #featureSliderControl vertical zentrieren
	var height = $('#featureSliderControl').height()/2;
	height = 177-height;
	$('#featureSliderControl').css('top', height);
	
	//tooltip
	$('.newsNavi a').tooltip({
        'pattern': '<div class="tooltip-news"><div>%s</div></div>',
        'speed': 100,
        'delay': 100,
        'offsetX': function(obj) { return 28; },
        'offsetY': function(obj) { return obj.tooltip.height() + 5; }
    });
	
	$('.kreationNavi a').tooltip({
        'pattern': '<div class="tooltip-kreation"><div class="right"><div>%s</div></div></div>',
        'speed': 100,
        'delay': 100,
        'offsetX': function(obj) { return 28; },
        'offsetY': function(obj) { return obj.tooltip.height() + 5; }
    });

	
})
