﻿var catidArray = new Array('4','5','6'); // default data
var keyidArray = new Array();
var keynameArray = new Array();
var defaultlkid = '';

var jobcatid = '14';
var orijobcatid = '15';
var this_cid = '0';
var this_page = 1;
var pagesize = 10;
var pagepartition = 10;

var domainPrefix = 'http://classified.on.cc';
//var domainPrefix = 'http://classified-uat03.webuat.opg';
//var domainPrefix = '';

var kw = '';
var kid = '';
var lkid = '';
var jyid = '';
var lid = '';
var sid = '';

var s = 0;
var ft = 0;
var st = 0;
var waitnextresult = false;
var firstdata;
var seconddata;
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
  return("undefined");
}
function writesearchbox(){
	var htmlcode = '';

	htmlcode += '<form name="searchform" action="" method="get" onsubmit="return searchsubmit();"><table id="searchboxtable">';
	htmlcode += '<tr>';
	htmlcode += '<td>關鍵字</td>';
	htmlcode += '<td><input type="text" maxlength="20" name="kw" id="kw" class="keyword" value="'+kw+'"></td>';
	htmlcode += '<td><div id="topselectcat"></div></td>';
	htmlcode += '<td><div id="topselectarea"></div></td>';
	htmlcode += '<td><a href="javascript:searchsubmit();"><img src="img/btn_search.gif" alt="搜尋" title="搜尋" border="0"></a></td>';
	htmlcode += '</tr>';
	htmlcode += '</table></form>';
	document.getElementById('searchboxcontent').innerHTML = htmlcode;
}
function writemenu(in_cid)
{
	var menuhtml = '';
	menuhtml += '<table cellpadding="0" cellspacing="0" border="0"><tr>';
	/*if(in_cid == jobcatid || pagetype=='main')
	{
		menuhtml += '<td><div id="menu1_on" style="display:block"><a href="list.html?cid='+jobcatid+'"><img src="img/btn_1_on.gif" border="0"></a></div></td>';
	}
	else
	{
		menuhtml += '<td><div onmouseover="overmenu(1)" onmouseout="outmenu(1)"><div id="menu1_on" style="display:none"><a href="list.html?cid='+jobcatid+'"><img src="img/btn_1_on.gif" border="0"></a></div><div id="menu1_off" style="display:block"><a href="list.html?cid='+jobcatid+'"><img src="img/btn_1_off.gif" border="0"></a></div></div></td>';
	}*/
	if(in_cid == 15)
	{
		menuhtml += '<td><div id="menu77_on" style="display:block"><a href="list.html?cid=15"><img src="img/btn_8_on.gif" border="0"></a></div></td>';
	}
	else
	{
		menuhtml += '<td><div onmouseover="overmenu(77)" onmouseout="outmenu(77)"><div id="menu77_on" style="display:none"><a href="list.html?cid=15"><img src="img/btn_8_on.gif" border="0"></a></div><div id="menu77_off" style="display:block"><a href="list.html?cid=15"><img src="img/btn_8_off.gif" border="0"></a></div></div></td>';
	}	
	/*
	//for(var i=0; i < catidArray.length; i++)
	for(var i=0; i < 4; i++)
	{
		if(catidArray[i] != undefined && catidArray[i] != jobcatid)
		{
			if(in_cid == catidArray[i])
			{
				menuhtml += '<td><div id="menu'+(i+2)+'_on" style="display:block"><a href="list.html?cid='+catidArray[i]+'"><img src="img/btn_'+(i+2)+'_on.gif" border="0"></a></div></td>';
			}
			else
			{
				menuhtml += '<td><div onmouseover="overmenu('+(i+2)+')" onmouseout="outmenu('+(i+2)+')"><div id="menu'+(i+2)+'_on" style="display:none"><a href="list.html?cid='+catidArray[i]+'"><img src="img/btn_'+(i+2)+'_on.gif" border="0"></a></div><div id="menu'+(i+2)+'_off" style="display:block"><a href="list.html?cid='+catidArray[i]+'"><img src="img/btn_'+(i+2)+'_off.gif" border="0"></a></div></div></td>';
			}
		}
	}
	*/
	// edit 110824
	/*if(in_cid == 6)
	{
		menuhtml += '<td><div id="menu4_on" style="display:block"><a href="list.html?cid=6"><img src="img/btn_4_on.gif" border="0"></a></div></td>';
	}
	else
	{
		menuhtml += '<td><div onmouseover="overmenu(4)" onmouseout="outmenu(4)"><div id="menu4_on" style="display:none"><a href="list.html?cid=6"><img src="img/btn_4_on.gif" border="0"></a></div><div id="menu4_off" style="display:block"><a href="list.html?cid=4"><img src="img/btn_4_off.gif" border="0"></a></div></div></td>';
	}*/
	// end edit 110824
	if(in_cid == 13)
	{
		menuhtml += '<td><div id="menu88_on" style="display:block"><a href="list.html?cid=13"><img src="img/btn_7_on.gif" border="0"></a></div></td>';
	}
	else
	{
		menuhtml += '<td><div onmouseover="overmenu(88)" onmouseout="outmenu(88)"><div id="menu88_on" style="display:none"><a href="list.html?cid=13"><img src="img/btn_7_on.gif" border="0"></a></div><div id="menu88_off" style="display:block"><a href="list.html?cid=13"><img src="img/btn_7_off.gif" border="0"></a></div></div></td>';
	}
	if(in_cid == -1)
	{
		menuhtml += '<td><div id="menu99_on" style="display:block"><a href="list.html?cid=-1"><img src="img/btn_6_on.gif" border="0"></a></div></td>';
	}
	else
	{
		menuhtml += '<td><div onmouseover="overmenu(99)" onmouseout="outmenu(99)"><div id="menu99_on" style="display:none"><a href="list.html?cid=-1"><img src="img/btn_6_on.gif" border="0"></a></div><div id="menu99_off" style="display:block"><a href="list.html?cid=-1"><img src="img/btn_6_off.gif" border="0"></a></div></div></td>';
	}
	/*
	if(in_cid == 15)
	{
		menuhtml += '<td><div id="menu77_on" style="display:block"><a href="list.html?cid=15"><img src="img/btn_8_on.gif" border="0"></a></div></td>';
	}
	else
	{
		menuhtml += '<td><div onmouseover="overmenu(77)" onmouseout="outmenu(77)"><div id="menu77_on" style="display:none"><a href="list.html?cid=15"><img src="img/btn_8_on.gif" border="0"></a></div><div id="menu77_off" style="display:block"><a href="list.html?cid=15"><img src="img/btn_8_off.gif" border="0"></a></div></div></td>';
	}*/
	
	menuhtml += '<td width="100%"></td></tr></table>';
	//document.getElementById('mainmenu').innerHTML = '<img src="img/btn_01_on.gif" border="0"><img src="img/btn_02_off.gif" border="0"><img src="img/btn_03_off.gif" border="0"><img src="img/btn_04_off.gif" border="0"><img src="img/btn_05_off.gif" border="0">';
	document.getElementById('mainmenu').innerHTML = menuhtml;
	
	if(pagetype != 'main'){
		startquery();
	}
	else
	{
		var latestjobxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result.cgi?cid='+jobcatid+'&e='+pagesize, false);
		latestjobxml.setOutputArrayAll();
		//latestjobxml.async(onloadlatestjobad);
		latestjobxml.async(onloadsplatestjobad);
		latestjobxml.parse();
		var otherjobxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result_shortad.cgi?kid=010,020,030,040,050,060,070,080&e='+pagesize, false);
		otherjobxml.setOutputArrayAll();
		otherjobxml.async(onloadotherjobad);
		otherjobxml.parse();
	}
}

function startquery(){
	//Start query data
	if(this_cid == '0')
	{

			//search all cat with keyword
			if(ft == 0 || ft > pagesize*(this_page-1))
			{
				//alert("load1");
				var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result.cgi?kw='+encodeURIComponent(kw)+'&s='+s+'&e='+pagesize+'&kid='+kid+'&jyid='+jyid+'&lid='+lid+'&sid='+sid, false);
				resultxml.setOutputArrayAll();
				resultxml.async(onloadfirstresult);
				resultxml.parse();
			}
			else
			{	//direct load second result
				var this_s = s - ft+1;
				//alert("load2:"+this_s+" "+encodeURIComponent(kw));
				var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result_shortad.cgi?kw='+encodeURIComponent(kw)+'&s='+this_s+'&e='+pagesize, false);
				resultxml.setOutputArrayAll();
				resultxml.async(onloadsecondresult);
				resultxml.parse();
			}

	}
	else
	{
		if(pagetype == 'list')
		{
			var checkid = parseInt(this_cid);
			if(checkid > 0)
			{
				if(this_cid == jobcatid){
					var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result.cgi?cid='+this_cid+'&s='+s+'&e='+pagesize+'&kw='+encodeURIComponent(kw)+'&kid='+kid+'&jyid='+jyid+'&lid='+lid+'&sid='+sid, false);
					resultxml.setOutputArrayAll();
					resultxml.async(onloadresult);
					resultxml.parse();
				}
				else if(lkid == '' && kid == '')
				{
						if((ft==0 && st==0)||ft > pagesize*(this_page-1))
						{
							//alert("list mix load1 lkid");
							var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result.cgi?cid='+this_cid+'&kw='+encodeURIComponent(kw)+'&s='+s+'&e='+pagesize+'&kid='+kid+'&jyid='+jyid+'&lid='+lid+'&sid='+sid, false);
							resultxml.setOutputArrayAll();
							resultxml.async(onloadfirstresult);
							resultxml.parse();
						}
						else
						{	//direct load second result
							var this_s = s - ft+1;
							//alert("list mix load2 lkid:"+this_s+" "+encodeURIComponent(kw));
							var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result_shortad.cgi?kw='+encodeURIComponent(kw)+'&s='+this_s+'&e='+pagesize+'&kid='+defaultlkid, false);
							resultxml.setOutputArrayAll();
							resultxml.async(onloadsecondresult);
							resultxml.parse();
						}
				}
				else if(lkid == '' && kid != '')
				{
						//alert('list mix load1 only');
						var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result.cgi?cid='+this_cid+'&s='+s+'&e='+pagesize+'&kw='+encodeURIComponent(kw)+'&kid='+kid+'&jyid='+jyid+'&lid='+lid+'&sid='+sid, false);
						resultxml.setOutputArrayAll();
						resultxml.async(onloadresult);
						resultxml.parse();
				}
				else if(lkid != '' && kid == '')
				{
						var this_s = s - ft+1;
						//alert("list mix load 2 only:"+this_s+" "+encodeURIComponent(kw));
						var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result_shortad.cgi?kw='+encodeURIComponent(kw)+'&s='+this_s+'&e='+pagesize+'&kid='+lkid, false);
						resultxml.setOutputArrayAll();
						resultxml.async(onloadsecondresult);
						resultxml.parse();
				}
				else if(lkid != '' && kid != '')
				{
						if(ft == 0 || ft > pagesize*(this_page-1))
						{
							//alert("list mix load1 lkid");
							var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result.cgi?cid='+this_cid+'&kw='+encodeURIComponent(kw)+'&s='+s+'&e='+pagesize+'&kid='+kid+'&jyid='+jyid+'&lid='+lid+'&sid='+sid, false);
							resultxml.setOutputArrayAll();
							resultxml.async(onloadfirstresult);
							resultxml.parse();
						}
						else
						{	//direct load second result
							var this_s = s - ft+1;
							//alert("list mix load2 lkid:"+this_s+" "+encodeURIComponent(kw));
							var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result_shortad.cgi?kw='+encodeURIComponent(kw)+'&s='+this_s+'&e='+pagesize+'&kid='+lkid, false);
							resultxml.setOutputArrayAll();
							resultxml.async(onloadsecondresult);
							resultxml.parse();
						}
				}
			}
			else
			{	//direct load second result
				//alert("shortad only");
				if(lkid == '')
				{
					var this_s = s - ft+1;
					//alert("list load2 only:"+this_s+" "+encodeURIComponent(kw));
					var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result_shortad.cgi?kw='+encodeURIComponent(kw)+'&s='+this_s+'&e='+pagesize+'&kid='+defaultlkid, false);
					resultxml.setOutputArrayAll();
					resultxml.async(onloadsecondresult);
					resultxml.parse();
				}
				else
				{
					var this_s = s - ft+1;
					//alert("list load2 only:"+this_s+" "+encodeURIComponent(kw));
					var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result_shortad.cgi?kw='+encodeURIComponent(kw)+'&s='+this_s+'&e='+pagesize+'&kid='+lkid, false);
					resultxml.setOutputArrayAll();
					resultxml.async(onloadsecondresult);
					resultxml.parse();
				}
			}
		}
		else if(pagetype == 'detail')
		{
			var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/detail.cgi?id='+this_id, false);
			resultxml.setOutputArrayAll();
			resultxml.async(onloaddetail);
			resultxml.parse();
		}
	}
}

function onloadcat(data)
{
	catidArray = new Array();
	for (var i=0; i<data.categoryxml[0].category.length; i++)
	{
		catidArray[i] = data.categoryxml[0].category[i].id;
	}
}
function onloadmenu(data)
{
	onloadcat(data);
	var temparray = new Array();
	var templadarray = new Array();
	if(getQueryVariable('kid') != 'undefined' && getQueryVariable('kid') != '')
	{
		kid = getQueryVariable('kid');
		temparray = kid.split(',');
	}
	if(getQueryVariable('lkid') != 'undefined' && getQueryVariable('lkid') != '')
	{
		lkid = getQueryVariable('lkid');
		templadarray = lkid.split(',');
	}
	
	//main cat list
	var curcatpos = -1;
	var htmlcode = '';


		htmlcode += '<select name="cat_select" id="cat_select">';
		htmlcode += '<option value="0">所有分類</option>';
		for (var i=0; i<data.categoryxml[0].category.length; i++)
		{
			var isselected = '';
			if(String(data.categoryxml[0].category[i].id) == this_cid)
			{
				curcatpos = i;
				isselected = ' selected';
				if(data.categoryxml[0].category[i].keywordlist != undefined && data.categoryxml[0].category[i].keywordlist != null)
				{
					if(data.categoryxml[0].category[i].keywordlist[0].keyword != undefined && data.categoryxml[0].category[i].keywordlist[0].keyword != '')
					{
						for (var j=0; j<data.categoryxml[0].category[i].keywordlist[0].keyword.length; j++)
						{
							if(data.categoryxml[0].category[i].keywordlist[0].keyword[j].lad != '0')
							{
								if(defaultlkid != '')
								{
									defaultlkid +=',';
								}
								defaultlkid += data.categoryxml[0].category[i].keywordlist[0].keyword[j].id;
							}
						}
					}
				}
			}
			
			
			htmlcode += '<option value="'+data.categoryxml[0].category[i].id+'" '+isselected+'>'+data.categoryxml[0].category[i].name+'</option>';
			
		}
		htmlcode += '</select>';
		
		document.getElementById('topselectcat').innerHTML = htmlcode;
	if(pagetype != 'main'){
		//sub cat list
		htmlcode = '';
		if(curcatpos >=0)
		{
			htmlcode = '';
			htmlcode += '<select name="subcat_select" id="subcat_select" onchange="listsearchsubmit()">';
			htmlcode += '<option value="">所有類別</option>';
			if(data.categoryxml[0].category[curcatpos].keywordlist != undefined && data.categoryxml[0].category[curcatpos].keywordlist != null)
			{
				if(data.categoryxml[0].category[curcatpos].keywordlist[0].keyword != undefined && data.categoryxml[0].category[curcatpos].keywordlist[0].keyword != '')
				{
					for (var i=0; i<data.categoryxml[0].category[curcatpos].keywordlist[0].keyword.length; i++)
					{
						var isselected = '';
						if(temparray.length>0)
						{
							if(String(data.categoryxml[0].category[curcatpos].keywordlist[0].keyword[i].id) == temparray[0])
							{
								isselected = ' selected';
							}
						}
						else
						{
							if(String(data.categoryxml[0].category[curcatpos].keywordlist[0].keyword[i].id) == templadarray[0])
							{
								isselected = ' selected';
							}
						}
						keyidArray.push(data.categoryxml[0].category[curcatpos].keywordlist[0].keyword[i].id);
						keynameArray.push(data.categoryxml[0].category[curcatpos].keywordlist[0].keyword[i]['#cdata-section']);
						htmlcode += '<option value="'+data.categoryxml[0].category[curcatpos].keywordlist[0].keyword[i].lad+'|'+data.categoryxml[0].category[curcatpos].keywordlist[0].keyword[i].id+'" '+isselected+'>'+data.categoryxml[0].category[curcatpos].keywordlist[0].keyword[i]['#cdata-section']+'</option>';
					}
				}
			}
			htmlcode += '</select>';
		}

		document.getElementById('selectsubcat').innerHTML = htmlcode;
	}
	else
	{
		var jobsubcatidarray = [];
		var jobsubcatnamearray = [];
		curcatpos = 0;
		for (var i=0; i<data.categoryxml[0].category.length; i++)
		{
			if(String(data.categoryxml[0].category[i].id) == jobcatid)
			{
				curcatpos = i;
				break;
			}
		}
		htmlcode = '';
		htmlcode += '<select name="subcat_select" id="subcat_select">';
		htmlcode += '<option value="">所有類別</option>';
		if(data.categoryxml[0].category[curcatpos].keywordlist != undefined && data.categoryxml[0].category[curcatpos].keywordlist != null)
		{
			if(data.categoryxml[0].category[curcatpos].keywordlist[0].keyword != undefined && data.categoryxml[0].category[curcatpos].keywordlist[0].keyword != '')
			{
				for (var i=0; i<data.categoryxml[0].category[curcatpos].keywordlist[0].keyword.length; i++)
				{
					htmlcode += '<option value="'+data.categoryxml[0].category[curcatpos].keywordlist[0].keyword[i].id+'" '+isselected+'>'+data.categoryxml[0].category[curcatpos].keywordlist[0].keyword[i]['#cdata-section']+'</option>';
					jobsubcatidarray.push(data.categoryxml[0].category[curcatpos].keywordlist[0].keyword[i].id);
					jobsubcatnamearray.push(data.categoryxml[0].category[curcatpos].keywordlist[0].keyword[i]['#cdata-section']+'');
				}
			}
		}
		htmlcode += '</select>';
		document.getElementById('selectsubcat').innerHTML = htmlcode;
		
		//remove cat box
		/*
		htmlcode = '';
		
		
		var trclass = '';

		htmlcode += '<table><tr>';


		//for(var i=0; i<jobsubcatidarray.length; i++){

		for(var i=0; i<32; i++){
			if(i%3 == 0 && i>0)
			{
				if(trclass == ' class="bluecell"')
				{
					trclass = '';
				}
				else
				{
					trclass = ' class="bluecell"';
				}
				htmlcode += '</tr><tr'+trclass+'>';
			}
			htmlcode += '<td><a href="list.html?cid='+jobcatid+'&kid='+jobsubcatidarray[i]+'">'+jobsubcatnamearray[i]+'</a></td>';
		}
		htmlcode += '<td><a href="list.html?cid=12">小廣告</a></td></tr></table>';
		document.getElementById('jobtypelist').innerHTML = htmlcode;
		*/
	}
	
	writemenu(this_cid);
	loadrandomlist();
}

function onloadresult(data)
{
	firstdata = data;
	mergeresult();
}

function onloadfirstresult(data)
{
	firstdata = data;
	if(this_cid == '0')
	{
		if(st==0 || parseInt(data.resultxml[0].content[0].record.length) < pagesize)
		{
			//alert('load 2nd');
			var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result_shortad.cgi?kw='+encodeURIComponent(kw), false);
			resultxml.setOutputArrayAll();
			resultxml.async(onloadsecondresult);
			resultxml.parse();
		}
		else
		{
			mergeresult();
		}
	}
	else
	{
		if(defaultlkid != '')
		{
			//alert(defaultlkid);
			//alert("list mix load2 - kid:"+kid);
			if(lkid == '')
			{
				var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result_shortad.cgi?kw='+encodeURIComponent(kw)+'&e='+pagesize+'&kid='+defaultlkid, false);
				resultxml.setOutputArrayAll();
				resultxml.async(onloadsecondresult);
				resultxml.parse();
			}
			else
			{
				var resultxml = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result_shortad.cgi?kw='+encodeURIComponent(kw)+'&e='+pagesize+'&kid='+lkid, false);
				resultxml.setOutputArrayAll();
				resultxml.async(onloadsecondresult);
				resultxml.parse();
			}
		}
		else
		{
			mergeresult();
		}
	}
}

function onloadsecondresult(data)
{
	seconddata = data;
	mergeresult();
}

function mergeresult()
{
	var data;
	if(firstdata != null)
	{
		ft = parseInt(firstdata.resultxml[0].content[0].totalresult);
		data = firstdata;
	}
	if(seconddata != null)
	{
		st = parseInt(seconddata.resultxml[0].content[0].totalresult);
		data = seconddata;
	}

	var this_total = ft+st;
	var this_totalpage = Math.ceil(this_total/pagesize);
	var htmlinfocode = '';
	var htmlinfocode_line2 = '';

	htmlinfocode += '<div>數量：'+this_total+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;頁數：'+this_page+' / '+this_totalpage+'</div>';
	var thiskw = '';
	if(data.resultxml[0].content[0].keyword != '' && data.resultxml[0].content[0].keyword != undefined)
	{
		thiskw = data.resultxml[0].content[0].keyword;
	}

	var htmlinfocode_paging = '';
	var startpage = 1;
	var templink = 'list.html?cid='+this_cid+'&kw='+escape(kw)+'&kid='+kid+'&lkid='+lkid+'&ft='+ft+'&st='+st;

	if(this_totalpage > 1)
	{
		htmlinfocode_paging += '';
		/*********************************/
		//paging calculate and display
		/*********************************/

		if(this_page > 6)
		{
			startpage = this_page - 5;
		}
		var endpagepage = startpage + pagepartition-1;
		if(this_totalpage < endpagepage)
		{
			endpagepage = this_totalpage;
		}
		if(this_page > 1)
		{
			htmlinfocode_paging += '<a class="paginglink" href="'+templink+'&tp='+(this_page-1)+'"><span>上一頁</span></a>';
			htmlinfocode_paging += '&nbsp;&nbsp;';
		}
		for(var i=startpage; i<= endpagepage; i++)
		{
			if(i==this_page)
			{
				htmlinfocode_paging += '<span class="pagingthis">'+i+'</span>';
			}
			else
			{
				htmlinfocode_paging += '<a class="paginglink" href="'+templink+'&tp='+i+'">'+i+'</a>';
			}
			htmlinfocode_paging += '&nbsp;&nbsp;';
		}
		if(this_page < this_totalpage)
		{
			htmlinfocode_paging += '<a class="paginglink" href="'+templink+'&tp='+(this_page+1)+'"><span>下一頁</span></a>';
		}
		htmlinfocode_paging += '';
	}

	if(thiskw =='')
	{
		htmlinfocode += '<div>'+htmlinfocode_paging+'</div>';
	}
	else
	{
		htmlinfocode += '<div>關鍵字：'+thiskw+'　　　　'+htmlinfocode_paging+'</div>';
	}

	document.getElementById('searchinfotop').innerHTML = htmlinfocode;
	document.getElementById('searchinfobottom').innerHTML = htmlinfocode;

	// 分類廣告data
	var remaining = pagesize;
	var htmlresultocode = '';
	if(firstdata != null)
	{
			if(ft>0)
			{
				for(var i=0; i<firstdata.resultxml[0].content[0].record.length; i++)
				{
					var isjobad = false;
					if(firstdata.resultxml[0].content[0].record[i].catid == jobcatid || firstdata.resultxml[0].content[0].record[i].catid == orijobcatid)
					{
						isjobad = true;
					}
					else
					{
						isjobad = false;
					}

					htmlresultocode += '<div class="insideDiv">';
					if(firstdata.resultxml[0].content[0].record[i].thumbnail != undefined && firstdata.resultxml[0].content[0].record[i].thumbnail != '')
					{
						htmlresultocode += '<div class="fleft adsicon"><a href="detail.html?id='+firstdata.resultxml[0].content[0].record[i].id+'&cid='+firstdata.resultxml[0].content[0].record[i].catid+'"><img src="'+domainPrefix+'/adimg/'+firstdata.resultxml[0].content[0].record[i].catid+'/'+firstdata.resultxml[0].content[0].record[i].thumbnail+'" width="120" height="100" border="0"></a></div>';
					}
					/*else if(firstdata.resultxml[0].content[0].record[i].logo != undefined && firstdata.resultxml[0].content[0].record[i].logo != '')
					{
						htmlresultocode += '<div class="fleft adsicon"><a href="detail.html?id='+firstdata.resultxml[0].content[0].record[i].id+'&cid='+firstdata.resultxml[0].content[0].record[i].catid+'"><img src="'+domainPrefix+'/adimg/'+firstdata.resultxml[0].content[0].record[i].logo+'" width="90" border="0"></a></div>';
					}*/
					htmlresultocode += '<div class="fleft cellcontent">';

					var temptitle = '';
					var tempvalue = '';
					/*if(isjobad)
					{
						if(firstdata.resultxml[0].content[0].record[i].title != undefined)
						{
							temptitle = firstdata.resultxml[0].content[0].record[i].title;
						}
						else
						{
							temptitle = firstdata.resultxml[0].content[0].record[i].job_detail[0].job_title[0]+'';
						}
						if(firstdata.resultxml[0].content[0].record[i].desc != undefined)
						{
							tempvalue = shortentext(firstdata.resultxml[0].content[0].record[i].desc+'',150);
						}
					}
					else
					{*/
						if(firstdata.resultxml[0].content[0].record[i].job_detail != undefined && firstdata.resultxml[0].content[0].record[i].job_detail != ''){
							if(firstdata.resultxml[0].content[0].record[i].job_detail.length>0){
								if(firstdata.resultxml[0].content[0].record[i].job_detail[0].job_reqs != undefined && firstdata.resultxml[0].content[0].record[i].job_detail[0].job_reqs != ''){
									tempvalue = firstdata.resultxml[0].content[0].record[i].job_detail[0].job_reqs[0].job_req[0]['#cdata-section']+'';
								}
								if(firstdata.resultxml[0].content[0].record[i].job_detail[0].job_title != undefined){
									temptitle = firstdata.resultxml[0].content[0].record[i].job_detail[0].job_title[0]+'';
								}
							}
						}
						if(tempvalue == '')
						{
							tempvalue = firstdata.resultxml[0].content[0].record[i].desc+'';
						}
						if(temptitle == '')
						{
							temptitle = firstdata.resultxml[0].content[0].record[i].title;
						}
						var temptext = tempvalue;
						var tempjobreqarray = temptext.split('|.|');
						var thistemptext = '';
						for(var x=0; x<tempjobreqarray.length; x++)
						{
							if(x>1 && x < 3)
							{
								thistemptext+= '<br>';
							}
							if(x < 3)
							{
								thistemptext+= tempjobreqarray[x];
							}
						}
						tempjobreqarray = thistemptext.split('&lt;br&gt;');
						thistemptext = '';
						for(var x=0; x<tempjobreqarray.length; x++)
						{
							thistemptext+= tempjobreqarray[x];
						}
						tempvalue = shortentext(thistemptext,150);
					//}
					htmlresultocode += '<div><a href="detail.html?id='+firstdata.resultxml[0].content[0].record[i].id+'&cid='+firstdata.resultxml[0].content[0].record[i].catid+'"><span class="titleSpan">'+temptitle+'</span></a></div>';
					htmlresultocode += '<div><a href="detail.html?id='+firstdata.resultxml[0].content[0].record[i].id+'&cid='+firstdata.resultxml[0].content[0].record[i].catid+'">'+tempvalue+'</a></div>';
					htmlresultocode += '<div>';

					
					//招聘
					if(isjobad)
					{
						tempvalue = '－';
						var keywordArray = [];
						if(firstdata.resultxml[0].content[0].record[i].order_keywords != undefined){
							if(firstdata.resultxml[0].content[0].record[i].order_keywords[0].order_keyword_id != undefined){
								if(firstdata.resultxml[0].content[0].record[i].order_keywords[0].order_keyword_id[0] == undefined || firstdata.resultxml[0].content[0].record[i].order_keywords[0].order_keyword_id[0] == '')
								{
									tempvalue = '－';
								}
								else
								{
									for(var j=0; j<firstdata.resultxml[0].content[0].record[i].order_keywords[0].order_keyword_id.length; j++)
									{
										keywordArray.push(firstdata.resultxml[0].content[0].record[i].order_keywords[0].order_keyword_id[j]);
									}
									//get first only
									for(var j=0; j<keyidArray.length; j++)
									{
										if(keyidArray[j] == keywordArray[0]){
											tempvalue = keynameArray[j];
										}
									}
								}
							}
						}
						htmlresultocode += '<table><tr>';
						htmlresultocode += '<td class="titletd">類別：</td>';
						htmlresultocode += '<td class="tcontent">'+tempvalue+'</td>';
						tempvalue = '－';
						if(firstdata.resultxml[0].content[0].record[i].locations != undefined){
							if(firstdata.resultxml[0].content[0].record[i].locations[0].location[0]['#cdata-section'] != undefined && firstdata.resultxml[0].content[0].record[i].locations[0].location[0]['#cdata-section'] != '')
							{
								tempvalue = firstdata.resultxml[0].content[0].record[i].locations[0].location[0]['#cdata-section']+'';
							}
						}
						htmlresultocode += '<td class="titletd">地區：</td>';
						htmlresultocode += '<td class="tcontent">'+tempvalue+'</td>';
						htmlresultocode += '</tr>';
						
						htmlresultocode += '<tr>';
						
						tempvalue = '－';

						var job_type = '－';
						var job_salary = '－';

						if(firstdata.resultxml[0].content[0].record[i].job_detail != undefined && firstdata.resultxml[0].content[0].record[i].job_detail != ''){
							if(firstdata.resultxml[0].content[0].record[i].job_detail[0].job_type != undefined && firstdata.resultxml[0].content[0].record[i].job_detail[0].job_type != ''){
								job_type = firstdata.resultxml[0].content[0].record[i].job_detail[0].job_type;
							}
							if(firstdata.resultxml[0].content[0].record[i].job_detail[0].salary != undefined && firstdata.resultxml[0].content[0].record[i].job_detail[0].salary != ''){
								job_salary = firstdata.resultxml[0].content[0].record[i].job_detail[0].salary;
							}
						}
						htmlresultocode += '<td class="titletd">類型：</td>';
						htmlresultocode += '<td class="tcontent">'+job_type+'</td>';

						htmlresultocode += '<td class="titletd">薪酬：</td>';
						htmlresultocode += '<td class="tcontent">'+job_salary+'</td>';
						htmlresultocode += '</tr>';

						htmlresultocode += '<tr>';
						tempvalue = '－';
						if(firstdata.resultxml[0].content[0].record[i].telephones != undefined){
							if(firstdata.resultxml[0].content[0].record[i].telephones[0].telephone[0]['#cdata-section'] != undefined && firstdata.resultxml[0].content[0].record[i].telephones[0].telephone[0]['#cdata-section'] != '')
							{
								tempvalue = firstdata.resultxml[0].content[0].record[i].telephones[0].telephone[0]['#cdata-section'];
							}
						}
						htmlresultocode += '<td class="titletd">聯絡電話：</td>';
						htmlresultocode += '<td class="tcontent">'+tempvalue+'</td>';
						tempvalue = '－';
						if(firstdata.resultxml[0].content[0].record[i].start_date != undefined){
							var tempdatearray = firstdata.resultxml[0].content[0].record[i].start_date[0].split(' ');
							tempvalue = tempdatearray[0];
						}

						htmlresultocode += '<td class="titletd">刊登日期：</td>';
						htmlresultocode += '<td class="tcontent">'+tempvalue+'</td>';
						htmlresultocode += '</tr>';
						htmlresultocode += '</table>';
					}
					else{
						tempvalue = '－';
						if(firstdata.resultxml[0].content[0].record[i].addresses != undefined){
							if(firstdata.resultxml[0].content[0].record[i].addresses[0].address[0]['#cdata-section'] != undefined && firstdata.resultxml[0].content[0].record[i].addresses[0].address[0]['#cdata-section'] != '')
							{
								tempvalue = firstdata.resultxml[0].content[0].record[i].addresses[0].address[0]['#cdata-section']+'';
							}
						}
						htmlresultocode += '<table><tr>';
						htmlresultocode += '<td class="titletd">地址：</td>';
						htmlresultocode += '<td class="tcontent">'+tempvalue+'</td>';
						tempvalue = '－';
						if(firstdata.resultxml[0].content[0].record[i].telephones != undefined){
							if(firstdata.resultxml[0].content[0].record[i].telephones[0].telephone[0]['#cdata-section'] != undefined && firstdata.resultxml[0].content[0].record[i].telephones[0].telephone[0]['#cdata-section'] != '')
							{
								tempvalue = firstdata.resultxml[0].content[0].record[i].telephones[0].telephone[0]['#cdata-section'];
							}
						}
						htmlresultocode += '<td class="titletd">聯絡電話：</td>';
						htmlresultocode += '<td class="tcontent">'+tempvalue+'</td>';
						tempvalue = '－';
						if(firstdata.resultxml[0].content[0].record[i].website != undefined && firstdata.resultxml[0].content[0].record[i].website!= '')
						{
							tempvalue = firstdata.resultxml[0].content[0].record[i].website;
						}
						htmlresultocode += '</tr><tr>';
						htmlresultocode += '<td class="titletd">網址：</td>';
						htmlresultocode += '<td class="tcontent">'+tempvalue+'</td>';
						tempvalue = '－';
						if(firstdata.resultxml[0].content[0].record[i].email != undefined && firstdata.resultxml[0].content[0].record[i].email != '')
						{
							tempvalue = firstdata.resultxml[0].content[0].record[i].email;
						}
						htmlresultocode += '<td class="titletd">電郵：</td>';
						htmlresultocode += '<td class="tcontent">'+tempvalue+'</td>';
						htmlresultocode += '</tr></table>';
					}
					htmlresultocode += '</div>';
					htmlresultocode += '</div>';
					htmlresultocode += '</div>';
					htmlresultocode += '<div class="linediv"><img src="img/list_line.gif" border="0"></div>';
					remaining--;
				}
			}
	}
	//alert('remaining:'+remaining);
	// 小廣告data
	
	if(seconddata != null && remaining >0)
	{
			if(st>0)
			{
				var maxlength = remaining;
				if(seconddata.resultxml[0].content[0].record.length < remaining)
				{
					maxlength = seconddata.resultxml[0].content[0].record.length
				}

				for(var i=0; i<maxlength; i++)
				{
					htmlresultocode += '<div class="insideDiv">';
					htmlresultocode += '<div class="fleft cellcontent">';
					if(seconddata.resultxml[0].content[0].record[i].title != undefined)
					{
						htmlresultocode += '<div><span class="titleSpan">'+seconddata.resultxml[0].content[0].record[i].title+'</span></div>';
					}
					if(seconddata.resultxml[0].content[0].record[i].desc != undefined)
					{
						htmlresultocode += '<div>'+seconddata.resultxml[0].content[0].record[i].desc+'</div>';
					}
					htmlresultocode += '</div>';
					htmlresultocode += '<div class="linediv"><img src="img/list_line.gif" border="0"></div>';
					htmlresultocode += '</div>';
				}
			}
	}
	document.getElementById('searchresultlist').innerHTML = htmlresultocode;
}


function clearsearch()
{
	if(this_cid != '0')
	{
		if(document.all.keyword_cb)
		{
			if(document.all.keyword_cb.length)
			{
				for(var i=0; i<document.all.keyword_cb.length; i++)
				{
					if(document.all.keyword_cb[i].checked)
					{
						document.all.keyword_cb[i].checked = false;
					}
				}
			}
			else
			{
				document.all.keyword_cb.checked = false;
			}
		}
		if(document.all.keyword_lad_cb)
		{
			if(document.all.keyword_lad_cb.length)
			{
				for(var i=0; i<document.all.keyword_lad_cb.length; i++)
				{
					if(document.all.keyword_lad_cb[i].checked)
					{
						document.all.keyword_lad_cb[i].checked = false;
					}
				}
			}
			else
			{
				document.all.keyword_lad_cb.checked = false;
			}
		}
		else
		{

		}
		kid = '';
		lkid = '';
		document.all.kw.value = '';
	}
	else
	{
		kid = '';
		lkid = '';
		document.all.kw.value = '';
	}
}
function searchsubmit()
{
	var thiscid = document.getElementById('cat_select').value;
	var thislid = '';
	//var thislid = document.getElementById('toparea_select').value;
	var kw = escape(String(document.searchform.kw.value).trim());
	//window.location = 'list.html?cid='+thiscid+'&kw='+kw+'&kid='+kid+'&lkid='+lkid;
	window.location = 'list.html?cid='+thiscid+'&kw='+kw+'&lid='+thislid;
	return false;
}
function listsearchsubmit()
{
	var kid = '';
	var thisjyid = '';
	var thislid = '';
	var thissid = '';
	var issa = false;

	if(document.getElementById('subcat_select') != undefined)
	{
		var thissubcatarray = document.getElementById('subcat_select').value.split('|');
		if(thissubcatarray.length>1)
		{
			if(thissubcatarray[0] == '1')
			{
				issa = true;
			}
			kid = thissubcatarray[1];
		}
		//kid = document.getElementById('subcat_select').value;
	}
	if(document.getElementById('area_select') != undefined)
	{
		thislid = document.getElementById('area_select').value;
	}
	if(document.getElementById('jtype_select') != undefined)
	{
		thisjyid = document.getElementById('jtype_select').value;
		thissid = document.getElementById('salary_select').value;
	}
	if(this_cid == -1)
	{
		window.location = 'list.html?cid='+this_cid+'&kw='+kw+'&lkid='+kid;
	}
	else
	{
		if(issa)
		{
			window.location = 'list.html?cid='+this_cid+'&kw='+kw+'&lkid='+kid+'&jyid='+thisjyid+'&lid='+thislid+'&sid='+thissid;
		}
		else
		{
			window.location = 'list.html?cid='+this_cid+'&kw='+kw+'&kid='+kid+'&jyid='+thisjyid+'&lid='+thislid+'&sid='+thissid;
		}
	}
}
function jobsearchsubmit()
{
	var thiskid = document.jobsearchform.subcat_select.value;
	var thisjyid = document.jobsearchform.jtype_select.value;
	//var thislid = document.jobsearchform.area_select.value;
	var thislid = '';
	var thissid = document.jobsearchform.salary_select.value;

	var jkw = escape(String(document.jobsearchform.jkw.value).trim());
	//window.location = 'list.html?cid='+jobcatid+'&kw='+jkw;
	window.location = 'list.html?cid='+jobcatid+'&kw='+jkw+'&kid='+thiskid+'&jyid='+thisjyid+'&lid='+thislid+'&sid='+thissid;
	return false;
}
function onloadhot(data)
{
	var htmlhotcode = '<div>熱門搜尋：&nbsp;';
	for(var i=0; i<data.hotkeywordxml[0].hotkeywordlist[0].hotkeyword.length; i++)
	{
		htmlhotcode += '<a href="list.html?cid=0&kw='+escape(data.hotkeywordxml[0].hotkeywordlist[0].hotkeyword[i])+'">'+data.hotkeywordxml[0].hotkeywordlist[0].hotkeyword[i]+'</a>&nbsp;&nbsp;&nbsp';
	}
	htmlhotcode += '</div>';
	document.getElementById('hotkeywordlist').innerHTML = htmlhotcode;
}
function onloaddetail(data)
{
	var htmlresultocode = '';
	if(data.detailxml[0] == undefined){
		
	}
	else
	{
		var thumbnailArray = new Array();
		var imageArray = new Array();
		var captionArray = new Array();
		var addrArray = new Array();
		var teleArray = new Array();
		var faxArray = new Array();
		var locationArray = new Array();
		var job_reqsArray = new Array();
		var keywordArray = new Array();

		var job_title = '－';
		var job_type = '－';
		var job_salary = '－';
		var job_edu_level = '－';
		var job_work_exp = '－';
		var job_pay_type = '－';
		var job_reqs = '－';
		var job_dutys = '－';
		var isjobad = false;
		if(this_cid == jobcatid || this_cid == orijobcatid)
		{
			isjobad = true;
		}
		else
		{
			isjobad = false;
		}
		if(data.detailxml[0].job_detail != undefined && data.detailxml[0].job_detail != ''){
			
			if(data.detailxml[0].job_detail.length>0){
				if(data.detailxml[0].job_detail[0].job_title != undefined && data.detailxml[0].job_detail[0].job_title != ''){
					job_title = data.detailxml[0].job_detail[0].job_title;
				}
				if(data.detailxml[0].job_detail[0].job_type != undefined && data.detailxml[0].job_detail[0].job_type != ''){
					job_type = data.detailxml[0].job_detail[0].job_type;
				}
				if(data.detailxml[0].job_detail[0].salary != undefined && data.detailxml[0].job_detail[0].salary != ''){
					job_salary = data.detailxml[0].job_detail[0].salary;
				}
				if(data.detailxml[0].job_detail[0].edu_level != undefined && data.detailxml[0].job_detail[0].edu_level != ''){
					job_edu_level = data.detailxml[0].job_detail[0].edu_level;
				}
				if(data.detailxml[0].job_detail[0].work_exp != undefined && data.detailxml[0].job_detail[0].work_exp != ''){
					job_work_exp = data.detailxml[0].job_detail[0].work_exp;
				}
				if(data.detailxml[0].job_detail[0].pay_type != undefined && data.detailxml[0].job_detail[0].pay_type != ''){
					job_pay_type = data.detailxml[0].job_detail[0].pay_type;
				}
				if(data.detailxml[0].job_detail[0].job_reqs != undefined && data.detailxml[0].job_detail[0].job_reqs != ''){
					/*if(isjobad){
						for(var i=0;i<data.detailxml[0].job_detail[0].job_reqs[0].job_req.length; i++)
						{
							if(job_reqs == '－')
							{
								job_reqs = '';
							}
							else
							{
								job_reqs += '<tr><td><img src="img/bullet.gif" border="0"></td><td>';
							}
							job_reqs += data.detailxml[0].job_detail[0].job_reqs[0].job_req[i]['#cdata-section']+'</td></tr>';
						}
					}
					else
					{*/
						if(data.detailxml[0].job_detail[0].job_reqs[0].job_req != undefined)
						{
							job_reqs = data.detailxml[0].job_detail[0].job_reqs[0].job_req[0]['#cdata-section']+'';
						}
					//}
				}
				if(data.detailxml[0].job_detail[0].job_dutys != undefined && data.detailxml[0].job_detail[0].job_dutys != ''){
					job_dutys = data.detailxml[0].job_detail[0].job_dutys;
				}
			}
		}

		if(data.detailxml[0].thumbnail != undefined)
		{
			thumbnailArray.push(domainPrefix+'/adimg/'+data.detailxml[0].catid+'/'+data.detailxml[0].thumbnail);
			imageArray.push(domainPrefix+'/adimg/'+data.detailxml[0].catid+'/'+data.detailxml[0].image);
		}
		if(data.detailxml[0].photos != undefined)
		{
			if(data.detailxml[0].photos[0].photo != undefined)
			{
				for(var i=0; i<data.detailxml[0].photos[0].photo.length; i++)
				{
					thumbnailArray.push(domainPrefix+'/adimg/'+data.detailxml[0].catid+'/'+data.detailxml[0].photos[0].photo[i].thumbnail);
					imageArray.push(domainPrefix+'/adimg/'+data.detailxml[0].catid+'/'+data.detailxml[0].photos[0].photo[i].image);
					captionArray.push(data.detailxml[0].photos[0].photo[i].caption);
				}
			}
		}
var thistele = '－';
var thisaddress = '－';
var thisfax = '－';
var thiswebsite = '－';
var thisemail = '－';
var thislocation = '－';
var thiskeyword = '－';
var thispostdate = '－';
var thislogo ='';
//keyidArray
//keynameArray
		if(data.detailxml[0].logo == undefined || data.detailxml[0].logo == '')
		{
			thislogo = '';
		}
		else
		{
			thislogo = domainPrefix+'/adimg/'+data.detailxml[0].logo;
		}
		if(data.detailxml[0].order_keywords != undefined){
			if(data.detailxml[0].order_keywords[0].order_keyword_id[0] == undefined || data.detailxml[0].order_keywords[0].order_keyword_id[0] == '')
			{
				thiskeyword = '－';
			}
			else
			{
				for(var i=0; i<data.detailxml[0].order_keywords[0].order_keyword_id.length; i++)
				{
					keywordArray.push(data.detailxml[0].order_keywords[0].order_keyword_id[i]);
				}
				//get first only
				for(var i=0; i<keyidArray.length; i++)
				{
					if(keyidArray[i] == keywordArray[0]){
						thiskeyword = keynameArray[i];
					}
				}
			}
		}
		if(data.detailxml[0].start_date != undefined)
		{
			var tempdatearray = data.detailxml[0].start_date[0].split(' ');
			thispostdate = tempdatearray[0];
		}
		if(data.detailxml[0].locations != undefined)
		{
			if(data.detailxml[0].locations[0].location[0]['#cdata-section'] == undefined || data.detailxml[0].locations[0].location[0]['#cdata-section'] == '')
			{
				thislocation = '－';
			}
			else
			{
				for(var i=0; i<data.detailxml[0].locations[0].location.length; i++)
				{
					locationArray.push(data.detailxml[0].locations[0].location[i]['#cdata-section'])
				}
				//get first only
				thislocation = locationArray[0];
			}
		}
		if(data.detailxml[0].addresses != undefined)
		{
			if(data.detailxml[0].addresses[0].address[0]['#cdata-section'] == undefined || data.detailxml[0].addresses[0].address[0]['#cdata-section'] == '')
			{
				thisaddress = '－';
			}
			else
			{
				for(var i=0; i<data.detailxml[0].addresses[0].address.length; i++)
				{
					addrArray.push(data.detailxml[0].addresses[0].address[i]['#cdata-section'])
				}
				//get first only
				thisaddress = addrArray[0];
			}
		}
		if(data.detailxml[0].telephones != undefined)
		{
			if(data.detailxml[0].telephones[0].telephone[0]['#cdata-section'] == undefined || data.detailxml[0].telephones[0].telephone[0]['#cdata-section'] == '')
			{
				thistele = '－';
			}
			else
			{
				for(var i=0; i<data.detailxml[0].telephones[0].telephone.length; i++)
				{
					teleArray.push(data.detailxml[0].telephones[0].telephone[i]['#cdata-section'])
				}
				//get first only
				thistele = teleArray[0];
			}
		}
		if(data.detailxml[0].faxes != undefined)
		{
			if(data.detailxml[0].faxes[0].fax[0]['#cdata-section'] == undefined || data.detailxml[0].faxes[0].fax[0]['#cdata-section'] == '')
			{
				thisfax = '－';
			}
			else
			{
				for(var i=0; i<data.detailxml[0].faxes[0].fax.length; i++)
				{
					faxArray.push(data.detailxml[0].faxes[0].fax[i]['#cdata-section'])
				}
				//get first only
				thisfax = faxArray[0];
			}
		}
		if(data.detailxml[0].website == undefined || data.detailxml[0].website == '')
		{
			thiswebsite = '－';
		}
		else
		{
			thiswebsite = data.detailxml[0].website;
		}
		if(data.detailxml[0].email == undefined || data.detailxml[0].email == '')
		{
			thisemail = '－';
		}
		else
		{
			thisemail = data.detailxml[0].email;
		}

		htmlresultocode += '<div class="insideDivB">';
		htmlresultocode += '<div><img src="img/inside_top.gif" border="0"></div>';
		htmlresultocode += '<div class="index_box6">';
		if(thislogo !='')
		{
			htmlresultocode += '<div id="companylogo"><img src="'+thislogo+'" border="0"></div>';
		}
		if(data.detailxml[0].title != undefined){
			htmlresultocode += '<div class="headerText">'+data.detailxml[0].title+'</div>';
		}
		if(isjobad){
			if(data.detailxml[0].desc != undefined)
			{
				var temptext = data.detailxml[0].desc+'';
				var tempjobreqarray = temptext.split('|.|');
				var thistemptext = '';
				for(var x=0; x<tempjobreqarray.length; x++)
				{
					thistemptext+= tempjobreqarray[x];
				}
				tempjobreqarray = thistemptext.split('&lt;br&gt;');
				thistemptext = '';
				for(var x=0; x<tempjobreqarray.length; x++)
				{
					if(x>0)
					{
						thistemptext+= '<br>';
					}
					thistemptext+= tempjobreqarray[x];
				}

				htmlresultocode += '<div>'+thistemptext+'</div>';
			}
		}
		else
		{
			if(job_reqs == '－'){
				if(data.detailxml[0].desc != undefined)
				{
					var temptext = data.detailxml[0].desc+'';
					var tempjobreqarray = temptext.split('|.|');
					var thistemptext = '';
					for(var x=0; x<tempjobreqarray.length; x++)
					{
						thistemptext+= tempjobreqarray[x];
					}
					tempjobreqarray = thistemptext.split('&lt;br&gt;');
					thistemptext = '';
					for(var x=0; x<tempjobreqarray.length; x++)
					{
						if(x>0)
						{
							thistemptext+= '<br>';
						}
						thistemptext+= tempjobreqarray[x];
					}

					htmlresultocode += '<div>'+thistemptext+'</div>';
				}
			}
			else{
				var temptext = job_reqs;
				var tempjobreqarray = temptext.split('|.|');
				var thistemptext = '';
				for(var x=0; x<tempjobreqarray.length; x++)
				{
					thistemptext+= tempjobreqarray[x];
				}
				tempjobreqarray = thistemptext.split('&lt;br&gt;');
				thistemptext = '';
				for(var x=0; x<tempjobreqarray.length; x++)
				{
					if(x>0)
					{
						thistemptext+= '<br>';
					}
					thistemptext+= tempjobreqarray[x];
				}
				htmlresultocode += '<div>'+thistemptext+'</div>';
			}
		}
		htmlresultocode += '</div>';
		if(isjobad){//招聘
			htmlresultocode += '<div class="highlightText bluecell">職位：'+job_title+'</div>';
		}
			htmlresultocode += '<div class="index_box6">';
		if(isjobad){//招聘
			htmlresultocode += '<div><table id="detailinfotable">';
			/*if(job_edu_level!="－"){
				htmlresultocode += '<tr><td width="15"><img src="img/bullet.gif" border="0"></td><td>'+job_edu_level+'</td></tr>';
			}
			if(job_work_exp!="－"){
				htmlresultocode += '<tr><td><img src="img/bullet.gif" border="0"></td><td>'+job_work_exp+'</td></tr>';
			}
			if(job_pay_type!="－"){
				htmlresultocode += '<tr><td><img src="img/bullet.gif" border="0"></td><td>'+job_pay_type+'</td></tr>';
			}
			if(job_dutys!="－"){
				htmlresultocode += '<tr><td><img src="img/bullet.gif" border="0"></td><td>'+job_dutys+'</td></tr>';
			}*/
			if(job_reqs!='－'){
				//htmlresultocode += '<tr><td><img src="img/bullet.gif" border="0"></td><td>'+job_reqs+'</td></tr>';
				//<img src="img/bullet.gif" border="0">
				var tempjobreqarraylist = job_reqs.split('&lt;br&gt;&lt;br&gt;');
				var tempjobreqarray = [];
				var thisjob_reqs = '';
				for(var j=0; j<tempjobreqarraylist.length; j++)
				{
					var tempjobreqarray = tempjobreqarraylist[j].split('|.|');

					thisjob_reqs+= '<table style="width:620px;">';
					for(var i=0; i<tempjobreqarray.length; i++)
					{
						if(i>0)
						{
							thisjob_reqs+= '<tr><td valign="top" style="width:15px;overflow:hidden;padding:0px;"><img src="img/bullet.gif" border="0" style="margin-top:6px;"></td><td valign="top" style="width:610px;overflow:hidden;padding:0px;">';
						}
						else
						{
							thisjob_reqs+= '<tr><td colspan="2" valign="top" style="width:605px;overflow:hidden;padding:0px;">';
						}
						thisjob_reqs+= ''+tempjobreqarray[i]+'</td></tr>';
					}
					thisjob_reqs+= '</table>';
				}
				//thisjob_reqs+= '';
				tempjobreqarray = thisjob_reqs.split('&lt;br&gt;');
				thisjob_reqs = '';
				for(var i=0; i<tempjobreqarray.length; i++)
				{
					if(i>0)
					{
						thisjob_reqs+= '<br>';
						//thisjob_reqs+= '<li class="bbullet">';
					}
					thisjob_reqs+= tempjobreqarray[i];
				}
				htmlresultocode += '<tr><td>'+thisjob_reqs+'</td></tr>';
			}
			if(this_cid == orijobcatid)
			{
				htmlresultocode += '<tr><td style="padding:10px;">';
				htmlresultocode += '<div class="corphighlightText">Application Method</div>';
				htmlresultocode += '<div>Interested parties, please send full resume with expected salary to the Personnel Department by one of the following methods (Please quote reference on the application letter):</div>';
				//htmlresultocode += '<table style="width:300px;"><tr><td>By Fax :</td><td> 3600 1900</td><tr><td>By E-mail :</td><td> employ@oriental.com.hk</td></tr></table>';
				htmlresultocode += '<div>By Fax : 3600 1900<br>By E-mail : employ@oriental.com.hk</div><br>';
				htmlresultocode += '<div><i>Personal data collected will be treated in accordance with our Personal Data Policy and handled in strict confidence by authorized personnel for recruitment related purpose only.</i></div>';
				htmlresultocode += '</td></tr>';

			}
			htmlresultocode += '</table></div>';
		}
		htmlresultocode += '<table>';
		htmlresultocode += '<tr>';
		htmlresultocode += '<td class="titletd">類別：</td>';
		htmlresultocode += '<td>'+thiskeyword+'</td>';
		htmlresultocode += '<td class="titletd">刊登日期：</td>';
		htmlresultocode += '<td>'+thispostdate+'</td>';
		htmlresultocode += '</tr>';
		htmlresultocode += '<tr><td colspan="4"><img src="img/hor_line.gif" border="0"</td></tr>';
		if(isjobad){//招聘
			htmlresultocode += '<tr>';
			htmlresultocode += '<td class="titletd">類型：</td>';
			htmlresultocode += '<td>'+job_type+'</td>';
			htmlresultocode += '<td class="titletd">薪酬：</td>';
			htmlresultocode += '<td>'+job_salary+'</td>';
			htmlresultocode += '</tr>';
			htmlresultocode += '<tr><td colspan="4"><img src="img/hor_line.gif" border="0"</td></tr>';
			htmlresultocode += '<tr>';
			htmlresultocode += '<td class="titletd">教育程度：</td>';
			htmlresultocode += '<td>'+job_edu_level+'</td>';
			htmlresultocode += '<td class="titletd">工作經驗：</td>';
			htmlresultocode += '<td>'+job_work_exp+'</td>';
			htmlresultocode += '</tr>';
			htmlresultocode += '<tr><td colspan="4"><img src="img/hor_line.gif" border="0"</td></tr>';
		}
		htmlresultocode += '<tr>';
		htmlresultocode += '<td class="titletd">聯絡電話：</td>';
		//htmlresultocode += '<td>'+thistele+'</td>';
		if(teleArray.length>1)
		{
			htmlresultocode += '<td>';
			for(var i=0; i<teleArray.length; i++)
			{
				if(i>0){
					htmlresultocode += '<br>';
				}
				htmlresultocode += teleArray[i];
			}
			htmlresultocode += '</td>';
		}
		else
		{
			htmlresultocode += '<td>'+thistele+'</td>';
		}
		htmlresultocode += '<td class="titletd">地區：</td>';
		if(locationArray.length>1)
		{
			htmlresultocode += '<td>';
			for(var i=0; i<locationArray.length; i++)
			{
				if(i>0){
					htmlresultocode += '<br>';
				}
				htmlresultocode += locationArray[i];
			}
			htmlresultocode += '</td>';
		}
		else
		{
			htmlresultocode += '<td>'+thislocation+'</td>';
		}
		htmlresultocode += '</tr>';
		htmlresultocode += '<tr><td colspan="4"><img src="img/hor_line.gif" border="0"</td></tr>';
		htmlresultocode += '<tr>';
		htmlresultocode += '<td class="titletd">傳真號碼：</td>';
		//htmlresultocode += '<td>'+thisfax+'</td>';
		if(faxArray.length>1)
		{
			htmlresultocode += '<td>';
			for(var i=0; i<faxArray.length; i++)
			{
				if(i>0){
					htmlresultocode += '<br>';
				}
				htmlresultocode += faxArray[i];
			}
			htmlresultocode += '</td>';
		}
		else
		{
			htmlresultocode += '<td>'+thisfax+'</td>';
		}
		htmlresultocode += '<td class="titletd">地址：</td>';
		//htmlresultocode += '<td>'+thisaddress+'</td>';
		if(addrArray.length>1)
		{
			htmlresultocode += '<td>';
			for(var i=0; i<addrArray.length; i++)
			{
				if(i>0){
					htmlresultocode += '<br>';
				}
				htmlresultocode += addrArray[i];
			}
			htmlresultocode += '</td>';
		}
		else
		{
			htmlresultocode += '<td>'+thisaddress+'</td>';
		}
		htmlresultocode += '</tr>';
		htmlresultocode += '<tr><td colspan="4"><img src="img/hor_line.gif" border="0"</td></tr>';
		htmlresultocode += '<tr>';
		htmlresultocode += '<td class="titletd">網址：</td>';
		htmlresultocode += '<td>'+thiswebsite+'</td>';
		htmlresultocode += '<td class="titletd">電郵：</td>';
		htmlresultocode += '<td>'+thisemail+'</td>';
		htmlresultocode += '</tr>';
		htmlresultocode += '</table>';
		htmlresultocode += '</div>';
		htmlresultocode += '</div>';

		htmlresultocode += '<div class="insideDivB index_box6">';
		for(var i=0; i<thumbnailArray.length; i++)
		{
			htmlresultocode += '<div class="fleft" style="margin-bottom:10px;">';
			htmlresultocode += '<div><a href="javascript:void(0);" onclick="javascript:popupwin(\'enlarge.html?cid='+this_cid+'&inl='+imageArray[i]+'\',300,300);"><img src="'+thumbnailArray[i]+'" width="160" height="120" border="0"></a></div>';
			htmlresultocode += '<div style="margin-top:5px;"><a href="javascript:void(0);" onclick="javascript:popupwin(\'enlarge.html?cid='+this_cid+'&inl='+imageArray[i]+'\',300,300);"><img src="img/btn_enlarge.gif" border="0"></a></div>';
			htmlresultocode += '</div>';
		}
		htmlresultocode += '<div class="backbtn"><a href="javascript:history.go(-1);"><img src="img/btn_back.gif" border="0"></a></div>';
		htmlresultocode += '</div>';
		htmlresultocode += '<div class="insideDivB"><img src="img/inside_bottom.gif" border="0"></div>';
		document.getElementById('detailcontent').innerHTML = htmlresultocode;
	}
}

String.prototype.trim=trim;
function trim() {
	if ( this == null ) {
		return null;
	}
	var newString = this;
	var start = 0;
	var end = 0;
	for ( var i = 0; i < newString.length; i++ ) {
		if ( newString.substring(i, i + 1) != ' ' && newString.substring(i, i + 1) != '　' ) {
			start = i;
			break;
		}
	}
	for ( var i = newString.length; i > 0; i-- ) {
		if ( newString.substring(i - 1, i) != ' ' && newString.substring(i - 1, i) != '　' ) {
			end = i;
			break;
		}
	}
	return newString.substring(start, end);
}
function popupwin(link, width, height) {
	window.open(link,'popup','location=no,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+',top=0,left=0');
}
function overmenu(inid)
{
	document.getElementById('menu'+inid+'_on').style.display = 'block';
	document.getElementById('menu'+inid+'_off').style.display = 'none';
}
function outmenu(inid)
{
	document.getElementById('menu'+inid+'_on').style.display = 'none';
	document.getElementById('menu'+inid+'_off').style.display = 'block';
}

function classified_footer()
{
	//sync with unicorp.js by James 2010/03/05
	/*
	var copyright_year = '2010';
	var footer = '<div>| <a class="LowLink" href="http://opg.com.hk" target="_blank">企業網站</a> | <a class="LowLink" href="http://home.on.cc/disclaimer/" class="LowLink" target="_blank">免責聲明</a> | <a class="LowLink" href="https://on.cc/cgi-bin/mem/newuser_terms.cgi?came_from=OC" target="popupdetail">登記成為on.cc會員 | </a><a href="http://on.cc/edm/accept.html" class="LowLink" target="_blank">免費會員尊訊 | </a><a href="http://on.cc/faq/hkfonts_bottom.html" class="LowLink" target="_blank">下載字庫 | </a><a class="LowLink" href="http://on.cc/copyright/" target="_blank">版權收費機制 | </a><a class="LowLink" href="http://opg.com.hk/tc/contactus.html" target="_blank">聯絡我們 | </a><a class="LowLink" href="http://on.cc/ratecard/" target="_blank">廣告查詢 | </a><a class="LowLink" href=\'javascript:popupwin("http://on.cc/orimain/contactus/index.html", "501", "421");\'>提供意見 | </a><a class="LowLink" href="http://opg.com.hk/tc/product_websites.html" target="_blank">關於on.cc | </a><a class="LowLink" href="http://on.cc/orimain/recruit/index.html" target="_blank">招聘人才 | </a><a href="http://on.cc/faq/index.html" target="_blank" class="LowLink"> 常見問題</a> |<a class="LowLink" href="#"></a></div>';
	footer += '<div>建議使用微軟Internet Explorer 5.5 或以上版本及瀏覽解象度為 1024 x 768 <br>版權所有 &copy; '+ copyright_year +' ON.CC (BVI) LTD. All rights reserved.</div>';
	document.write(footer);
	*/
	var pub = 'classified';
	document.write('<div>');
	pbmenu(pub);
	document.write('</div>');
	document.write('<div>');
	pyear(pub);
	document.write('</div>');
}

function loadrandomlist()
{
	var this_checkid = this_cid;

	var resultxml1 = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result.cgi?e=100', false);
	resultxml1.setOutputArrayAll();
	resultxml1.async(onloadrandresult1);
	resultxml1.parse();
	var resultxml2 = new onccLib.ParseXML(domainPrefix+'/cgi-bin/search/result_shortad.cgi?e=100', false);
	resultxml2.setOutputArrayAll();
	resultxml2.async(onloadrandresult2);
	resultxml2.parse();
}
var listno = 5;
var randnoArray = new Array();
var randdata1 = null;
var randdata2 = null;
var alltitleArray = new Array();
var allcatArray = new Array();
var allcontentArray = new Array();
var allidArray = new Array();
function onloadrandresult1(data)
{
	randdata1 = data;
	if(randdata1 != null && randdata2 != null)
	{
		onloadrandresult();
	}
}
function onloadrandresult2(data)
{
	randdata2 = data;
	if(randdata1 != null && randdata2 != null)
	{
		onloadrandresult();
	}
}
function onloadrandresult()
{
	if(randdata1.resultxml[0].content[0].record!=null)
	{
		for(var i=0; i<randdata1.resultxml[0].content[0].record.length;i++)
		{
			var temptitle = '－';
			var tempdesc = '－';

				if(randdata1.resultxml[0].content[0].record[i].job_detail != undefined && randdata1.resultxml[0].content[0].record[i].job_detail != ''){
					if(randdata1.resultxml[0].content[0].record[i].job_detail.length>0){
						if(randdata1.resultxml[0].content[0].record[i].job_detail[0].job_reqs != undefined && randdata1.resultxml[0].content[0].record[i].job_detail[0].job_reqs != ''){
							tempdesc = randdata1.resultxml[0].content[0].record[i].job_detail[0].job_reqs[0].job_req[0]['#cdata-section']+'';
						}
						if(randdata1.resultxml[0].content[0].record[i].job_detail[0].job_title != undefined){
							temptitle = randdata1.resultxml[0].content[0].record[i].job_detail[0].job_title[0]+'';
						}
					}
				}
				if(temptitle == '－')
				{
					if(randdata1.resultxml[0].content[0].record[i].title != undefined)
					{
						temptitle = randdata1.resultxml[0].content[0].record[i].title;
					}
				}
				if(tempdesc == '－')
				{
					if(randdata1.resultxml[0].content[0].record[i].desc != undefined)
					{
						tempdesc = randdata1.resultxml[0].content[0].record[i].desc+'';
					}
				}
				var temptext = tempdesc;
				var tempjobreqarray = temptext.split('|.|');
				var thistemptext = '';
				for(var x=0; x<tempjobreqarray.length; x++)
				{
					thistemptext+= tempjobreqarray[x];
				}
				tempjobreqarray = thistemptext.split('&lt;br&gt;');
				thistemptext = '';
				for(var x=0; x<tempjobreqarray.length; x++)
				{
					thistemptext+= tempjobreqarray[x];
				}
			alltitleArray.push(temptitle);
			allcontentArray.push(thistemptext);
			allidArray.push(randdata1.resultxml[0].content[0].record[i].id);
			allcatArray.push(randdata1.resultxml[0].content[0].record[i].catid);
		}
	}
	if(randdata2.resultxml[0].content[0].record!=null)
	{
		for(var i=0; i<randdata2.resultxml[0].content[0].record.length;i++)
		{
			alltitleArray.push(randdata2.resultxml[0].content[0].record[i].title);
			var tempdesc = '－';
			if(randdata2.resultxml[0].content[0].record[i].desc != undefined)
			{
				tempdesc = randdata2.resultxml[0].content[0].record[i].desc+'';
			}
			allcontentArray.push(tempdesc);
			allidArray.push(null);
			allcatArray.push(null);
		}
	}

	if(listno > alltitleArray.length)
	{
		listno = alltitleArray.length;
	}
	var tempno = Math.floor(Math.random()*alltitleArray.length);

	while (randnoArray.length <listno)
	{
		var addok = true;
		for(var i=0; i<randnoArray.length; i++)
		{
			if(randnoArray[i] == tempno)
			{
				addok = false;
				break;
			}
		}
		if(allcatArray[tempno] == this_cid)
		{
			//addok = false;
		}
		if(addok)
		{
			randnoArray.push(tempno);
		}
		tempno = Math.floor(Math.random()*alltitleArray.length);
	}

	var htmlcode = '';
	var htmlcodein = '';
	htmlcode +='<div><img src="img/side_top.gif" width="300" height="26"></div>';
	htmlcode +='<div style="width:300px;background:url(img/side_patt.gif) repeat-y;">';
	for(var i=0; i<randnoArray.length;i++)
	{
		if(htmlcodein != '')
		{
			htmlcodein +='<div><img src="img/side_line.gif" width="300" height="1"></div>';
		}
		var thislink = '';
		if(allcatArray[randnoArray[i]] == null)
		{
			thislink = 'list.html?cid=-1';
		}
		else
		{
			thislink = 'detail.html?id='+allidArray[randnoArray[i]]+'&cid='+allcatArray[randnoArray[i]];
		}
		htmlcodein += '<div class="ranad"><a href="'+thislink+'"><span class="randtitle">'+alltitleArray[randnoArray[i]]+'</span></a><br>';
		htmlcodein += '<a href="'+thislink+'">'+shortentext(allcontentArray[randnoArray[i]]+'', 50)+'</a></div>';
	}
	htmlcode += htmlcodein;
	htmlcode +='</div><div><img src="img/side_bottom.gif" width="300" height="10"></div>';
	document.getElementById('randomlist').innerHTML = htmlcode;
}
function onloadlocation(data)
{
	var htmlcode = '';
	var thtmlcode = '';
	htmlcode += '<option value="">所有地區</option>';
	//alert(data.adlocationxml[0].adlocation[0].id)
	for (var i=0; i<data.adlocationxml[0].adlocation.length; i++)
	{
		var isselected = '';
		if(String(data.adlocationxml[0].adlocation[i].id) == lid)
		{
			isselected = ' selected';
		}
		htmlcode += '<option value="'+data.adlocationxml[0].adlocation[i].id+'" '+isselected+'>'+data.adlocationxml[0].adlocation[i].description+'</option>';
	}
	htmlcode += '</select>';
	if(pagetype == 'main')
	{
		document.getElementById('selectarea').innerHTML = '<select name="area_select" id="area_select">'+htmlcode;
	}
	else
	{
		document.getElementById('selectarea').innerHTML = '<select name="area_select" id="area_select" onchange="listsearchsubmit()">'+htmlcode;
	}
	document.getElementById('topselectarea').innerHTML = '<select name="toparea_select" id="toparea_select">'+htmlcode;
}
function onloadjobtype(data)
{
	var htmlcode = '';
	if(pagetype == 'main')
	{
		htmlcode += '<select name="jtype_select" id="jtype_select">';
	}
	else
	{
		htmlcode += '<select name="jtype_select" id="jtype_select" onchange="listsearchsubmit()">';
	}
	htmlcode += '<option value="">所有類型</option>';

	for (var i=0; i<data.adjobtypexml[0].adjobtype.length; i++)
	{
		var isselected = '';
		if(String(data.adjobtypexml[0].adjobtype[i].code) == jyid)
		{
			isselected = ' selected';
		}
		htmlcode += '<option value="'+data.adjobtypexml[0].adjobtype[i].code+'" '+isselected+'>'+data.adjobtypexml[0].adjobtype[i].description+'</option>';
	}
	htmlcode += '</select>';
	document.getElementById('selectjobtype').innerHTML = htmlcode;
}

function onloadsalary(data)
{
	var htmlcode = '';
	if(pagetype == 'main')
	{
		htmlcode += '<select name="salary_select" id="salary_select">';
	}
	else
	{
		htmlcode += '<select name="salary_select" id="salary_select" onchange="listsearchsubmit()">';
	}
	htmlcode += '<option value="">所有薪酬</option>';

	for (var i=0; i<data.adsalaryxml[0].adsalary.length; i++)
	{
		var isselected = '';
		if(String(data.adsalaryxml[0].adsalary[i].id) == sid)
		{
			isselected = ' selected';
		}
		htmlcode += '<option value="'+data.adsalaryxml[0].adsalary[i].id+'" '+isselected+'>'+data.adsalaryxml[0].adsalary[i].description+'</option>';
	}
	htmlcode += '</select>';
	document.getElementById('selectsalary').innerHTML = htmlcode;
}
function onloadlatestjobad(data)
{
	var htmlcode='';
	var thismax = 3;
	if(data.resultxml[0].content[0].record != null)
	{
		if(data.resultxml[0].content[0].record.length <3)
		{
			thismax = data.resultxml[0].content[0].record.length;
		}
		htmlcode += '<table><tr>';
		for(var i=0; i<thismax; i++)
		{
			var thisid = data.resultxml[0].content[0].record[i].id;
			var thistitle = '';
			var thisdesc = '';
			//thistitle = data.resultxml[0].content[0].record[i].title;
			//thisdesc = shortentext(data.resultxml[0].content[0].record[i].desc+'', 100);
			if(data.resultxml[0].content[0].record[i].job_detail != undefined && data.resultxml[0].content[0].record[i].job_detail != ''){
				if(data.resultxml[0].content[0].record[i].job_detail.length>0){
					if(data.resultxml[0].content[0].record[i].job_detail[0].job_reqs != undefined && data.resultxml[0].content[0].record[i].job_detail[0].job_reqs != ''){
						var temptext = data.resultxml[0].content[0].record[i].job_detail[0].job_reqs[0].job_req[0]['#cdata-section']+'';
						var tempjobreqarray = temptext.split('|.|');
						var thistemptext = '';
						for(var x=0; x<tempjobreqarray.length; x++)
						{
							thistemptext+= tempjobreqarray[x];
						}
						tempjobreqarray = thistemptext.split('&lt;br&gt;');
						thistemptext = '';
						for(var x=0; x<tempjobreqarray.length; x++)
						{
							thistemptext+= tempjobreqarray[x];
						}
						thisdesc = shortentext(thistemptext,100);
					}
					if(data.resultxml[0].content[0].record[i].job_detail[0].job_title != undefined){
						thistitle = data.resultxml[0].content[0].record[i].job_detail[0].job_title[0]+'';
					}
				}
			}
			
			var thisthumb = '';
			if(data.resultxml[0].content[0].record[i].logo != undefined)
			{
				thisthumb = domainPrefix+'/adimg/'+data.resultxml[0].content[0].record[i].logo;
			}
			if(i>0){
				htmlcode += '<td><div class="vline"><img src="img/ver_line.gif" border="0"></div></td>';
			}
			htmlcode += '<td><div class="newjobcell">';
			if(thisthumb != '')
			{
				//htmlcode += '<div style="float:left;"><a href="detail.html?id='+thisid+'&cid='+jobcatid+'" ><img src="'+thisthumb+'" width="80" border="0"></a></div>';
			}
			htmlcode += '<a href="detail.html?id='+thisid+'&cid='+jobcatid+'" ><span class="randtitle">'+thistitle+'</span><br>'+thisdesc+'</a>';
			htmlcode += '</div></td>';
		}
		htmlcode += '</tr></table>';

	}
	document.getElementById('latestjobad').innerHTML = htmlcode;
}
function onloadsplatestjobad(data)
{
	var htmlcode='';
	var thismax = 2;
	if(data.resultxml[0].content[0].record != null)
	{
		if(data.resultxml[0].content[0].record.length <2)
		{
			thismax = data.resultxml[0].content[0].record.length;
		}
		for(var i=0; i<thismax; i++)
		{
			var thisid = data.resultxml[0].content[0].record[i].id;
			var thistitle = '';
			var thisdesc = '';
			//thistitle = data.resultxml[0].content[0].record[i].title;
			//thisdesc = shortentext(data.resultxml[0].content[0].record[i].desc+'', 100);
			if(data.resultxml[0].content[0].record[i].job_detail != undefined && data.resultxml[0].content[0].record[i].job_detail != ''){
				if(data.resultxml[0].content[0].record[i].job_detail.length>0){
					if(data.resultxml[0].content[0].record[i].job_detail[0].job_reqs != undefined && data.resultxml[0].content[0].record[i].job_detail[0].job_reqs != ''){
						var temptext = data.resultxml[0].content[0].record[i].job_detail[0].job_reqs[0].job_req[0]['#cdata-section']+'';
						var tempjobreqarray = temptext.split('|.|');
						var thistemptext = '';
						for(var x=0; x<tempjobreqarray.length; x++)
						{
							thistemptext+= tempjobreqarray[x];
						}
						tempjobreqarray = thistemptext.split('&lt;br&gt;');
						thistemptext = '';
						for(var x=0; x<tempjobreqarray.length; x++)
						{
							thistemptext+= tempjobreqarray[x];
						}
						thisdesc = shortentext(thistemptext,100);
					}
					if(data.resultxml[0].content[0].record[i].job_detail[0].job_title != undefined){
						thistitle = data.resultxml[0].content[0].record[i].job_detail[0].job_title[0]+'';
					}
				}
			}
			htmlcode += '<div>';
			htmlcode += '<a href="detail.html?id='+thisid+'&cid='+jobcatid+'" ><span class="randtitle">'+thistitle+'</span><br>'+thisdesc+'</a>';
			htmlcode += '</div>';
		}
	}
	document.getElementById('jobtypelist').innerHTML = htmlcode;
}
function onloadotherjobad(data)
{
	//010,020,030,040,050,060,070,080
	var htmlcode='';
	var thiscolor = '';
	if(data.resultxml[0].content[0].record != null)
	{
		if(data.resultxml[0].content[0].record.length>0)
		{
			htmlcode += '<table><tr class="trheader"><td>標題</td><td>內容</td><td width="60">聯絡資料</td></tr>';
			for(var i=0; i<data.resultxml[0].content[0].record.length; i++)
			{
				var thistitle = data.resultxml[0].content[0].record[i].title;
				var thisdesc = shortentext(data.resultxml[0].content[0].record[i].desc+'', 30);
				var thistel = '－';
				if(data.resultxml[0].content[0].record[i].remarks != null)
				{
					if(data.resultxml[0].content[0].record[i].remarks[0].remark != null)
					{
						for(var j=0; j< data.resultxml[0].content[0].record[i].remarks[0].remark.length; j++)
						{
							if(data.resultxml[0].content[0].record[i].remarks[0].remark[j].id=='3')
							{
								if(data.resultxml[0].content[0].record[i].remarks[0].remark[j]['#cdata-section'] != undefined)
								{
									var temptel = String(data.resultxml[0].content[0].record[i].remarks[0].remark[j]['#cdata-section']+'').split('/');
									thistel = temptel[0];
								}
							}
						}
						
					}
				}

				if(thiscolor == ' class="bluecell"')
				{
					thiscolor = '';
				}
				else
				{
					thiscolor = ' class="bluecell"';
				}
				htmlcode += '<tr'+thiscolor+'>';
				htmlcode += '<td><a href="list.html?cid=-1">'+thistitle+'</a></td>';
				htmlcode += '<td><a href="list.html?cid=-1">'+thisdesc+'</a></td>';
				htmlcode += '<td><a href="list.html?cid=-1">'+thistel+'</a></td>';
				htmlcode += '</tr>';
			}
			htmlcode += '</table>';
		}
	}
	document.getElementById('otherjobad').innerHTML = htmlcode;
}
function shortentext(intext, slength){
	if(intext.length < slength)
	{
		return intext;
	}
	else
	{
		return (intext.substr(0, slength))+'...';
	}
}
