function initSlideShow(wpr, photos, height) {

    if (!wpr.hasClass('image-icon')) height += 20;

	// create slideshow
	var slideshow = new Slideshow(wpr, photos, {
		loader: false,
		center: false,
		height: height,
		delay: 3000,
		resize: false,
		duration: 1000
	});
}

window.addEvent('domready', function() {

	var body = $(document.body);
	var screenHeight = $(document.body).getSize().y;
	var paddingTop = 150;

	if (screenHeight < 650) {
		body.addClass('small-screen');
		paddingTop = 76;
	}

	// cufon replacement
	Cufon.replace('h1');
	Cufon.replace('#sidebar-left .module-v2 h2');
	Cufon.replace('#mainmenu ul li a', {
		hover: true
	});
	Cufon.replace('.poll-button-bad-small');
	Cufon.replace('.poll-button-good-small');

	// set tooltips on icons
	var iconTips = new Tips('#icon-menu a', {
		title: 'text',
		text: ''
	});

	// create plug animation sidebar menu
	var plug     = body.getElement('.plug');
	var iconMenu = $('icon-menu');

	if (plug && iconMenu) {
		plug.heightFx = new Fx.Tween(plug, {
			duration: 750,
			transition: Fx.Transitions.linear.easeIn
		});

		var currentIcon = iconMenu.getElement('li.current a');
		var icons       = iconMenu.getElements('a');

		plug.heightFx.set('height', 500);

		if (currentIcon) {
			currentIcon.yPos = currentIcon.getPosition().y;
			plug.heightFx.start('height', currentIcon.yPos - paddingTop);
		} else {
			plug.heightFx.start('height', 90);
		}

		icons.each(function(icon) {
			icon.addEvent('mouseover', function(e) {
				plug.heightFx.pause();
				var yPos = this.getPosition().y;
				plug.heightFx.start('height', yPos - paddingTop);
			});

			icon.addEvent('mouseout', function(e) {
				plug.heightFx.pause();
				if (currentIcon && currentIcon.yPos) {
					plug.heightFx.start('height', currentIcon.yPos - paddingTop);
				} else {
					plug.heightFx.set('tween', { duration: 6000 });
					plug.heightFx.start('height', 90);
				}
			});
		});
	}

	// init slideshow
	var wprSlideshow = $('sidebar-left').getElement('div.image-icon') ? $('sidebar-left').getElement('div.image-icon') : $('sidebar-left').getElement('div.slideshow');

	if (wprSlideshow) {
        var imagePaths = wprSlideshow.getElements('img').getProperty('src');

        if (imagePaths.length > 1) {
            var imageHeight = wprSlideshow.getElements('img').getProperty('height').max();
            wprSlideshow.empty();
            initSlideShow(wprSlideshow, imagePaths, imageHeight);
	    }
	}
});
