function SetDate(year, month, day)
{
  year = year;
  month.strlength
  if (month.length == 1)
  {
    month = "0"+month;
  }

  if (day.length == 1)
  {
    day = "0"+day;
  }

   searchGubun = year+month+day;
   strDate = year + "-" + month + "-" + day;

  if(searchGubun >= 20070101)
  {
    document.all['eyescrap_top'].style.display = "block";
    document.all['today'].value = strDate;
    document.all['eyescrap_contents'].height = 4200;
    document.all['eyescrap_contents'].src = "http://papers.eyescrap.com/pbc/list.aspx?paper_date=" + strDate + "&actionURL=http://pdf.pbc.co.kr/eyescrapAction.html";
  }
  else
  {
    document.all['eyescrap_top'].style.display = "block";
    //document.all['today'].value = strDate;
    document.all['eyescrap_contents'].src = "./list.php?paper_date=" + searchGubun;
  }
}

function pdf_type(id)
{

  if (id == 1)
  {
    document.images.Image1.src = "./img/tab_btn1_ov.gif";
    document.images.Image2.src = "./img/tab_btn2.gif";
    document.getElementById('pdf_type').value = id;
    //document.getElementById('search_other').style.display = 'block';
    document.search_key.startdate.value = '2006-11-26';
    document.search_key.enddate.value = '2006-12-31';
  }
  else
  {
    document.images.Image1.src = "./img/tab_btn1.gif";
    document.images.Image2.src = "./img/tab_btn2_ov.gif";
    document.getElementById('pdf_type').value = id;
    document.getElementById('search_other').style.display = 'none';
    today = new Date();

    document.search_key.startdate.value = toTimeString(today,"true");
    document.search_key.enddate.value = toTimeString(today);
  }
}

function toTimeString(date, last)
{
    var year  = date.getFullYear();
    var month = date.getMonth() + 1; // 1월=0,12월=11이므로 1 더함
    var day  = date.getDate();

  if (last == "true")
  {
    if (("" + month).length == 1) { month = "0" + (month-1); }
  }
  else
  {
    if (("" + month).length == 1) { month = "0" + month; }
  }

  if (("" + day).length == 1) { day = "0" + day; }

  return ("" + year + "-" + month + "-" + day );

}

//검색창에 엔터키 입력시에
function goSearch()
{
  if (event.keyCode == 13)
  {
    pdf_search();
  }
}

//PDF검색 버튼
function pdf_search()
{
  var keyword = search_key.keyword.value;
  var n_writer = unescape(search_key.n_writer.value);
  var n_series_no = unescape(search_key.n_series_no.value);
  var n_series_name = unescape(search_key.n_series_name.value);
  var n_num = unescape(search_key.n_num.value);
  var startdate = search_key.startdate.value;
  var enddate = search_key.enddate.value;
  var actionURL = "http://pdf.pbc.co.kr/eyescrapAction.html";

  var scope = 0;
  for(var i=0;i<search_key.scope.length;i++)
  {
      if (search_key.scope[i].checked == true)
      {
          scope = search_key.scope[i].value;
      }
  }

  if (keyword == "")
  {
    alert("검색어를 입력해주세요.");
    return;
  }

  if ( startdate == "" )
  {
    alert("검색 시작일을 입력해주세요.");
    return;
  }

  if ( enddate == "" )
  {
    alert("검색 종료일을 입력해주세요.");
    return;
  }

  // 2007년 이전

  if(document.getElementById('pdf_type').value == '1')
  {
    document.all['eyescrap_top'].style.display = "block";
    //document.all['today'].value = strDate;
    document.all['eyescrap_contents'].src = "./list.php?pgcode=Search&keyword2=" + unescape(escape(encodeURIComponent(keyword))) + "&actionURL=" + actionURL + "&startDate=" + startdate +"&endDate=" + enddate +"&scope=" + scope + "&searchType=pds&n_writer" + n_writer + "&n_series_no" + n_series_no + "&n_series_name" + n_series_name + "&n_num" + n_num;
    //document.all['eyescrap_contents'].height = 1200;
    //eyescrap_contents.location.replace('http://papers.eyescrap.com/pbc/list.aspx?pgcode=Search&keyword2=' + keyword + '&actionURL=' + actionURL + '&startDate=' + startdate +'&endDate=' + enddate +'&scope=' + scope + '&nTerm4=o');
  }
  else
  {
    document.all['eyescrap_top'].style.display = "block";
    document.all['eyescrap_contents'].height = 1200;
    eyescrap_contents.location.replace('http://papers.eyescrap.com/pbc/list.aspx?pgcode=Search&keyword2=' + unescape(escape(keyword)) + '&actionURL=' + actionURL + '&startDate=' + startdate +'&endDate=' + enddate +'&scope=' + scope + '&nTerm4=o');
  }

}
