$(document).ready(function () {
    initTimebar();
    initGallery();

    $(window).load(function () {
        initSlideshow();
    });

    fixPng(); //script om png's te fixen voor IE6. gebruik is simpel, gewoon class "png" geven aan de tags die gefixed moeten worden
});

function initSlideshow() {
    $('#slideshow-image').slides({
        container: 'slides_container',
        paginationClass: 'slideshow-pagination',
        effect: 'fade',
        play: 10000,
        pause: 2500,
        animationStart: function () {
            initTimebar();
        }
    });
    $('#container-slideshow-block').bgslides({
        container: 'bg-container-slideshow',
        paginationClass: 'bgslideshow-pagination',
        effect: 'fade',
        play: 10000,
        pause: 2500,
        fadeEasing: 'easeInOutQuad',
        fadeSpeed: 500
    });
    $('.slideshow-pagination li a').click(function () {
        initTimebar();
    });
}

function initTimebar() {
    var totalLengthTime, totalLengthBar, ProgressBar;
    $('#slideshow-progress').stop().show();
    $('#slideshow-progress-current').stop().css({ width: 0 });
    totalLengthTime = 9900;
    totalLengthBar = $('#slideshow-progress').width();
    ProgressBar = 66;
    $('#slideshow-progress-current').animate({ width: totalLengthBar }, totalLengthTime);
}

function initGallery() {
    $('.img_color').hover(
        function () {
            $(this).stop().animate({ opacity: 1 }, 500);
        },
        function () {
            $(this).stop().animate({ opacity: 0 }, 500);
        }
    );
           
    $("a[rel^='ttc_gallery']").prettyPhoto({
        animationSpeed: 'fast',
        opacity: 0.85,
        showTitle: true,
        allowresize: true,
        counter_separator_label: ' / ',
        theme: 'tastetheconcept',
        social_tools: '',
        deeplinking: false,
        horizontal_padding: 0,
        markup: '<div class="pp_pic_holder"> \
                        <p class="pp_description"></p><a class="pp_close" href="#">Close project</a> \
						<div class="pp_content_container"> \
							<div class="pp_left"> \
							<div class="pp_right"> \
								<div class="pp_content"> \
									<div class="pp_loaderIcon"></div> \
									<div class="pp_fade"> \
										<a href="#" class="pp_expand" title="Expand the image">Expand</a> \
										<div class="pp_hoverContainer"> \
											<a class="pp_next" href="#">next</a> \
											<a class="pp_previous" href="#">previous</a> \
										</div> \
										<div id="pp_full_res"></div> \
									</div> \
								</div> \
							</div> \
							</div> \
						</div> \
                        <div class="ppt">&nbsp;</div> \
					</div> \
					<div class="pp_overlay"></div>'
    });
}

function fixPng() { /* ABSOLUUT ENKEL EN ALLEEN IN IE6 UITVOEREN, GEEFT ERROR IN IE7+ ! PLUS HET SCRIPT ZELF WORDT ENKEL IN IE6 GEINITIALISEERD ! */
    if ($.browser.msie) {
        if ($.browser.version < 7) {
            DD_belatedPNG.fix('.png');            
        }
    }
}
