var http;
var notFirst='';
var selectedlocid;
var selectedmakeid;
var selectedbedroomid;
var selectedbathroomid;
var locstrarr='';
var makestrarr='';
var bedroomarr = '';
var bathroomarr = '';
var mk=0;
var lc=0;
var br = 0;
var bthr = 0;
var comboid = ''
function getClassified(start,iCal,id)
{
	if(id != ''){
		comboid = id; 		
	}
	
	if(document.getElementById('location') && document.getElementById('make'))
	{
		if(document.getElementById('location').value == '' &&
			document.getElementById('make').value == ''){
			notFirst = '';
			locstrarr ='';
			lc = 0;				
			makestrarr ='';
			mk = 0;			
		}
	}
	if(document.getElementById('location') && document.getElementById('bedrooms')
		&& document.getElementById('bathrooms')){
		
		if(document.getElementById('location').value == '' &&
			document.getElementById('bedrooms').value == '' && document.getElementById('bathrooms').value == ''){
			notFirst = '';
			locstrarr ='';
			lc = 0;	
			bedroomarr ='';
			br = 0;	
			bthr = 0;
			bathroomarr = '';
		}
	}
	
	document.getElementById("divShowLoading").style.display="";
	var ext = '';
		if(document.getElementById("totsub")){
			var totsub = document.getElementById("totsub").value;
			var stringtype='';
			for(i=0;i<totsub;i++){
				if(document.getElementById("rel_"+i)){
					if(document.getElementById("rel_"+i).checked == true){
						var subval= document.getElementById("rel_"+i).value;
						stringtype +=",";
						stringtype +=subval;
					}
				}
			}
			if(stringtype !='')
			ext+='&subval='+stringtype;
		}
		if(document.getElementById("orderby")){
			var orderby = document.getElementById("orderby").value;
			if(orderby != '')
			{
				ext+='&orderby='+orderby;
			}
		}
		if(iCal !='')
		ext+='&iCCategoryId='+iCal;
		if(document.getElementById("keyword")){
			if(document.getElementById("keyword")){
				var keyword = document.getElementById("keyword").value;
				if(keyword !='')
				ext+='&keyword='+keyword;
			}
		}
		if(document.getElementById("make")){
			var make = document.getElementById("make").value;
			if(make !='')
			ext+='&make='+make;
		}
		if(document.getElementById("location")){
			var location = document.getElementById("location").value;
			if(location !='')
			ext+='&location='+location;
		}
		if(document.getElementById("model")){
			var model = document.getElementById("model").value;
			if(model !='')
			ext+='&model='+model;
		}
		if(document.getElementById("price")){
			var price = document.getElementById("price").value;
			if(price !='')
			ext+='&price='+price;
		}
		if(document.getElementById("iParentId")){
			var iParentId = document.getElementById("iParentId").value;
			if(iParentId =='0')
				ext+='&iParentId='+iParentId;
		}
		if(document.getElementById("bedrooms")){
			var bedrooms = document.getElementById("bedrooms").value;
			if(bedrooms !='')
				ext+='&bedrooms='+bedrooms;
		}
		if(document.getElementById("bathrooms")){
			var bathrooms = document.getElementById("bathrooms").value;
			if(bathrooms !='')
				ext+='&bathrooms='+bathrooms;
		}
		
		var url = SITE_AJAX_URL+"classifiedlist.php?&start="+start+"&rec_limit="+rec_limit+ext;
		//alert(url);	//return false;		
		//document.getElementById("divClassified").style.display = "";
		//$("divClassified").load(url+pars);
	if (window.XMLHttpRequest)
  	{
  		http=new XMLHttpRequest()
  		http.open("GET",url,true)
	  	http.onreadystatechange=getClassifiedlist;
	  	http.send(null)
  	}
	// code for IE
	else if (window.ActiveXObject)
  	{
  		http=new ActiveXObject("Microsoft.XMLHTTP")
    	if (http)
    	{
    		http.open("GET",url,true)
    		http.onreadystatechange=getClassifiedlist;
    		http.send()
    	}
  	}
}
function getClassifiedlist()
{
	if (http.readyState == 4) 
	{	
      	isWorking = false;
    	if (http.responseText.indexOf('invalid') == -1) 
		{
			var html = '';
    		var xmlDocument = http.responseXML; 
			var totrec = xmlDocument.getElementsByTagName('totrec').item(0).firstChild.data;
			var start = xmlDocument.getElementsByTagName('start').item(0).firstChild.data;
			var recmsg = xmlDocument.getElementsByTagName('recmsg').item(0).firstChild.data;
			var no = xmlDocument.getElementsByTagName('iclassifiedid').length;
			var cat_id 	= xmlDocument.getElementsByTagName('cat_id').item(0).firstChild.data;
			var iparentid 	= xmlDocument.getElementsByTagName('iparentid').item(0).firstChild.data;
			
			/* New Condition For Display Combo*/
			if(document.getElementById('location'))
				selectedlocid = document.getElementById('location').value;
			if(document.getElementById('make'))
				selectedmakeid = document.getElementById('make').value;	
			if(document.getElementById('bedrooms'))
				selectedbedroomid = document.getElementById('bedrooms').value;	
			if(document.getElementById('bathrooms'))
				selectedbathroomid = document.getElementById('bathrooms').value;		
			/* ENDS HERE */	
		if(xmlDocument.getElementsByTagName('ical').item(0))
				var iCal = xmlDocument.getElementsByTagName('ical').item(0).firstChild.data;
			else
				var iCal = '';
			
			if(no > 0)
			{
			html+='<TABLE width="100%" border="0" class="category-table-border-orange" align="center" cellpadding="1" cellspacing="1" >';
					if(cat_id == '135' || iparentid == '135' || cat_id == '145' || iparentid == '145' || cat_id == '169' || iparentid == '169' || cat_id == '173' || iparentid == '173' || cat_id == '41' || iparentid == '41' || cat_id == '209' || iparentid == '209' || cat_id == '65' || iparentid == '65' || cat_id == '185' || iparentid == '185' || cat_id == '203' || iparentid == '203' || cat_id == '215' || iparentid == '215' || cat_id == '327' || iparentid == '327' || cat_id == '329' || iparentid == '329')
					{
					html+='<TR  class="categoryhead-bg-orange"> ';
						if(cat_id != '209' &&  iparentid != '209' && cat_id != '65' &&  iparentid != '65'){
							html+='<TD width="5%"  align="center" valign="middle">'+LBL_IMAGE+'</TD>';
						}
						
						if(cat_id == '135' || iparentid == '135'){
							html+='<TD width="5%"  align="center" valign="middle">'+LBL_VIEW+'</TD>';
							html+='<TD width="16%"  align="center" valign="middle">'+LBL_MAKE+'</TD>';
							html+='<TD width="16%"  align="center" valign="middle">'+LBL_MODEL+'</TD>';
							html+='<TD width="10%"  align="center" valign="middle">'+LBL_YEAR+'</TD>';
							html+='<TD width="15%"  align="center" valign="middle">'+LBL_PRICE+'</TD>';
						}else if(cat_id == '145' || iparentid == '145' || cat_id == '169' || iparentid == '169'){
							html+='<TD width="5%"  align="center" valign="middle">'+LBL_VIEW+'</TD>';
							html+='<TD width="10%"  align="center" valign="middle">'+LBL_PROVINCE+'</TD>';
							html+='<TD width="35%"  align="center" valign="middle">'+LBL_OTHER_INFO+'</TD>';
							html+='<TD width="15%"  align="center" valign="middle">'+LBL_PRICE+'</TD>';
						}else if(cat_id == '173' || iparentid == '173' || cat_id == '41' || iparentid == '41' || cat_id == '215' || iparentid == '215' || cat_id == '185' || iparentid == '185' || cat_id == '327' || iparentid == '327'){
							html+='<TD width="5%"  align="center" valign="middle">'+LBL_VIEW+'</TD>';
							html+='<TD width="8%"  align="center" valign="middle">'+LBL_CONDITION+'</TD>';
							html+='<TD width="10%"  align="center" valign="middle">'+LBL_BRAND+'</TD>';
							html+='<TD width="12%"  align="center" valign="middle">'+LBL_PRICE+'</TD>';
							html+='<TD width="22%"  align="left" valign="middle">'+LBL_DESC+'</TD>';
						}else if(cat_id == '329' || iparentid == '329'){
							html+='<TD width="5%"  align="center" valign="middle">'+LBL_VIEW+'</TD>'
							html+='<TD width="20%"  align="center" valign="middle">'+LBL_PRICE+'</TD>';
							html+='<TD width="32%"  align="left" valign="middle">'+LBL_DESC+'</TD>';;	
							
						}else if(cat_id == '203' || iparentid == '203'){
							html+='<TD width="5%"  align="center" valign="middle">'+LBL_VIEW+'</TD>';
							html+='<TD width="20%"  align="center" valign="middle">'+LBL_LOCATION+'</TD>';
							html+='<TD width="16%"  align="center" valign="middle">'+LBL_CONDITION+'</TD>';
							html+='<TD width="20%"  align="center" valign="middle">'+LBL_BRAND+'</TD>';
							html+='<TD width="15%"  align="center" valign="middle">'+LBL_PRICE+'</TD>';
						}else if(cat_id == '209' || iparentid == '209'){
							html+='<TD width="5%"  align="center" valign="middle">'+LBL_VIEW+'</TD>';
							html+='<TD width="15%"  align="center" valign="middle">'+LBL_NAME+'</TD>';
							html+='<TD width="15%"  align="center" valign="middle">'+LBL_LOCATION+'</TD>';
							html+='<TD width="15%"  align="center" valign="middle">'+LBL_SPECIALISATION+'</TD>';
							html+='<TD width="25%"  align="center" valign="middle">'+LBL_YEAR_OF_EXP+'</TD>';
							html+='<TD width="15%"  align="center" valign="middle">'+LBL_AGE+'</TD>';
						}else if(cat_id == '65' || iparentid == '65'){
							html+='<TD width="5%"  align="center" valign="middle">'+LBL_VIEW+'</TD>';
							html+='<TD width="20%"  align="center" valign="middle">'+LBL_COMPANY_NAME+'</TD>';
							html+='<TD width="15%"  align="center" valign="middle">'+LBL_LOCATION+'</TD>';
							html+='<TD width="20%"  align="center" valign="middle">'+LBL_SPECIALISATION+'</TD>';
							html+='<TD width="25%"  align="center" valign="middle">'+LBL_YEAR_OF_EXP+'</TD>';
							html+='<TD width="15%"  align="center" valign="middle">'+LBL_SALARY_RANGE+'</TD>';
						}
						
					html+='</TR>';	
					
					}
							document.getElementById('REC_MSG_TOP').innerHTML =recmsg;
							document.getElementById('REC_MSG_BOTTOM').innerHTML =recmsg;
							 mk=0;
							 lc=0;
							 br = 0;
							 bthr = 0;
							for(i=0; i<no; i++)
							{
								var iclassifiedid 	= xmlDocument.getElementsByTagName('iclassifiedid').item(i).firstChild.data;
								
								var clname 			= xmlDocument.getElementsByTagName('clname').item(i).firstChild.data;
								var vimage 			= xmlDocument.getElementsByTagName('vimage').item(i).firstChild.data;
								var hrefprod 		= xmlDocument.getElementsByTagName('hrefprod').item(i).firstChild.data;
								var cldesc 			= xmlDocument.getElementsByTagName('cldesc').item(i).firstChild.data;
								var cl_largimg 		= xmlDocument.getElementsByTagName('cl_largimg').item(i).firstChild.data;
								var lang_id 		= xmlDocument.getElementsByTagName('lang_id').item(i).firstChild.data;							
								var isubc 		= xmlDocument.getElementsByTagName('isubc').item(i).firstChild.data;							
								
								var bgcolor;
								var bgcolor = (i%2)?"category-bg-orange-light" : "classified-bg-orange";
							if(cat_id != '135' && iparentid != '135' && cat_id != '145' && iparentid != '145' && cat_id != '169' && iparentid != '169' && cat_id != '173' && iparentid != '173' && cat_id != '41' && iparentid != '41' && cat_id != '209' && iparentid != '209' && cat_id != '65' && iparentid != '65' && cat_id != '185' && iparentid != '185'  && cat_id != '203' && iparentid != '203' && cat_id != '215' && iparentid != '215' && cat_id != '327' && iparentid != '327' && cat_id != '329' && iparentid != '329')
								{
									html+='<TR  class="categoryhead-bg-orange"> ';
										html+='<TD align="left" valign="middle" colspan="6">'+clname+'</TD>';
									html+='</TR>';	
									html+='<TR class="'+bgcolor+'" >';
										if(vimage != '-'){
										html+='<TD align="center" valign="middle" class="right-border" ><b><a href="'+SITE_URL+'clasificados_descripcion/'+hrefprod+'/'+isubc+'/'+lang_id+'"><IMG align="middle" class="img-border" style="cursor:pointer" src="images/camera-icon.gif" /></a></b></TD>';
										}else{
										  html+='<TD align="center" valign="middle" class="right-border" width="10%" ><b></TD>';										
										}
										if(cldesc == '-'){
										 html+='<TD  lign="left" valign="top" colspan="4">...<a href="'+SITE_URL+'clasificados_descripcion/'+clname+'/'+cat_id+'/'+lang_id+'">'+VIEW_DETAILS+'</a></TD>';
										}else{
											html+='<TD  align="left" valign="top" colspan="3">'+cldesc+'...<a href="'+SITE_URL+'clasificados_descripcion/'+clname+'/'+cat_id+'/'+lang_id+'">'+VIEW_DETAILS+'</a></TD>';
										}
									html+=' </TR>';
									html+=' <TR><TD></TD></TR>';					
								}else{
								var fprice 			= xmlDocument.getElementsByTagName('fprice').item(i).firstChild.data;
								var year 			= xmlDocument.getElementsByTagName('year').item(i).firstChild.data;
								var vmake 			= xmlDocument.getElementsByTagName('vmake').item(i).firstChild.data;
								var model 			= xmlDocument.getElementsByTagName('model').item(i).firstChild.data;
								var location 		= xmlDocument.getElementsByTagName('location').item(i).firstChild.data;
								//alert(location);
								if(document.getElementById('location') && notFirst == ''){
									if(in_array(locstrarr,location) == 0){
										document.getElementById('location').options[lc+1] = new Option(location);
										document.getElementById('location').options[lc+1].value = location;
										if(selectedlocid == location){
											document.getElementById('location').options[lc+1].selected = true;
										}
										locstrarr+=location+',';	
										lc++;
									}
								}else if(document.getElementById('location') && comboid != 'location'){	
										if(i == 0){
											document.getElementById('location').options.length = 1;
											lc = 0;
											locstrarr = '';
										}	
										if(in_array(locstrarr,location) == 0){	
											document.getElementById('location').options[lc+1] = new Option(location);
											document.getElementById('location').options[lc+1].value = location;
											if(selectedlocid == location){
												document.getElementById('location').options[lc+1].selected = true;
											}
											locstrarr+=location+',';	
											lc++;
										}
								}								
								if(document.getElementById('make') && notFirst == ''){									
									if(in_array(makestrarr,vmake) == 0){
										document.getElementById('make').options[mk+1] = new Option(vmake);
										document.getElementById('make').options[mk+1].value = vmake;
										if(selectedmakeid == vmake){
											document.getElementById('make').options[mk+1].selected = true;
										}
										mk++;
										makestrarr+=vmake+',';	
									}
								}else if(document.getElementById('make') && comboid != 'make') {									
										if(i == 0){
											document.getElementById('make').options.length = 1;
											mk = 0;
											makestrarr = '';
										}	
										if(in_array(makestrarr,vmake) == 0){
											document.getElementById('make').options[mk+1] = new Option(vmake);
											document.getElementById('make').options[mk+1].value = vmake;
											if(selectedmakeid == vmake){
												document.getElementById('make').options[mk+1].selected = true;
											}
											mk++;
											makestrarr+=vmake+',';	
										}																		
								}
								
								html+='<TR class="'+bgcolor+'" >';	
									if(cat_id != '209' &&  iparentid != '209'  && cat_id != '65' &&  iparentid != '65'){
									html+='<TD  align="center" valign="middle">';
										if(vimage != '-'){
										html+='<b><a href="'+SITE_URL+'clasificados_descripcion/'+hrefprod+'/'+isubc+'/'+lang_id+'"><IMG align="middle" class="img-border" style="cursor:pointer" src="images/camera-icon.gif" /></a></b>';
										}
									html+='</TD>';
								}
								if(cat_id == '135' || iparentid == '135'){
									html+='<TD height="25px" align="center" valign="middle">';
											html+='<a href="'+SITE_URL+'clasificados_descripcion/'+hrefprod+'/'+isubc+'/'+lang_id+'" class="greylinkbold">'+LBL_VIEW+'</a>';
									html+='</TD>';
									html+='<TD  align="center" valign="middle">'+vmake+'</TD>';
									html+='<TD  align="center" valign="middle">'+model+'</TD>';
									html+='<TD  align="center" valign="middle" >'+year+'</TD>';
									html+='<TD  align="center" valign="middle">'+fprice+'</TD>';
								}else if(cat_id == '145' || iparentid == '145' || cat_id == '169' || iparentid == '169'){
									html+='<TD  align="center" valign="middle">';
											html+='<a href="'+SITE_URL+'clasificados_descripcion/'+hrefprod+'/'+isubc+'/'+lang_id+'" class="greylinkbold">'+LBL_VIEW+'</a>';
									html+='</TD>';
									html+='<TD  align="center" valign="middle">'+location+'</TD>';
									var sector = xmlDocument.getElementsByTagName('sector').item(i).firstChild.data;	
									var bathroom = xmlDocument.getElementsByTagName('bathroom').item(i).firstChild.data;	
									var bedroom = xmlDocument.getElementsByTagName('bedroom').item(i).firstChild.data;	
									var size = xmlDocument.getElementsByTagName('size').item(i).firstChild.data;									
									
									if(document.getElementById('bedrooms') && notFirst == ''){									
										if(in_array(bedroomarr,bedroom) == 0){
											document.getElementById('bedrooms').options[br+1] = new Option(bedroom);
											document.getElementById('bedrooms').options[br+1].value = bedroom;
											if(selectedbedroomid == bedroom){
												document.getElementById('bedrooms').options[br+1].selected = true;
											}
											br++;
											bedroomarr+=bedroom+',';	
										}
									}else if(document.getElementById('bedrooms') && comboid != 'bedrooms'){	
										if(i == 0){
											document.getElementById('bedrooms').options.length = 1;
											br = 0;
											bedroomarr = '';
										}	
										if(in_array(bedroomarr,bedroom) == 0){	
											document.getElementById('bedrooms').options[br+1] = new Option(bedroom);
											document.getElementById('bedrooms').options[br+1].value = bedroom;
											if(selectedbedroomid == bedroom){
												document.getElementById('bedrooms').options[br+1].selected = true;
											}
											bedroomarr+=bedroom+',';	
											br++;
										}
									}
									if(document.getElementById('bathrooms') && notFirst == ''){									
										if(in_array(bathroomarr,bathroom) == 0){
											document.getElementById('bathrooms').options[bthr+1] = new Option(bathroom);
											document.getElementById('bathrooms').options[bthr+1].value = bathroom;
											if(selectedbathroomid == bathroom){
												document.getElementById('bathrooms').options[bthr+1].selected = true;
											}
											bthr++;
											bathroomarr+=bathroom+',';
										}
									}else if(document.getElementById('bathrooms') && comboid != 'bathrooms'){	
										if(i == 0){
											document.getElementById('bathrooms').options.length = 1;
											bthr = 0;
											bathroomarr = '';
										}	
										if(in_array(bathroomarr,bathroom) == 0){	
											document.getElementById('bathrooms').options[bthr+1] = new Option(bathroom);
											document.getElementById('bathrooms').options[bthr+1].value = bathroom;
											if(selectedbathroomid == bathroom){
												document.getElementById('bathrooms').options[bthr+1].selected = true;
											}
											bathroomarr+=bathroom+',';	
											bthr++;
										}
									}
									html+='<TD  align="center" valign="middle">';
										html+='<TABLE width="97%" border="0" align="center" cellpadding="1" cellspacing="1" >';
										html+='<TR>';
											html+='<TD>';
												html+='<TABLE width="97%" border="0"  cellpadding="1" cellspacing="1" >';
												html+='<TR>';
													html+='<TD width="50%" align="right" valign="top">'+LBL_SECTOR+'</TD>';
													html+='<TD width="1%" valign="top">:</TD>';
													html+='<TD align="left" valign="top"><strong>'+sector+'</strong></TD>';
												html+='</TR>';
												html+='<TR>';
													html+='<TD  align="right">'+LBL_BATHROOM+'</TD>';
													html+='<TD  valign="top">:</TD>';
													html+='<TD align="left" valign="top"><strong>'+bathroom+'</strong></TD>';
												html+='</TR>';
												html+='<TR>';
													html+='<TD  align="right">'+LBL_BEDROOMS+'</TD>';
													html+='<TD  valign="top">:</TD>';
													html+='<TD align="left" valign="top"><strong>'+bedroom+'</strong></TD>';
												html+='</TR>';
												html+='<TR>';
													html+='<TD  align="right">'+LBL_SIZE_M2+'</TD>';
													html+='<TD valign="top">:</TD>';
													html+='<TD  valign="top" align="left"><strong>'+size+'</strong></TD>';
												html+='</TR>';
												html+='</TABLE>';
											html+='</TD>';
 										html+='</TR>';
										html+='</TABLE>';	
									html+='</TD>';
									html+='<TD  align="center" valign="middle">'+fprice+'</TD>';
								}else if(cat_id == '173' || iparentid == '173' || cat_id == '41' || iparentid == '41' || cat_id == '215' || iparentid == '215' || cat_id == '185' || iparentid == '185' || cat_id == '327' || iparentid == '327'){
									var condition = xmlDocument.getElementsByTagName('condition1').item(i).firstChild.data;	
									
									var brand = xmlDocument.getElementsByTagName('brand').item(i).firstChild.data;	
									var tsdesc = xmlDocument.getElementsByTagName('tsdesc').item(i).firstChild.data;	
									
									html+='<TD height="25px" align="center" valign="middle">';
											html+='<a href="'+SITE_URL+'clasificados_descripcion/'+hrefprod+'/'+isubc+'/'+lang_id+'" class="greylinkbold">'+LBL_VIEW+'</a>';
									html+='</TD>';
									html+='<TD  align="center" valign="middle">'+condition+'</TD>';
									html+='<TD  align="center" valign="middle">'+brand+'</TD>';
									html+='<TD  align="center" valign="middle">'+fprice+'</TD>';
									html+='<TD  align="left" valign="middle">'+tsdesc+'</TD>';
								}else if(cat_id == '329' || iparentid == '329'){
									//var tsdesc = xmlDocument.getElementsByTagName('tsdesc').item(i).firstChild.data;	
									html+='<TD height="25px" align="center" valign="middle">';
											html+='<a href="'+SITE_URL+'clasificados_descripcion/'+hrefprod+'/'+isubc+'/'+lang_id+'" class="greylinkbold">'+LBL_VIEW+'</a>';
									html+='</TD>';
									html+='<TD  align="center" valign="middle">'+fprice+'</TD>';
									html+='<TD  align="left" valign="middle">'+cldesc+'</TD>';
								}else if(cat_id == '203' || iparentid == '203'){
									var condition1 = xmlDocument.getElementsByTagName('condition1').item(i).firstChild.data;
									var brand = xmlDocument.getElementsByTagName('brand').item(i).firstChild.data;	
									html+='<TD height="25px"  align="center" valign="middle">';
											html+='<a href="'+SITE_URL+'clasificados_descripcion/'+hrefprod+'/'+isubc+'/'+lang_id+'" class="greylinkbold">'+LBL_VIEW+'</a>';
									html+='</TD>';
									html+='<TD  align="left" valign="middle">'+location+'</TD>';
									html+='<TD  align="left" valign="middle">'+condition1+'</TD>';
									html+='<TD  align="left" valign="middle">'+brand+'</TD>';
									html+='<TD  align="center" valign="middle">'+fprice+'</TD>';
									
								}else if(cat_id == '209' || iparentid == '209'){
									var spec = xmlDocument.getElementsByTagName('spec').item(i).firstChild.data;	
									var yoe = xmlDocument.getElementsByTagName('yoe').item(i).firstChild.data;	
									var age = xmlDocument.getElementsByTagName('age').item(i).firstChild.data;	
									html+='<TD height="25px"  align="center" valign="middle">';
											html+='<a href="'+SITE_URL+'clasificados_descripcion/'+hrefprod+'/'+isubc+'/'+lang_id+'" class="greylinkbold">'+LBL_VIEW+'</a>';
									html+='</TD>';	
									html+='<TD align="center" valign="middle">'+clname+'</TD>';
									html+='<TD align="center" valign="middle">'+location+'</TD>';
									html+='<TD align="center" valign="middle">'+spec+'</TD>';
									html+='<TD align="center" valign="middle">'+yoe+'</TD>';
									html+='<TD align="center"  valign="middle">'+age+'</TD>';
								}else if(cat_id == '65' || iparentid == '65'){
									var compname = xmlDocument.getElementsByTagName('compname').item(i).firstChild.data;	
									var spec = xmlDocument.getElementsByTagName('spec').item(i).firstChild.data;	
									var yoe = xmlDocument.getElementsByTagName('yoe').item(i).firstChild.data;
									var salaryrange = xmlDocument.getElementsByTagName('salaryrange').item(i).firstChild.data;	
                  
									html+='<TD  align="center" valign="middle">';
											html+='<a href="'+SITE_URL+'clasificados_descripcion/'+hrefprod+'/'+isubc+'/'+lang_id+'" class="greylinkbold">'+LBL_VIEW+'</a>';
									html+='</TD>';	
									html+='<TD  height="25px" align="center" valign="middle">'+compname+'</TD>';
									html+='<TD   align="center" valign="middle">'+location+'</TD>';
									html+='<TD   align="center" valign="middle">'+spec+'</TD>';
									html+='<TD   align="center" valign="middle">'+yoe+'</TD>';
									html+='<TD   align="center" valign="middle">'+salaryrange+'</TD>';
								}
								html+=' </TR>';
								
								}
							}
			html+=' </TABLE>';
			
			if(document.getElementById("orderbyrow")){
				document.getElementById("orderbyrow").style.display='';
			}
			}else{
			html+='<TABLE width="97%" border="0" align="right" cellpadding="1" cellspacing="1" >';
				html+='<TR>';
					html+='<TD colspan="3" class="omatter-bold" align="center"><b>'+recmsg+'</b></TD>';
				html+='</TR>';
			html+='</TABLE>';	
			
			document.getElementById('REC_MSG_TOP').innerHTML ="";
			document.getElementById('REC_MSG_BOTTOM').innerHTML ="";
			if(document.getElementById("orderbyrow")){
				document.getElementById("orderbyrow").style.display='none';
			}
			}
			html+='<TR><TD height="5">&nbsp;</TD></TR>';
			document.getElementById('divClassified').innerHTML =html;
			
			notFirst="1";			
			document.getElementById("divShowLoading").style.display="none";
			setPaging(totrec, start,iCal);
		}
	}	
}



var start;
var var_limit = ''
var page_string = "";
var start_loop;
function setPaging(tot_rec, start,iCal)
{


	if(tot_rec == "")	
		tot_rec = 0;
		page_string = "";
		extra = "";
		num_limit = 0;
		last_rec = 0;
		if(start != '0')
		{	
			num_limit = (start-1)*rec_limit;
			var_limit = " LIMIT "+num_limit+" ,"+rec_limit; 
		}
		else 
		{
			var_limit = " LIMIT 0,"+rec_limit;
		}	
			
		if(start == '0')
		{
			start = '1';
		}
	tot_pages = Math.ceil(tot_rec/rec_limit) ; 

	loop_limit = ((page_limit > tot_pages) ? tot_pages : page_limit);
	start_loop = Math.floor(start/page_limit);
	
	if(start_loop != (start/page_limit))
		start_loop = start_loop * page_limit+1;
	else
		start_loop = (start_loop-1) * page_limit+1;
	
	page_string+="<div id='paging' class='bluematter' align='center'>";
	page_string+="<ul>";
    		
			if(start_loop>page_limit)
			{
				prev_loop = start_loop - 1;
				page_string+="<li><a href='javascript:getClassified(\""+prev_loop+"\",\""+iCal+"\");' title=\""+LBL_PREVIOUS+"\"><b>"+LBL_PREVIOUS+"</b></a></li>";
    		}
			
			for(loop=1 ; loop<=loop_limit ; loop++)
			{	
				if(start_loop>tot_pages) break;
				if(parseInt(start_loop) == parseInt(start))
					clas = "current";
				else
					clas = "";
				page_string+="<li><a href='javascript:getClassified(\""+start_loop+"\",\""+iCal+"\");' title=\""+start_loop+"\" class="+clas+" ><b>"+start_loop+"</b></a></li>";
				start_loop++;
			}
			if(start_loop<=tot_pages)
			page_string+="<li><a href='javascript:getClassified(\""+start_loop+"\",\""+iCal+"\")'; title=\""+LBL_NEXT+"\"><b>"+LBL_NEXT+"</b></a></li>";
		
	page_string+="</ul>";
	page_string+="</div>";
	document.getElementById("PAGING-BOTTOM").innerHTML = page_string;
	document.getElementById("PAGING-TOP").innerHTML = page_string;
}

function HideCat()
{
	document.getElementById("divStCat").style.display = 'none';
	document.getElementById("vdivLink").innerHTML = '<A href="#" title="Expand"><IMG src="images/btn-expand.gif" onclick="ShowCat();return false;" width="94" height="15" border="0"/></A>';	
}

function ShowCat()
{
	document.getElementById("divStCat").style.display = '';
	document.getElementById("vdivLink").innerHTML = '<A href="#" title="Collapse"><IMG src="images/btn-collapse.gif" onclick="HideCat();return false;" width="94" height="15" border="0"/></A>';	
}

function in_array(arr,compval){
	var loarr = arr.split(',');
	var nosofmatched = 0;
	for(k=0;k<parseInt(loarr.length)-1;k++){
		//alert(loarr[k]+'==>'+compval);
		if(loarr[k] == compval){
			nosofmatched++;	
		}	
	}
	//alert(nosofmatched);
	return nosofmatched;
	
}
