// globalallience.js

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function judgeIsNetscape () {
  if (window.navigator.appName.match (/Netscape/)) {
    window.isNetscape = true;
  } else {
    window.isNetscape = false;
  }
}

function setDivBackgroundImage(div,url){
  div.style.backgroundImage=url?('url('+url+')'):'none';
}

function setBackgroundImage(btn, visible) {
  var url;
  var div = MM_findObj(btn);
  if (visible) {
    url = 'image/'+btn+'-on.jpg';
  } else {
    url = 'image/'+btn+'-off.jpg';
  }
  setDivBackgroundImage(div, url);
}

function setMenuVisibility(btn, visible) {
  if (visible) {
    MM_swapImage(btn,'','image/'+btn+'-on.gif',1);
  } else {
    MM_swapImgRestore();
  }
}

function getLayerObject (idName){  

  if (document.getElementById) 
      return document.getElementById (idName).style;
      
  else if (document.all)       
      return document.all (idName).style;
      
  else if (document.layers)    
      return document.layers[idName];
  
}

function topPageGetMenuTop () {

  var tableHeight = 453;
  var windowHeight;
  var topBasis = 0;

  var tableWidth;
  var windowWidth;

  var menuTop;

  if (!window.isNetscape) {
    windowHeight = document.body.clientHeight;
    tableWidth = tableMain.width;
    windowWidth = document.body.clientWidth;
  } else {
    windowHeight = 0;
    tableWidth = 0;
    windowWidth = 0;
  }

  if (tableHeight <= windowHeight) {
    menuTop = (windowHeight - tableHeight) / 2 + topBasis;
  } else {
    menuTop = topBasis;
  }

  if (tableHeight <= windowHeight &&  windowWidth < tableWidth ) {
    menuTop = menuTop + 8.5;
  }

  return Math.floor (menuTop);
}

function topPageGetMenuLeft () {

  var leftBasis = 1;
  var tableWidth;
  var windowWidth;
  var menuLeft;

  if (!window.isNetscape) {
    tableWidth = tableMain.width;
    windowWidth = document.body.clientWidth;
  } else {
    tableWidth = 0;
    tableWidth = document.getElementById ("tableMain").width;
    windowWidth = window.innerWidth;
  }

  if (tableWidth <= windowWidth) {
    menuLeft = (windowWidth - tableWidth) / 2 + leftBasis;
  } else {
    menuLeft = leftBasis;
  }

  return Math.floor (menuLeft);
}

function getMenuTop () {
  return 90;
}

function getMenuLeft () {
  var leftBasis = 1;
  var tableWidth;
  var windowWidth;
  var menuLeft;

  if (!window.isNetscape) {
    tableWidth = tableMain.width;
    windowWidth = document.body.clientWidth;
  } else {
    tableWidth = 0;
    tableWidth = document.getElementById ("tableMain").width;
    windowWidth = window.innerWidth - 15;
  }

  if (tableWidth <= windowWidth) {
    menuLeft = (windowWidth - tableWidth) / 2 + leftBasis;
  } else {
    menuLeft = leftBasis;
  }

  return Math.floor (menuLeft);
}

function showMenu (left, top) {
  menu = getLayerObject ("menuFlash");

  menu.top = top;
  menu.left = left;
  menu.visibility = "visible";
}

function hideMenu () {
  menu = getLayerObject ("menuFlash");

  menu.visibility = "hidden";
}

function topPageWriteMenu (name, classid) {

  document.write ("<div id=\"menuFlash\"");
  document.write ("style=\"position:absolute; top:0; left:0; visibility:hidden;\">");
  document.write ("<A HREF=\"contact.html\"></A> <A HREF=\"service.html\"></A> <A HREF=\"press.html\"></A>");
  document.write ("<A HREF=\"sitemap.html\"></A> <A HREF=\"index.html\"></A> <A HREF=\"aboutus_adviser.html\"></A>");
  document.write ("<A HREF=\"aboutus_officer.html\"></A> <A HREF=\"aboutus.html\"></A> <A HREF=\"service_portfolio.html\"></A>");
  document.write ("<OBJECT classid=\"clsid:" + classid + "\"");
  document.write (" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"");
  document.write (" WIDTH=\"743\" HEIGHT=\"105\" id=\"" + name + "\" ALIGN=\"\">");
  document.write ("<PARAM NAME=movie VALUE=\"" + name + ".swf\">");
  document.write ("<PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF>");
  document.write ("<PARAM NAME=wmode VALUE=transparent>");
  document.write ("<EMBED src=\"" + name + ".swf\" quality=high wmode=transparent bgcolor=#FFFFFF");
  document.write (" WIDTH=\"743\" HEIGHT=\"105\" NAME=\"" + name + "\" ALIGN=\"\"");
  document.write (" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\">");
  document.write ("</EMBED>");
  document.write ("</OBJECT>");

  document.write ("</div>");
}

function writeMenu (name, classid) {

  document.write ("<div id=\"menuFlash\"");
  document.write ("style=\"position:absolute; top:0; left:0; visibility:hidden;\">");
  document.write ("<A HREF=\"contact.html\"></A> <A HREF=\"service.html\"></A> <A HREF=\"press.html\"></A>");
  document.write ("<A HREF=\"sitemap.html\"></A> <A HREF=\"index.html\"></A> <A HREF=\"aboutus_adviser.html\"></A>");
  document.write ("<A HREF=\"aboutus_officer.html\"></A> <A HREF=\"aboutus.html\"></A> <A HREF=\"service_portfolio.html\"></A>");
  document.write ("<OBJECT classid=\"clsid:" + classid + "\"");
  document.write (" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"");
  document.write (" WIDTH=\"737\" HEIGHT=\"105\" id=\"" + name + "\" ALIGN=\"\">");
  document.write ("<PARAM NAME=movie VALUE=\"" + name + ".swf\">");
  document.write ("<PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF>");
  document.write ("<PARAM NAME=wmode VALUE=transparent>");
  document.write ("<EMBED src=\"" + name + ".swf\" quality=high wmode=transparent bgcolor=#FFFFFF");
  document.write (" WIDTH=\"737\" HEIGHT=\"105\" NAME=\"" + name + "\" ALIGN=\"\"");
  document.write (" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\">");
  document.write ("</EMBED>");
  document.write ("</OBJECT>");

  document.write ("</div>");
}

function StyleSheet () {

        sheet_default = 'css.css';
        sheet_macie = 'macie.css';

        user_agent = navigator.userAgent;

        if (user_agent.match (/MSIE.*Mac/)) {
          document.write ("<link href=\"" + sheet_macie + "\" rel=\"stylesheet\" type=\"text/css\">");
        } else {
          document.write ("<link href=\"" + sheet_default + "\" rel=\"stylesheet\" type=\"text/css\">");
        }
}

