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_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_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 Search_InitWin()
{
  	var nJob = GetUrlQueryParam("j");
  	var sCate = GetUrlQueryParam("c");
  	var sSCate =  GetUrlQueryParam("sc");
  	var sFig =  GetUrlQueryParam("f");

  	parent.list.document.all("data").innerHTML = "";
  	parent.info.document.all("data").innerHTML = "";

}


function Search_goSearchOnClick()
{
  	if(document.inputform.searchvalue.value == "version8192")
	{
		//20070712var Version_No = gVersion_Version_No;
		var Version_No = "1.70";//20080912 Version

    	alert("Version "+Version_No);
  	}
	else
	{
		parent.list.gConnNo = "";//20070706add
  		parent.list.document.all("data").innerHTML = Search_SearchConnecter(document.inputform.searchfield,document.inputform.searchvalue);
  		parent.info.document.all("data").innerHTML = "";
	}
}


function Search_KeyDown()
{
    if(event.keyCode == 13)
	{
      	Search_goSearchOnClick();
      	return false;
    }
}


function Search_SearchConnecter(vCheckbox, vTextbox)
{
  	var sRet = "";
  	var search_mode = "name";
	var ndMode = "";
  	var sFilter = "";

	var length = vCheckbox.length;
    for(var i = 0; i < length; i++)
	{
      	if(vCheckbox[i].checked)
		{
        	switch(i)
			{
          	case 0:
				search_mode = "name";
  				sFilter="name";

            	break;
          	case 1:
				search_mode = "no";
  				sFilter = "@no";

            	break;
        	}

      	}
    }

  	sFilter = "/connector/con" + "[" + sFilter + "]";

	if(parent.gmsxv == "4")
	{//4.0
  		var oDoc = new ActiveXObject("msxml2.DOMDocument.4.0");
  		oDoc.async = false;
  		oDoc.load(gConXmlfile);
  		var oStl = new ActiveXObject("msxml2.DOMDocument.4.0");
	}
	else if(parent.gmsxv == "3")
	{//3.0
  		var oDoc = new ActiveXObject("msxml2.DOMDocument.3.0");
  		oDoc.async = false;
  		oDoc.load(gConXmlfile);
  		var oStl = new ActiveXObject("msxml2.DOMDocument.3.0");
	}
	else if(parent.gmsxv == "0")
	{
		Open_XML_Message();
		return;
	}
	else
	{
		alert(gMsxmlVersion_Error3);
		return;
	}
  	oStl.setProperty("SelectionLanguage","XPath");
  	oStl.setProperty("SelectionNamespaces","xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
  	oStl.async = false;
  	oStl.load(gConXslfile);

	if(search_mode == "name")
	{//name sort
  		ndMode = oStl.selectSingleNode("//xsl:variable[@name='viewmode']");
  		ndMode.text = "list";
  		ndMode = oStl.selectSingleNode("//xsl:variable[@name='ConnectorList']");
  		ndMode.text = gConnctorInfomation_ConnectorList;
	}
	else
	{//No. sort
  		ndMode = oStl.selectSingleNode("//xsl:variable[@name='viewmode']");
  		ndMode.text = "list4";
  		ndMode = oStl.selectSingleNode("//xsl:variable[@name='ConnectorList']");
  		ndMode.text = gConnctorInfomation_ConnectorNumberList;
	}

	if(parent.gmsxv == "4")
	{//4.0
  		var oWDoc = new ActiveXObject("msxml2.DOMDocument.4.0");
	}
	else if(parent.gmsxv == "3")
	{//3.0
	  	var oWDoc = new ActiveXObject("msxml2.DOMDocument.3.0");
	}

  	var ndWk = oWDoc.createNode("1","connector","");
  	var ndPickup = oDoc.selectNodes(sFilter);
	var length = ndPickup.length;
	for(var i = 0; i < length; i++)
	{
    	ndWk.appendChild(ndPickup.item(i));
  	}

  	oWDoc.appendChild(ndWk);

  	sRet = oWDoc.transformNode(oStl);

	if(vTextbox.value)
	{
		var serch_result = "";
		var serch_line = "";
		var serch_name = "";
		var serch_no = "";
		var p0;
		var p1;
		var p2;
		var p3;
		var p4;
		var p5;

		var fOnetime = "N";

		for(var i = 0; i < sRet.length - 5; i++)
		{
			if(fOnetime == "N")
			{
				fOnetime = "Y"
				p0 = sRet.indexOf("</div>", 0);

				serch_result = sRet.substring(0, p0 + 6);
				i = p0 + 4;
			}
			else
			{
				if(search_mode == "name")
				{//name
					p0 = sRet.indexOf("<div class=\"", i);
					p1 = sRet.indexOf(",this)\">", p0 + 12);
					p2 = sRet.indexOf("&lt\;", p1 + 8);
					p3 = sRet.indexOf("&gt\;", p2 + 4);
					p4 = sRet.indexOf("</div>", p3 + 4);
					i = p4 + 5;

					serch_line = sRet.substring(p0, p4 + 6);
					serch_name = sRet.substring(p1 + 8, p2);

					p5 = serch_name.indexOf(vTextbox.value, 0);
					if(p5 != -1)
					{
						serch_result = serch_result + serch_line;
					}
					else
					{//none
						;
					}
				}
				else
				{//No.
					p0 = sRet.indexOf("<table class=\"", i);
					p1 = sRet.indexOf("searchstyle1\">", p0 + 13);
					p2 = sRet.indexOf("</td>", p1 + 14);
					p3 = sRet.indexOf("</table>", p2 + 5);
					i = p3 + 7;

					serch_line = sRet.substring(p0, p3 + 8);
					serch_no = sRet.substring(p1 + 14, p2);

					p4 = serch_no.indexOf(vTextbox.value, 0);
					if(p4 != -1)
					{
						serch_result = serch_result + serch_line;
					}
					else
					{//none
						;
					}
				}
			}
		}
	}
	else
	{
		serch_result = sRet;
	}

  	return serch_result;

}


function navi_OutPutJuncMenu()
{
	var sSearch = gSearch_Search;
	OutHtml = '<img src=\"../../common/image/other/space.gif\" width=\"5\" height=\"10\" border=\"0\" alt=\"\">';

	OutHtml = OutHtml + '<input name=\"searchvalue\" type=\"text\" id=\"searchvalue\" size=\"30\" vertical-align=\"middle\">';//inputbox

	OutHtml = OutHtml + '<img src=\"../../common/image/other/space.gif\" width=\"5\" height=\"10\" border=\"0\" alt=\"\">';

	OutHtml = OutHtml + '<a href=\"javascript:Search_goSearchOnClick()\; MM_swapImage(\'Image14\',\'\',\'../../common/image/button/connector/bottom_search.gif\',1)\;\" onMouseOver=\"MM_swapImage(\'Image14\',\'\',\'../../common/image/button/connector/over_search.gif\',1)\" onMouseOut=\"MM_swapImgRestore()\">';

	OutHtml = OutHtml + '<img src=\"../../common/image/button/connector/search.gif\" alt=\"';

	OutHtml = OutHtml + sSearch;

	OutHtml = OutHtml + '\" name=\"Image14\" width=\"60\" height=\"25\" border=\"0\" id=\"Image14\" align=\"absmiddle\"></a>';

	return OutHtml;

}

