//=========================================
function Move()
{
   try
   {  
     top.document.all.menu.style.display="none";
     top.document.all.DoorKey.style.display="";
     

     //top.frames["main"].location.href="http://www.hinet.net";
     //top.frames["main"].document.all.menu.style.display="none";
     //top.frames["main"].document.all.DoorKey.style.display="";



     xx=top.document.all.myiframe.style.left;

     //alert(xx);

     if(xx=='5px')
       { }
     else
       {
        top.document.all.myiframe.style.left=20;
       }

   }
   catch(e)
   {
     window.close();
   }


}
//--------------------------------------------------------------------
//=======================================================================//
function Today1()     //取出今天日期090.01.01;
 {
   //alert("Hello");
   var today=new Date();
   var yy=today.getYear();
   var mm=today.getMonth();
   var dd=today.getDate();
   
   var Os=getOs();  //取得瀏覽器版本;在Func.js中;
   
   if(Os=="MSIE")
   {   
	if(yy<100)
		{
	    	yy=yy-11;
		}
	else
		{
		    yy=yy-1911;
		}
   }
   else
   {
       yy=yy-11;
   }


   mm=mm+1;
   if(mm<10)
     {
      mm="0"+mm
     }
   else
     {
      mm=mm+"";
     }

   if(dd<10)
     {
      dd="0"+dd;
     }

   var Temp=yy+"."+mm+"."+dd;
   
   if(Temp.length==8)
     {
      Temp="0"+Temp;
     }
   else if(Temp.length<8)
     {
      //alert("Func.js--日期格式錯誤");
     }

     return  Temp;
 }
//-----------------------------------------------------------------------//
function Today2()     //取出今天日期2005.01.01;
 {
   var today=new Date();
   var yy=today.getYear();
   var mm=today.getMonth();
   var dd=today.getDate();

   mm=mm+1;
   if(mm<10)
     {
      mm="0"+mm
     }
   else
     {
      mm=mm+"";
     }

   if(dd<10)
     {
      dd="0"+dd;
     }

   var Os=getOs();  //取得瀏覽器版本;在Func.js中;
   if(Os=="MSIE")
   {
     if(yy<100)
     {
        yy="19"+yy;
     }   
   }
   else
   {
     if(yy<100)
     {
        yy="19"+yy;
     }
     else
     {
        yy=1900+yy;
     }
   }

   var Temp=yy+"."+mm+"."+dd;
   return  Temp;
 }
//-----------------------------------------------------------------------//
function Today3()     //取出今天日期2005-01-01;
 {
   var today=new Date();
   var yy=today.getYear();
   var mm=today.getMonth();
   var dd=today.getDate();


   mm=mm+1;
   if(mm<10)
     {
      mm="0"+mm
     }
   else
     {
      mm=mm+"";
     }

   if(dd<10)
     {
      dd="0"+dd;
     }
     
   var Os=getOs();  //取得瀏覽器版本;在Func.js中;
   if(Os=="MSIE")
   {
     if(yy<100)
     {
        yy="19"+yy;
     }   
   }
   else
   {
     if(yy<100)
     {
        yy="19"+yy;
     }
     else
     {
        yy=1900+yy;
     }
   }     
     

   var Temp=yy+"-"+mm+"-"+dd;
   return  Temp;
 }
//-----------------------------------------------------------------------//
//-----------------------------------------------------------------------//
function Today4()     //取出今天日期2005/01/01;
 {
   var today=new Date();
   var yy=today.getYear();
   var mm=today.getMonth();
   var dd=today.getDate();


   mm=mm+1;
   if(mm<10)
     {
      mm="0"+mm
     }
   else
     {
      mm=mm+"";
     }

   if(dd<10)
     {
      dd="0"+dd;
     }

   var Temp=yy+"/"+mm+"/"+dd;
   return  Temp;
 }
//-----------------------------------------------------------------------//
//===========================================
function AllTrim(stringdata)    //去除字串前後空白;
//===========================================
 {
  var temp;
  if(typeof(stringdata)!='string')
    {
     return "";
    }


   var ii=stringdata.length;
   if(ii==0)
     {
      return "";
     }

   while(ii!=0)
        {
         var subdata=stringdata.substr(ii-1,1);

         if(subdata!=" ")
           {
            var jj=ii;   //從後方算回,取出數字所在位置;
            ii=0;
           }
         else
           {
            ii-=1;
           }
        }
        temp=stringdata.substr(0,jj);

   var ii=temp.length;
   var jj=0;   //算出字元起始位置;

   while(jj!=ii)
        {
         var subdata=stringdata.substr(jj,1);

         if(subdata!=" ")
           {
            var ii=jj;   //從前方算起,取出數字所在位置;
           }
         else
           {
            jj+=1;
           }
        }

        temp=temp.substr(ii);

        return temp;

 }
//-------------------------------------------
//===========================================
function CopyToClipboard(DivX)   //Copy網頁特定字串可貼到別的地方
//===========================================
{
    //alert("Go..");   
    //物件名稱不要和對應的物件名稱一樣會發生錯誤; 
    TmpHolderTextArea1 = document.getElementById("TmpHolderTextArea");   //網頁中須要有的物件;
    TmpHolderTextArea1.innerText = DivX.innerText;                       //要複製的內容; 
    Copied = TmpHolderTextArea1.createTextRange();
    Copied.execCommand("RemoveFormat");
    Copied.execCommand("Copy");
}
//-------------------------------------------
//===========================================
// 使用<A>開起指定大小的新視窗.
//===========================================
/* 呼叫方式如下:
  document.getElementById("Atag").onclick = function()
  {
    var obj = makePopup('subWin', this.href, 640, 480, 'scroll','yes');
    obj.focus();
    return obj.closed;    //不能少;
  };
*/

function makePopup(winName, url, width, height, overflow ,st)
{
  if (width > 800) { width = 800; }
  if (height > 600) { height = 600; }

  if (overflow == '' || !/^(scroll|resize|both)$/.test(overflow))
  {
    overflow = 'both';
  }

  var win = window.open(url, winName,
      'width=' + width + ',height=' + height
      + ',scrollbars=' + (/^(scroll|both)$/.test(overflow) ? 'yes' : 'no')
      + ',resizable=' + (/^(resize|both)$/.test(overflow) ? 'yes' : 'no')
      + ',status='+st+',toolbar=no,menubar=no,location=no'
  );

  return win;
}
//-------------------------------------------
//用於刪除被按時瀏覽器的判斷;
function getOs() 
{ 
	var OsObject = ""; 
	
	if(navigator.userAgent.indexOf("MSIE")>0) 
	{ 
	  return "MSIE"; 
	} 
	if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)
	{ 
	  return "Firefox"; 
	} 
	if(isSafari=navigator.userAgent.indexOf("Safari")>0) 
	{ 
	  return "Safari"; 
	} 
	if(isCamino=navigator.userAgent.indexOf("Camino")>0)
	{ 
	  return "Camino"; 
	} 
	if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0)
	{ 
	  return "Gecko"; 
	} 

} 
//-------------------------------------------
//判斷瀏覽器的另一種方式;
function identifyBrowser() 
{
  var agent = navigator.userAgent.toLowerCase();

  if (typeof navigator.vendor != "undefined" && navigator.vendor == "KDE" &&
      typeof window.sidebar != "undefined")
  {
    return "kde";
  }
  else if (typeof window.opera != "undefined")
  {
    var version = parseFloat(agent.replace(/.*opera[\/ ]([^ $]+).*/, "$1"));

    if (version >= 7)
    {
      return "opera7";
    }
    else if (version >= 5)
    {
      return "opera5";
    }

    return false;
  }
  else if (typeof document.all != "undefined")
  {
    if (typeof document.getElementById != "undefined")
    {
      var browser = agent.replace(/.*ms(ie[\/ ][^ $]+).*/, "$1").replace(/ /, "");

      if (typeof document.uniqueID != "undefined")
      {
        if (browser.indexOf("5.5") != -1)
        {
          return browser.replace(/(.*5\.5).*/, "$1");
        }
        else
        {
          return browser.replace(/(.*)\..*/, "$1");
        }
      }
      else
      {
        return "ie5mac";
      }
    }

    return false;
  }
  else if (typeof document.getElementById != "undefined")
  {
    if (navigator.vendor.indexOf("Apple Computer, Inc.") != -1)
    {
      if (typeof window.XMLHttpRequest != "undefined")
      {
        return "safari1.2";
      }

      return "safari1";
    }
    else if (agent.indexOf("gecko") != -1)
    {
      return "mozilla";       //如:Mozilla/Firefox 都傳會mozilla字串;
    }
  }
  return false;
}

//-----------------------------------------------------
//=======================================================================//
//  可以讓load載入更多的不特定函數;
//=======================================================================//
function addLoadListener(fn)
{
  if (typeof window.addEventListener != 'undefined')
  {
    window.addEventListener('load', fn, false);
  }
  else if (typeof document.addEventListener != 'undefined')
  {
    document.addEventListener('load', fn, false);
  }
  else if (typeof window.attachEvent != 'undefined')
  {
    window.attachEvent('onload', fn);
  }
  else
  {
    var oldfn = window.onload;
    if (typeof window.onload != 'function')
    {
      window.onload = fn;
    }
    else
    {
      window.onload = function()
      {
        oldfn();
        fn();
      };
    }
  }
}
//-------------------------------------------
//=======================================================================//
//  為了同時支援ie(attchEvent)及非ie(addEventListener)方法,並同時支援不使用W3C DOM瀏覽器的方法.
//=======================================================================//
function attachEventListener(target, eventType, functionRef, capture)
{
  if (typeof target.addEventListener != "undefined")
  {
    target.addEventListener(eventType, functionRef, capture);
  }
  else if (typeof target.attachEvent != "undefined")
  {
    target.attachEvent("on" + eventType, functionRef);
  }
  else
  {
    eventType = "on" + eventType;

    if (typeof target[eventType] == "function")
    {
      var oldListener = target[eventType];

      target[eventType] = function()
      {
        oldListener();

        return functionRef();
      };
    }
    else
    {
      target[eventType] = functionRef;
    }
  }
}
//-------------------------------------------
//=======================================================================//
//在第十二章有提到的;取的某一物件的的狀態參數值;
//addLoadListener(init);
/*
function init()
{
  var h1 = document.getElementsByTagName("h1")[0];  //此種方法適用於所有瀏覽器;
  var fontSize = retrieveComputedStyle(h1, "fontSize");
  
  alert("The computed font-size of the h1 is: " + fontSize);   //24pt;
  
  return true;
}
*/
//=======================================================================//
function retrieveComputedStyle(element, styleProperty)
{ //取得物件所有狀態內容值;
  var computedStyle = null;

  if (typeof element.currentStyle != "undefined")
  { //ie
    computedStyle = element.currentStyle;
  }
  else
  { //FireFox 
    computedStyle = document.defaultView.getComputedStyle(element, null);
  }

  return computedStyle[styleProperty];
}
//-------------------------------------------
//=======================================================================//
