// -------------------------------------------------------------------- //
// --------------- 呼叫首頁 ------------------------------------------- //
// -------------------------------------------------------------------- //
function start_html(num)
{
  document.body.innerHTML = makeRequest('index.php', '_Sys_Flag=start&thekey='+num);
}
// -------------------------------------------------------------------- //

// -------------------------------------------------------------------- //
// --------------- 將 form 的值, 轉成GET 形式後回傳 ------------------- //
// -------------------------------------------------------------------- //
function postvalue2get(theform) 
{
  
  var i=0;
  var getstr = '';
  
  while(theform.elements[i])
  {
	if(theform.elements[i].name)
	{
	  if(theform.elements[i].type == 'radio' || theform.elements[i].type == 'checkbox')
	  {
		if(theform.elements[i].checked == true)
		{
		  getstr = getstr+'&'+theform.elements[i].name+'='+encodeURI(theform.elements[i].value);
		}    
	  }
	  else
	  {  
		getstr = getstr+'&'+theform.elements[i].name+'='+encodeURI(theform.elements[i].value);
      }
    }
  i++;
  }
  return getstr;
}
// -------------------------------------------------------------------- //

// -------------------------------------------------------------------- //
// --- 將 form or 畫面上所有的 checkbox or radio, 全選 or 取消 -------- //
// -------------------------------------------------------------------- //
//用於資料量少時
function select_all(theform, attribute, method) 
{
  var i=0;
  //var Msec1 = (new Date()).getTime();
  //alert(Msec1);
  while(theform.elements[i])
  {
    if(theform.elements[i].type == 'radio' || theform.elements[i].type == 'checkbox')
	  if(theform.elements[i].attribute == attribute)
        theform.elements[i].checked = method;
  i++;
  }
  //var Msec2 = (new Date()).getTime();
  //alert(Msec2);
  //alert(Msec2 - Msec1);
  return true;
}
//用於資料量大時, 1. 可不受 form 中的欄位數量限制, 2. 處理速度快約 68%
function select_all_2(prefix, id_string, method) 
{
  var i=0;
  //var Msec1 = (new Date()).getTime();
  //alert(Msec1);  
  id_array = id_string.split(",");
  while(id_array[i] >= 1)
  {
	this_id = prefix + '' + id_array[i];
	this_obj = document.getElementById(this_id);
	if(this_obj.type == 'radio' || this_obj.type == 'checkbox')
    {
      this_obj.checked = method;
    }
  i++;
  }
  //var Msec2 = (new Date()).getTime();
  //alert(Msec2);
  //alert(Msec2 - Msec1);
  return true;
}
// -------------------------------------------------------------------- //

// -------------------------------------------------------------------- //
// --------------- 物件顯示與隱藏 ------------------------------------- //
// -------------------------------------------------------------------- //
function be_display(obj)
{
  if(obj.style.display == "none") obj.style.display = "";
  else obj.style.display = "none";
}

function display_be_hidden_absolute(bt_obj, obj)
{
  if (obj.style.display == 'none') {
    obj.style.position = '';
    obj.style.display = '';
    bt_obj.style.display = 'none';
  } else {
    obj.style.display = 'none';
    bt_obj.style.display = '';
  }
  return false;
}

function hidden_a_display(obj, img, img_open, img_close)
{
  if (obj.style.display == 'none') {
    obj.style.display = '';
    img.src =img_close;
  } else {
    obj.style.display = 'none';
    img.src =img_open;
  }
  return false;
}

function hidden_a_display_2(obj, checkbox, str1)
{
  var i=0;
  DIV_obj = document.getElementsByTagName("DIV");
  while(DIV_obj[i])
  {
    thisobj = DIV_obj[i];
    if(thisobj.id.match(str1)) {
      thisobj.style.display = 'none';
    }
  i++;
  }

  if(checkbox.checked == true) { obj.style.display = ''; }
  else {  obj.style.display = 'none';  }
  return false;
}
// -------------------------------------------------------------------- //

// -------------------------------------------------------------------- //
// --------------- 關閉視窗相關 --------------------------------------- //
// -------------------------------------------------------------------- //
function CloseClicked()
{
  window.returnValue = '';
  window.close();
}
// -------------------------------------------------------------------- //

// -------------------------------------------------------------------- //
// --------------- 字串取代 ------------------------------------------- //
// -------------------------------------------------------------------- //
function ReplaceAll(strSource, strFind, strRepl) {
    var str5 = new String(strSource);
    
	while (str5.indexOf(strFind) != -1) {
          str5=str5.replace(strFind, strRepl);
    }
   return str5;
}
// -------------------------------------------------------------------- //

// -------------------------------------------------------------------- //
// --------------- Select 選單 ---------------------------------------- //
// -------------------------------------------------------------------- //
var dropShow=false
var currentID
function dropdown(el){
if(dropShow){
dropFadeOut()
}else{
currentID=el
el.style.visibility="visible"
dropFadeIn()
}
}
function dropFadeIn(){//選單淡入的效果
if(currentID.filters.alpha.opacity<100){
currentID.filters.alpha.opacity+=20
fadeTimer=setTimeout("dropFadeIn()",50)
}else{
dropShow=true
clearTimeout(fadeTimer)
}
}
function dropFadeOut(){//選單淡出的效果
if(currentID.filters.alpha.opacity>0){
clearTimeout(fadeTimer)
currentID.filters.alpha.opacity-=20
fadeTimer=setTimeout("dropFadeOut()",50)
}else{
dropShow=false
currentID.style.visibility="hidden"
}
}
function dropdownHide(){
if(dropShow){
dropFadeOut()
dropShow=false
}
}
function hiLight(el){//高亮度顯示指標位置
if(dropShow){
for(i=0;i<el.parentElement.childNodes.length;i++){
el.parentElement.childNodes(i).className="link_record0"
}
el.className="link_record1"
}
}
function CheckMe(el){//替換顯示內容
el.parentElement.parentElement.childNodes(0).childNodes(0).childNodes(0).childNodes(0).childNodes(0).childNodes(0).innerHTML=el.innerHTML
}
document.onclick=dropdownHide
// -------------------------------------------------------------------- //  
