function loaddata(fname) {
  httpObj = createXMLHttpRequest(displayData);
  if (httpObj) {
    httpObj.open("GET", fname, true);
    httpObj.send(null);
  }
  xhttpObj = createXMLHttpRequest(displayData2);
  if (xhttpObj) {
    xhttpObj.open("GET", "dat/overseas.xml", true);
    xhttpObj.send(null);
  }
}

function displayData() {
  if ((httpObj.readyState == 4) && (httpObj.status == 200)) {
	xmlData = httpObj.responseXML;
	tabs = xmlData.getElementsByTagName("Table");
	for (i=0; i<tabs.length; i++) {
		text = tabs[i].getElementsByTagName("Branch")[0].firstChild.nodeValue;
		value =	tabs[i].getElementsByTagName("Address")[0].firstChild.nodeValue + "|" +
			tabs[i].getElementsByTagName("Tel")[0].firstChild.nodeValue  + "|" +
			tabs[i].getElementsByTagName("Fax")[0].firstChild.nodeValue + "|" +
			tabs[i].getElementsByTagName("Postcode")[0].firstChild.nodeValue  + "|" +
			tabs[i].getElementsByTagName("Web")[0].firstChild.nodeValue;
	document.form1.s0.options[i] = new Option(text, value);
	}

document.all.tab_name.innerHTML = document.form1.s0.options[0].text;
document.all.tab_post.innerHTML = "Postcode: " + document.form1.s0.options[0].value.split('|')[3];
document.all.tab_addr.innerHTML = document.form1.s0.options[0].value.split('|')[0] ;
document.all.tab_tel.innerHTML = document.form1.s0.options[0].value.split('|')[1] ;
document.all.tab_fax.innerHTML = document.form1.s0.options[0].value.split('|')[2];
document.all.tab_web.innerHTML = "<a href='" + document.form1.s0.options[0].value.split('|')[4] + "' target='_blank'>" +document.form1.s0.options[0].value.split('|')[4] + "</a>";
  }
}

function displayData2() {
  if ((xhttpObj.readyState == 4) && (xhttpObj.status == 200)) {
	xxmlData = xhttpObj.responseXML;
	xtabs = xxmlData.getElementsByTagName("Table");
	for(i=0; i<xtabs.length; i++) {
		xtext = xtabs[i].getElementsByTagName("Branch")[0].firstChild.nodeValue;
		xvalue = xtabs[i].getElementsByTagName("Address")[0].firstChild.nodeValue;
		xvalue = xvalue + "|" + xtabs[i].getElementsByTagName("Tel")[0].firstChild.nodeValue;
		xvalue = xvalue + "|" + xtabs[i].getElementsByTagName("Fax")[0].firstChild.nodeValue;
		try {
			xvalue = xvalue + "|" + xtabs[i].getElementsByTagName("BIC")[0].firstChild.nodeValue;
		} catch(e) {
			xvalue = xvalue + "|";
		}
		try {
			xvalue = xvalue + "|" + xtabs[i].getElementsByTagName("Web")[0].firstChild.nodeValue;
		} catch(e) {
			xvalue = xvalue + "|";
		}
		try {
			xvalue = xvalue + "|" + xtabs[i].getElementsByTagName("e-mail")[0].firstChild.nodeValue;
		} catch(e) {
			xvalue = xvalue + "|";
		}
		try {
			xvalue = xvalue + "|" + xtabs[i].getElementsByTagName("Telex")[0].firstChild.nodeValue;
		} catch(e) {
			xvalue = xvalue + "|";
		}
		document.form2.s2.options[i] = new Option(xtext, xvalue);
	}
  }

}
// 
function createXMLHttpRequest(cbFunc) {
  var XMLhttpObject = null;
  try{
    XMLhttpObject = new XMLHttpRequest();
  } catch(e){
    try{
      XMLhttpObject = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e){
      try{
        XMLhttpObject = new ActiveXObject("Microsoft.XMLHTTP");
      }catch(e){
        return null;
      }
    }
  }

  if (XMLhttpObject) XMLhttpObject.onreadystatechange = cbFunc;
  return XMLhttpObject;
}

function dispOption(oj) {
document.all.tab_name.innerHTML = oj.options[oj.selectedIndex].text;
document.all.tab_post.innerHTML = "Postcode: " + oj.options[oj.selectedIndex].value.split('|')[3];
document.all.tab_addr.innerHTML = oj.options[oj.selectedIndex].value.split('|')[0] ;
document.all.tab_tel.innerHTML = oj.options[oj.selectedIndex].value.split('|')[1]
document.all.tab_fax.innerHTML = oj.options[oj.selectedIndex].value.split('|')[2]
document.all.tab_web.innerHTML = "<a href='" + oj.options[oj.selectedIndex].value.split('|')[4] + "' target='_blank'>" + oj.options[oj.selectedIndex].value.split('|')[4] + "</a>";

document.all.tab_email_txt.innerHTML = "";
document.all.tab_telex_txt.innerHTML = "";
document.all.tab_bic_txt.innerHTML = "";
document.all.tab_email.innerHTML = "";
document.all.tab_telex.innerHTML = "";
document.all.tab_bic.innerHTML = "";

}

function dispOption2(xoj) {
document.all.tab_name.innerHTML = xoj.options[xoj.selectedIndex].text;
document.all.tab_addr.innerHTML = "";
document.all.tab_post.innerHTML = xoj.options[xoj.selectedIndex].value.split('|')[0];
document.all.tab_tel.innerHTML = xoj.options[xoj.selectedIndex].value.split('|')[1]
document.all.tab_fax.innerHTML = xoj.options[xoj.selectedIndex].value.split('|')[2]
document.all.tab_web.innerHTML = "<a href='http://" + xoj.options[xoj.selectedIndex].value.split('|')[4] + "' target='_blank'>" + xoj.options[xoj.selectedIndex].value.split('|')[4] + "</a>";

document.all.tab_email_txt.innerHTML = "e-mail: ";
document.all.tab_telex_txt.innerHTML = "テレックス: ";
document.all.tab_bic_txt.innerHTML = "SWIFT BIC: ";
document.all.tab_email.innerHTML = xoj.options[xoj.selectedIndex].value.split('|')[5];
document.all.tab_telex.innerHTML = xoj.options[xoj.selectedIndex].value.split('|')[6];
document.all.tab_bic.innerHTML = xoj.options[xoj.selectedIndex].value.split('|')[3];

}

