if (typeof(BASE_HREF) == 'undefined')
  BASE_HREF = '';

var linkURLs = new Array();
linkURLs['sugang'] = '/lecture/lecture_request.html';
linkURLs['mydesk'] = '/lecture/mydesk.html';

function gotoPage(menu)
{
  var target;
  try {
    target = linkURLs[menu + '_t'];
  } catch (e) {
    target = window.self;
  }

  try {
    var url = linkURLs[menu];
    if (typeof(url) == "undefined") {
      window.alert('À¥ÁÖ¼Ò°¡ ÁöÁ¤µÇÁö ¾Ê¾Ò½À´Ï´Ù.');
    } else {
      goUrl(url, target);
    }
  } catch (e) {
    alert('ERROR::' + e.name + '\n\n' + e.message);
  }
}

function goUrl(url, win)
{
  if (!win)
    win = self;
  
  if (url.indexOf('http://') != 0)
    url = BASE_HREF + url;

  win.location.href = url;
}

function goBoard(bbsid, mode, idx)
{
  var url = '/chboard/chboard.php?bbsid=' + bbsid;
  if (mode)
  {
    if (!idx)
    {
      alert('°Ô½Ã¹° ¹øÈ£°¡ ÇÊ¿äÇÕ´Ï´Ù.');
      return;
	}
    url += '&mode=' + mode + '&idx=' + idx;
  }
  goUrl(url);
}

function openSampleWin(lec_code)
{
  switch (lec_code)
  {
    case 'AN201':
      openCenterWin('/DATA/lecture/AN201/AN201VIEW.html?unit=sample', 'flashWin', 523, 577);
      break;

    case 'TO201':
      openCenterWin('/DATA/lecture/TO201/intro.html?unit=sample', 'lectureTO201Win', 800, 570);
      break;

    case 'AP101':
      openCenterWin('/DATA/lecture/AP101/review.html?unit=sample', 'lectureAP101Win', 800, 600);
      break;

    default:
      openCenterWin('/lecture/sample.html?lc=' + lec_code, 'sampleWin', 877, 700, 'scrollbars=yes');
      break;
  }
}

function openLectureWin(lec_code, unit, section, step)
{
  var url = '';

  switch (lec_code)
  {
    case 'AN201':
      url = "/DATA/lecture/AN201/AN201VIEW.html?unit=" + unit;
      winObj = window.open(url, "lectureAN201Win", "top=0,left=0,width=523,height=577");
      break;

    case 'TO201':
      url = "/DATA/lecture/TO201/intro.html?unit=" + unit;
      winObj = window.open(url, "lectureTO201Win", "top=0,left=0,width=800,height=570");
      break;

    case 'AP101':
      url = "/DATA/lecture/AP101/review.html?unit=" + unit;
      winObj = window.open(url, "lectureAP101Win", "top=0,left=0,width=800,height=600");
      break;

    default:
      url = "/lecture/class.html?lc=" + lec_code + "&unit=" + unit;
      if (section)
        url += "&sc=" + section;
      if (step)
        url += "&step=" + step;
      winObj = window.open(url, "lectureWin", "top=0,left=0,width=877,height=700,scrollbars=yes");
      break;
  }
}

function openVideoWin(fname, winName)
{
  if (!winName)
    winName = 'videoWin';
  window.open("/media/video9.html?file=" + fname, winName, "width=340,height=325");
}

function openAudioWin(fname, winName)
{
  if (!winName)
    winName = 'AudioWin';
  window.open("/media/audio.html?file=" + fname, winName, "width=340,height=100");
}

function openEHAudioWin(fname, winName)
{
  if (!winName)
    winName = 'AudioWin';
  window.open("/media/audio_eh.html?file=" + fname, winName, "width=340,height=100");
}

function openEtcAudioWin(fname, winName)
{
  if (!winName)
    winName = 'AudioWin';
  window.open("/media/audio_etc.html?file=" + fname, winName, "width=340,height=100");
}

function openPrintFriendlyWin()
{
  window.open('/common/popup_print.html','printFriendlyWin','width=640,height=600,scrollbars=yes,toolbar=yes');
}
function openZipcodeSearchWin()
{
  window.open('/member/zipcode.html','zipcodeSearchWin','width=360,height=400,scrollbars=yes');
}
function openIdSearchWin(frmName, midField, useridField, usernameField)
{
  var url = '/common/find_user.html'
          + '?frmName=' + frmName
          + '&midField=' + midField;
  if (useridField)
    url += '&useridField=' + useridField;
  if (usernameField)
    url += '&usernameField=' + usernameField;
  window.open(url,'zipcodeSearchWin','width=360,height=400,scrollbars=yes');
}

function alertPrepare()
{
  window.alert("ÁØºñÁßÀÔ´Ï´Ù.");
}

function toplink1() { toplink1_1(); }
function toplink1_1() { goUrl('/sub1/sub1_01.html'); }
function toplink1_2() { goUrl('/sub1/sub1_02.html'); }
function toplink1_3() { goUrl('/sub1/sub1_03.html'); }
function toplink1_4() { goBoard('notice'); }
function toplink1_5() { goUrl('/sub1/sub1_05.html'); }

function toplink2() { toplink2_2(); }
function toplink2_1() { goUrl('/sub2/sub2_01.html'); }
function toplink2_2() { goUrl('/sub2/sub2_02.html'); }
function toplink2_3() { goUrl('/sub2/sub2_03.html'); }

function toplink3() { toplink3_1(); }
function toplink3_1() { goUrl('/sub3/sub3_01.html'); }

function toplink4() { toplink4_1(); }
function toplink4_1() { goUrl('/sub4/sub4_01.html'); }

function toplink5() { toplink5_1(); }
function toplink5_1() { goUrl('/sub5/sub5.html'); }

function toplink6() { toplink6_1(); }
function toplink6_1() { goUrl('/sub6/sub6_01.html'); }
