function test1(test){
	DWREngine._execute(_cfscriptLocation, null, 'test1', test, testtext);
	alert(test);
}
function testtext(result)
{
	alert(result);
}

// add listing categories
function getListingSubCategory(catID,objID)
{
	var curIDIndex1 = objID.charAt(8); //category1_2: 1
	var curIDRoot = objID.substring(0,objID.indexOf('_')+1); //category1_2: category2_
	var curIDIndex2 = objID.substring(objID.indexOf('_')+1); //category1_2: 2
	var newIDIndex = parseInt(curIDIndex2) + 1;
	if(catID > 0) {
		if(newIDIndex != 3) {
			showSpan(objID);
			hideSpan(curIDRoot+newIDIndex);
		}
		var str = catID + "," + objID;
		DWREngine._execute(_cfscriptLocation, null, 'getListingSubCategory', str, showListingSubCategory);
	} else {
		hideSpan('category1_1');
		hideSpan('category1_2');
	}
}

function showListingSubCategory(result)
{
	//alert(result);return;
	var d = result.split('::');
	var m;
	//d[0] = 0000
	//d[2] = catid and catname
	//d[1] = objID or spanID or divID
	var objID = d[1];
	var curIDIndex1 = objID.charAt(8); //category1_2:1
	var curIDRoot = objID.substring(0,objID.indexOf('_')+1); //category1_1:category1_
	var curIDIndex2 = objID.substring(objID.indexOf('_')+1); //category1_2:2
	var newIDIndex = parseInt(curIDIndex2) + 1;
	//alert(curIDRoot);return;
	var separator = "&nbsp;&nbsp;&nbsp;&nbsp;";
	var onChangeStr = "setFormValue('listing','cat"+curIDIndex1+"',this.value);getListingSubCategory(this.value,'"+curIDRoot+newIDIndex+"');showSpan('" +curIDRoot+newIDIndex+ "');";
	if(newIDIndex == 3) {
		onChangeStr = "setFormValue('listing','cat"+curIDIndex1+"',this.value);";
		separator = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	}
	var html_output = separator + "<img src=images/subcat.gif border=0 align=top /><select onChange=" +onChangeStr+ " name="+objID+"><option value=0> Select a Sub Category </option>";
	//alert(html_output);
	var selection = "";
	for(i=2;i<d.length;i++) {
		selection = "";
		if(d[i] != '0000') {
			m = d[i].split(':');
			//m[0] = sic code
			//m[1] = industry name
			if(m[0] == d[1]) selection = " selected ";
			html_output = html_output + '<option alt=\'test\' value='+m[0]+ selection + '>'+m[1]+'</option>';
			
		}
	}
	html_output = html_output + '</select>';
	document.getElementById(objID).innerHTML = html_output;
	document.getElementById(objID).style.visibility = 'visible';

}


// list yp categories
function getSubYPCategory(str)
{
	if(str > 0)
		DWREngine._execute(_cfscriptLocation, null, 'getSubYPCategory', str, showSubYPCategory);
	else {
		document.getElementById("subypcategory").style.visibility = 'hidden';
		document.getElementById("subypcategory").innerHTML = '<select name=ypsubcatid><option value=0>None</option></select>';
	}
}

function showSubYPCategory(result)
{
	var d = result.split('::');
	var m;
	var html_output = '<img src=images/subcat.gif border=0 align=top /><select onChange="saveSubYPCat(this.value)" name=ypsubcatid><option value=0> Select a Sub Category </option>';
	//d[0] = 0000
	//d[1] = full industrycode
	var selection = "";
	for(i=2;i<d.length;i++) {
		selection = "";
		if(d[i] != '0000') {
			m = d[i].split(':');
			//m[0] = sic code
			//m[1] = industry name
			if(m[0] == d[1]) selection = " selected ";
			html_output = html_output + '<option value='+m[0]+ selection + '>'+m[1]+'</option>';
			
		}
	}
	html_output = html_output + '</select>';
	document.getElementById("subypcategory").innerHTML = html_output;
	document.getElementById("subypcategory").style.visibility = 'visible';
	
	//document.getbiz.subindustry.focus();
	//selectedcode();
}

// list industry
function getSubIndustry(str)
{
	if(str > 0)
		DWREngine._execute(_cfscriptLocation, null, 'getSubIndustry', str, showSubIndustry);
	else {
		document.getElementById("subindustry").style.visibility = 'hidden';
		document.getElementById("subindustry").innerHTML = '<select name=subindustry><option value=0>None</option></select>';
	}
}

function showSubIndustry(result)
{
	var d = result.split('::');
	var m;
	var html_output = '<img src=images/subcat.gif border=0 align=top /><select onChange="saveSubIndustryCode(this.value)" name=subindustry><option value=0> Select a Sub Category </option>';
	//d[0] = 0000
	//d[1] = full industrycode
	var selection = "";
	for(i=2;i<d.length;i++) {
		selection = "";
		if(d[i] != '0000') {
			m = d[i].split(':');
			//m[0] = sic code
			//m[1] = industry name
			if(m[0] == d[1]) selection = " selected ";
			html_output = html_output + '<option value='+m[0]+ selection + '>'+m[1]+'</option>';
			
		}
	}
	html_output = html_output + '</select>';
	document.getElementById("subindustry").innerHTML = html_output;
	document.getElementById("subindustry").style.visibility = 'visible';
	
	//document.getbiz.subindustry.focus();
	//selectedcode();
}


// get categories for products
function getCat(str)
{
	var target = document.getElementById("productsubcat1");
	if(str > 0)
	{
		target.style.height = '';
		target.innerHTML = '<select name=productsubcat1><option value=0>None</option></select>';
		DWREngine._execute(_cfscriptLocation, null, 'getSubCat', str, showSubCat);
	}
	else
	{
		target.innerHTML = "";
		target.style.height = '1px';
	}
}

function showSubCat(result)
{
	var d = result.split('::');
	var m;
	var html_output = '<img src=images/subcat.gif border=0 align=absmiddle/><select onChange="saveValue(this.form.name,\'searchcatid\',this.value)" name=productsubcat1><option value=0> ---------- </option>';
	for(i=0;i<d.length;i++) {
		if(d[i] != '0000') {
			m = d[i].split(':');
			//m[0] = catid
			//m[1] = cat name
			html_output = html_output + '<option value='+m[0]+'>'+m[1]+'</option>';
			
		}
	}
	html_output = html_output + '</select>';
	document.getElementById("productsubcat1").innerHTML = html_output;
	document.getElementById("productsubcat1").style.visibility = 'visible';
}



// get categories for classifieds ads
function getClassifiedsCat(str)
{alert(str);
	var target = document.getElementById("classifiedssubcat1");
	if(str > 0)
	{
		target.style.height = '';
		target.innerHTML = '<select name=classifiedssubcat1><option value=0>None</option></select>';
		DWREngine._execute(_cfscriptLocation, null, 'getClassifiedsSubCat', str, showClassifiedsSubCat);
	}
	else
	{
		target.innerHTML = "";
		target.style.height = '1px';
	}
}

function showClassifiedsSubCat(result)
{
	var d = result.split('::');
	var m;
	var html_output = '<img src=images/subcat.gif border=0 align=absmiddle/><select onChange="saveValue(this.form.name,\'classifiedscatid\',this.value)" name=classifiedssubcat1><option value=0> ---------- </option>';
	for(i=0;i<d.length;i++) {
		if(d[i] != '0000') {
			m = d[i].split(':');
			//m[0] = catid
			//m[1] = cat name
			html_output = html_output + '<option value='+m[0]+'>'+m[1]+'</option>';
			
		}
	}
	html_output = html_output + '</select>';
	document.getElementById("classifiedssubcat1").innerHTML = html_output;
	document.getElementById("classifiedssubcat1").style.visibility = 'visible';
}


// get cities for state
function getNewsCities(str)
{
	document.getElementById("TipLayer").innerHTML = '';
	//var test = ['California','Some Lists <li>list one</li> <li>list two</li> <li>list three</li> <li>list four</li>']
	//stm(test,Style[5]);
	//document.getElementById("TipLayer").style.visibility = 'hidden';
	DWREngine._execute(_cfscriptLocation, null, 'getNewsCities', str, showGetNewsCities);
}

function showGetNewsCities(result)
{

	var d = result.split(':');
	//i=1 ~ statename
	//i=0 ~ state 2-letter

	var s = "['"+d[1]+"','";
	var t;
	var c = 'USA';
	if(d[0].length > 3) {c = 'CANADA'};
	for(i=2;i<d.length;i++) {
		
		t = d[i];
		t = unescape(t);
		
		s += "<a href=index.cfm?fuseaction=main.news&search=state&state="+d[0]+"&city="+d[i]+"&country="+c+"&#newspaperlist>"+t+"</a><br>";
	}
	s += "']";
	//s = ['California','something'];
	stm(eval(s),Style[5]);
	OnMoveTip(lastMouseX, lastMouseY)
}

// ad posting - getting cities
function getAdCities(str)
{
	DWREngine._execute(_cfscriptLocation, null, 'getAdCities', str, showAdCities);
}

function showAdCities(result)
{
	var d = result.split('::');
	var html_output = '<select name="ad_city">';
	for(i=0;i<d.length;i++) {
		if(d[i] != '0000') {
			html_output = html_output + '<option value="'+d[i]+'">'+d[i]+'</option>';
		}
	}
	html_output = html_output + '</select>';
	document.getElementById("cities").innerHTML = html_output;
}

// ad posting - getting cities
function getAdModels(str)
{
	DWREngine._execute(_cfscriptLocation, null, 'getAdModels', str, showAdModels);
}

function showAdModels(result)
{
	var d = result.split('::');
	var m;
	var html_output = '<select name="ad_modeltext">';
	for(i=0;i<d.length;i++) {
		if(d[i] != '0000') {
			m = d[i].split(':');
			html_output = html_output + '<option value='+m[0]+'>'+m[1]+'</option>';	
		}
	}
	html_output = html_output + '</select>';
	document.getElementById("models").innerHTML = html_output;
}

// business search results
function getBusinessSearchResults(searchTerms, center, distance, industrycodemin, industrycodemax, page)
{
	if(objectExists("resultsloading","div"))
		document.getElementById("resultsloading").style.display = "inline";
	var lat = center.lat(), lng = center.lng();
	DWREngine._execute(_cfscriptLocation, null, 'getBusinessSearchResults', searchTerms, lat, lng, distance, industrycodemin, industrycodemax, page, showBusinessSearchResults);
	
}

// products search results
function getProductSearchResults(searchTerms, center, distance, industrycodemin, industrycodemax, page)
{
	if(objectExists("resultsloading","div"))
		document.getElementById("resultsloading").style.display = "inline";
	var lat = center.lat(), lng = center.lng();
	DWREngine._execute(_cfscriptLocation, null, 'getProductSearchResults', searchTerms, lat, lng, distance, industrycodemin, industrycodemax, page, showBusinessSearchResults);
	
}

function showBusinessSearchResults(result)
{
	//alert(result);return;
	
	var results = result.split('::');
	if(results.length < 7 || results[0] != '0000') return;
	var numResults = results[1], lat = results[2], lng = results[3], city = results[4], state = results[5], curpage = results[6];
	results = results.slice(7);
	var local_addresses = new Array();
	for(var counter = 0; counter < results.length; counter ++)
	{
		var business = results[counter].split(':');
		local_addresses[counter] = new Array(
			business[0],
			new GLatLng(parseFloat(business[1]), parseFloat(business[2])),
			counter,
			business[3] + ', ' + business[4],
			business[0] + '<br />' + business[3] + '<br />' + business[5] + ' ' + business[4] + '<br />' + business[6],
			null
		);
	}
	UpdateBusinessSearchResults(parseInt(curpage), parseInt(numResults), new GLatLng(lat, lng), local_addresses, city, state);
	
}

/* parks and recreation routines */
function parkSearchBy(str)
{
	DWREngine._execute(_cfscriptLocation, null, 'parkSearchBy', str, showParkSearchBy);
}

function showParkSearchBy(result)
{
	document.getElementById("p2").innerHTML = result;
}

function parkList(type,ignore1,letter,ignore2)
{
	//letter = letter.charAt(5);

	letter = letter.substring(5);

	//alert(letter);
	if(letter == 'q') letter = 'all'; //Currently have problem with letter Q not able to load data from nps.gov
	var str = type+','+letter;
	DWREngine._execute(_cfscriptLocation, null, 'parkList', str, showParkList);
}

function showParkList(result)
{
	document.getElementById("p3").innerHTML = result;
}

function parkMiniInfo(str)
{
	document.getElementById("TipLayer").innerHTML = '';
	DWREngine._execute(_cfscriptLocation, null, 'parkMiniInfo', str, showParkMiniInfo);
}

function showParkMiniInfo(result)
{
	//alert(result);return;
	stm(['',result],Style[4]);
	//OnMoveTip(lastMouseX, lastMouseY);
}
function parkMiniInfoMap(str)
{
	document.getElementById("TipLayer").innerHTML = '';
	DWREngine._execute(_cfscriptLocation, null, 'parkMiniInfo', str, showParkMiniInfoMap);
}

function showParkMiniInfoMap(result)
{
	stm(['',result],Style[7]);
	//OnMoveTip(lastMouseX, lastMouseY);
}

/* end park and recreation routines */