// JavaScript Document

var destination = false;
var fresh;
var geocoder;
var lat;
var local_height = 380;
var long;
var map;
var origin = false;
var postcode;
var radius;

var country_value;

function get_country_response(country,origin_0,destination_0) {
			
		if(navigator.appName == "Microsoft Internet Explorer"){
			http = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
			http = new XMLHttpRequest();
		}
		params = "country="+country+"&origin="+origin_0+"&destination="+destination_0;
		
		var url = window.locale.baseUrl+'/ajax/search_country.php';
		http.open('POST', url);
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", params.length);
		http.setRequestHeader("Connection", "close");
		http.onreadystatechange = function(){ get_country_result(http); };
		http.send(params);
		
	
}
function get_country(fr)
{
	country_value=document.getElementById('search_country').value;
	
	var country=country_value;	
	var destination=document.getElementById('destination_in_country').checked;
	var origin=document.getElementById('origin_in_country').checked;
	if(destination== false && origin==false)
		alert(window.locale.trs.MUST_SELECT_MIN_ONE_BOX);
	else
	{
		if(destination==true && origin==true)
			get_country_response(country,1,1);
		else
		{
			if(destination==true && origin==false)
				get_country_response(country,0,1);
			else
				get_country_response(country,1,0);
		}
	}
}

function wait_on_calc()
{

		var search_results = document.getElementById('search_results');
		search_results.innerHTML = "";
		var p = document.createElement('p');
		p.setAttribute('class', 'calc');
		p.setAttribute('classname', 'calc');
		var text = document.createTextNode(window.locale.trs.CALCULATING+'...');
		p.appendChild(text);
		var img = document.createElement('img');
		img.setAttribute('src', 'http://cdn.shiply.com/images/working.gif');
		img.setAttribute('class', 'working');
		search_results.appendChild(p);
		search_results.appendChild(img);
	
}


// scriu rezultatele frumos in tabela 
function get_country_result(http){
	
	var _tr = window.locale.trs;
	
	if(http.readyState==3)
	{
		wait_on_calc();		
	}
	
	if(http.readyState == 4 && http.status == 200){
		var response = http.responseText;
		if(response){			
			if(window.ActiveXObject){
				//IE
				var doc = new ActiveXObject("Microsoft.XMLDOM");
				doc.async = "false";
				doc.loadXML(response);
			} else {
				//Mozilla, Firefox, Opera, etc.
				var parser = new DOMParser();
				var doc = parser.parseFromString(response, "text/xml");
			}
						
			// documentElement always represents the root node
			var x = doc.documentElement;
			if(x.childNodes[0].childNodes[0].nodeName != 'errorno'){
				var search_results = document.getElementById('search_results');
				search_results.innerHTML = "";
				set_result_display(x.childNodes[1].childNodes.length, x.childNodes[0].childNodes[0].childNodes[0].firstChild.nodeValue);
				set_pagination_display(x.childNodes[0].childNodes[0].childNodes[1].firstChild.nodeValue, x.childNodes[1].childNodes.length);
				var table = document.createElement('table');
				//console.debug("Created table element");
				table.setAttribute('id', 'search_results_table');
				table.setAttribute('cellspacing', '0');
				table.setAttribute('cellpadding', '0');
				table.setAttribute('class', 'bids_table');
				table.setAttribute('className', 'bids_table');
				table.setAttribute('width', '100%');
				var tbody = document.createElement('tbody');
				var tr = document.createElement('tr');
				tr.setAttribute('class', 'header');
				tr.setAttribute('className', 'header');
				var td = document.createElement('td');
				td.setAttribute('class', 'shipment cell first');
				td.setAttribute('className', 'shipment cell first');
				td.setAttribute('height', '27');
				text = document.createTextNode(_tr.SHIPMENT);
				td.appendChild(text);
				tr.appendChild(td);
				//console.debug("Created shipment cell");
				td = document.createElement('td');
				td.setAttribute('class', 'origin cell');
				td.setAttribute('className', 'origin cell');
				text = document.createTextNode(_tr.ORIGIN);
				td.appendChild(text);
				tr.appendChild(td);
				//console.debug("Created origin cell");
				td = document.createElement('td');
				td.setAttribute('class', 'destination cell');
				td.setAttribute('className', 'destination cell');
				text = document.createTextNode(_tr.DESTINATION);
				td.appendChild(text);
				tr.appendChild(td);
				//console.debug("Created destination cell");
				td = document.createElement('td');
				td.setAttribute('class', 'miles cell');
				td.setAttribute('className', 'miles cell');
				a = document.createElement('a');
				a.setAttribute('href', window.locale.baseUrl+'/search.php?s=0&sort_by=distance%20DESC');
				text = document.createTextNode(_tr.MILES);
				a.appendChild(text);
				td.appendChild(a);
				tr.appendChild(td);
				//console.debug("Created miles cell");				
				td = document.createElement('td');
				td.setAttribute('class', 'date cell');
				td.setAttribute('className', 'date cell');
				a = document.createElement('a');
				a.setAttribute('href', window.locale.baseUrl+'/search.php?s=0&sort_by=date%20DESC');
				text = document.createTextNode(_tr.DATE);
				a.appendChild(text);
				td.appendChild(a);
				tr.appendChild(td);
				//console.debug("Created date cell");
				td = document.createElement('td');
				td.setAttribute('class', 'bids cell last');
				td.setAttribute('className', 'bids cell last');
				text = document.createTextNode(_tr.BIDS);
				td.appendChild(text);
				tr.appendChild(td);
				//console.debug("Created bids cell");
				tbody.appendChild(tr);
				if (x.childNodes[2]) {
  				var j = true;
				
				
				/*   Featured listings  */
				
				
				
          for(var i = 0; i < x.childNodes[2].childNodes.length; i++){
        	  //console.debug("Feartured Listing "+i+" start");
				    tr = document.createElement('tr');
  					if(j){
  						tr.setAttribute('class', 'featured_listing featured_dark');
							tr.setAttribute('className', 'featured_listing featured_dark');
  								j = false;
  							} else {
  								tr.setAttribute('class', 'featured_listing featured_light');
  								tr.setAttribute('className', 'featured_listing featured_light');
  								j = true;
  							}
  					td = document.createElement('td');
  					td.setAttribute('class', 'shipment cell first');
						td.setAttribute('className', 'shipment cell first');
						td.setAttribute('height', '53');


						//Add bid span
						var bidid = x.childNodes[2].childNodes[i].childNodes[0].firstChild.nodeValue      ;
						bidspan = document.createElement('span');

						bidspan.setAttribute('id', 'show'+x.childNodes[2].childNodes[i].childNodes[0].firstChild.nodeValue);
						bidspan.setAttribute('class', 'showmoresearchinfo');
            bidspan.setAttribute('title', 'Click to expand');
            bidspan.setAttribute('onclick', 'showbox(\'listing'+x.childNodes[2].childNodes[i].childNodes[0].firstChild.nodeValue+'\',\''+x.childNodes[2].childNodes[i].childNodes[0].firstChild.nodeValue+'\')');

						var text = document.createTextNode("+");
						bidspan.appendChild(text);

						td.appendChild(bidspan);
						
					//featured listing picture
  					if(x.childNodes[2].childNodes[i].childNodes[13].firstChild){
  						var a = document.createElement('a');
  						a.setAttribute('href', window.locale.baseUrl+'/transport/'+x.childNodes[2].childNodes[i].childNodes[26].firstChild.nodeValue+'/'+x.childNodes[2].childNodes[i].childNodes[0].firstChild.nodeValue+'/');
  						var img = document.createElement('img');
  						if (x.childNodes[2].childNodes[i].childNodes[13].firstChild.nodeValue > 13827) {
                img.setAttribute('src', 'http://images.shiply.com/uploads/'+x.childNodes[2].childNodes[i].childNodes[13].firstChild.nodeValue+'_thumb');
              } else {
                img.setAttribute('src', '/uploads/'+x.childNodes[2].childNodes[i].childNodes[13].firstChild.nodeValue+'_thumb');
              }            
  						a.appendChild(img);
  						td.appendChild(a);
  					}
					//featured listing title
  					var a = document.createElement('a');
  					a.setAttribute('href', window.locale.baseUrl+'/transport/'+x.childNodes[2].childNodes[i].childNodes[26].firstChild.nodeValue+'/'+x.childNodes[2].childNodes[i].childNodes[0].firstChild.nodeValue+'/');
  					var text = document.createTextNode(x.childNodes[2].childNodes[i].childNodes[25].firstChild.nodeValue);
  					a.appendChild(text);
  					td.appendChild(a);
  					/*if(x.childNodes[2].childNodes[i].childNodes[14].firstChild){
  						if(parseInt(x.childNodes[2].childNodes[i].childNodes[15].firstChild.nodeValue) == 1){
  							var img = document.createElement('img');
  							img.setAttribute('class', 'ebay');
  							img.setAttribute('className', 'ebay');
  							img.setAttribute('src', '/images/auction_won.gif');
							img.setAttribute('onMouseover', 'showhint(\'eBay auction item won\', this, event, \'150px\')');
  							td.appendChild(img);
  						} else if(parseInt(x.childNodes[2].childNodes[i].childNodes[15].firstChild.nodeValue) == 2){
  							var img = document.createElement('img');
  							img.setAttribute('class', 'ebay');
  							img.setAttribute('className', 'ebay');
  							img.setAttribute('src', '/images/auction.gif');
							img.setAttribute('onMouseover', 'showhint(\'User currently bidding on eBay auction - item not yet won\', this, event, \'200px\')');
  							td.appendChild(img);
  						}
  					}*/
  					var p = document.createElement('span');
  					p.setAttribute('class', 'category');
  					p.setAttribute('className', 'category');
  					if(x.childNodes[2].childNodes[i].childNodes[25].firstChild && x.childNodes[2].childNodes[i].childNodes[9].firstChild.nodeValue != "Other"){
  						text = document.createTextNode(x.childNodes[2].childNodes[i].childNodes[9].firstChild.nodeValue+' > '+x.childNodes[2].childNodes[i].childNodes[27].firstChild.nodeValue);
  					} else {
  						text = document.createTextNode(x.childNodes[2].childNodes[i].childNodes[9].firstChild.nodeValue);
  					}
  					//p.appendChild(text);
  					//td.appendChild(p);
  					tr.appendChild(td);
  					td = document.createElement('td');
  					td.setAttribute('class', 'origin cell');
  					td.setAttribute('className', 'origin cell');
  					var postcode = x.childNodes[2].childNodes[i].childNodes[8].firstChild.nodeValue;
  					p = document.createElement('p');
  					text = document.createTextNode(postcode);
  					p.appendChild(text);
  					td.appendChild(p);
  					/*if(x.childNodes[2].childNodes[i].childNodes[17].firstChild && x.childNodes[2].childNodes[i].childNodes[17].firstChild.nodeValue == 1){
  						var img = document.createElement('img');
  						img.setAttribute('src', '/images/search_cal.gif');
  						td.appendChild(img);
  						p = document.createElement('p');
  						text = document.createTextNode(x.childNodes[2].childNodes[i].childNodes[18].firstChild.nodeValue+' - '+x.childNodes[2].childNodes[i].childNodes[19].firstChild.nodeValue);
  						p.appendChild(text);
  						td.appendChild(p);
  					}*/
  					tr.appendChild(td);
  					td = document.createElement('td');
  					td.setAttribute('class', 'destination cell');
  					td.setAttribute('className', 'destination cell');
  					var postcode = x.childNodes[2].childNodes[i].childNodes[12].firstChild.nodeValue;
  					p = document.createElement('p');
  					text = document.createTextNode(postcode);
  					p.appendChild(text);
  					td.appendChild(p);
  					/*if(x.childNodes[2].childNodes[i].childNodes[20].firstChild && x.childNodes[2].childNodes[i].childNodes[20].firstChild.nodeValue == 1){
  						var img = document.createElement('img');
  						img.setAttribute('src', '/images/search_cal.gif');
  						td.appendChild(img);
  						p = document.createElement('p');
  						text = document.createTextNode(x.childNodes[2].childNodes[i].childNodes[21].firstChild.nodeValue+' - '+x.childNodes[2].childNodes[i].childNodes[22].firstChild.nodeValue);
  						p.appendChild(text);
  						td.appendChild(p);
  					}*/
  					tr.appendChild(td);
  					td = document.createElement('td');
  					td.setAttribute('class', 'miles cell');
  					td.setAttribute('className', 'miles cell');
  					text = document.createTextNode(x.childNodes[2].childNodes[i].childNodes[10].firstChild.nodeValue);
  					td.appendChild(text);
  					tr.appendChild(td);
  					
  					td = document.createElement('td');
  					td.setAttribute('class', 'date cell');
  					td.setAttribute('className', 'date cell');
  					text = document.createTextNode(x.childNodes[2].childNodes[i].childNodes[6].firstChild.nodeValue);
  					
  					td.appendChild(text);
  					tr.appendChild(td);
					td = document.createElement('td');
  					td.setAttribute('class', 'bids cell last');
  					td.setAttribute('className', 'bids cell last');
  					a = document.createElement('a');					
  				    a.setAttribute('href', window.locale.baseUrl+'/transport/'+x.childNodes[2].childNodes[i].childNodes[26].firstChild.nodeValue+'/'+x.childNodes[2].childNodes[i].childNodes[0].firstChild.nodeValue+'/#bids');		
  					text = document.createTextNode(x.childNodes[2].childNodes[i].childNodes[28].firstChild.nodeValue);
  					a.appendChild(text);
  					td.appendChild(a);
  					tr.appendChild(td);
  					tbody.appendChild(tr);
  					
  					// Add invisible bid row
	          trbid = document.createElement('tr');
	          tdbid = document.createElement('td');

	          tdbid.setAttribute('colspan', 7);
	          tdbid.setAttribute('id', 'listing'+bidid);
	          tdbid.setAttribute('class', 'showlistinginfo');
	          tdbid.setAttribute('style', 'display:none;');

	          trbid.appendChild(tdbid);
	          tbody.appendChild(trbid);
  					
  				}
  				
  				tr = document.createElement('tr');
          tr.setAttribute('class', 'featured_bottom');
          tr.setAttribute('className', 'featured_bottom');
          td = document.createElement('td');
          td.setAttribute('colspan', 7);
          td.setAttribute('class', 'table_span');
		  		td.setAttribute('className', 'table_span');
          text = document.createTextNode('Featured Shipments! ');
          td.appendChild(text);
          a = document.createElement('a');
          a.setAttribute('href', '/myshiply.php?featured=1')
          text = document.createTextNode('Promote your shipment listings »');
          a.appendChild(text);
          td.appendChild(a);
          tr.appendChild(td);
          tbody.appendChild(tr);
          //console.debug("Feartured Listing "+i+" end");

  			}
			
			
			
			/* Normal Listings */
			
			
			
				var j = true;
				for(var i = 0; i < x.childNodes[1].childNodes.length; i++){
					//console.debug("Listing "+i+" start");
					tr = document.createElement('tr');
					if(j){
						tr.setAttribute('class', 'dark');
						tr.setAttribute('className', 'dark');
						j = false;
					} else {
						tr.setAttribute('class', 'light');
						tr.setAttribute('className', 'light');
						j = true;
					}
					td = document.createElement('td');
					td.setAttribute('class', 'shipment cell first');
					td.setAttribute('className', 'shipment cell first');
					td.setAttribute('height', '53');
					
     				//Add bid span
						bidspan = document.createElement('span');
						var bidid = x.childNodes[1].childNodes[i].childNodes[0].firstChild.nodeValue;

						bidspan.setAttribute('id', 'show'+x.childNodes[1].childNodes[i].childNodes[0].firstChild.nodeValue);
						bidspan.setAttribute('class', 'showmoresearchinfo');
            bidspan.setAttribute('title', 'Click to expand');
            bidspan.setAttribute('onclick', 'showbox(\'listing'+x.childNodes[1].childNodes[i].childNodes[0].firstChild.nodeValue+'\',\''+x.childNodes[1].childNodes[i].childNodes[0].firstChild.nodeValue+'\')');

						var text = document.createTextNode("+");
						bidspan.appendChild(text);

						td.appendChild(bidspan);
					
					if(x.childNodes[1].childNodes[i].childNodes[13].firstChild){
						var a = document.createElement('a');
						//alert(x.childNodes[1].childNodes[i].childNodes[26].firstChild.nodeValue);
						a.setAttribute('href', window.locale.baseUrl+'/transport/'+x.childNodes[1].childNodes[i].childNodes[26].firstChild.nodeValue+'/'+x.childNodes[1].childNodes[i].childNodes[0].firstChild.nodeValue+'/');
						var img = document.createElement('img');
						if (x.childNodes[1].childNodes[i].childNodes[13].firstChild.nodeValue > 13827) {
              img.setAttribute('src', 'http://images.shiply.com/uploads/'+x.childNodes[1].childNodes[i].childNodes[13].firstChild.nodeValue+'_thumb');
            } else {
              img.setAttribute('src', '/uploads/'+x.childNodes[1].childNodes[i].childNodes[13].firstChild.nodeValue+'_thumb');
            }            
						a.appendChild(img);
						td.appendChild(a);
						//console.debug("Created image");
					}
					
					var a = document.createElement('a');
					a.setAttribute('href', window.locale.baseUrl+'/transport/'+x.childNodes[1].childNodes[i].childNodes[26].firstChild.nodeValue+'/'+x.childNodes[1].childNodes[i].childNodes[0].firstChild.nodeValue+'/');
					var text = document.createTextNode(x.childNodes[1].childNodes[i].childNodes[25].firstChild.nodeValue);
					a.appendChild(text);
					td.appendChild(a);
					
					//console.debug("Created title");
					/*if(x.childNodes[1].childNodes[i].childNodes[14].firstChild){
						if(parseInt(x.childNodes[1].childNodes[i].childNodes[15].firstChild.nodeValue) == 1){
							var img = document.createElement('img');
							img.setAttribute('class', 'ebay');
							img.setAttribute('className', 'ebay');
							img.setAttribute('src', '/images/auction_won.gif');
							img.setAttribute('onMouseover', 'showhint(\'eBay auction item won\', this, event, \'150px\')');
							td.appendChild(img);
							//console.debug("Created auction won");
						} else if(parseInt(x.childNodes[1].childNodes[i].childNodes[15].firstChild.nodeValue) == 2){
							var img = document.createElement('img');
							img.setAttribute('class', 'ebay');
							img.setAttribute('className', 'ebay');
							img.setAttribute('src', '/images/auction.gif');
							img.setAttribute('onMouseover', 'showhint(\'User currently bidding on eBay auction - item not yet won\', this, event, \'200px\')');
							td.appendChild(img);
							//console.debug("Created auction");
						}
					}*/
					var p = document.createElement('span');
					p.setAttribute('class', 'category');
					p.setAttribute('className', 'category');
					
					
					//category
					if(x.childNodes[1].childNodes[i].childNodes[27].firstChild && x.childNodes[1].childNodes[i].childNodes[9].firstChild.nodeValue != "Other"){
						text = document.createTextNode(x.childNodes[1].childNodes[i].childNodes[9].firstChild.nodeValue+' > '+x.childNodes[1].childNodes[i].childNodes[27].firstChild.nodeValue);
					} else {
						text = document.createTextNode(x.childNodes[1].childNodes[i].childNodes[9].firstChild.nodeValue);
					}
					//p.appendChild(text);
					//td.appendChild(p);
					tr.appendChild(td);
					//console.debug("Created category");
					td = document.createElement('td');
					td.setAttribute('class', 'origin cell');
					td.setAttribute('className', 'origin cell');
					//from countrt 24
					if (x.childNodes[1].childNodes[i].childNodes[8].firstChild) {
						var postcode = x.childNodes[1].childNodes[i].childNodes[8].firstChild.nodeValue;
					}
					else {
						var postcode = "-";
					}
					p = document.createElement('p');
					text = document.createTextNode(postcode);
					p.appendChild(text);
					td.appendChild(p);
					//console.debug("Created from address");
					/*if(x.childNodes[1].childNodes[i].childNodes[17].firstChild && x.childNodes[1].childNodes[i].childNodes[17].firstChild.nodeValue == 1){
						var img = document.createElement('img');
						img.setAttribute('src', '/images/search_cal.gif');
						td.appendChild(img);
						p = document.createElement('p');
						text = document.createTextNode(x.childNodes[1].childNodes[i].childNodes[18].firstChild.nodeValue+' - '+x.childNodes[1].childNodes[i].childNodes[19].firstChild.nodeValue);
						p.appendChild(text);
						td.appendChild(p);
						//console.debug("Created pickup");
					}*/
					tr.appendChild(td);
					td = document.createElement('td');
					td.setAttribute('class', 'destination cell');
					td.setAttribute('className', 'destination cell');
					//to country
					if (x.childNodes[1].childNodes[i].childNodes[12].firstChild) {
						var postcode = x.childNodes[1].childNodes[i].childNodes[12].firstChild.nodeValue;
					}
					else {
						var postcode = "-";						
					}
					p = document.createElement('p');
					text = document.createTextNode(postcode);
					p.appendChild(text);
					td.appendChild(p);
					//console.debug("Created to address");
					/*if(x.childNodes[1].childNodes[i].childNodes[20].firstChild && x.childNodes[1].childNodes[i].childNodes[20].firstChild.nodeValue == 1){
						var img = document.createElement('img');
						img.setAttribute('src', '/images/search_cal.gif');
						td.appendChild(img);
						p = document.createElement('p');
						text = document.createTextNode(x.childNodes[1].childNodes[i].childNodes[21].firstChild.nodeValue+' - '+x.childNodes[1].childNodes[i].childNodes[22].firstChild.nodeValue);
						p.appendChild(text);
						td.appendChild(p);
						//console.debug("Created delivery");
					}*/
					tr.appendChild(td);
					td = document.createElement('td');
					td.setAttribute('class', 'miles cell');
					td.setAttribute('className', 'miles cell');
					text = document.createTextNode(x.childNodes[1].childNodes[i].childNodes[10].firstChild.nodeValue);
					td.appendChild(text);
					tr.appendChild(td);
					//console.debug("Created miles");
					
					td = document.createElement('td');
					td.setAttribute('class', 'date cell');
					td.setAttribute('className', 'date cell');
					text = document.createTextNode(x.childNodes[1].childNodes[i].childNodes[6].firstChild.nodeValue);
					td.appendChild(text);
					tr.appendChild(td);
					//console.debug("Created date");
					td = document.createElement('td');
					td.setAttribute('class', 'bids cell last');
					td.setAttribute('className', 'bids cell last');
					// bids
					a = document.createElement('a');					
				    a.setAttribute('href', window.locale.baseUrl+'/transport/'+x.childNodes[1].childNodes[i].childNodes[26].firstChild.nodeValue+'/'+x.childNodes[1].childNodes[i].childNodes[0].firstChild.nodeValue+'/#bids');		
					text = document.createTextNode(x.childNodes[1].childNodes[i].childNodes[28].firstChild.nodeValue);
					a.appendChild(text);
					td.appendChild(a);
					tr.appendChild(td);
					//console.debug("Created bids");
					tbody.appendChild(tr);
					//console.debug("Listing "+i+" end");
					
					// Add invisible bid row
          trbid = document.createElement('tr');
          tdbid = document.createElement('td');

          tdbid.setAttribute('colspan', 7);
          tdbid.setAttribute('id', 'listing'+bidid);
          tdbid.setAttribute('class', 'showlistinginfo');
          tdbid.setAttribute('style', 'display:none;');

          trbid.appendChild(tdbid);
          tbody.appendChild(trbid);
					
				}
				table.appendChild(tbody);
				search_results.appendChild(table);
				var footer = set_footer_display(x.childNodes[0].childNodes[0].childNodes[1].firstChild.nodeValue, x.childNodes[1].childNodes.length);
				search_results.innerHTML = search_results.innerHTML+footer;
			} else {
				var search_results = document.getElementById('search_results');
				search_results.innerHTML = "";
				set_result_display(0,0);
				set_pagination_display(0,0);
				var table = document.createElement('table');
				table.setAttribute('id', 'search_results_table');
				table.setAttribute('cellspacing', '0');
				table.setAttribute('cellpadding', '0');
				table.setAttribute('class', 'bids_table');
				table.setAttribute('className', 'bids_table');
				table.setAttribute('width', '100%');
				var tbody = document.createElement('tbody');
				var tr = document.createElement('tr');
				tr.setAttribute('class', 'header');
				tr.setAttribute('className', 'header');
				var td = document.createElement('td');
				td.setAttribute('class', 'shipment cell first');
				td.setAttribute('className', 'shipment cell first');
				text = document.createTextNode(_tr.SHIPMENT);
				td.appendChild(text);
				tr.appendChild(td);
				td = document.createElement('td');
				td.setAttribute('class', 'origin cell');
				td.setAttribute('className', 'origin cell');
				text = document.createTextNode(_tr.ORIGIN);
				td.appendChild(text);
				tr.appendChild(td);
				td = document.createElement('td');
				td.setAttribute('class', 'destination cell');
				td.setAttribute('className', 'destination cell');
				text = document.createTextNode(_tr.DESTINATION);
				td.appendChild(text);
				tr.appendChild(td);
				td = document.createElement('td');
				td.setAttribute('class', 'miles cell');
				td.setAttribute('className', 'miles cell');
				a = document.createElement('a');
				a.setAttribute('href', window.locale.baseUrl+'/search.php?s=0&sort_by=distance%20DESC');
				text = document.createTextNode(_tr.MILES);
				a.appendChild(text);
				td.appendChild(a);
				tr.appendChild(td);
				td = document.createElement('td');
				td.setAttribute('class', 'date cell');
				td.setAttribute('className', 'date cell');
				a = document.createElement('a');
				a.setAttribute('href', window.locale.baseUrl+'/search.php?s=0&sort_by=date%20DESC');
				text = document.createTextNode(_tr.DATE);
				a.appendChild(text);
				td.appendChild(a);
				tr.appendChild(td);
				td = document.createElement('td');
				td.setAttribute('class', 'bids cell last');
				td.setAttribute('className', 'bids cell last');
				text = document.createTextNode(_tr.BIDS);
				td.appendChild(text);
				tr.appendChild(td);
				tbody.appendChild(tr);
				tr = document.createElement('tr');
				td = document.createElement('td');
				td.setAttribute('colspan', '7');
				td.colSpan = 7;
				td.setAttribute('class', 'table_span');
				td.setAttribute('className', 'table_span');
				var center = document.createElement('center');
				var text = document.createTextNode('- '+_tr.NO_RESULTS+' -');
				center.appendChild(text);
				td.appendChild(center);
				tr.appendChild(td);
				tbody.appendChild(tr);
				table.appendChild(tbody);
				search_results.appendChild(table);
				var footer = set_footer_display(0,0);
				search_results.innerHTML = search_results.innerHTML+footer;
			}
		}
	}
}





function remove_local_suggestions() {
	postcode = false;
	if(document.getElementById('local_suggest')){
		document.getElementById('local_suggest').parentNode.removeChild(document.getElementById('local_suggest'));
	}
	/*var local = document.getElementById('local');
	local.style.height = local_height+'px';*/
}

function set_postcode(p) {
	postcode = p;
	document.getElementById('local_suggest').parentNode.removeChild(document.getElementById('local_suggest'));
	/*var local = document.getElementById('local');
	local.style.height = local_height+'px';*/
	document.getElementById('local_post_code').value = postcode;
	set_radius();
}
