function scaleCenterImage(slide_image, div_in) 
{
	var widthScale = div_in.width() / slide_image.width();
	var heightScale = sliderHeight / slide_image.height();
	
	if (heightScale < widthScale)
	{
		slide_image.height(div_in.height() + 'px');
		var padding = ((div_in.width() - slide_image.width()) / 2) + 'px';
		slide_image.css("padding-left", padding);
		slide_image.css("padding-right", padding);
	}
	else if (widthScale < heightScale)
	{
		slide_image.width(div_in.width() + 'px');
		var padding = ((div_in.height() - slide_image.height()) / 2) + 'px';
		slide_image.css("padding-top", padding);
		slide_image.css("padding-bottom", padding);
	}
	else
	{
		slide_image.width("100%");
		slide_image.height("100%");
	}
}
function slideSwitch() {
	var slider = $('#slideshow');
    var sliderActive = $('#slideshow div.active');
 
    if (  sliderActive.length == 0 )  sliderActive = $('#slideshow div:last');
 
    var sliderNext =   sliderActive.next().length ?  sliderActive.next()
        : $('#slideshow div:first');

    sliderActive.addClass('last-active');
	$("#slider_content").html(sliderNext.find("img").attr("rel"));
    sliderNext.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            sliderActive.removeClass('active last-active');
        });
}
$(window).load(function(){
	$("#slideshow").css("display", "block");
	$("#slideshow_container #slideshow a img").each(function(index) {
			if (sliderStyle == 1)
				scaleCenterImage($(this), $("#slideshow_container"));
			else if (sliderStyle == 2)
			{
				$(this).width("100%");
				$(this).height("100%");
			}
		});
	$("#slider_content").html($('#slideshow div.active').find("img").attr("rel"));
    setInterval( "slideSwitch()", 6000 );
});

