// 垂直跑馬燈 作業系統類型判斷
function stopIEFlicker(el)
{  el.link = el.href;
   el.removeAttribute("href");
   el.onclick = clickIEFlicker;
   el.runtimeStyle.behavior="null";
}

function clickIEFlicker()
{  self.location.href = this.link;
   return false;
}

function RenderMasterHead()
{  var _ie5 = (document.all!=null)&& (window.opera==null);
   var sp2 = (navigator.appMinorVersion && navigator.appMinorVersion.toLowerCase().indexOf('sp2') != -1);
   if(_ie5 || document.getBoxObjectFor)
   {  if(window.createPopup || document.getBoxObjectFor )
      {  gObj("nmh").className ="adv";
         gObj("nmh").style.backgroundImage= "url(" + (gAttr(gObj("nmh"),"src") || "") + ")";
      }
      if(_ie5)
      {  var h1 =gObj("nmh").all.tags("h1")[0];
         var hpa = document.createElement("a");
         hpa.style.cssText= "display:block !important;font-size:38%;text-align:left;position:relative;top:53px;left:35px;";
         hpa.innerHTML = "設為首頁";
         var db =document.body;
         db.style.behavior = "url(#default#homepage)";
         hpa.setAttribute("href","javascript:void(0)");
         var hr = "http://tw.yahoo.com";
         self.isHomePage=1;
         document.body.setAsHome = 2;
         if( !db.isHomePage(hr) && ! db.isHomePage(hr +"/"))
         {  self.isHomePage=0;
            document.body.setAsHome = 0;
            hpa.onclick=function()
            {  document.body.setHomePage("http://tw.yahoo.com");
               document.body.setAsHome=1;
               return false;
            }
            h1.appendChild(hpa);
         }
      }
      if(window.createPopup)
      {  var ics = gTags(gObj("nmh"),"icon");
         for(var i=0;i<ics.length;i++)
         {  var s = gAttr(ics[i],"src") || "";
            if(s.indexOf("png")>0)
            {  ics[i].style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+s+"')";
            }
            else if(s.indexOf("gif")>0)
                 {  ics[i].style.height = ics[i].offsetHeight+1 +"px";
                    ics[i].style.backgroundImage="url(" + s+")";
                    ics[i].style.backgroundRepeat = "no-repeat";
                    /*ics[i].innerHTML="<img src='"+s+"'>";*/
                 }
         }
      }
      else
      {  var ics = gTags(gObj("nmh"),"y:icon");
         for(var i=0;i<ics.length;i++)
         {  var s = gAttr(ics[i],"src") || "";
            ics[i].innerHTML="<img src='"+s+"'>";
         }
      }
   }
}
window.appVersion = window.navigator.appVersion;
if(window.appVersion!=null)
{  window.appVersion = window.appVersion.toUpperCase();
   window.MacIE5 = ((window.appVersion.toUpperCase().indexOf("MSIE") >=0) && (window.appVersion.toUpperCase().indexOf("MACINTOSH") >=0) && (window.appVersion.indexOf("5.0") >=0));
}
window.OPR =(window.opera!=null)|| false;
window.IE = (document.all && (!window.OPR))|| false;
window.IE55 = (window.IE && window.createPopup!=null && document.createComment==null) || false;
window.MOZ = (window.outerWidth && !window.OPR && (window.navigator.product!=null)) || false;
window.IE50 = (window.IE && (document.createTextNode!=null) && (window.createPopup==null)) || false;
window.IE60= (window.IE && document.createComment!=null ) || false;
window.IE40 = (document.all && !window.IE50 && !window.IE55 && !window.IE60 &&(window.opera==null) ) || false;
window.MS =( window.navigator.userAgent.toLowerCase().indexOf("windows") >= 0 ) || false;
window.MAC =( window.navigator.appVersion.toLowerCase().indexOf("mac") >= 0 ) || false;
window.CSS1 = (document.compatMode!=null)||false;
window.GDA = (( window.IE55 || window.IE50 || window.MOZ || window.IE60 ) && !window.MAC);
if(window.IE)
{  window.WIN98 = (window.navigator.userAgent.toLowerCase().indexOf("windows 98")>=0);
   /* windows 98 has serous pronlem with DirectX when use filter, we need to remove that;*/
}

function gObj(ID)
{  if(document.getElementById==null)
   {  document.getElementById = document.all;
   }
   if(ID==null)
   {  return null;
   }
   return document.getElementById(ID);
}

function gTags(srcDocument, TagName)
{  if(document.getElementsByTagName==null)
   {  return (new Array());
   }
   if(TagName==null)
   {  return (new Array());
   }
   return srcDocument.getElementsByTagName(TagName);
}

function gAttr(srcObj,attributeName)
{  if(srcObj==null || attributeName==null)
   {  return null;
   }
   if(srcObj.getAttribute == null)
   {  return null;
   }
   attributeName = srcObj.getAttribute(attributeName);
   if(attributeName=="")
   {  attributeName=null;
   }
   return attributeName;
}

function resizeFix()
{  if(!window.IE|| window.Mac )
   {  return;
   }
   if(!window.GDA)
   {  return;
   }
   if(window.baseFont1==null)
   {  window.baseFont1 = document.createElement("div");
      window.baseFont1.innerHTML="&nbsp;";
      window.baseFont1.style.cssText = "position:absolute;top:-5000px;font-size:16px;";
      document.body.insertAdjacentElement("AfterBegin", window.baseFont1);
   }
   if(window.baseFont2==null)
   {  window.baseFont2 = document.createElement("div");
      window.baseFont2.innerHTML="&nbsp;";
      window.baseFont2.style.cssText = "position:absolute;top:-5000px;font-size:100%;";
      document.body.insertAdjacentElement("AfterBegin", window.baseFont2);
      window.baseFont2.onresize = function()
      {  resizeFix();
      }
   }
   var ratio =window.baseFont2.offsetHeight / window.baseFont1.offsetHeight;
   gObj("main").style.width = Math.max( gObj("basewidth").offsetWidth, Math.ceil( ratio * gObj("basewidth").offsetWidth)) +"px";
   window.pageWidth = gObj("main").style.width;
}

function renderBox()
{  return null;
}

function PageLoad()
{  var sbtext=gObj("sbtext");
   SRBoxFox();
}
if(window.attachEvent)
{  window.attachEvent("onload",PageLoad);
}
else if(window.addEventListener)
{  window.addEventListener("load",PageLoad,false);
}
else
{  window.onload = PageLoad;
}

function SRBoxFox(ev)
{  if(self!=top)
   {  return;
   }
   try
   {  gObj("sbtext").focus();
      document.body.scrollTop=0;
      document.documentElement.scrollTop=0;
   }
   catch(e){ }
}

function getKeyCode(evt)
{  if(window.GDA)
   {  evt = evt || event;
      var tg = evt.target || evt.srcElement;
      if(evt.shiftKey && (evt.keyCode==9))
      {  gObj("sbtext").value="";
      }
      var tagName = tg.tagName.toLowerCase();
      if(tagName == "body" || tagName=="div" || tagName=="HTML" || tagName=="a")
      {  if(( (evt.keyCode >=48) &&(evt.keyCode <=57) ) || evt.altKey || ( (evt.keyCode >=65) &&(evt.keyCode <=90) ) )
         {  SRBoxFox();
         }
      }
   }
}
if(self==top)
{  document.onkeydown = getKeyCode;
}
