$(document).ready(function(){
	
	// logo bg
	$("h1").hover(function(){
		$("#bg_logo").fadeIn();},
		function(){
		$("#bg_logo").fadeOut();
	});
	
	// contents box animate
	$("#main_bar").animate({height:"112px"});
	$("#main_bar p").fadeIn();

	$("#left article").hide();
	$("#left article").slideDown('slow');

	// study
	$('#study>article>h3').toggle(function(){
		$("#study>article>h3>a").removeClass("on");
		$("#study>article>h3").removeClass("on");
		$("#study>article>div.con").slideUp();
		$(this).next(".con").slideDown();
		$(this).addClass("on");
		$('a:first',this).addClass("on");
		},
		function(){
		$(this).removeClass("on");
		$(this).next(".con").slideUp();
	});
	
	// study open, hide
	$("#study>#full>#full_open").fadeIn("slow");
	$('#study>#full').toggle(function(){
		$("#study>#full>#full_open").hide();
		$("#study>#full>#full_close").fadeIn("slow");
		$("#study>article>div.con").slideDown();
		},
		function(){
		$("#study>#full>#full_close").hide();
		$("#study>#full>#full_open").fadeIn("slow");
		$("#study>article>div.con").slideUp();
	});

	// e-mail on, off
	$("#mail_box>fieldset>p>input,#mail_box>fieldset>p>textarea").focus(function(){
		$("#mail_box>fieldset>p>input,#mail_box>fieldset>p>textarea").removeClass("on");
		$(this).addClass("on");
	});

	$("#mail_box>fieldset>p>input,#mail_box>fieldset>p>textarea").mouseover(function(){
		$("#mail_box>fieldset>p>input,#mail_box>fieldset>p>textarea").removeClass("on");
		$(this).addClass("on");
	});

	$("#mail_box>fieldset>p>input,#mail_box>fieldset>p>textarea").mouseout(function(){
		$("#mail_box>fieldset>p>input,#mail_box>fieldset>p>textarea").removeClass("on");
	});

	// comments on, off
	$("#comments_box>fieldset>#wr_box>p>input,#comments_box>fieldset>#wr_box>p>textarea").focus(function(){
		$("#comments_box>fieldset>#wr_box>p>input,#comments_box>fieldset>#wr_box>p>textarea").removeClass("on");
		$(this).addClass("on");
	});

	$("#comments_box>fieldset>#wr_box>p>input,#comments_box>fieldset>#wr_box>p>textarea").mouseover(function(){
		$("#comments_box>fieldset>#wr_box>p>input,#comments_box>fieldset>#wr_box>p>textarea").removeClass("on");
		$(this).addClass("on");
	});

	$("#comments_box>fieldset>#wr_box>p>input,#comments_box>fieldset>#wr_box>p>textarea").mouseout(function(){
		$("#comments_box>fieldset>#wr_box>p>input,#comments_box>fieldset>#wr_box>p>textarea").removeClass("on");
	});


});

// mouse rollover
function imgRollover(aLink, nextSrc){
	aLink[0].src = nextSrc;
}

//
	function mod(num) {
		
		var pw = 'comment_pw02'+num;
		var pwd = document.getElementById(pw).value;
		var rePw = 'rePwd'+num;
		var rePwd = document.getElementById(rePw).value;
		var mod = 'mod'+num;
		var view = 'view'+num;
		var ok = 'ok'+num;
		var img = 'img'+num;
		var dis = 'disPw'+num;

		if(pwd =="") {
			alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.');
			return false;
		}
		if(pwd != rePwd) {
			alert('ºñ¹Ð¹øÈ£°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.');
			return false;
		}
		if(pwd == rePwd) {
		document.getElementById(mod).style.display='block';
		document.getElementById(view).style.display='none';
		document.getElementById(ok).style.display='block';
		document.getElementById(img).style.display='none';
		document.getElementById(dis).style.display='none';
		return false;
		}
	}	

	function ok(num) {
		var con = 'comment02'+num;
		var content = document.getElementById(con).value;
		var mod = 'mod'+num;
		var view = 'view'+num;

		if(content ==''){
			alert('³»¿ëÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä');
			return false;
		}
		document.getElementById('mod').style.display='none';
		document.getElementById('view').style.display='block';
	}

	function del(num,rNum){
		var pw = 'comment_pw02'+rNum;
		var pwd = document.getElementById(pw).value;
		var rePw = 'rePwd'+rNum;
		var rePwd = document.getElementById(rePw).value;

		if(pwd =="") {
			alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.');
			return false;
		}
		if(pwd != rePwd) {
			alert('ºñ¹Ð¹øÈ£°¡ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.');
			return false;
		}
		if(pwd == rePwd) {
			alert('»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?');
			location.href='/sub/delete_con.php?num='+num;
		}
	}


	function insert() {
		var name = document.wForm.co_name.value;
		var pwd = document.wForm.co_pw.value;
		var content = document.wForm.comment.value;

		if(name=='') {
			alert('ÀÌ¸§À» ÀÔ·ÂÇØÁÖ¼¼¿ä.');
			return false;
		}
		if(pwd=='') {
			alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
			return false;
		}
		if(content=='') {
			alert('³»¿ëÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.');
			return false;
		}
		document.wForm.action='/sub/insert_con.php';
		document.wForm.submit();
	}

