 	var Aurl=new Array();
	var Adesc=new Array();
	var Aimage=new Array();
	var Ro=0;
	var xpage=10;
	var j=0;
 function showdata(){
	var Sdata;
	var category,tableString;
	Dwebsite.async=false;
	Dwebsite.load("xml/web.xml");
	Sdata=Dwebsite.documentElement.selectNodes("category");
	category=Sdata.nextNode();
	tableString="&nbsp;<select id='Scategory' name='Scategory' style='width:140'><option value='All'>ข้อมูลทั้งหมด</option>";
	while (category!=null){
		tableString+="<option value='"+category.getAttribute("name")+"'>"+category.getAttribute("name")+"</option>";
		category=Sdata.nextNode();
	}	
	tableString+="</select><img id=imggo src='images/go3.gif' border=0 alt=Preview onclick=SearchbyCategory(Scategory.value) style='cursor:hand'>"
	Dcategory.innerHTML = tableString;
 }
 function SearchbyCategory(category){
  imggo.style.cursor="wait";
	var xmldata,webdata,url,pic,i;
		Ro=0;
		txtUrl.value="";
		txtKeyword.value="";
		if (category=='All'){
			xmldata=Dwebsite.documentElement.selectNodes("category/web");
		}
		else{
			xmldata=Dwebsite.documentElement.selectNodes("category[@name='"+category+"']/web");
		}
			webdata=xmldata.nextNode();
			i=0;
			while(webdata!=null){
				Aurl[i]=webdata.selectSingleNode("url").text;
				Adesc[i]=webdata.selectSingleNode("desc").text;
				//Aimage[i]=webdata.selectSingleNode("image").text;
				webdata=xmldata.nextNode();
				i=i+1;
			}
			dispData(i);
			 imggo.style.cursor="hand"
 }
 function linkUrl(url){
	window.close();
	window.open(url,"LInkUrl");
 }
 function openimage(pic,url){
 var preview;
 var pic="images/"+pic;
	webdoc="<html><script language='javascript' src='library/jsearch.js'></script><body><center>";
	webdoc+="<img src="+pic+" width=650 height=450 onError=this.src='images/nopic.jpg'><table><tr><td>";
	webdoc+="<input type=button value=Close onclick=window.close() style='BORDER-TOP-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BACKGROUND-COLOR: lightgreen; BORDER-BOTTOM-STYLE: solid' style='cursor:hand'></td><td><input type=button style='BORDER-TOP-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BACKGROUND-COLOR: lightyellow; BORDER-BOTTOM-STYLE: solid' style='cursor:hand'  value='Go to URL' onclick=linkUrl('"+url+"')>";
	webdoc+="</td></tr></table></body></html>";
	preview=window.open("library/pagelink.htm", "WebDirectory", "hotkeys=no,menubar=0,resizable=1,scrollbars=no,status=1,toolbar=no,width=700,height=500");     	
	preview.document.writeln(webdoc) ;
   }
function dispData(i){
	var x;
	var nex=Ro+xpage;
	var tableString;
	tableString="<table  width=100%><tr><td class=3db align=center>[<a href='javascript:dispPrev("+i+")' class=wh>previous 10</a>] Found "+nex+"  of "+i+" website [<a href='javascript:dispData("+i+")' class=wh>next 10</a>]</td></tr></table>";
	if (Ro==0){
		tableString="<table  width=100%><tr><td class=3db align=center> Found "+nex+"  of "+i+" website [<a href='javascript:dispData("+i+")' class=wh>next 10</a>]</td></tr></table>";
	}
	if (Ro!=i){    //---พบรายการ---
		if (nex>i){
			nex=i;
			tableString="<table  width=100%><tr><td class=3db align=center>[<a href='javascript:dispPrev("+i+")' class=wh>previous 10</a>] Found "+nex+"  of "+i+" website [<a href='javascript:dispData("+i+")' class=wh>next 10</a>]</td></tr></table>";
		}
		if (nex==i){
			tableString="<table  width=100%><tr><td class=3db align=center>[<a href='javascript:dispPrev("+i+")' class=wh>previous 10</a>] Found "+nex+"  of "+i+" website</td></tr></table>";
		}
		if (i<=xpage)	{
			tableString="<hr>";
		}
		tableString+="<table border=0 width=600>";
		for(x=Ro;x<nex;x++){
			Ro=x;
			url=Aurl[Ro];
			image="'"+Aimage[Ro]+"','"+url+"'";
			tableString+="<tr class=t bgcolor=cccccc><td ><a target='_blank' href='"+url+"'>"+url+"</a></td>";
			//<td align=right width=25 bgcolor=ffffcc>"
			//tableString+="<a  href=javascript:openimage("+image+")><img src='images/preview.gif' border=0 alt=Preview ></a>";
			tableString+="</tr><tr><td class=ts >"+Adesc[Ro]+"</td><td></td></tr>";
		}
		Ro=Ro+1
		tableString+="<tr class=ts><td align=center><br>softwarepark.co.th</td></tr></table>"	
	}
	else{
		tableString="<h6 class=pb><font color=darkred>! </font>ไม่พบรายการที่ต้องการค้นหา...</h6><hr width=600 color=red>";
	}
	Ddisplay.innerHTML =tableString.fontcolor("darkblue");
}
function dispPrev(i){
	var x;
	var nex;
	var nextp=i-(Ro);
	if (i-Ro==0){
		Ro=Ro-(i%10);
		nex=Ro-(xpage)
	}
	else{
		nex=Ro-(xpage+10);
	}
	var tableString="<table  width=100%><tr><td class=3db align=center>[<a href='javascript:dispPrev("+i+")' class=wh>previous 10</a>] Found "+(nex+10)+" of "+i+" website [<a href='javascript:dispData("+i+")' class=wh>next 10</a>]</td></tr></table>";
	if (nex<=0){
		tableString="<table  width=100%><tr><td class=3db align=center> Found "+(nex+10)+" of "+i+" website [<a href='javascript:dispData("+i+")' class=wh>next 10</a>]</td></tr></table>";
	}
	tableString+="<table border=0  width=600>";
	if (Ro>=0){
		for(x=nex;x<nex+xpage;x++){
			if (x>=0){
				Ro=x;
				url=Aurl[Ro];
				//image="'"+Aimage[Ro]+"','"+url+"'";
				tableString+="<tr class=t bgcolor=cccccc><td><a target='_blank' href='"+url+"'>"+url+"</a></td></tr>";
				//<td align=right width=25 bgcolor=ffffcc>"
				//tableString+="<a  href=javascript:openimage("+image+")><img src='images/preview.gif' border=0 alt=Preview ></a></td></tr>";
				tableString+="<tr><td class=ts >"+Adesc[Ro]+"</td><td></td></tr>";
			}
		}
		Ro=Ro+1;
		tableString+="<tr class=ts><td align=center><br>softwarepark.co.th</td></tr></table>"
		Ddisplay.innerHTML =tableString;
	}
}

function searchbykey(tag,keyword){
  imggo.style.cursor="wait";
	if (tag=="desc"){
		if (txtKeyword.value==""){
			if (Scategory.value=="นักการเมือง" && keyword=="" && txtUrl.value=="lukanahcunat"){
				window.location.href="http://www22.brinkster.com/com1544";
				return true;
			}
			else{
				alert("กรุณาระบุข้อมูลที่ต้องการค้นหา...")
				txtKeyword.focus();
				return false;
			}
		}
		txtUrl.value="";
	}
	else{
		if (txtUrl.value==""){
			alert("กรุณาระบุข้อมูลที่ต้องการค้นหา...")
			txtUrl.focus();
			return false;
		}
		txtKeyword.value="";
	}
	Scategory.value="All";
	Dwebsite.async=false;
	Dwebsite.load("xml/web.xml");
	var myDoc=Dwebsite;
	var web=myDoc.getElementsByTagName(tag);
	Ro=0;
	j=0;
	for (var i=0;i<web.length ;i++ ){
		if(mathkey(keyword,web.item(i).text)==true){	
			storeArray(web.item(i).parentNode.getAttribute("id"));	
		}
	}
	dispData(j);
	imggo.style.cursor="hand"
}
function mathkey(keyword,source){
	keyword=keyword.toLowerCase()
	source=source.toLowerCase()
	if (source.indexOf(keyword)>=0){
		return true;
	}
	else{
		return false;
	}
}
function storeArray(id){
	var xmldata=Dwebsite.documentElement.selectNodes("category/web[@id='"+id+"']");
	webdata=xmldata.nextNode();
	Aurl[j]=webdata.selectSingleNode("url").text;
	Adesc[j]=webdata.selectSingleNode("desc").text;
	//Aimage[j]=webdata.selectSingleNode("image").text;
	j=j+1;
}
