﻿function showtime(ctrlID)
   {
   var now = new Date();
   var hours = now.getHours();
   var minutes = now.getMinutes();
   var seconds = now.getSeconds();
   var timeValue = "" + ((hours < 10) ? "0" : "") + hours;

   var ctrl = document.getElementById(ctrlID);

   timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
   timeValue += ((seconds < 10) ? ":0" : ":") + seconds;

   ctrl .value = timeValue;
   timerID = setTimeout("showtime()",1000);
   timerRunning = true;
   }

function ShowDialog(obj,w,h,url) 
{
  var path = url;
  var height = h+'px';
  var width = w+'px';
  eval("obj.value = window.showModalDialog(path,obj.value, 'dialogHeight:'+height+';dialogWidth:'+width+';center:yes;help:no;scroll:no;resizable:no;status:no;');if (obj.value == 'undefined') obj.value='';");
  //return false;
}

function reback(pn,timepoint)
{
 if ((navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4) || parseInt(navigator.appVersion) >= 4) 
 { TimerID = window.setInterval(pn,timepoint); } 
 else 
 { TimerID = window.setTimeout(pn,timepoint); }
}

function dropset_value(s,v)
{
 if (v.value == s) 
   v.value = '';
 else
   v.select();
}

function reset_value(s,v)
{
 if (v.value == '') 
   v.value = s;
 else
   v.focus = false;
}

function CheckForm(c1,c2)
{
 if (c1.value == c2.value)
  {
    return true;
  }
 else if (c1.value != c2.value)
  {
   var exm = '驗證碼輸入錯誤!!';
   alert(exm);
   return false;
  }
}

var email_regexp = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
function checkmail(email)
{
 var boolint = 0; 
 var msg = "";
 for (i = 0; i < email.length; i++)
  {
   if (email_regexp.test(email[i]))
    { boolint = 1; }
   else
	{
	  boolint = 0;
	  msg = msg + email[i] + " Mail格式錯誤!!";
	}
  }
  if (boolint == 1)
   { return true; }
  else
   { return false; }
}

function viewCE(objname,linkname){
	var obj1=document.getElementById(objname);
	var obj2=document.getElementById(linkname);
	if(obj1) 
		obj1.style.display = (obj1.style.display=='')?'none':'';
		
	if(obj2)
	{
	    obj2.src= (obj1.style.display=='')?'../Image/icon_11.gif':'../Image/icon_10.gif';
	    obj2.alt= (obj1.style.display=='')?'Collapse':'Expand';
	} 

}

	function GoChange(objectName1,objectName2) 
                          {
                         var obj1=document.getElementById(objectName1);
                         var obj2=document.getElementById(objectName2); 
 var SltIndex=obj1.selectedIndex
		 if (obj1.options[SltIndex].value != '')
{
obj2["URL"] = '../Sound/file/'+ obj1.options[SltIndex].value;
} 

                           }
                           

        function ValidateLogin(source, arguments,idBox,pwBox,idMsg,pwMsg)
        {
           var strLine = '';
           if(idBox.value.length == 0 )
             strLine += idMsg + "\r\n";
           if(pwBox.value.length == 0)
             strLine += pwMsg + "\r\n";
           if(strLine.length > 0)
           {
             arguments.IsValid=false;
             alert(strLine);
           }
           else
           {
              arguments.IsValid= true
           }
        }
        
function EnterFocus(tbIDName,tbPWName,postBtnName) 
{ 
    try 
    { 
        var keydown=window.event.srcElement; 
        var postbtn = document.getElementById(postBtnName);
        var pwBox = document.getElementById(tbPWName); 
        if(event.keyCode ==13 && keydown.id==tbIDName)     
        {                                                     
            pwBox.focus(); 
        } 
        else if (event.keyCode ==13)
        { 
            postbtn.focus(); 
        } 
    } 
    catch(e) 
    { 
        return; 
    } 
}  

function SetAll(check)
{ 
 with( document.forms[0] ) {
      for( i = 0 ; i < elements.length ; i ++ ) {
         if ( elements[i].type == "radio") {
            var s = elements[i].id;
            s = s.substring((s.length -1),(s.length));
            if (s == "0") elements[i].checked = check;
         }
     } 
 }
}

function SetAllCheckBox(check)
{ 
 with( document.forms[0] ) {
      for( i = 0 ; i < elements.length ; i ++ ) {
         if (elements[i].type == "checkbox") {
            elements[i].checked = check;
         }
     } 
 }
}

function HaveChecked()
{ 
var v_count = 0;
 with( document.forms[0] ) {
      for( i = 0 ; i < elements.length ; i ++ ) {
         if ( elements[i].type == "checkbox" && elements[i].checked ==true) {
            v_count++;
         }
     } 
 }
if (v_count > 0)
 return true 
else
{
alert('請核取任一資料');
return false;
}    
}

function IsVisible(n)
{
  var obj = document.getElementById(n);
 if  (obj.style.display == 'block')
    obj.style.display = 'none';
 else
    obj.style.display = 'block';
}