$(function() {
		
	/**
	 * Main Image
	 * jQuery fade animation
	 */
	var placeholder = $('#keyimgArea h2 a').empty();

	$('#keyimgArea ul a').each(function(i) {
		
		$('<img />').appendTo(placeholder).attr({
			'id': 'main' + ( i + 1 ),
			'src': './images/main' + ( i + 1 ) + '.jpg',
			'alt': ''
		}).css({ opacity: 0 });
		
		$(this).hover(
			function() {
				placeholder.attr({ 'href': this });
				$('#main' + ( i + 1 )).appendTo(placeholder).fadeTo(500, 1, function(){
					$('#keyimgArea h2 a img').not('#main' + ( i + 1 ) + ', #main0').css({ opacity: 0 });
				});
			},
			function () {
				var timer = setTimeout( function(){
					$('#keyimgArea h2 a img').each(function(){
						if ( $(this).css('opacity') > 0 && $(this).attr('id') != 'main0' ){
							$(this).fadeTo(500, 0);
						}
					});
				}, 500 );
				$('#keyimgArea a').mouseover(function(){
					clearTimeout(timer);
				});
  		}
		);
	});
	
	$('<img />').prependTo(placeholder).attr({
		'id': 'main0',
		'src': './images/main0.jpg',
		'alt': ''
	});
	

});


