/////////////////////////////////////////////////////////////////
// ●파일 : /js/normal/normal.js
// ●설명 : 사용자 자바스크립트 (자주 쓰이는 스크립트)
// ●작성자 : by NINE
/////////////////////////////////////////////////////////////////

/* 검색어 입력 여부 확인 */
function input_search_word_check(search)
{
  var search_length = search.value.length;

  if ( search_length == 0 || search.value.trim() == "") 
  {
    alert("검색어를 입력 하세요.");
    search.focus();
    return (false);
  }

  return (true);
}

/* 게시물 작성시 입력 내역 확인 */
function check_bbs_write_form(check_form)
{
  document.getElementById("content").value = myeditor.outputBodyHTML();

  if (!check_form.name.value.trim().length || check_form.name.value.trim() == "") 
  {
    alert('이름을 입력해 주세요.');
    check_form.name.focus();
    return (false);
  }
  
  if ( !check_form.subject.value.trim().length || check_form.subject.value.trim() == "") 
  {
    alert('제목을 입력해 주세요.');
    check_form.subject.focus();
    return (false);
  }
  
  if ( !check_form.content.value.trim().length || check_form.content.value.trim() == "") 
  {
    alert('내용을 입력해 주세요.');
    return (false);
  }
}

/* 메인페이지 메뉴 탭 기능 */
function set_img(iconid) 
{ 
  var main_notice_img, main_prize_img, main_gb_img, main_choice_more_img, loop_i;
  
  main_notice_img = document.getElementById("main_notice_tit");
  main_prizeuser_img = document.getElementById("main_prizeuser_tit");
  main_user_center_notice_img = document.getElementById("main_user_center_notice_tit");
  
  choice_iconid = document.getElementById("icon_id");
  
  if(iconid == "t01")
  {
    main_notice_img.src = "/imgs/normal/main/d_t01_over.gif";
    main_prizeuser_img.src = "/imgs/normal/main/d_t02.gif";
    main_user_center_notice_img.src = "/imgs/normal/main/d_t03.gif";
    choice_iconid.value="t01";
  }
  else if(iconid == "t02")
  {
    main_notice_img.src = "/imgs/normal/main/d_t01.gif";
    main_prizeuser_img.src = "/imgs/normal/main/d_t02_over.gif";
    main_user_center_notice_img.src = "/imgs/normal/main/d_t03.gif";
    choice_iconid.value="t02";
  }
  else if(iconid == "t03")
  {
    main_notice_img.src = "/imgs/normal/main/d_t01.gif";
    main_prizeuser_img.src = "/imgs/normal/main/d_t02.gif";
    main_user_center_notice_img.src = "/imgs/normal/main/d_t03_over.gif";
    choice_iconid.value="t03";
  }
}

/* 선택된 탭의 메인 URL로 이동 */
function set_move_url() 
{ 
  var choice_iconid;
  
  choice_iconid = document.getElementById("icon_id");
  
  if(choice_iconid.value == "t01")
  {
    location.href = "/cyber/notice.php?tid=notice";
  }
  else if(choice_iconid.value == "t02")
  {
    location.href = "/enjoy/notice.php?tid=prizeuser";
  }
  else if(choice_iconid.value == "t03")
  {
    location.href = "/center/notice.php?tid=user_center_notice";
  }
}
	
/* 우축 사이드 롤링 배너 */
max_body_height = 0;
right_side_menu_height = 0;
right_side_menu_top = 0;
nQuickSpeed = 0.1;
nQuickTop = 110;

function right_side_bar_fixed()
{
	var right_side_menu_left = 0;
	var menu, top_menu_left = 0;
	var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
	var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
	
	right_side_menu_top = parseInt(document.getElementById("right_side_menu").style.top);
	
	if(max_body_height == 0)
  {
    max_body_height = document.body.scrollHeight;
  }
	
	if(right_side_menu_height == 0)
  {
    right_side_menu_height = document.getElementById("right_side_menu").scrollHeight;
  }
	
	right_side_menu_top += ((scrollTop + nQuickTop) - right_side_menu_top) * nQuickSpeed;
	
	menu  = document.getElementById("menu").getBoundingClientRect();
	top_menu_left = parseInt(menu.left + scrollLeft);
	right_side_menu_left = top_menu_left + 920;

	if(max_body_height < right_side_menu_top + right_side_menu_height)
  {
    right_side_menu_top = max_body_height - right_side_menu_height
  }
  
  document.getElementById("right_side_menu").style.left = right_side_menu_left+"px";
	document.getElementById("right_side_menu").style.top = right_side_menu_top+"px";
	
	document.getElementById("right_side_menu").style.visibility = "visible";
	
	window.setTimeout(right_side_bar_fixed, 10);
}

