
$(function(){
	bgImage();
	headerNavi();
});

function bgImage(){
	skinDir = '../images/skin/'
	$('#container').css('background-image','url("'+skinDir + $('body').attr('id') +'/body_bg.jpg")');
	$('#skinBG').css('background-image','url("'+skinDir + $('body').attr('id') +'/main_bg.gif")');
	$('#skinTop').css('background-image','url("'+skinDir + $('body').attr('id') +'/main_top.gif")');
	$('#skinBtm').css('background-image','url("'+skinDir + $('body').attr('id') +'/main_btm.gif")');
}

function headerNavi(){
	activePath = '../images/navi/active/'
//	bodyID = $('body').attr('id');
//	$('dd#navi-' +bodyID+ ' img').attr('src',activePath + bodyID +'.gif');

	$('#header dl dd img').each(function(){
		naviSwapObj = new Image();
		preLoadImg = $(this).attr('src');
		if(!preLoadImg.match('active')){
			//preLoad
			preLoadNav = activePath + preLoadImg.split('navi/')[1];
			naviSwapObj.src = preLoadNav;
			imgName = $(this).attr('name',preLoadNav);
			
			//MouseOver
			$(this).hover(
				function(){
					$(this).attr('lowsrc',$(this).attr('src'));
					$(this).attr('src',$(this).attr('name'));
				},
				function(){
					$(this).attr('src',$(this).attr('lowsrc'));
				}
			);
		}
	});
}

/* 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.'));
					}
				);
			}
		});
	})
});

/* target="_blank" */
jQuery.fn.extend({
	tBlank:  $(document).ready(function(){
		return $('a._blank').click(function(){
			this.target = '_blank';
		});
	})
});

/*-- PopUP Window --*/
jQuery.fn.extend({
	opw:  $(document).ready(function(){
		return $('a.opw').click(function(){
			wh = $(this).attr('class').split(' ')[1];
			xHref = $(this).attr('href');
			xHeight = wh.split('h')[1];
			xWidth = wh.split('h')[0].split('w')[1];
			window.open(xHref,'SubWin','resizable=no,scrollbars=yes,menubar=no,directories=no,status=no,location=no,width='+xWidth+',height='+xHeight+'');
			return false;
		});
	})
});

jQuery.fn.extend({
	privacyOpen:  $(document).ready(function(){
		return $('#privacyOpen').click(function (){
			xHref = $(this).attr('href');
			window.open(xHref,'SubWin','resizable=no,scrollbars=yes,menubar=no,directories=no,status=no,location=no,width=650,height=450');
			return false;
		});
	})
});

function privacyOpen(xHref){
	window.open(xHref,'SubWin','resizable=no,scrollbars=yes,menubar=no,directories=no,status=no,location=no,width=650,height=450');
	return false;
}

