﻿
$(function(){
	imgH = 666;
	imgW = 968;

	function resizeImg(){
		windowH = document.documentElement.clientHeight-10;
		windowW = document.documentElement.clientWidth-10;
		$('table td').css('height',windowH +'px');
		$('#baceBg').css('height',windowH+10 +'px');
		if (jQuery.browser.msie) {
			if(jQuery.browser.version == 8) {
				$('table th img').attr('height',windowH+10 +'px');
			}
		}
/*
		if(windowH < (imgH)){
			$('#bgImg img').css('width',imgW/2);
		}else{
			$('#bgImg img').css('width','100%');
		}
*/

		if(windowW < imgW/1.5){
			$('#bgImg img').css('width',imgW/1.5).css('height','auto');
		}else{
			$('#bgImg img').css('width','100%').css('height','auto');
		}

	}

	resizeImg();
	$(window).bind('resize', resizeImg);

	if ($.browser.msie && $.browser.version < 7){
		$('#ageBox').css('background','#000').fadeTo(0, 0.75);;
	}
});

/* swapImg */
jQuery.fn.extend({
	swapImg: $(document).ready(function(){
		return $('.swapImg').each(function(){
			if($(this).attr('class').match('swapImg change')){
				//ImgPreLoad
				swapObj = new Image();
				preLoad = $(this).attr('class').split('swapImg change(')[1].split(')')[0];
				swapObj.src = preLoad;
				imgNm = $(this).attr('name',preLoad);
				
				//MouseOver
				$(this).hover(
					function(){
						$(this).attr('lowsrc',$(this).attr('src'));
						$(this).attr('src',$(this).attr('name'));
					},
					function(){
						$(this).attr('src',$(this).attr('lowsrc'));
					}
				);
			}else if($(this).attr('src').match('_no.')){
				//ImgPreLoad
				swapObj = new Image();
				imgpath = $(this).attr('src');
				preLoad = imgpath.replace('_no.','_ro.');
				swapObj.src = preLoad;
				
				$(this).hover(
					function(){
						$(this).attr('src',$(this).attr('src').replace('_no.','_ro.'));
					},
					function(){
						$(this).attr('src',$(this).attr('src').replace('_ro.','_no.'));
					}
				);
			}
		});
	})
});
