	function getWidth() {
		var win_width = $(window).width();
		return win_width;
	}
		
	function getHeight() {
		var win_height = $(window).height();
		return win_height;
	}
	
	var border = 60;
	
	function height() {
		win_height = $(window).height();
		div_width = $("#image").width();
		//$("#image").css("width", div_width - border)
		$("#image").css("height", (win_height -border) + 'px');
		$("#info").css("height", (win_height -border) + 'px');
		$(".hider").css("height", (win_height -border) + 'px');
		$(".hider").css("width", (div_width) + 'px');
	}
	
	
		function LandSwitch() {
			var $active = $('#landscape IMG.active');
			if ( $active.length == 0 ) $active = $('#landscape IMG:last');
			var $next =  $active.next().length ? $active.next() : $('#landscape IMG:first');
			$active.addClass('last-active');
			$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 1000);
			$active.animate({opacity: 0.0}, 1000, function() {
				$active.removeClass('active last-active');
			});
		}

		$(function() {
			setInterval( "LandSwitch()", 5000 );
		});
	
		
	
		function PortSwitch() {
			var $active = $('#portrait IMG.active');
			if ( $active.length == 0 ) $active = $('#portrait IMG:last');
			var $next =  $active.next().length ? $active.next() : $('#portrait IMG:first');
			$active.addClass('last-active');
			$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 1000);
			$active.animate({opacity: 0.0}, 1000, function() {
				$active.removeClass('active last-active');
			});
		}

		$(function() {
			setInterval( "PortSwitch()", 5000 );
		});
	
	
	function imgz() {
		var div_width = $("#image").width();
		var div_height = $(window).height();
		div_height = div_height-border;
		
		$(".landscape").each(function(index) {
			$(this).css("width", div_width - 10);
			var this_h = $(this).height();
			var this_w = $(this).width();
			if (this_h >= div_height) {
					$(this).css("height", div_height);
					$(this).css("width", "auto");
					$(this).css("top", "0px");
					this_w = $(this).width();
					if(this_w >= div_width) {
						$(this).css("height", "auto");
						$(this).css("top", ((div_height)/2)-(this_h/2));
						$(this).css("left", "5px");
					} else {
						$(this).css("height", div_height);
						$(this).css("width", "auto");
						$(this).css("top", "0px");
						this_w = $(this).width();
						$(this).css("left", (div_width/2)-(this_w/2));
					}
			} else {
				$(this).css("height", "auto");
				$(this).css("top", ((div_height)/2)-(this_h/2));
				$(this).css("left", "5px");
			}
		});
		
		$(".portrait").each(function(index) {
			$(this).css("width", div_width - 10);
			var this_h = $(this).height();
			var this_w = $(this).width();
			if (this_h >= div_height) {
					$(this).css("height", div_height);
					$(this).css("width", "auto");
					$(this).css("top", "0px");
					this_w = $(this).width();
					if(this_w >= div_width) {
						$(this).css("height", "auto");
						$(this).css("top", ((div_height)/2)-(this_h/2));
						$(this).css("left", "5px");
					} else {
						$(this).css("height", div_height);
						$(this).css("width", "auto");
						$(this).css("top", "0px");
						this_w = $(this).width();
						$(this).css("left", (div_width/2)-(this_w/2));
					}
			} else {
				$(this).css("height", "auto");
				$(this).css("top", ((div_height)/2)-(this_h/2));
				$(this).css("left", "5px");
			}
		});
	}
	
	function getShow() {
		if (getWidth() > getHeight()) {
			$('#landscape').show();
			$('#portrait').hide();
		} else {
			$('#portrait').show();
			$('#landscape').hide();
		}
	}
	
	$(document).ready(function(){
		height();
		$(window).bind('load', function(){
			imgz();
			LandSwitch();
			PortSwitch();
			getShow();
		});
	});
	
	
	$(window).resize(function() { 
		height();
		getShow();
		imgz(); 
	});
