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.0
  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 && document.getElementById) x=document.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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

var langsBtn = ['en','b5','gb'];
var langsPath = ['english','chinese','sc'];
var langsId = 0;
for(x in langsBtn){
	if(location.href.search('/'+langsPath[x]+'/')!=-1){
		langsId = x;
	}
}
function changeLang(lang) {
	serverside=""
	x=(window.location+'');
	if (x.match('.cgi')!=null) {
		alert("在搜尋結果內不能轉換語言。")
	}else{
		for(x in langsBtn){
			if(lang==langsBtn[x]){
				location.href = location.href.replace('/'+langsPath[langsId]+'/','/'+langsPath[x]+'/')
			}
		}
	}
}

function explain2(url){
stop=window.screen.height-280;
sleft=window.screen.width-310;
window.open(url,'_blank','scrollbars=1,width=300,height=200,top='+stop+',left='+sleft);
}


function explain(url){
window.open(url);
}


//show layer

var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;


function setpost(img, layerid){
	tmp_img = getImage(img);	
	tmp_y = getImagePageTop(tmp_img);
	tmp_x = getImagePageLeft(tmp_img);

//alert(layerid);
	if(isMinIE4){
		obj = eval(layerid);
		obj.style.posLeft = tmp_x + 165;
		obj.style.posTop = tmp_y;		
	}else{
		document.getElementById(layerid).style.left = tmp_x + 165;
		document.getElementById(layerid).style.top = tmp_y;
	}	
}

function setpost2(img, layerid){
	tmp_img = getImage(img);	
	tmp_y = getImagePageTop(tmp_img);
	tmp_x = getImagePageLeft(tmp_img);

//alert(layerid);
	if(isMinIE4){
		obj = eval(layerid);
		obj.style.posLeft = tmp_x + 228;
		obj.style.posTop = tmp_y;		
	}else{
		document.getElementById(layerid).style.left = tmp_x + 394;
		document.getElementById(layerid).style.top = tmp_y + 301;
	}	
}

function getImage(name) {

  if (isMinNS4) {
    return findImage(name, document);
  }
  if (isMinIE4)
    return eval('document.all.' + name);
  return null;
}

function findImage(name, doc) {

  var i, img;

  for (i = 0; i < doc.images.length; i++)
    if (doc.images[i].name == name)
      return doc.images[i];
  for (i = 0; i < doc.layers.length; i++)
    if ((img = findImage(name, doc.layers[i].document)) != null) {
      img.container = doc.layers[i];
      return img;
    }
  return null;
}

function getImagePageTop(img) {

  var y, obj;

  if (isMinNS4) {
    if (img.container != null)
      return img.container.pageY + img.y;
    else
      return img.y;
  }
  if (isMinIE4) {
    y = 0;
    obj = img;
    while (obj.offsetParent != null) {
      y += obj.offsetTop;
      obj = obj.offsetParent;
    }
    y += obj.offsetTop;
    return y;
  }
  return -1;
}

function getImagePageLeft(img) {

  var x, obj;

  if (isMinNS4) {
    if (img.container != null)
      return img.container.pageX + img.x;
    else
      return img.x;
  }
  if (isMinIE4) {
    x = 0;
    obj = img;
    while (obj.offsetParent != null) {
      x += obj.offsetLeft;
      obj = obj.offsetParent;
    }
    x += obj.offsetLeft;
    return x;
  }
  return -1;
}

