﻿var isIE	= (navigator.appName=="Microsoft Internet Explorer")?true:false;

function GenTaxXML(xmlfile, roottag, taxclassname) {
  var x = XmlLoading(xmlfile, roottag)
  
  if (x!=null) {

    for (var i=0;i<x.length;i++)
      for (var j=0; j<x[i].childNodes.length; j++) {
        document.write ("<span class=\"" + taxclassname + "\"><b>"+x[i].getElementsByTagName("items")[j].getElementsByTagName("title")[0].childNodes[0].nodeValue+"</b><br></span>");

	var totalnodes = x[i].getElementsByTagName("items")[j].getElementsByTagName("content")[0].childNodes.length;
	if (navigator.appName!="Microsoft Internet Explorer") totalnodes = (totalnodes - 1)/2

	document.write ("<ul class=\"" + taxclassname + "\" type=\"square\">")
	for (var k=0; k<totalnodes; k++) 
	  document.write ("<li>"+x[i].getElementsByTagName("items")[j].getElementsByTagName("content")[0].getElementsByTagName("c")[k].childNodes[0].nodeValue+"</li>");
	document.write ("</ul>")
      }
  }
}

function GenTaxXMLContent(xmlfile, roottag, taxclassname) {
  var x = XmlLoading(xmlfile, roottag)
  
  if (x!=null) {

    for (var i=0;i<x.length;i++)
      for (var j=0; j<x[i].childNodes.length; j++) {
        document.write ("<span style=\" border-left:11px solid " +x[i].getElementsByTagName("items")[j].getElementsByTagName("title")[0].attributes.getNamedItem("color1").value+ "; border-top:0px outset  " +x[i].getElementsByTagName("items")[j].getElementsByTagName("title")[0].attributes.getNamedItem("color1").value+ "; height: 15px;  color:"+ x[i].getElementsByTagName("items")[j].getElementsByTagName("title")[0].attributes.getNamedItem("color1").value +"\" class=\"" + taxclassname + "\">&nbsp;"+x[i].getElementsByTagName("items")[j].getElementsByTagName("title")[0].childNodes[0].nodeValue+"<br></span>");
	
	var totalnodes = x[i].getElementsByTagName("items")[j].getElementsByTagName("content")[0].childNodes.length;
	if (navigator.appName!="Microsoft Internet Explorer") totalnodes = (totalnodes - 1)/2

	document.write ("<ul class=\"" + taxclassname + "\" type=\"square\">")
	for (var k=0; k<totalnodes; k++) 
	  document.write ("<li style=\"margin-left:20px;\">"+x[i].getElementsByTagName("items")[j].getElementsByTagName("content")[0].getElementsByTagName("c")[k].childNodes[0].nodeValue+"</li>");
	document.write ("</ul>")
      }
  }
}


function checkGuiaNull(generalList,node){
    try{
        if(node!="")
        return generalList.getElementsByTagName(node)[0].firstChild.nodeValue;
    }catch(err){
        return "";
    }
}

function GenGuiaXMLContent(xmlfile, roottag, taxclassname) {
  var x = XmlImport(xmlfile, roottag)
  
  if (x!=null) {
    var generalList=x[0].getElementsByTagName("General")[0];
    
    var generalListNodes = (isIE)?x[0].getElementsByTagName("General")[0].childNodes.length:(x[0].getElementsByTagName("General")[0].childNodes.length - 1)/2;
    //document.write(x[0].getElementsByTagName("General")[0].childNodes[0].getAttribute("value"));
       // document.write (generalList.getElementsByTagName("ServiceNumber")[0].firstChild.nodeValue);
      

       document.write (checkGuiaNull(generalList,"Category"));

        document.write ("<br>");
    

       document.write (checkGuiaNull(generalList,"AgencyCode"));

    
        document.write ("<br>");
    

       document.write (checkGuiaNull(generalList,"ServiceNumber"));

    
        document.write ("<br>");
        

       document.write (checkGuiaNull(generalList,"ServiceName"));

    
        document.write ("<br>");
    

       document.write (checkGuiaNull(generalList,"Description"));

    
        document.write ("<br>");
 
       document.write (checkGuiaNull(generalList,"Agency"));

        document.write ("<br>");
    
 
       document.write (checkGuiaNull(generalList,"RelevantAgency"));

    
        document.write ("<br>");
        

       document.write (checkGuiaNull(generalList,"Location"));
 
    
        document.write ("<br>");
    
  
       document.write (checkGuiaNull(generalList,"WorkingHour"));

    
        document.write ("<br>");
    

       document.write (checkGuiaNull(generalList,"Inquiry"));

       
//    for (var m=0;m<generalListNodes;m++){ 
//        try{
//         document.write (generalList.childNodes[(isIE)?m:m*2+1].firstChild.nodeValue);
//         
//         
//         
//         
//        }catch(err){}
//    }
 
    document.writeln("<br><br>");
    
    var applicationListNodes = (isIE)?x[0].getElementsByTagName("Application").length:(x[0].getElementsByTagName("Application").length - 1)/2;
    
    for(var k=0;k<applicationListNodes;k++){
    
    document.write(k+"<hr>");
        var applicationList=x[0].getElementsByTagName("Application")[(isIE)?k:k*2+1];
        
        document.write (checkGuiaNull(applicationList,"ApplicationNumber"));

        document.write ("<br>");
    

        document.write (checkGuiaNull(applicationList,"ApplicationType"));


        document.write ("<br>");


        document.write (checkGuiaNull(applicationList,"RelevantService"));


        document.write ("<br>");


        document.write (checkGuiaNull(applicationList,"ServingTarget"));


        document.write ("<br>");


        document.write (checkGuiaNull(applicationList,"Requirement"));


        document.write ("<br>");

        document.write (checkGuiaNull(applicationList,"Method"));

        document.write ("<br>");


        document.write (checkGuiaNull(applicationList,"RequiredDocument"));


        document.write ("<br>");


        document.write (checkGuiaNull(applicationList,"SupplementaryDocument"));


        document.write ("<br>");


        document.write (checkGuiaNull(applicationList,"OtherSupportingDocument"));


        document.write ("<br>");


        document.write (checkGuiaNull(applicationList,"DocumentToPresent"));
        
        
        document.write (checkGuiaNull(applicationList,"Fee"));


        document.write ("<br>");



        document.write (checkGuiaNull(applicationList,"Deposit"));


        document.write ("<br>");



        document.write (checkGuiaNull(applicationList,"FeeDescription"));


        document.write ("<br>");
        
        document.write (checkGuiaNull(applicationList,"ProcessingTime"));


        document.write ("<br>");
        
        document.write (checkGuiaNull(applicationList,"QualityIndex"));


        document.write ("<br>");
        
        document.write (checkGuiaNull(applicationList,"DownloadForm"));


        document.write ("<br>");
        
        document.write (checkGuiaNull(applicationList,"ArticleUrl"));


        document.write ("<br>");

    }
 /*   
    var applicationListNodes = (isIE)?x[0].getElementsByTagName("Application")[0].childNodes.length:(x[0].getElementsByTagName("Application")[0].childNodes.length - 1)/2;
    
    
    for(var k=0;k<applicationListNodes;k++){
        var applicationList=x[0].getElementsByTagName("Application")[(isIE)?k:k*2+1];
        document.write("<a name='anchor"+ k +"' /><div style='text-align:right; width:800px; background:#edcded'><a href='#anchor"+ k +"' id='expand"+ k +"' onclick='showhideGuia(app"+ k +", expand"+ k +")'>[-]</a></div><div id='app" + k + "' >");
        
        var applicationListNodes = (isIE)?x[0].getElementsByTagName("Application")[0].childNodes.length:(x[0].getElementsByTagName("Application")[0].childNodes.length - 1)/2;
        
        for (var m=0;m<applicationList.length;m++){ 
            try{
            document.writeln (applicationList[(isIE)?m:m*2+1].childNodes[0].nodeValue);
            }catch(err){}
        }
        document.writeln("</div>");
       
    } */
    

    }
  
}

function showhideGuia(div1,button1){
    if(button1.innerHTML == "[-]"){
        div1.style.display = "none";
        button1.innerHTML = "[+]";
    }else{
        div1.style.display = "block";
        button1.innerHTML = "[-]";
    }
    
}


function XmlImport(xfile, roottag) {
  var xmlDoc=null;
  var x = null;

  if (window.ActiveXObject) xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  else if (document.implementation.createDocument) xmlDoc=document.implementation.createDocument("","",null);
  else alert('Your browser cannot handle this script');

  if (xmlDoc!=null) {
    xmlDoc.async=false;

    if (xmlDoc.load(xfile)) {
      x = xmlDoc.getElementsByTagName(roottag);
    } else x = null;
    //} else document.write("Could not read data file : " + xfile);
  } else document.write("Your browser cannot handle this script!!");

  return x;
}


function GenSitemapXMLContent(xmlfile, roottag, taxclassname) {
  var x = XmlLoading(xmlfile, roottag)
  
  if (x!=null) {
	document.write("<tr height='20'><td width='50%'></td><td width='50%'></td></tr>");
    for (var i=0;i<x.length;i++)
      for (var j=0; j<x[i].childNodes.length; j++) {
	if(j%2==0){

		document.write("<tr valign='top'><td>");
	}else{
		document.write("<td>");
	}

	if(x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("link").value!=""){
        document.write ("<div style='height: 30px;'><div id='LayerLR' style='background-image: url(/images/Head_Layer_L.gif); width:40px;'></div><div style='float:left; height:100%; background-image: url(/images/Head_Layer_Bg.gif); text-align:center;'><span style='filter:Glow(color=#ffffff, strength=6); height: 22px; font-size: 16px; color: #00614d; font-family:新細明體; font-weight: bold; padding: 0 0 0 10;'>"
	+"<a href='"+x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("link").value
	+"'  target='"+x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("target1").value
	+"' class='newsout1' onmouseover=\"this.className='newsover1'\" onmouseout=\"this.className='newsout1'\">"
	+x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("name").value+ "</a></span></div><div id='LayerLR' style='background-image: url(/images/Head_Layer_R.gif); width:40px;'></div></div>");
	}
	else
	{
		document.write ("<div style='height: 30px;'><div id='LayerLR' style='background-image: url(/images/Head_Layer_L.gif); width:40px;'></div><div style='float:left; height:100%; background-image: url(/images/Head_Layer_Bg.gif); text-align:center;'><span style='filter:Glow(color=#ffffff, strength=6); height: 22px; font-size: 16px; color: #00614d; font-family:新細明體; font-weight: bold; padding: 0 0 0 10;'>"
		+x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("name").value+ "</span></div><div id='LayerLR' style='background-image: url(/images/Head_Layer_R.gif); width:40px;'></div></div>");
	}

	var totalnodes = x[i].getElementsByTagName("menu")[j].childNodes.length;
	if (navigator.appName!="Microsoft Internet Explorer") totalnodes = (totalnodes - 1)/2
	
	for (var k=0; k<totalnodes; k++) {
		document.write ("<div style='height: 30px; margin-left:20px;'><div id='LayerLR' style='background-image: url(/images/Sub_Layer_L.gif); width:39px;'></div><div style='float:left; height:100%; background-image: url(/images/Sub_Layer_Bg.gif); text-align:center;'><span id='SubLayerC'>" 
		+"<a href='"+x[i].getElementsByTagName("menu")[j].getElementsByTagName("chapter")[k].attributes.getNamedItem("link").value
		+"'  target='"+x[i].getElementsByTagName("menu")[j].getElementsByTagName("chapter")[k].attributes.getNamedItem("target1").value
		+"' class='newsout1' onmouseover=\"this.className='newsover1'\" onmouseout=\"this.className='newsout1'\">"
		+x[i].getElementsByTagName("menu")[j].getElementsByTagName("chapter")[k].attributes.getNamedItem("name").value
		+ "</a></span></div><div id='LayerLR' style='background-image: url(/images/Sub_Layer_R.gif); width:35px;'></div></div>");
	
	}
	if(j%2==1){
		document.write("</td></tr>");
		document.write("<tr height='40'><td width='50%'></td><td width='50%'></td></tr>");
	}else{
		document.write("</td>");
	}

      }
  }
}

function GenPSitemapXMLContent(xmlfile, roottag, taxclassname) {
  var x = XmlLoading(xmlfile, roottag)
  
  if (x!=null) {
	document.write("<tr height='20'><td width='50%'></td><td width='50%'></td></tr>");
    for (var i=0;i<x.length;i++)
      for (var j=0; j<x[i].childNodes.length; j++) {
	if(j%2==0){
		if(j==2)
		document.write("<tr valign='top' ><td colspan='2'>");
		else
		document.write("<tr valign='top' ><td>");
	}else{
		if(j==2)
		document.write("<tr valign='top' ><td colspan='2'>");
		else
		document.write("<td>");
	}

	if(x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("link").value!=""){
        document.write ("<div style='height: 30px;'><div id='LayerLR' style='background-image: url(/images/Head_Layer_L.gif); width:40px;'></div><div style='float:left; height:100%; background-image: url(/images/Head_Layer_Bg.gif); text-align:center;'><span style='filter:Glow(color=#ffffff, strength=6); height:22px; color: #00614d; font-family: Verdana; font-weight: bold; letter-spacing:-1px; padding: 0 0 0 10; font-size: 16px;'>"
	+"<a href='"+x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("link").value
	+"'  target='"+x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("target1").value
	+"' class='newsout1' onmouseover=\"this.className='newsover1'\" onmouseout=\"this.className='newsout1'\">"
	+x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("name").value+ "</a></span></div><div id='LayerLR' style='background-image: url(/images/Head_Layer_R.gif); width:40px;'></div></div>");	
	}
	else
	{
		document.write ("<div style='height: 30px;'><div id='LayerLR' style='background-image: url(/images/Head_Layer_L.gif); width:40px;'></div><div style='float:left; height:100%; background-image: url(/images/Head_Layer_Bg.gif); text-align:center;'><span style='filter:Glow(color=#ffffff, strength=6); height:22px; color: #00614d; font-family: Verdana; font-weight: bold; letter-spacing:-1px; padding: 0 0 0 10; font-size: 16px;'>"
		+x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("name").value+ "</span></div><div id='LayerLR' style='background-image: url(/images/Head_Layer_R.gif); width:40px;'></div></div>");
	}	

	var totalnodes = x[i].getElementsByTagName("menu")[j].childNodes.length;
	if (navigator.appName!="Microsoft Internet Explorer") totalnodes = (totalnodes - 1)/2
	
	for (var k=0; k<totalnodes; k++) {
		document.write ("<div style='height: 30px; margin-left:20px;'><div id='LayerLR' style='background-image: url(/images/Sub_Layer_L.gif); width:39px;'></div><div style='float:left; height:100%; background-image: url(/images/Sub_Layer_Bg.gif); text-align:center;'><span id='SubLayerE'>" 
		+"<a href='"+x[i].getElementsByTagName("menu")[j].getElementsByTagName("chapter")[k].attributes.getNamedItem("link").value
		+"'  target='"+x[i].getElementsByTagName("menu")[j].getElementsByTagName("chapter")[k].attributes.getNamedItem("target1").value
		+"' class='newsout1' onmouseover=\"this.className='newsover1'\" onmouseout=\"this.className='newsout1'\">"
		+x[i].getElementsByTagName("menu")[j].getElementsByTagName("chapter")[k].attributes.getNamedItem("name").value
		+ "</a></span></div><div id='LayerLR' style='background-image: url(/images/Sub_Layer_R.gif); width:35px;'></div></div>");
	
	}
	if(j%2==1){
		if(j==2){
		document.write("</td></tr>");
		document.write("<tr height='40'><td width='50%'></td><td width='50%'></td></tr>");
		}
		else{
		document.write("</td></tr>");
		document.write("<tr height='40'><td width='50%'></td><td width='50%'></td></tr>");
		}
	}else{
		if(j==2){
		document.write("</td></tr>");
		document.write("<tr height='40'><td width='50%'></td><td width='50%'></td></tr>");
		}else
		document.write("</td>");
	}

      }
  }
}

function GenESitemapXMLContent(xmlfile, roottag, taxclassname) {
  var x = XmlLoading(xmlfile, roottag)
  
  if (x!=null) {
	document.write("<tr height='20'><td width='50%'></td><td width='50%'></td></tr>");
    for (var i=0;i<x.length;i++)
      for (var j=0; j<x[i].childNodes.length; j++) {
	if(j%2==0){
		if(j==4)
		document.write("<tr valign='top' ><td colspan='2'>");
		else
		document.write("<tr valign='top' ><td>");
	}else{
		if(j==4)
		document.write("<tr valign='top' ><td colspan='2'>");
		else
		document.write("<td>");
	}

	if(x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("link").value!=""){
        document.write ("<div style='height: 30px;'><div id='LayerLR' style='background-image: url(/images/Head_Layer_L.gif); width:40px;'></div><div style='float:left; height:100%; background-image: url(/images/Head_Layer_Bg.gif); text-align:center;'><span style='filter:Glow(color=#ffffff, strength=6); height:22px; color: #00614d; font-family: Verdana; font-weight: bold; letter-spacing:-1px; padding: 0 0 0 10; font-size: 16px;'>"
	+"<a href='"+x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("link").value
	+"'  target='"+x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("target1").value
	+"' class='newsout1' onmouseover=\"this.className='newsover1'\" onmouseout=\"this.className='newsout1'\">"
	+x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("name").value+ "</a></span></div><div id='LayerLR' style='background-image: url(/images/Head_Layer_R.gif); width:40px;'></div></div>");		
	}
	else
	{
		document.write ("<div style='height: 30px;'><div id='LayerLR' style='background-image: url(/images/Head_Layer_L.gif); width:40px;'></div><div style='float:left; height:100%; background-image: url(/images/Head_Layer_Bg.gif); text-align:center;'><span style='filter:Glow(color=#ffffff, strength=6);height:22px; color: #00614d; font-family: Verdana; font-weight: bold; letter-spacing:-1px; padding: 0 0 0 10; font-size: 16px;'>"
		+x[i].getElementsByTagName("menu")[j].attributes.getNamedItem("name").value+ "</span></div><div id='LayerLR' style='background-image: url(/images/Head_Layer_R.gif); width:40px;'></div></div>");
	}

	var totalnodes = x[i].getElementsByTagName("menu")[j].childNodes.length;
	if (navigator.appName!="Microsoft Internet Explorer") totalnodes = (totalnodes - 1)/2
	
	for (var k=0; k<totalnodes; k++) {
		document.write ("<div style='height: 30px; margin-left:20px;'><div id='LayerLR' style='background-image: url(/images/Sub_Layer_L.gif); width:39px;'></div><div style='float:left; height:100%; background-image: url(/images/Sub_Layer_Bg.gif); text-align:center;'><span id='SubLayerE'>" 
		+"<a href='"+x[i].getElementsByTagName("menu")[j].getElementsByTagName("chapter")[k].attributes.getNamedItem("link").value
		+"'  target='"+x[i].getElementsByTagName("menu")[j].getElementsByTagName("chapter")[k].attributes.getNamedItem("target1").value
		+"' class='newsout1' onmouseover=\"this.className='newsover1'\" onmouseout=\"this.className='newsout1'\">"
		+x[i].getElementsByTagName("menu")[j].getElementsByTagName("chapter")[k].attributes.getNamedItem("name").value
		+ "</a></span></div><div id='LayerLR' style='background-image: url(/images/Sub_Layer_R.gif); width:35px;'></div></div>");
	
	}
	if(j%2==1){
		if(j==4){
		document.write("</td></tr>");
		document.write("<tr height='40'><td width='50%'></td><td width='50%'></td></tr>");
		}
		else{
		document.write("</td></tr>");
		document.write("<tr height='40'><td width='50%'></td><td width='50%'></td></tr>");
		}
	}else{
		if(j==4){
		document.write("</td></tr>");
		document.write("<tr height='40'><td width='50%'></td><td width='50%'></td></tr>");
		}else
		document.write("</td>");
	}

      }
  }
}

