// JavaScript Document


/*------------------------------------
	init
------------------------------------*/
function init()
{
	setFsCookie();
	rollOverAlpha();
	scrollTop();
	ieFix();
}


/*------------------------------------
	FontSize
------------------------------------*/
var fs_arry ={ s: "77%", m: "93%",	b: "123.1%"};

/*- Set FontSize CSS ---------------*/
function setFontsize()
{
	var src,replace_src,cookie,nm;
	
	cookie = getCookie("fs");
	//alert(cookie);
	
	if(cookie != null)
	{
		$("#box").css("font-size",fs_arry[cookie]);
		if(cookie== "s") nm = 0;
		if(cookie== "m") nm = 1;
		if(cookie== "b") nm = 2;	
	}else {
		$("#box").css("font-size",fs_arry["m"]);
		nm=1;
	}
	
	src =$("#font_size dd:eq(" +nm+ ")").find("img").attr("src");
	replace_src = srcReplace(src,"_on");
	$("#font_size dd:eq(" +nm+ ")").find("img")
			.attr({src:replace_src}).end().addClass("current_fs");
}

/*- Set FontSize Cookie ------------ */
function setFsCookie()
{
	var value,num,src,replace_src;
	
	$("#font_size dd").click(function()
		{
			num = $("#font_size dd").index(this);
			
			if(num== 0) value = "s";
			if(num== 1) value = "m";
			if(num== 2) value = "b";

			setCookie("fs", value);
			$("#box").css("font-size",fs_arry[value]);
			
			if($(".current_fs").size() > 0)
			{
				src = $(".current_fs").find("img").attr("src");
				replace_src = srcReplace(src,"_on");
				$(".current_fs").find("img").attr({src:replace_src}).end().removeClass("current_fs");
			}

			src = $(this).find("img").attr("src");
			replace_src = srcReplace(src,"_on");
			$(this).find("img").attr({src:replace_src}).end().addClass("current_fs");
	});
}

/*- Get Cookie ---------------------*/
function getCookie(str)
{
	var cookie = $.cookie(str);	
	return cookie;
}

/*- Set Cookie ---------------------*/
function setCookie(str,value)
{
	$.cookie(str, value, {expires: 31, path: '/100th'});
}



/*------------------------------------
	RollOver
------------------------------------*/
function rollOverAlpha(){
	$(".over").hover(
/*		function(){
			$(this).stop().animate({"opacity":0.4},"slow");
		},
		function(){
			$(this).stop().animate({"opacity":1},"slow");
		}
*/
	function(){
		var src = $(this).attr('src');
		var ftype = src.substring(src.lastIndexOf('.'), src.length);
		if(src.search('_on') == -1){
			src = src.replace(ftype, '_on'+ftype);
			$(this).attr({src:src});
		}
	},
	function(){
		var src = $(this).attr('src');
		var ftype = src.substring(src.lastIndexOf('.'), src.length);
		if(src.search('_on') != -1){
			src = src.replace('_on'+ftype, ftype);
			$(this).attr({src:src});
		}
	});
}



/*------------------------------------
	SRC Reolace
------------------------------------*/
function srcReplace(src, prefix)
{
	var ftype = src.substring(src.lastIndexOf('.'), src.length);
	
	if(src.search(prefix) == -1){
		src = src.replace(ftype, prefix+ftype);
	}else {
		src = src.replace(prefix+ftype, ftype);
	}
	
	return src;
}



/*------------------------------------
	POPUP WINDOW
------------------------------------*/
function popup(url,wnm,pram)
{
	w = window.open(url, wnm, pram);
	w.focus();
}



/*------------------------------------
	Scroll Top
------------------------------------*/
function scrollTop()
{
	$(".pagetop").click(function(){
		$('html,body').stop().animate({ scrollTop: 0 }, 'slow');
		return false;
	});
}


/*------------------------------------
	IE6,7 BugFix
------------------------------------*/
function ieFix()
{
	$('<div/>').css('clear','both').appendTo('#contents > .inner');
}




/*------------------------------------
	onLoad
------------------------------------*/

if(window.addEventListener){  
	window.addEventListener("load", init, false);  
}  
else if(window.attachEvent){  
	window.attachEvent("onload", init);  
}



