//메뉴 구현 함수
function bindNav(){

	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)

	$("ul.topnav li span").click(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

	//상위 메뉴 클릭시에도 목록 보이게
	$("ul.topnav li a").click(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
}

function countLineBreaks (string) {
  var re = /\r\n|\r|\n/g;
  var n = 0;
  while (re.exec(string))
    n++;
  return n;
}
 
function adjustRows (textarea) {
  if (document.all) {
    while (textarea.scrollHeight > textarea.clientHeight)
      textarea.rows++;
    textarea.scrollTop = 0;
  }
  else if (textarea.rows) {
    var lineBreaks = countLineBreaks(textarea.value);
    var rows = parseInt(textarea.rows);
    var wrap = textarea.getAttribute('wrap');
    if (lineBreaks > rows)
      textarea.rows = ++rows;
    else if (wrap.toLowerCase() == 'soft' || wrap.toLowerCase() == 'hard') {
      while (textarea.rows * textarea.cols <= textarea.value.length) {
        textarea.rows = ++rows;
      }
    }
  }
}
