$(document).ready(function() {
$(".picturelink a").attr("rel", "cslide");


	  if($("[rel='csingle'], [rel='cfade'], [rel='cslide'], .tp_editlink, .cbsection, .cboxelement, .cboxOnLoad, .colorbox, .youtube, .iframe, #inline").length)
            {
                
                $.include(
                {
                '/modules/colorbox/1/colorbox.css':null,
                '/modules/colorbox/jquery.colorbox-min.js':function(){

  var $gallery, previous, next;

        next = $.fn.colorbox.next;

        $.fn.colorbox.next = function(){
                if($gallery.index(previous) == ($gallery.length - 1)){
                        $.fn.colorbox.close();
                } else {
                        next();
                }
        };


                $gallery = $("a[rel='cslide']");

                $gallery.colorbox({onComplete: function(){
                        previous = this;
                }, onOpen: function(){
                        previous = this;
                }});

                    $(".colorbox").colorbox({
                                                loop:false,
                                                maxWidth:"90%",
                                                maxHeight:"90%",
                                                opacity: "0.7",
                                                current: "Bild {current} von {total}"
                                                });
                    $("a[rel='csingle']").colorbox({
						loop:false,
                                                opacity: "0.7",
                                                maxWidth:"90%",
                                                maxHeight:"90%",
						current: "Bild {current} von {total}"
                                               });

                    $("a[rel='csingle2']").colorbox({
						loop:false,
                                                opacity: "0.7",
                                                maxWidth:"90%",
                                                maxHeight:"90%",
						current: "Bild {current} von {total}"
                                               });

                    $("a[rel='cfade']").colorbox({
                                                 loop:false,
                                                 transition:"fade",
                                                 opacity: "0.7",
                                                 maxWidth:"90%",
                                                 maxHeight:"90%",
						 current: "Bild {current} von {total}",
                                                 speed: 800
                                                });
                    $("a[rel='cslide']").colorbox({
                                                 slideshow:true,
                                                 loop:true,
                                                 slideshowSpeed:6000,
                                                 slideshowAuto:true,
                                                 transition:"elastic",
                                                 speed:500,
                                                 opacity: "0.7",
                                                 maxWidth:"90%",
                                                 maxHeight:"90%",
                                                 previous:"zur&uuml;ck",
                                                 next:"vor",
                                                 close:"schlie&szlig;en",
                                                 current: "Bild {current} von {total}",
                                                 slideshowStart: "Diashow starten",
                                                 slideshowStop: "Diashow anhalten"                                                                                              
                                               });
		
                    $(".youtube").colorbox({
                                                loop:false,
                                                iframe:true,
                                                width:650,
                                                height:550
                                                });
                    $(".iframe").colorbox({
                                                loop:false,
                                                width:"90%",
                                                height:"90%",
                                                iframe:true
                                                });
                    $(".tp_editlink").colorbox({
                                                loop:false,
                                                width:"90%",
                                                height:"90%",
                                                iframe:true
                                                });
}
});
}
});

