﻿var english = "/english/";
var chinese = "/chinese/";
var sc = "/sc/";
var textonly = "/text";

// For Interactive Glossary of Chemical Terms search result page
var e_glossary = "http://www.govtlab.gov.hk/english/glossary.htm";
var c_glossary = "http://www.govtlab.gov.hk/chinese/glossary.htm";
var s_glossary = "http://www.govtlab.gov.hk/sc/glossary.htm";

function tran_gb() {
  var lk = top.location.href;

  if (lk.indexOf(english) != -1) lk = lk.replace(english,sc);
  if (lk.indexOf(chinese) != -1) lk = lk.replace(chinese,sc);

  // For Interactive Glossary of Chemical Terms search result page
  if (lk.indexOf("e_result") != -1 || lk.indexOf("c_result") != -1) lk = s_glossary;

  top.location.href = lk;
}

function tran_b5() {
  var lk = top.location.href;

  if (lk.indexOf(english) != -1) lk = lk.replace(english,chinese);
  if (lk.indexOf(sc) != -1) lk = lk.replace(sc,chinese);

  // For Interactive Glossary of Chemical Terms search result page
  if (lk.indexOf("e_result") != -1 || lk.indexOf("s_result") != -1) lk = c_glossary;

  top.location.href = lk;
}

function tran_en() {
  var lk = top.location.href;

  if (lk.indexOf(chinese) != -1) lk = lk.replace(chinese,english);
  if (lk.indexOf(sc) != -1) lk = lk.replace(sc,english); 	

  // For Interactive Glossary of Chemical Terms search result page
  if (lk.indexOf("c_result") != -1 || lk.indexOf("s_result") != -1) lk = e_glossary;

  top.location.href = lk;
}

function tran_text() {
  var lk = top.location.href;

  if (lk.indexOf(english) != -1) lk = lk.replace(english,textonly+english); 	
  if (lk.indexOf(chinese) != -1) lk = lk.replace(chinese,textonly+chinese); 	
  if (lk.indexOf(sc) != -1) lk = lk.replace(sc,textonly+sc); 	

  // For Interactive Glossary of Chemical Terms search result page
  if (lk.indexOf("e_result") != -1) lk = e_glossary.replace(english,textonly+english); 	
  if (lk.indexOf("c_result") != -1) lk = c_glossary.replace(chinese,textonly+chinese); 	
  if (lk.indexOf("s_result") != -1) lk = s_glossary.replace(sc,textonly+sc); 	

  top.location.href = lk;
}

function openar(year) {
  var lk = top.location.href;
  var path1, path2;

  path1 = (lk.indexOf(textonly) != -1) ? '../..' : '..';
  switch (year) {
    case 2009:
      if (lk.indexOf(english) != -1) path2 = 'en';
      if (lk.indexOf(chinese) != -1) path2 = 'tc';
      if (lk.indexOf(sc) != -1) path2 = 'sc';
      window.open(path1 + "/ar2009/" + path2 + "/index.htm",null,"scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no");
      break;
    case 2008:
      window.open(path1 + "/ar2008/index.html",null,"height=600,width=800,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no");
  }
}

function opencoer() {
  var lk = top.location.href;
  var path1;

  if (lk.indexOf(english) != -1) path1 = 'en';
  if (lk.indexOf(chinese) != -1) path1 = 'tc';
  if (lk.indexOf(sc) != -1) path1 = 'sc';
  window.open("../coer2010/" + path1 + "/index.html",null,"width=800,height=600,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no");
}

function openkeyind(pg) {
  window.open(pg,null,"height=500,width=600,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no");
}

function openwin(pg) {
  window.open(pg,null,"height=500,width=600,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no");
}

function adobereader() {
  var lk = top.location.href;

  document.write('<hr>');

  if (lk.indexOf(textonly) != -1) {
    if (lk.indexOf(english) != -1) {
      document.write('<p class="engPara" style="font-size:70%;color:#333333">You may need to use Adobe Reader to read the above PDF files.<br>');
      document.write('Click <a href="http://www.adobe.com/go/getreader" target="_blank">here</a> to download Adobe Reader.</p>');
    } else if (lk.indexOf(chinese) != -1) {
      document.write('<p class="chiPara" style="font-size:80%;color:#333333">以 上 PDF 格 式 文 件 或 需 用 Adobe Reader 閱 讀。<br>');
      document.write('請 按 <a href="http://www.adobe.com/go/getreader" target="_blank">此 處</a> 下 載 Adobe Reader</p>');
    } else if (lk.indexOf(sc) != -1) {
      document.write('<p class="chiPara" style="font-size:80%;color:#333333">以 上 PDF 格 式 文 件 或 需 用 Adobe Reader 阅 读。<br>');
      document.write('请 按 <a href="http://www.adobe.com/go/getreader" target="_blank">此 处</a> 下 载 Adobe Reader</p>');
    }
  } else if (lk.indexOf(english) != -1) {
    document.write('<p class="engPara" style="font-size:70%;color:#333333">You may need to use Adobe Reader to read the above PDF files<br>');
    document.write('<a href="http://www.adobe.com/go/getreader" target="_blank"><img src="../g/get_adobe_reader.gif" alt="Get Adobe Reader" width="112" height="33" border="0"></a>Click to download Adobe Reader</p>');
  } else if (lk.indexOf(chinese) != -1) {
    document.write('<p class="chiPara" style="font-size:80%;color:#333333">以 上 PDF 格 式 文 件 或 需 用 Adobe Reader 閱 讀。<br>');
    document.write('<a href="http://www.adobe.com/go/getreader" target="_blank"><img src="../g/get_adobe_reader.gif" alt="下載 Adobe Reader" width="112" height="33" border="0"></a>請 按 下 載 Adobe Reader</p>');
  } else if (lk.indexOf(sc) != -1) {
    document.write('<p class="chiPara" style="font-size:80%;color:#333333">以 上 PDF 格 式 文 件 或 需 用 Adobe Reader 阅 读。<br>');
    document.write('<a href="http://www.adobe.com/go/getreader" target="_blank"><img src="../g/get_adobe_reader.gif" alt="下载 Adobe Reader" width="112" height="33" border="0"></a>请 按 下 载 Adobe Reader</p>');
  }
}

