

$(window).bind("resize", function() {
	resizeImage();
});

function resizeImage() {




	var h = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
	var w = (typeof window.innerWidth != 'undefined' ? window.innerWidth : document.body.offsetWidth);


/*

$('ul#animated-panorama').animatedinnerfade({ 
            speed: 2000, 
            //timeout:  5000, 
            type: 'sequence', 
            containerheight: h, 
            containerwidth: w, 
            animationSpeed: 0, 
            animationtype: 'fade',
	   // bgFrame: 'img/frame.png',
	    controlBox: 'show',
	    controlBoxClass: 'mycontrolboxclass',
	    controlButtonsPath: 'img',
            //displayTitle: 'yes'
      }); 

*/

		// Image relative to its container
		$("#animated-panorama li img").css("position", "relative");

        // Resize the img object to the proper ratio of the window.
       // var iw = $("#animated-panorama li img").width();
       // var ih = $("#animated-panorama li img").height();
		
		var iw = 1700;
		var ih = 977;
		
		var vw = 540;
		var vh = 304;
        
       // if (w > h) {
		if ($(window).width() > $(window).height()) {

            if (iw > ih) {
                var fRatio = iw/ih;
                $("#animated-panorama li img").css("width",$(window).width() + "px");
                $("#animated-panorama li img").css("height",Math.round($(window).width() * (1/fRatio)));
			   
			   $("#animated-panorama li iframe").css("width",$(window).width() + "px");
                $("#animated-panorama li iframe").css("height",Math.round($(window).width() * (1/fRatio)));
			   
				
					
               var newIh = Math.round($(window).width() * (1/fRatio));

               if(newIh < $(window).height()) {
                    var fRatio = ih/iw;
                    $("#animated-panorama li img").css("height",$(window).height());
                   $("#animated-panorama li img").css("width",Math.round($(window).height() * (1/fRatio)));
				   
				   

					
					$("#animated-panorama li iframe").css("height",$(window).height());
                   $("#animated-panorama li iframe").css("width",Math.round($(window).height() * (1/fRatio)));
					
					
					

					
                }
            } else {
                var fRatio = ih/iw;
                $("#animated-panorama li img").css("height",$(window).height());
                $("#animated-panorama li img").css("width",Math.round($(window).height() * (1/fRatio)));
				
				

				
				$("#animated-panorama li iframe").css("height",$(window).height());
                $("#animated-panorama li iframe").css("width",Math.round($(window).height() * (1/fRatio)));
				
				

				
            }
        } else {
            var fRatio = ih/iw;
           $("#animated-panorama li img").css("height",$(window).height());
            $("#animated-panorama li img").css("width",Math.round($(window).height() * (1/fRatio)));
			
			

			
			$("#animated-panorama li iframe").css("height",$(window).height());
            $("#animated-panorama li iframe").css("width",Math.round($(window).height() * (1/fRatio)));
			

			
        }
		
		// Center the image



			if ($("#animated-panorama li img").width() > $(window).width()) {
				
				var this_left = ($("#animated-panorama li img").width() - $(window).width()) / 2;
				$("#animated-panorama li img").css({
					"top"  : 0,
					"left" : -this_left
				});
				
				$("#animated-panorama li iframe").css({
					"top"  : 0,
					"left" : -this_left
				});
			}
			

			
			
			if ($("#animated-panorama li img").height() > $(window).height()) {
				
				var this_height = ($("#animated-panorama li img").height() - $(window).height()) / 2;
				$("#animated-panorama li img").css({
					"left" : 0,
					"top" : -this_height
				});
				
				$("#animated-panorama li iframe").css({
					"left" : 0,
					"top" : -this_height
				});
			}
        
    }
	
	$(window).load(function() {
		resizeImage();
	})

