$(document).ready(function(){

    //reset slideshow size on window resize
    $('#slideshow').shuffle();

	var resizeTimer = null;
	$(window).wresize(setSlideshowSize);

    setSlideshowSize();

	$('#slideshow').cycle({
	    fx:           'fade', // one of: fade, shuffle, zoom, scrollLeft, etc
	    timeout:       7000,  // milliseconds between slide transitions (0 to disable auto advance)
	    continuous:    null,     // true to start next transition immediately after current one completes
		speed:         2000  // speed of the transition (any valid fx speed value)
	});

//
//	$("#tv").mouseenter(function() {
//        $("#intro").hide(200);
//	}).mouseleave(function() {
//        $("#intro").show(200);
//	});
//

    function setSlideshowSize()
	{
        // maximum width
		var max_width = 600; // to calculate max_height
        var asp_ratio = 0.658; // aspect ratio
        var max_height = parseInt(max_width * asp_ratio);

		// get current content container width
		var cont_width = $("#content").width();

		var new_width = cont_width;
		var new_height = parseInt(new_width * asp_ratio);


		var img_height = new_height;
		new_height = (new_height > max_height) ? max_height : new_height;

		// adjust info text sizes
		var font_size		= parseInt(new_height * 0.055);
		var margin_top		= parseInt(font_size * 1.75);

		$("#intro li")
			.css("margin-top",margin_top)
            .animate({
		        opacity: 0.6
		      }, 0 );


		$("#intro li")
			.css("font-size",font_size);

         $("#intro li span")
		 	.each(function (i) {
		        var this_width = $(this).width();
                $(this).parent().width(this_width);
		      });

		/*$("h3").text(new_width+":"+new_height);  */
		$("#slideshow img, #slideshow")
			.width(cont_width)
			.height(new_height);

		$("#tv")
			.width(cont_width)
			.height(max_height);


	}


});