$(document).ready(function(){

    Cufon.replace('h1 a', {  color: '-linear-gradient(#fbfbfb, #aaa)' });
    Cufon.replace('.text-willkommen h2', { color: '-linear-gradient(#fbfbfb, #d4d4d4)', textShadow: '#222 0px 1px'});
    Cufon.replace('ul.boxes li a');
    Cufon.replace('h3', { fontFamily: 'hvlt25' });
    Cufon.replace('h4', { fontFamily: 'hvlt25' });
    Cufon.replace('h5', { fontFamily: 'hvlt25' });
    Cufon.replace('h6', { fontFamily: 'hvlt25' });
    Cufon.replace('.sitename a', { hover: true, fontFamily: 'hvlt25' });
    Cufon.replace('.nav1 ul li a', { color: '-linear-gradient(#fbfbfb, #aaa)',  hover: true, hoverables: { color: '#fff' } });
    Cufon.replace('.nav1 ul li.active-trail a', { color: '#fff' });
    Cufon.replace('.cf_repl', { fontFamily: 'hvlt25' });
    Cufon.replace('.contactpre', { fontFamily: 'hvlt25' });	
    
    
    /* startseite recent */
    $('ul.blocks li.block a').each(function(){
        $(this).mouseover(function(event){
            if($(this).attr('href') != 'kunden'){
                $('.newBlock-1').hide();
                $('.newBlock-2').hide();
                $('.newBlock-3').hide();
                if($(this).attr('href') == 'blog') $('.newBlock-1').show();
                if($(this).attr('href') == 'bilderbuch') $('.newBlock-2').show();
            }
        });
    });
    
    
    $('.customerlist ul li .customerinfo').hide();    
    $('.customerlist ul li').mouseover(function(event){
         $(this).find(".customerinfo").slideDown(200);
    });
    $('.customerlist ul li').mouseleave(function(event){
         $(this).find(".customerinfo").slideUp(200);
    }); 
    
    /* Blog img-Title als caption */
    $('.blog_image img').each(function(){
        $(this).after('<div class="caption" style="width:'+$(this).attr('width')+'px"><span>'+$(this).attr('title')+'</span></div>');    
    });
    
    /* Blog short */
    $('.view-content .blog_body').hide();
    $('.view-content .blog_short').show();
    $('.view-content .blog_short').append('<a class="blog_more_link" >mehr...</a>');
    $('.view-content .blog_short a.blog_more_link').click(function(){
        $(this).parent().hide().next('.blog_body').show();
    })
    
    /* Blog Links stylen */
    $('a').each(function(){
        if($(this).attr('href') && ($(this).attr('href').substring(0,7) == "http://" || $(this).attr('href').substring(0,8) == "https://") && $(this).attr('target')== '' ){
            if($(this).find("img").length < 1){
                $(this).attr('target','_blank');
            }else{
                $(this).addClass("imglink");
            }
        }    
    });

    function formatTitle(title, currentArray, currentIndex, currentOpts) {
        title = title.split(" +++ ");
        return '<div><strong style="display:block;">'+title[0]+'</strong>'+title[1]+'</div>';
    }    
    $("a.pb_alt_gal_link").fancybox({
		'overlayOpacity':	0.8,
		'overlayColor'  :	'#222',
		'titleShow'     :   true,
		'titlePosition' :   'inside',
		'titleFormat'		: formatTitle,
		'changeFade'    :   0,
		'cyclic'        :   true,
		'padding'       :   10
    });
    
    $(".bilderbuch .pb_alt_gal_link img").insetBorder({
        inset           : 5
    });
    
    $('.picturebook').pb_galery({
        duration: 600,
        height: '560px' 
    });
    $('#bilderbuch_help').show();
         
});
