jQuery(document).ready(function($)
{
    // Pipe-Zeichen aus den headers löschen und durch br-tag ersetzen
    $('h3 a, .product-name h2').each( function() {
        var oldString = jQuery(this).text();
        var newString = oldString.replace(/\|/,"<br />");

        $(this).html(newString);
    });
    
    // Menüpunkte auf eine Breite ziehen (nur nötig, damit das auch im IE7 funktioniert!!!)
    $('#nav ul').each(function(){
        var lastWidth = $(this).width();
        $(this).find('li').each(function(index, item) {
	       $(item).width(lastWidth);
	    });
	});
	
    // Schnellfinder auf Startseite als iframe-Popup
	$('.homepage-schnellfinder').colorbox({width: '836px', height: '550px', iframe: true });

    var colorboxOptions = {
        current: 'Bild {current} von {total}'
    }
    $('a.lightbox').filter('[rel=productsimages]').each(function()
    {
        $(this).colorbox($.extend(colorboxOptions, {
            href: $(this).attr('href') + ' .product-image-popup' // ajax req. to given url (href), extract container with given class from result (div with caption + image)
        }));
    })
    .end().not('[rel=productsimages]').colorbox(colorboxOptions);

    
	// Größe der Tags in Tagcloud
    var min = 10;
    var max = 21;
    tagCloudSizes(min, max);
	
	// Rechtsklick verhindern
	$('img').bind("contextmenu", function(event){
		event.preventDefault();
	});

    $('.anythingSlider').anythingSlider({
       easing: "swing",                // Anything other than "linear" or "swing" requires the easing plugin
       autoPlay: true,                 // This turns off the entire FUNCTIONALITY, not just if it starts running or not
       startStopped: false,            // If autoPlay is on, this can force it to start stopped
       delay: 5500,                    // How long between slide transitions in AutoPlay mode
       animationTime: 600,             // How long the slide transition takes
       hashTags: true,                 // Should links change the hashtag in the URL?
       buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
       pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
       startText: "Start",             // Start text
       stopText: "Stop",               // Stop text
       navigationFormatter: function(index, $panel)
       {
           var title = $panel.attr('title');
           return (title && title.length) ? title : index;
       }
    });
		
});

// Zufallsgröße für die Links in der TagCloud
function tagCloudSizes(min, max)
{
    jQuery('.small-box .tag-cloud a').each(function(index, item){
        var randomSize = min + parseInt(Math.random() * ( max-min+1 ));
        jQuery(item).css({'font-size':randomSize});
    });	
}

// für Button auf der Seite KFZ-Teile
function teilefinder() {
    window.open('http://www.easyparts.de/webshop_start.html?otherparams=p_werkstattnr=370','','');
}
