	
	
	//var choicea;

	var choicea =
	{
		firstime: true,			//probably no longer needed since ignoreslider seems to do it all
		ignoreslider: false,
		fromsearchbut: false,
		reg1: [],			
		reg2: null,
		initialized: false,
		dragobj1: null,
		hrglass: null,
		mainmap: null,
		currmarkerstart: 0,
		dragmarker: null,
		thumbmap: null,
		toolsmenu: null,
		tabsheets: [],
		tabshtimgs: ['url("imgs/orange.png")', 'url("imgs1/bluewhitewhole1009px.png")', 'none', 'url("imgs/green.png")', '', 'url("imgs/green.png")', 'url("imgs/orange.png")'],	
		rowcolors: ['#E7F2FD', '#E6FCE6', '#A9EF4E'],
		//priceranges: ['$0 to $99K', '$100K to $199K', '$200K to $299K', '$300K to $399K', '$400K to $499K', '$500K to $599K', '$600K to $699K', '$700K to $799K', '$800K to $899K', '$900K & Over'],
		priceranges: null,
		priceslider: null,
		ticksp: null,
		pricetagarray: [],
		radiusarray: ['100', '50', '25', '20', '15', '10', '5'],
		currpriceidx: 2,
		currshortrec: [],
		currlongrec: null,
		viewflds: ['id','askPrice','listingAddr','listingZip','listingCity','state','yearBuilt','sqFeet', 'lat', 'lon', 'thumbImage'],
		listfrmhdrs: ['Listing Information','Basic Information','Interior','Exterior & Neighborhood Information','In Your Own Words'],
		favs: null,
		favsarray: [],
		results: [],
		info: '',
		resultsloaded: false,
		resultsmapped: false,
		visited: {},
		markrrefs: {},
		datviewpos: 0,
		galviewpos: 0,
		datscrollhop: 40,				//dataview scroll action resolution in pixels
		galscrollhop: 40,				//gallview scroll action resolution in pixels
		isdragging: false,
		isonmaptrigr: false,
		ismapview: false,
		issearchview: true,
		isddmousedown: false,
		isdragginmarker: false,
		isrightmousedown: false,
		isddguilty: false,
		isintarget: false,
		doublclkd: null,
		ddel: null,
		ddtgt: null,
		slug: null,
		ddrow: null,
		ddrowover: null,
		navbarindent: 0,
		dynainfo: null,
		dattable: null,
		galtable: null,
		listinfo: [],
		sortstate: [0, 0, 0, 0, 0, 0, 0, 0],
		ehtml: null,
		veil: null,
		onInit: null,			
		z: 0,
		links: 
{
	serverpath: 'http://www.choicea.com/',
	servercommands: {get_results: 'listings/results?&data=',
			 get_overlay: 'listings/overlay/'
			},

	//navbar menu relative uri's
	aboutus: '/about',
	search: '/listings',
	listit: '/my_listings/new_front',
	forms: '/legalforms',
	tools: '#',
		tool1: '/blog',
		tool2: '/faq',
		tool4: '/howto',
		tool5: '/terms',
	itsfree: '/itsfree',
	contact: '/contact'
},

		init: function()
		{
			
			//alert("init called");
			//this.adjust();
			choicea.readLeftMar();
			
			//entryzip1 is no longer used -- reads zip from cookie
			//document.getElementById('entryzip1').onclick = function(e)
			//	{ ironbox.stopPropag(e);};
			
			var idx = 0;
			var xt = null;
			while (xt = document.getElementById('contents' + idx++))
			{
				xt.style.backgroundImage = this.tabshtimgs[this.tabsheets.length];
				this.tabsheets.push(xt);
			}

			var xnavbig = [];				//for preload only
			for (var i = 1; i < 8; i++)
			{
				xnavbig.push(new Image());
				xnavbig[i-1].src = 'imgs1/navicons/xnavB' + i + '.png';
			}
			
			this.slug = document.getElementById('dragslug');
			this.slug.innerHTML = 'none';
			this.dragmarker = document.getElementById('dragmarker');			
			this.hrglass = document.getElementById('hourglass1');


			//var hostdiv = document.getElementById('datviewbak1');
			//alert(document.getElementById('rightpane1').offsetHeight);
			//choicea.buildDatview(hostdiv, 20);

			
			//hostdiv = document.getElementById('galviewbak1');
			//choicea.buildGalview(hostdiv, 1);
			

			this.favs = document.getElementById('favs1');

			//ironbox.setOpacity(document.getElementById('veil1'), '50');
			choicea.dynainfo = document.getElementById('dynainfo1');

			
			this.ehtml = document.getElementById('html');
			this.ehtml.onmousemove = function(e)
				{
						
					if (choicea.isdragging || choicea.isdragginmarker)
						choicea.dragSlug(e);						
				};
			this.ehtml.onmousedown = function(e)
				{
					var button = e ? e.button : event.button;
					if (button == 2)		//2 is rightclick
						choicea.isrightmousedown = true; 
						
					document.getElementById('infoalert').style.display = "none";
				};
			this.ehtml.onmouseup = function(e)
				{
					if (choicea.isdragging)
						choicea.dropSlug(e);
						
					var button = e ? e.button : event.button;
					if (button != 2)		//1 (ie) or 0 (ff) is leftclick
						choicea.isrightmousedown = false;
				};


			
			ironbox.keepTrying("YAHOO && choicea.priceranges", "choicea.buildPriceSlider();", 100, 100);
			
			ironbox.keepTrying("choicea.listinfo.length", "ironbox.makeOptions('propType1', choicea.listinfo[0][2].options, null, 'srchin');", 100, 100);
			
			ironbox.keepTrying("choicea.pricetagarray.length", "ironbox.makeOptions('priceRange1', choicea.pricetagarray, null, 'srchin', 0);", 100, 100);
			
			ironbox.keepTrying("choicea.radiusarray.length", "ironbox.makeOptions('xMiles1', choicea.radiusarray, null, 'srchin', null); document.getElementById('xMiles1').selectedIndex = 0;", 100, 100);


			ironbox.keepTrying("choicea.colors", "choicea.setColors();", 100, 100);

			
			this.toolsmenu = document.getElementById('toolsmenu1');
			this.toolsmenu.onmouseover = function()
			{
				this.style.display = 'block';
			}
			this.toolsmenu.onmouseout = function()
			{
				this.style.display = 'none';
			}
			
			var entryzipval;
			
			if ( /zip=/.test(document.cookie) )
				entryzipval = document.cookie.match( 'zip' + '=(.*?)(;|$)' )[1];
			else
				entryzipval = passzip;
		
			//alert(entryzipval);
			entryzipval = entryzipval ? entryzipval : '00000';
			document.getElementById('listZip1').value = entryzipval;
			//preload tables -- required b4 reloading stored favorites
			ironbox.keepTrying("choicea.dattable && choicea.listinfo.length", "choicea.doNewSearch(false);", 1000, 100, "choicea.onFetchFailed(101);");
			ironbox.keepTrying('choicea.resultsloaded && choicea.dattable', 'choicea.readOldFavs();', 300, 100);	
			
			
			this.initialized = true;
		},
		readLeftMar: function()
		{
			var navdiv = document.getElementById('navbarbak1');
			choicea.navbarindent = navdiv.offsetLeft;
		},
		setColors: function()
		{
			var navbar = document.getElementById('navbar1');
			var navcells = navbar.getElementsByTagName('div');
			
			ironbox.forEach(navcells, function(x)
				{	
					x.style.color = choicea.colors.navbartxt[0];
					x.onmouseover = function()
						{  
							this.style.backgroundImage = this.style.backgroundImage.replace(/xnav/, "xnavB");
							this.style.color = choicea.colors.navbartxtover[0];
							this.style.fontSize = '110%';
							//alert(this.style.backgroundImage);
							if (this.id == 'navcells5')
							{
								choicea.toolsmenu.style.left = (choicea.navbarindent + 567) + 'px';
								choicea.toolsmenu.style.display = 'block';
							}
						};
					x.onmouseout = function()
						{  
							this.style.backgroundImage = this.style.backgroundImage.replace(/xnavB/, "xnav");
							this.style.color = choicea.colors.navbartxt[0];
							this.style.fontSize = '100%';
							if (this.id == 'navcells5')
								choicea.toolsmenu.style.display = 'none';
						};
				});
			
			document.getElementById('ddcaption').style.color = choicea.colors.favpanetxt[0];
			ironbox.makeCSSRule('p.favs', 'color:' + choicea.colors.favaddr[0] + ';');
			document.getElementById('range0').style.color = choicea.colors.slidrtxt[0];
			document.getElementById('range1').style.color = choicea.colors.slidrtxt[0];
			var temp = document.getElementById('searchviewbak1');
				temp.style.background = choicea.colors.srchpanebg[0];
				temp.style.color = choicea.colors.srchpanetxt[0];
			ironbox.makeCSSRule('div.pickview', 'color:' + choicea.colors.viewbartxt[0] + ';');
			document.getElementById('dragslug').style.color = choicea.colors.dattblddtxt[0];
		},
		readOldFavs: function()
		{
			var fav = null;
			if ( /favs=/.test(document.cookie) )
				fav = document.cookie.match( 'favs' + '=(.*?)(;|$)' )[1];
			if (!fav)
				return;
			var baktoarray = eval(fav);
			ironbox.forEach(baktoarray, function(x)
			{
				choicea.currshortrec = x;
				//alert(choicea.currshortrec);
				choicea.isintarget = true;
				choicea.dropSlug();
			});	
		},
		buildPriceSlider: function()
		{
			ironbox.forEach(choicea.priceranges, function(x)
				{	
					choicea.pricetagarray.push(x.caption);
				});
				
			var tickct = choicea.priceranges.length;
			var ticksp = Math.ceil(190 / tickct);
			var tickwd = ((tickct - 1) * ticksp);
			document.getElementById('slider1').style.width = (tickwd + 14) + 'px';
			choicea.ticksp = ticksp;
			
			var slidr = YAHOO.widget.Slider.getHorizSlider("slider1", "handl1", 0, tickwd, ticksp);
			slidr.subscribe("change", choicea.onDragSlider);
			slidr.subscribe("slideEnd", choicea.onEndDragSlider);
			slidr.subscribe("slideStart", function(){choicea.ignoreslider = true;});
			slidr.animate = false;
			//slidr.setValue(0);
			choicea.priceslider = slidr;
			//choicea.setSlider(0);
			
		},
		setSlider: function(idx)
		{
			//alert(idx);
			choicea.priceslider.setValue(choicea.ticksp * idx);
		},
		choosePanel: function(whatpane)
		{
			//Following if overrides the built-in panel selection to call static pages by uri instead
			//except for case 1, the Search panel
			if (whatpane != 1)
			{
				switch (whatpane)
				{
					case 0 :
						window.location = choicea.links.aboutus;
						break;
					case 1 :
						break;
					case 2 :
						window.location = choicea.links.listit;
						break;
					case 3 :
						window.location = choicea.links.forms;
						break;
					case 4 :
						window.location = choicea.links.tools;
						break;
					case 5 :
						window.location = choicea.links.itsfree;
						break;
					case 6 :
						window.location = choicea.links.contact;
						break;
					default :
						return;
				}
				return;
			}
			
			ironbox.forEach(choicea.tabsheets, function(x) {x.style.display = 'none';});
			choicea.tabsheets[whatpane].style.display = 'block';
						
			var ftr = document.getElementById('footer1');
			
			
			switch (whatpane)
			{
				case 0 :
					ftr.style.backgroundImage = 'url("imgs/orange.png")';
					break;
				case 1 :
					ftr.style.backgroundImage = choicea.tabshtimgs[1];  //'url("imgs/colorBoxlower.png")';
					choicea.chooseView('searchviewbak1');
					document.getElementById('datviewbak1').style.backgroundImage = 'url("imgs1/animated_loading.gif")';
					choicea.dattable.style.backgroundColor = 'transparent';
					ironbox.forEach(choicea.dattable.rows, function(x)
					{
						x.style.visibility = 'hidden';
					});
					document.getElementById('sliderbak1').style.visibility = 'hidden';
					break;
				case 2 :
					ftr.style.backgroundImage = 'url("imgs/bluetoobg.png")';
					choicea.buildSubmitFrm(document.getElementById('inptfrm2'));
					break;
				case 3 :
					ftr.style.backgroundImage = 'url("imgs/green.png")';
					//choicea.buildSubmitFrm(document.getElementById('inptfrm1'));
					break;
				case 4 :
					document.getElementById('pad100').src = "http://pad100.wordpress.com";
					break;
				case 5 :
					ftr.style.backgroundImage = 'url("imgs/green.png")';
					break;
				case 6 :
					ftr.style.backgroundImage = 'url("imgs/orange.png")';
					break;
				default :
					return;
			}
		},
		chooseView: function(whatview, trigg)
		{
			if (whatview != 'searchviewbak1')
			{
				document.getElementById('sliderbak1').style.visibility = 'visible';
				choicea.issearchview = false;
			}
			else
				choicea.issearchview = true;
			
			var pv1 = document.getElementById('pickview1');
			pv1.style.background = 'transparent';
			document.getElementById('pickview2').style.background = 'transparent';
			document.getElementById('pickview3').style.background = 'transparent';
			if (trigg)
				trigg.style.background = 'transparent url("imgs1/green_tab.png")'; //'#9FE757';
			else
				pv1.style.background = 'transparent url("imgs1/green_tab.png")';  //'#9FE757';
			
			
			document.getElementById('datviewbak1').style.display = 'none';
			document.getElementById('galviewbak1').style.display = 'none';
			document.getElementById('mapviewbak1').style.display = 'none';
			document.getElementById('searchviewbak1').style.display = 'none';
			document.getElementById(whatview).style.display = 'block';
			
			//Corrects bug in FF that does not update scroll bar while panel was invisible
			if (whatview == 'galviewbak1')
				document.getElementById('galviewbak1').scrollTop = choicea.galviewpos;
			

			if (whatview == 'mapviewbak1')
			{
				if (!choicea.resultsmapped)
					document.getElementById("mapviewbak1").style.backgroundImage = 'url("imgs1/animated_loading.gif")';

				if (!suppress_maps) setTimeout('choicea.loadMainMap(!choicea.resultsmapped)', 100);
				choicea.ismapview = true;		//timeout is for view to change immediately
			}
			else
				choicea.ismapview = false;

			var headcaps = document.getElementById('headcaps');
			var viewcaps = document.getElementById('viewcaps1');
			var searchcap = document.getElementById('searchcapt1');
			var viewhead = document.getElementById('viewhead1');
			headcaps.style.visibility = (whatview == 'datviewbak1') ? 'visible' : 'hidden';
			viewcaps.style.visibility = (whatview == 'searchviewbak1') ? 'hidden' : 'visible';
			searchcap.style.display = (whatview == 'searchviewbak1') ? 'block' : 'none';
			viewhead.style.backgroundImage = (whatview == 'searchviewbak1') ? 'none' : 'url("imgs/headerJ43.jpg")';
			
		},
		doNewSearch: function(buttn)
		{
			if (buttn) choicea.firstime = false;
			
			choicea.fromsearchbut = buttn;
			/*
			var zipval = Number(document.getElementById('listZip1').value);
			if (isNaN(zipval) || zipval < 1)
			{
				alert ("Valid Zipcode Required!");
				return;
			}
			*/
			
			choicea.results.length = 0;	
			choicea.fetchNewResults(false);
			
		},	
		fetchNewResults: function(drilldown)
		{
			//TEST CODE ONLY -- to tell who's calling the fetch
			/*
			if (drilldown)
				ironbox.makeElement('slider', 'p', document.getElementById('favs1'));
			else
				ironbox.makeElement('not slider', 'p', document.getElementById('favs1'));
			*/
			//***************


			choicea.resultsloaded = false;
			choicea.info = '';
	
			var rangeval = Number(document.getElementById('priceRange1').value);
			if (!drilldown) choicea.setSlider(rangeval);
			
			
			if (is_test_sys)					//dev only
			{										
				ironbox.fetchJS('js/results_o.js');
				ironbox.keepTrying("choicea.resultsloaded", "choicea.processNewResults(" + drilldown + ");", 100, 100, "choicea.onFetchFailed();");
				return;
			}
				
			//TODO:  Need to delete old nodes for both results and details
			//(maybe do this from Ironbox code)	
			
			//var commnd = choicea.links.serverpath + choicea.links.servercommands.get_results;
			var commnd = 'http://www.choicea.com/listings/results?&data=';
			var qry = {};
			qry.json = 0;
			qry.propType = document.getElementById('propType1').value;
			if (qry.propType == 'Select')
			{
				//alert('Please Select a Property Type');
				return;
			}
			qry.listingZip = document.getElementById('listZip1').value;
			if (qry.listingZip == '00000')
			{
				//alert('Please Select a valid Zipcode');
				return;
			}
			qry.xMiles = Number(document.getElementById('xMiles1').value);
			
			qry.priceRange = drilldown ? choicea.currpriceidx : rangeval;
			
				
			//this should no longer be needed because it never happens
			/*
			if (drilldown && choicea.firstime)
			{
				qry.priceRange = 0;	
				choicea.firstime = false;
			}
			*/

			
			if (!qry.propType)
				qry.propType = "Single Family Home";
	
			
			//alert(qry.toJSONString());
			
			try { ironbox.fetchJS(commnd + qry.toJSONString()); }
			catch (sorry) {}
			
			ironbox.keepTrying("choicea.resultsloaded", "choicea.processNewResults(" + drilldown + ");", 100, 100, "choicea.onFetchFailed();");
			
		},
		fetchNewDetails: function(listid)
		{

			choicea.detailsloaded = false;
			
			if (is_test_sys)					//dev only
			{										
				//alert(listid);
				ironbox.fetchJS('js/DetailsData.js');
				ironbox.keepTrying("choicea.detailsloaded", "choicea.processNewDetails();", 100, 100);
				return;
			}
			
			//var commnd = choicea.links.serverpath + choicea.links.servercommands.get_details;

			var commnd = 'http://www.choicea.com/listings/results?&data=';
			var qry = {};
			qry.json = 0;
			qry.id = Number(listid);
			
			try { ironbox.fetchJS(commnd + qry.toJSONString()); }
			catch (sorry) {}
			
			ironbox.keepTrying("choicea.detailsloaded", "choicea.processNewDetails();", 100, 100, "choicea.onFetchFailed();");
			
		},
		fetchDetailsPage: function(listid)
		{
			//alert('buiding iframe');
			var hostdiv = document.getElementById('details2');
			hostdiv.innerHTML = '';
			hostdiv.style.height = (hostdiv.parentNode.offsetHeight - 24) + 'px';
			hostdiv.style.backgroundColor = 'white';
			hostdiv.style.visibility = 'visible';
			hostdiv.style.overflow = 'hidden';
			
			var ifr = ironbox.makeElement(null, 'iframe', hostdiv);
			ifr.style.width = '100%';
			ifr.style.height = '100%';
			ifr.style.borderStyle = 'none';
			ifr.src = 'http://www.choicea.com/listings/overlay/' + listid;
			
		},
		onFetchFailed: function(errno)
		{
			//TODO: make this fancier
			alert('Unable to obtain results from server!  ' + errno);
		},
		processNewResults: function(drilldown)
		{
			
			choicea.results.length = 0; 			//182;
			
			/*
			if (drilldown)
				alert('slider');
			else
				alert('not slider');
			*/
			
			//var idx = 0;

			ironbox.forEach(choicea.resultso, function(x)
			{
				var rec = [];
				ironbox.forEach(choicea.viewflds, function(y)
				{
					rec.push(x[y]);

				});
				
				choicea.results.push(rec);
			});

			document.getElementById('datviewpane1').style.height = (choicea.results.length * choicea.datscrollhop) + 'px';
			//alert(choicea.dattable.rows[0].offsetHeight);
			//alert(choicea.dattable.rows.length);
				
			document.getElementById('datviewbak1').onscroll = function(e)
				{
					choicea.refreshDatView();
				};
			
			
			//var then = new Date();
			choicea.loadSearchResults(0);
			//var now = new Date();
			//alert(now - then);
					
			//var hostdiv = document.getElementById('galviewbak1');
			//oldtable = hostdiv.getElementsByTagName('table')[0];
			//hostdiv.removeChild(oldtable);
			
			//var galrows = Math.ceil(choicea.results.length / 4);  //TODO: make cols an option
			//galrows = galrows < 9 ? galrows : 8;	//TODO:  THIS IS TEMPORARY
			//if (!choicea.galtable)
			//	choicea.buildGalview(hostdiv, 3);
			
			var scrlht = document.getElementById('rightpane1').clientHeight;
			document.getElementById('galviewpane1').style.height = (Math.ceil(choicea.results.length * choicea.galscrollhop / 4) + scrlht) + 'px';
			//alert(choicea.results.length);
			//alert(document.getElementById('galviewpane1').style.height);
			
			document.getElementById('galviewbak1').onscroll = function(e)
				{
					choicea.refreshGalView();
				};			
			
			choicea.loadGallery(0);

			choicea.resultsmapped = false;
			if (choicea.ismapview)
				if (!suppress_maps) choicea.loadMainMap(true);
				
		
			//housekeeping 
			
			var skipalert = choicea.issearchview;
			
			if (!drilldown)
			{
				//document.getElementById('contents1').style.visibility = "visible";
				document.getElementById('searchbut1').style.visibility = "visible";  //if turned on before shows up alone for some weird reason
				document.getElementById('searchviewbak1').style.visibility = "visible";
				
				if (choicea.results.length && entrypage)
					choicea.chooseView('datviewbak1');
				else if (choicea.fromsearchbut && choicea.results.length)
				{
					choicea.chooseView('datviewbak1');
					choicea.fromsearchbut = false;
				}
				else if (choicea.fromsearchbut)
				{
					choicea.fromsearchbut = false;
					skipalert = false;
				}
				else
				{
					choicea.chooseView('searchviewbak1');
					skipalert = true;
				}
			}
			

		
			//choicea.info = "Sorry, nothing for you here today. Maybe you can come back tomorrow.";		//For Test Only	
			
			if (choicea.info && (entrypage || !skipalert) )
			{
				var alrt = document.getElementById('infoalert');
				var messg = document.getElementById('infomessage');
				var indent = (navigator.userAgent.indexOf('MSIE 6') > -1) ? 100 : 300;
				alrt.style.left = (choicea.navbarindent + indent) + 'px';
				messg.innerHTML = choicea.info;
				alrt.style.display = 'block';
				alrt.onclick = function() {this.style.display = 'none';};
				setTimeout("choicea.clearAlerts();", 5000);
			}

				
		},
		getRecVisitedState: function(whatrecord)
		{
			//alert(whatrecord);
			if (!choicea.visited[whatrecord[0]])
				return {viewed: false, favorite: false};
			else
				return {viewed: choicea.visited[whatrecord[0]].viewed, favorite: choicea.visited[whatrecord[0]].favorite};

		},
		processNewDetails: function(cntrls)
		{
			var detail2 = document.getElementById('details2');
			detail2.style.visibility = 'visible';
			
			var div1 = document.getElementById('details4');
			var div2 = document.getElementById('details3');
			
			div1.innerHTML = '';
			div2.innerHTML = '';
			
			ironbox.makeElement(null, 'br', div1);

			ironbox.forEach(choicea.detailfldnams, function(x)
				{	
						
						var divx = ironbox.makeElement(x + ':', 'div', div1, 'left');
						divx.style.width = '200px';
						divx.style.textAlign = 'right';
						divx.style.marginTop = '5px';
						
			
						var inpx = ironbox.makeElement(null, 'input', div1);
						inpx.type = 'text';
						inpx.value = choicea.details[0][x];
						inpx.style.width = '400px';
						inpx.style.margin = '5px 0px 0px 10px';
						
			
						ironbox.makeElement(null, 'br', div1);
						
				});
			
			var idx = 0;
			ironbox.forEach(choicea.details[0]['fullImages'], function(x)
				{	
						
					var img1 = ironbox.makeElement(null, 'img', div2, 'right');
					if (is_test_sys)
						img1.src = 'imgs/house1.jpg';
					else
						img1.src = x;				//was path
					img1.style.height = '100px';
					img1.style.width = '100px';
					img1.style.margin = '5px 10px 5px 10px';
					img1.id = 'testmeup' + idx++;				//for grow only
					
					img1.onmouseover = function()
						{  
							ironbox.growImage(this.id, null, 100, 200, 10);
							this.endgrow = false;
							
							//alert(this.offsetHeight);
						};
					img1.onmouseout = function()
						{  
							this.endgrow = true;
							//this.style.height = '100px';
							//this.style.width = '100px';
						};
												
				});

				
			ironbox.makeElement(null, 'br', div1);
		},
		buildDatview: function(hostdiv, nrows)
		{
			if (choicea.dattable)
			{
				hostdiv.removeChild(choicea.dattable);
				choicea.dattable = null;
			}
				
			if (choicea.colors)
				choicea.rowcolors = [choicea.colors.dattblro0[0], choicea.colors.dattblro1[0], choicea.colors.dattblrover[0]];
			var tabl1 = ironbox.makeTable(nrows, 9, 'datview', '&nbsp;', choicea.rowcolors);
			//tabl1.style.width = '100%';
			//tabl1.style.height = '100%';
			tabl1.border = '1';
			tabl1.cellSpacing = '0px';
			tabl1.cellPadding = '5px';
			tabl1.id = 'datview1';

			tabl1.onselectstart = function(){return false;};
			tabl1.drag = function(){return false;};

			tabl1.rows[0].cells[0].style.width = '0px';
			tabl1.rows[0].cells[1].style.width = '65px';
			tabl1.rows[0].cells[2].style.width = '200px';
			tabl1.rows[0].cells[3].style.width = '55px';
			tabl1.rows[0].cells[4].style.width = '140px';
			tabl1.rows[0].cells[5].style.width = '40px';

			//hostdiv.innerHTML = '';
			hostdiv.appendChild(tabl1);

			//for (var i = 0; i < 8; i++)
			//	tabl1.tcells[i][1].innerHTML = i;	//Testing Only

			ironbox.forEach(tabl1.rows, function(x)
				{	
					x.onmouseover = function(e)
						{
							if (choicea.isrightmousedown)
								return;

							choicea.ddrowover = this;			// RFU
							if (choicea.isdragging)
								return;

							this.oldcolor = this.style.backgroundColor;
							this.style.backgroundColor = choicea.rowcolors[2];

							choicea.currlongrec = choicea.results[this.code];

							if (choicea.isonmaptrigr)
								choicea.showMapThumb(e, 1);

							choicea.showDynaInfo(this, e);
						};
					x.onmousemove = function(e)
						{
							if (choicea.isrightmousedown)
								return;

							if (choicea.isdragging)
							{
								choicea.dragSlug(e);
								return false;
							}

							choicea.moveDynaInfo(this, e);
						};
					x.onmouseout = function(e)
						{
							if (choicea.isrightmousedown)
								return;

							choicea.ddrowover = null;			//  RFU
							if (choicea.isddmousedown)
								choicea.dragSlug(e, this);
							else								
								this.style.backgroundColor = this.oldcolor;
								
							
							choicea.hideDynaInfo();

						};
					x.onmouseup = function(e)
						{
							if (choicea.isrightmousedown)
								return;										

							if (!choicea.isddguilty)
							{
								choicea.isdragging = false;
								choicea.isddmousedown = false;
								choicea.hideDynaInfo();
								choicea.showDetails(choicea.currshortrec);
							}		
						};
					x.onmousedown = function(e)
						{
							var button = e ? e.button : event.button;
							if (button == 2 || choicea.isrightmousedown)	//2 is rightclick
							{
								this.style.backgroundColor = this.oldcolor;
								choicea.hideDynaInfo();
								choicea.isrightmousedown = true;
								return;
							}
	
							choicea.isddguilty = false;
							choicea.isddmousedown = true;
							choicea.ddrow = this;
							
							for (var i = 0; i < 8; ++i)
								choicea.currshortrec[i] = choicea.results[this.code][i];
								//choicea.currshortrec[i] = this.cells[i].innerHTML;

							return false;
						};
				});

				
			choicea.dattable = tabl1;
		},
		refreshDatView: function()
		{
			if (!choicea.resultsloaded)
				return;
	
			var nupos = document.getElementById('datviewbak1').scrollTop;
			//if (nupos < choicea.datscrollhop)
			//	return;
			if (choicea.datviewpos != nupos)
			{
				//alert(nupos);
				var numrows = choicea.dattable.rows.length;
				var recstart = Math.floor(nupos / choicea.datscrollhop);
				if ((recstart + numrows) > choicea.results.length)
					recstart = choicea.results.length - numrows;
				choicea.loadSearchResults(recstart);
				choicea.datviewpos = nupos;
			}
		},
		addRow: function(tbl, y)
		{
				var tr = tbl.insertRow(0);
				tr.code = null;
				tr.className = 'datview_tr';
				
				for(var j = 0; j < y; ++j)
				{
					var td = tr.insertCell(j);
					td.code = null;
					td.className = 'datview_td';
					//tbl.tcells[idx++] = [cols.charAt(j) + (i + 1), td];
					
				}
			
		},
		buildGalview: function(hostdiv, nrows)
		{
			if (choicea.galtable)
			{
				hostdiv.removeChild(choicea.galtable);
				choicea.galtable = null;
			}
			
			var tabl1 = ironbox.makeTable(nrows, 4, 'galview', '&nbsp;');
			//tabl1.style.width = '100%';
			//tabl1.style.height = '100%';
			//tabl1.border = '1';
			tabl1.cellSpacing = '40px';
			tabl1.id = 'galview1';

			tabl1.onselectstart = function(){return false;};
			tabl1.drag = function(){return false;};
			
			//hostdiv.innerHTML = '';
			hostdiv.appendChild(tabl1);
			

			ironbox.forEach(tabl1.tcells, function(x)
				{	
					x[1].onmouseover = function(e)
						{									
							if (choicea.isrightmousedown)
								return;
								
							choicea.ddrowover = this;			//  RFU
							if (choicea.isdragging)
								return;
								
							this.oldbkgd = this.style.backgroundImage;
							this.style.backgroundImage = 'url("imgs1/galleryBG_on_mouseover3.png")';
			
							choicea.showDynaInfo(this, e);
						};
					x[1].onmouseout = function(e)
						{
							if (choicea.isrightmousedown)
								return;
								
							choicea.ddrowover = null;			//  RFU
							if (choicea.isddmousedown)
								choicea.dragSlug(e, this);
							else								
								this.style.backgroundImage = this.oldbkgd;

							choicea.hideDynaInfo();
						};
					x[1].onmousemove = function(e)
						{
							if (choicea.isrightmousedown)
								return;
								
								
							if (choicea.isddmousedown)    //choicea.isdragging)
							{
								//prevent crazy IE behaviour that grabs the mouse
								if (!e && this.getElementsByTagName('img')[0])
									this.getElementsByTagName('img')[0].releaseCapture();
								
								choicea.dragSlug(e, this);
								return false;
							}
							
						};
					x[1].onmousedown = function(e)
						{
							var button = e ? e.button : event.button;
							if (button == 2 || choicea.isrightmousedown)	//2 is rightclick
							{
								this.style.backgroundImage = this.oldbkgd;
								choicea.hideDynaInfo();
								choicea.isrightmousedown = true;
								return;
							}
							
							choicea.isddguilty = false;
							choicea.isddmousedown = true;
							choicea.ddrow = this;			

							for (var i = 0; i < 8; ++i)
								choicea.currshortrec[i] = choicea.results[this.code][i];
								
							return false;
						};
					x[1].onmouseup = function(e)
						{
							/*if (!choicea.isrightmousedown)
							{
								choicea.hideDynaInfo();
								choicea.showDetails(choicea.currshortrec);
							} */
							
							if (choicea.isrightmousedown)
								return;										

							if (choicea.isdragging)
								choicea.dropSlug(e);
								
							choicea.isdragging = false;
							choicea.isddmousedown = false;
								
							if (!choicea.isddguilty)
							{
								choicea.hideDynaInfo();
								choicea.showDetails(choicea.currshortrec);
							}		
							
							
						};
				});
			
			choicea.galtable = tabl1;
		},
		refreshGalView: function()
		{
			//TODO:   WORKING ON THIS
			
			if (!choicea.resultsloaded)
				return;
	
			var nupos = document.getElementById('galviewbak1').scrollTop;
			//if (nupos < choicea.galscrollhop)
			//	return;
				
			if (choicea.galviewpos != nupos)
			{
				//alert(nupos);
				var numcells = choicea.galtable.tcells.length;
				var recstart = 4 * Math.floor(nupos / choicea.galscrollhop);
				if ((recstart + numcells) > choicea.results.length)
					recstart = choicea.results.length - numcells;
				choicea.loadGallery(recstart);
				
				choicea.galviewpos = nupos;
			}
		},
		buildSubmitFrm: function(hostdiv)
		{
			var idx = 0;
			ironbox.forEach(choicea.listinfo, function(x)
			{
				var div1 = ironbox.makeElement('<b>' + choicea.listfrmhdrs[idx++] + '</b>', 'div', hostdiv);
				div1.style.backgroundColor = 'transparent';
				div1.style.margin = '0px auto 10px auto;'
				div1.style.padding = '10px 0px 0px 0px;'
				
				var idx2 = 1;
				ironbox.forEach(x, function(xx)
				{
					var div2 = ironbox.makeElement(null, 'div', div1);
					//div2.style.backgroundColor = '#D8EBEE';
					div2.style.textAlign = 'left';
					div2.style.height = (idx == 5) ? '6.5em' : '2.5em';
					div2.style.margin = '0px 4px 0px 10px;'
					div2.style.paddingTop = (idx2++ == 1) ? '10px' : '0px';
					var div3 = ironbox.makeElement(xx.caption, 'div', div2, 'left');
					div3.style.width = '310px';
					div3.style.textAlign = 'right';
					div3.style.paddingRight = '10px';
					var inp1;
					if (idx == 5)
					{
						inp1 = ironbox.makeElement(null, 'textarea', div2, 'left');
						inp1.rows = '4';						
						inp1.style.width = '300px';
					}
					else if (xx.type == 'drop')
					{
						inp1 = ironbox.makeElement(null, 'select', div2, 'left');
						inp1.style.width = '305px';
						ironbox.makeOptions(inp1, xx.options);
						inp1.value = xx.defltval;

					}
					else
					{
						inp1 = ironbox.makeElement(null, 'input', div2, 'left');
						inp1.type = 'text';
						inp1.style.width = '300px';
					}
					inp1.name = xx.name;
					inp1.value = xx.defltval;
					
					var tip = ironbox.makeElement('Tip', 'div', div2, 'left');
					tip.style.marginLeft = '10px';
					tip.style.cursor = 'default';
					tip.onmouseover = function(e)
						{
							choicea.showHint(e, xx.tip);
						};
					tip.onmousemove = function(e)
						{
							choicea.moveHint(e);
						};
					tip.onmouseout = function(e)
						{
							choicea.hideHint(e);
						};


				});
			});
		},
		showDynaInfo: function(whatrow, e)
		{			
			var xy = ironbox.readMousePos(e, false);
			var xpos = xy[0];
			var ypos = xy[1];
					
			var thcapt = document.getElementById('imgcapt1');
			var thimg = document.getElementById('imgview1');

			if (whatrow.cells)
			{
				thcapt.style.display = 'none';
				thimg.style.display = 'block';
				if (is_test_sys)
				{
					var housepic = (Number(whatrow.cells[6].innerHTML) % 2) ? 'house1.jpg' : 'house2.jpg';
					thimg.src = 'imgs/' + housepic;
				}
				else if (choicea.currlongrec[10])
					thimg.src = choicea.currlongrec[10];		//was path
			}
			else
			{
				thcapt.style.display = 'block';
				thimg.style.display = 'none';
				var rec = choicea.results[whatrow.code];
				thcapt.innerHTML = '<b>' + rec[2] + '<br />' + rec[4] + ', ' + rec[5] + '</b><br />Year Built: ' + rec[6] + '<br />Sq. Footage: ' + rec[7] + '<br /><b>' + choicea.makeMoney(rec[1]) + '</b>';
				
			}
			
			choicea.dynainfo.style.left = (choicea.navbarindent + 29) + 'px';
			choicea.dynainfo.style.top = (ypos - 71) + 'px';
			choicea.dynainfo.style.display = 'block';
			
		},
		moveDynaInfo: function(whatrow, e)
		{			
			var xy = ironbox.readMousePos(e, true);
			var xpos = xy[0];
			var ypos = xy[1];
								
			choicea.dynainfo.style.top = (ypos - 71) + 'px';
			
		},
		hideDynaInfo: function()
		{
			choicea.dynainfo.style.display = 'none';
		},
		showDetails: function(shortrec)
		{
			if (!choicea.visited[shortrec[0]])
				choicea.visited[shortrec[0]] = {};
			choicea.visited[shortrec[0]].viewed = true;
				
		
			var veil = document.getElementById('veil1');
			veil.style.backgroundColor = 'navy';
			veil.style.backgroundImage = 'none';
			ironbox.setOpacity(veil, '50');
			veil.style.width = '100%';
			veil.style.height = '100%';
			var detail1 = document.getElementById('details1');
			detail1.style.display = 'block';
			
			var detail2 = document.getElementById('details2');
			detail2.style.visibility = 'hidden';
			
			if (is_test_sys)					//dev only
				choicea.fetchNewDetails(shortrec[0]);
			else
				choicea.fetchDetailsPage(shortrec[0]);

				
			//to update visited	 -- TODO: gather these and all the others into a method
			choicea.loadGallery(choicea.galtable.tcells[0][1].code);	//reload currview of gallery
			choicea.loadSearchResults(choicea.dattable.rows[0].code);	//and data table	
			if (choicea.markrrefs[shortrec[0]] && !choicea.visited[shortrec[0]].favorite)
				choicea.markrrefs[shortrec[0]].setImageCA('imgs/map-4.png');	//but markr has own reference
			
		},
		hideDetails: function()
		{			
			var veil = document.getElementById('veil1');
			
			if (veil.style.backgroundImage != 'none')
			{
				//no longer called -- reads from the cookie instead
				
				var entryzipval = document.getElementById('entryzip1').value;
				document.getElementById('listZip1').value = entryzipval;
				document.getElementById('entrywrap').style.display = 'none';
			}
			
			veil.style.width = '0px';
			veil.style.height = '0px';
			document.getElementById('details1').style.display = 'none';
		},
		loadSearchResults: function(idx)
		{
			var datbak = document.getElementById('datviewbak1');
			datbak.style.overflow = 'auto';
			
			if (idx < 0) idx = 0;
			if (!idx) datbak.scrollTop = 0;
			
			
			choicea.dattable.style.width = '768px';


			var util1 = document.getElementById('util1');

			var fldct = choicea.dattable.rows[0].cells.length - 1;	//last one is MAP triggr

			//var idx = 0;
			ironbox.forEach(choicea.dattable.rows, function(x)
				{
					x.style.visibility = 'visible';		//in case it was hidden before
					if (idx >= choicea.results.length)
					{
						x.style.visibility = 'hidden';
						choicea.dattable.style.width = '784px';
						datbak.style.overflow = 'hidden';
						return;
					}

					//check if viewed and/or favorite
					var visitstate = choicea.getRecVisitedState(choicea.results[idx]);
					if (visitstate.viewed)
						x.style.color = 'orange';
					else
						x.style.color = choicea.dattable.style.color;
					if (visitstate.favorite)
						x.style.color = 'red';

					for (var i = 0; i < fldct; i++)
					{
						if (idx < choicea.results.length)
							x.cells[i].innerHTML = choicea.results[idx][i];
						else
							x.cells[i].innerHTML = '&nbsp;';
						x.cells[i].onselectstart = function(){return false;};
						x.cells[i].ondrag = function(){return false;};
						if (i == 1)
						{
							x.cells[i].style.textAlign = 'right';
							x.cells[i].style.paddingRight = '30px';
							x.cells[i].innerHTML = choicea.makeMoney(x.cells[i].innerHTML);
						}
					}
					x.code = idx++;


					//x.cells[0].innerHTML = '    ';	//keep ID field
					//x.cells[0].style.visibility = 'hidden';
					x.cells[0].style.color = choicea.rowcolors[0];
					x.cells[0].style.fontSize = '1px';

					x.cells[fldct].innerHTML = util1.innerHTML;
					
					var span1 = x.cells[fldct].getElementsByTagName('span')[0];
					span1.onmouseover = function(e)
						{
							choicea.isonmaptrigr = true;
							//if (!choicea.isdragging)
							//	choicea.showMapThumb(e, this);
						};
					span1.onmouseout = function(e)
						{
							choicea.isonmaptrigr = false;
							choicea.hideMapThumb(e, 1);
						};
						
				});
				
			document.getElementById('datviewbak1').style.backgroundImage = 'none';
			choicea.dattable.style.backgroundColor = '#E7F2FD';
			
		},
		loadGallery: function(idx)
		{
			//alert(idx);		//TODO: test w/ this when reviewing redundant multi-loading

			if (idx < 0) idx = 0;
			if (!idx) 
			{
				document.getElementById('galviewbak1').scrollTop = 0;
				choicea.galviewpos = 0;
			}
				
			ironbox.forEach(choicea.galtable.tcells, function(x)
			{
				x[1].code = idx;
				
				if (document.all)		//fix annoying centering problem between browsers
					x[1].style.paddingTop = '0px';
				else
					x[1].style.paddingTop = '4px';

				if (idx < choicea.results.length)
				{
					var housepic;
					if (is_test_sys)
						housepic = 'imgs/' + ((Number(x[1].code) % 2) ? 'house1.jpg' : 'house2.jpg');
					else
						housepic = choicea.results[idx][10];		//was path
					x[1].innerHTML = '<img src="' + housepic + '" style="height: 96px; width: 128px; border-width: 0px;" />';
					
					//check if viewed and/or favorite
					var visitstate = choicea.getRecVisitedState(choicea.results[idx]);
					if (visitstate.viewed)
						x[1].style.backgroundImage = 'url("imgs1/galleryBG_on_mouseover2.png")';
					else
						x[1].style.backgroundImage = 'url("imgs1/galleryBG.png")';
					if (visitstate.favorite)
						x[1].style.backgroundImage = 'url("imgs1/galleryBG_red.png")';
					
					x[1].style.visibility = 'visible';
				}
				else
				{
					x[1].innerHTML = ' ';
					x[1].style.visibility = 'hidden';
				}
				idx++;
			});
			
		},
		loadMainMap: function(nuresults)
		{
				
			if (!nuresults)
				return;				
							
      		if (GBrowserIsCompatible() && !choicea.mainmap)
			{
				//create main map if it does not yet exist
        		choicea.mainmap = new GMap2(document.getElementById("mapviewbak1"));
			 	choicea.mainmap.addControl(new GLargeMapControl());			
	 			choicea.mainmap.addControl(new GMapTypeControl());	
				
				GMarker.prototype.setImageCA = function(imge)
				{
					this.setImage(imge);
					this.imageca = imge;
				};	
			}
						
			choicea.mainmap.clearOverlays();
			if (!choicea.results.length)
				return;

        	//choicea.mainmap.setCenter(new GLatLng(37.4419, -122.1419), 13);
			var point = new GLatLng(Number(choicea.results[0][8]), Number(choicea.results[0][9]));
			choicea.mainmap.setCenter(point, 7);
			//alert(point.lat());
			//alert(point.lng());
			
			var minlat = point.lat();
			var maxlat = point.lat();
			var minlng = point.lng();
			var maxlng = point.lng();
			
			var dist = 0;				//no longer needed, but keep for future reference
			var edgepnt = null;			//no longer needed, but keep for future reference
			
			//THESE ARE NOT IMPROVEMENTS FOR NOW -- TODO:  maybe Timeout ea marker separately
			//setTimeout('choicea.addMapMarkers()', 100);
			//GEvent.addListener(choicea.mainmap, "load", function(){choicea.addMapMarkers();});
			//return;

			ironbox.forEach(choicea.results, function(x)
			{
				var respoint = new GLatLng(Number(x[8]), Number(x[9]));
				
				if (respoint.lat() > maxlat)
					maxlat = respoint.lat();
				else if (respoint.lat() < minlat)
					minlat = respoint.lat();
				if (respoint.lng() > maxlng)
					maxlng = respoint.lng();
				else if (respoint.lng() < minlng)
					minlng = respoint.lng();
				
				var tmpdist = respoint.distanceFrom(point);
				
				if (tmpdist > dist)
				{
					edgepnt = respoint;
					dist = tmpdist;
				}							
				
				var marker = new GMarker(respoint, {draggable: true});
				//var marker = new GMarker(respoint);

				var mrkrimg = 'imgs/map-2.png';
				if (choicea.visited[x[0]])
				{
					mrkrimg = choicea.visited[x[0]].viewed ? 'imgs/map-4.png' : mrkrimg;
					mrkrimg = choicea.visited[x[0]].favorite ? 'imgs/map-8.png' : mrkrimg;
				}
				
				var micon = marker.getIcon();
				micon.image = mrkrimg;
				micon.iconSize = new GSize(29, 29);
				micon.shadowSize = new GSize(0, 0);   // new GSize(37, 29);
				micon.iconAnchor = new GPoint(5, 29);
				micon.infoWindowAnchor = new GPoint(16, 2);
			
				marker.imageca = mrkrimg;
				choicea.markrrefs[x[0]] = marker;

 	  			GEvent.addListener(marker, "mouseover", function()
  	  			{
					//var pricestr = '$' + x[1].substr(0, x[1].length - 3) + ',' + x[1].substr(-3, 3);  // + '.00';
					var pricestr = choicea.makeMoney(x[1]);
					var htmlstr = '<img src="' + x[10] + '" style="width: 66px; height: 50px; float: left" />'
					htmlstr += '<div style="font-size: 10pt;"><b>' + pricestr + '</b><br />';
					htmlstr += (x[2] + '<br />' + x[4] + ', ' + x[5] + '</div>');
    					this.openInfoWindowHtml(htmlstr);

					for (var i = 0; i < 8; ++i)
						choicea.currshortrec[i] = x[i];
    			});
 	  			GEvent.addListener(marker, "mouseup", function()
  	  			{
					if(!choicea.isdragginmarker)
					{
						choicea.showDetails(choicea.currshortrec);
						return;
					}
					
					this.setPoint(this.ca_oldpoint);
					choicea.ddrow = null;
					choicea.dropSlug();
					//if (choicea.dropSlug())
					//	this.setImage('imgs/map-8.png');
					this.show();
					choicea.dragmarker.style.display = 'none';
					choicea.isdragginmarker = false;

					//Use one of this for changing image for favorites
					//marker.setImage(String(window.location).replace(/choicea\.htm/, "imgs/map-2.png"));
					//marker.setImage("imgs/map-2.png");

				});
 	  			GEvent.addListener(marker, "mousedown", function(e)
  	  			{
					
					this.ca_oldpoint = this.getPoint();
					choicea.dragmarker.style.backgroundImage = 'url("' + this.imageca + '")';
					
					/*GEvent.addDomListener(choicea.mainmap.getPane(0).parentNode,
							"mousedown",function(e)
						{
         					var xy = ironbox.readMousePos(e, true);
							var xpos = xy[0];
							var ypos = xy[1];
      
	  						alert('x is ' + xpos + ' and y is ' + ypos);
							//document.getElementById('mailto1').value = 'x is ' + xpos + ' and y is ' + ypos;
							
							choicea.dragmarker.style.left = (xpos) + 'px';
							choicea.dragmarker.style.top = (ypos) + 'px';

						});
					*/

					//choicea.mainmap.disableDragging();	//automatic when marker is dragging					
					
				});
				
 	  			GEvent.addListener(marker, "drag", function()
  	  			{
					this.hide();
					choicea.isdragginmarker = true;
					var mrkrpos = choicea.getMarkerXYPos(this);
					//choicea.dragmarker.style.zIndex = 100;
					choicea.dragmarker.style.left = (mrkrpos[0] - 17) + 'px';
					choicea.dragmarker.style.top = (mrkrpos[1] - 42) + 'px';
					choicea.dragmarker.style.display = 'block';
				});
						
				choicea.mainmap.addOverlay(marker);

			});
			//choicea.thumbmap.addOverlay(new GMarker(point));

			//choicea.dragobj1 = new GDraggableObject(document.getElementById("dragmarker") );
			//var objectToDrag = new GDraggableObject(document.getElementById("dragmarker"), {container: document.getElementById("mapviewbak1")}  );
			//GEvent.addListener(objectToDrag, "drag", function() { alert(this.top);});	

			
			//var bounds = new GLatLngBounds(point, point);
			var swpt = new GLatLng(minlat, minlng);
			var nept = new GLatLng(maxlat, maxlng);
			var bounds = new GLatLngBounds(swpt, nept);
			//edgepnt = edgepnt ? edgepnt : point;	
			//bounds.extend(edgepnt);
			var zoom = choicea.mainmap.getBoundsZoomLevel(bounds);
			//alert(zoom);
			//choicea.mainmap.setZoom(zoom);
			choicea.mainmap.setCenter(bounds.getCenter(), zoom);
			
			choicea.resultsmapped = true;
			document.getElementById("mapviewbak1").style.backgroundImage = 'none';

			
		},
		getMarkerXYPos: function(marker)
		{
				var mk = marker.getPoint();
				var ne = choicea.mainmap.getBounds().getNorthEast();
				var sw = choicea.mainmap.getBounds().getSouthWest();
				var diffx = choicea.mainmap.fromLatLngToDivPixel(mk).x - choicea.mainmap.fromLatLngToDivPixel(sw).x;
				var diffy = choicea.mainmap.fromLatLngToDivPixel(mk).y - choicea.mainmap.fromLatLngToDivPixel(ne).y;
				var x = choicea.mainmap.getContainer().offsetLeft + diffx;
				var y = choicea.mainmap.getContainer().offsetTop + diffy;
				//document.getElementById('mailto1').value = 'top is ' + y + ' and left is ' + x;
				return [x, y];
		},
		addMapMarkers: function()
		{
			//NOT CURRENTLY USED -- IF USED, NEEDS UPDATING PER PRESENT MARKER FEATURES
			ironbox.forEach(choicea.results, function(x)
			{
				var respoint = new GLatLng(Number(x[8]), Number(x[9]));
				var marker = new GMarker(respoint);

				var micon = marker.getIcon();
				micon.image = 'imgs/map-2.png';
				micon.iconSize = new GSize(29, 29);
				micon.shadowSize = new GSize(37, 29);
				micon.iconAnchor = new GPoint(5, 29);
				micon.infoWindowAnchor = new GPoint(16, 2);


 	  			GEvent.addListener(marker, "mouseover", function()
  	  			{
					var pricestr = '$' + x[1].substr(0, x[1].length - 3) + ',' + x[1].substr(-3, 3);  // + '.00';
					var htmlstr = '<img src="' + x[10] + '" style="width: 50px; height: 50px; float: left" />'
					htmlstr += '<div style="font-size: 10pt;"><b>' + pricestr + '</b><br />';
					htmlstr += (x[2] + '<br />' + x[4] + ', ' + x[5] + '</div>');
    					this.openInfoWindowHtml(htmlstr);

					for (var i = 0; i < 8; ++i)
						choicea.currshortrec[i] = x[i];
    				});
 	  			GEvent.addListener(marker, "click", function()
  	  			{
					choicea.showDetails(choicea.currshortrec);
				});
				choicea.mainmap.addOverlay(marker);

			});			
		},
		loadResrcs: function()
		{
		},
		installResrcs: function()
		{			
		},
		sortColumn: function(typ, colnum)
		{
			if (choicea.sortstate[colnum])
			{
				choicea.sortColumnAsc(typ, colnum);
				choicea.sortstate[colnum] = 0;
			}
			else
			{
				choicea.sortColumnDesc(typ, colnum);
				choicea.sortstate[colnum] = 1;
			}

			choicea.loadSearchResults(0);
			choicea.loadGallery(0);
		},
		sortColumnAsc: function(typ, colnum)	//typ 0 is string, typ 1 is number
		{
			if (typ)
				choicea.results.sort(function(a, b){return a[colnum] - b[colnum];});
			else
				choicea.results.sort(function(a, b)
						{
							if (b[colnum] > a[colnum])
								return -1;
							else if (b[colnum] < a[colnum])
								return 1;
							else
								return 0;
						});

		},
		sortColumnDesc: function(typ, colnum)	//typ 0 is string, typ 1 is number
		{
			if (typ)
				choicea.results.sort(function(b, a){return a[colnum] - b[colnum];});
			else
				choicea.results.sort(function(b, a)
						{
							if (b[colnum] > a[colnum])
								return -1;
							else if (b[colnum] < a[colnum])
								return 1;
							else
								return 0;
						});
		},
		dragSlug: function(e, whose)
		{
			var xy = ironbox.readMousePos(e, true);
			var xpos = xy[0];
			var ypos = xy[1];
				
			var ddcaption = document.getElementById('ddcaption');
			if (xpos > choicea.navbarindent && xpos < (choicea.navbarindent + 250) )
			{
				ddcaption.style.color = choicea.colors.favpanedrop[0];
				choicea.isintarget = true;
			}
			else
			{
				ddcaption.style.color = choicea.colors.favpanetxt[0];
				choicea.isintarget = false;
			}	


			if (choicea.isdragginmarker)
				return;							//slug code not applicable
			
			choicea.isdragging = true;
			choicea.isddguilty = true;
			
			choicea.slug.style.top = (ypos - 25) + 'px';
			choicea.slug.style.left = (xpos - 190) + 'px';  //keep cursor outside or ie7 problem
			
			if (whose && choicea.slug.innerHTML == 'none')
				choicea.slug.innerHTML = choicea.currshortrec[2];	//whose.cells[2].innerHTML;
			ironbox.setOpacity(choicea.slug, 80);
			choicea.slug.style.display = 'block';
			
		},
		dropSlug: function(e)
		{
			choicea.isdragging = false;
			choicea.isddmousedown = false;
		
			choicea.slug.style.display = 'none';
			
			if (choicea.ddrow && choicea.ddrow.cells)				//ddrow is row
				choicea.ddrow.style.backgroundColor = choicea.ddrow.oldcolor;
			else if (choicea.ddrow)									//ddrow is cell
				choicea.ddrow.style.backgroundImage = choicea.ddrow.oldbkgd;
				
			document.getElementById('ddcaption').style.color = choicea.colors.favpanetxt[0];
			
			var success = choicea.isintarget;
			if (success)
			{
				choicea.favsarray.push(choicea.currshortrec.toJSONString());
				
				if (!choicea.visited[choicea.currshortrec[0]])
					choicea.visited[choicea.currshortrec[0]] = {};
				choicea.visited[choicea.currshortrec[0]].favorite = true;
				choicea.loadGallery(choicea.galtable.tcells[0][1].code);	//reload currview of gallery
				choicea.loadSearchResults(choicea.dattable.rows[0].code);	//and data table
				if (choicea.markrrefs[choicea.currshortrec[0]])
					choicea.markrrefs[choicea.currshortrec[0]].setImageCA('imgs/map-8.png');	//but markr has own reference

			
				var nufav = document.createElement('p');
				nufav.innerHTML = choicea.currshortrec[2];  //choicea.slug.innerHTML;
				nufav.className = 'favs';
				nufav.recrd = choicea.currshortrec.concat();
					
				nufav.onclick = function()
					{
						//alert(this.recrd[0]);
						choicea.doublclkd = this.recrd;
						setTimeout("if (choicea.doublclkd) choicea.showDetails(choicea.doublclkd);", 300);
						
					}
				nufav.ondblclick = function()
					{
						choicea.doublclkd = null;
						//this.parentNode.removeChild(this);
					};
				nufav.onmouseover = function()
					{
						this.style.fontWeight = 'bold';
						if (!choicea.isdragging)
						{
							this.firstChild.style.visibility = 'visible';
							ironbox.fadeOut(this.firstChild, 100, 10, 500, 2000);
						}
					}
				nufav.onmouseout = function()
					{
						this.style.fontWeight = 'normal';
					}
				choicea.favs.appendChild(nufav);
				choicea.isintarget = false;
				
				var ximg = document.createElement('img');
				ximg.src = 'imgs1/x_out4.gif';	//'imgs/x_out.png';
				ximg.className = 'favs';
				ximg.onclick = function(e)
					{
						ironbox.stopPropag(e);
						
						choicea.visited[this.parentNode.recrd[0]].favorite = false;
						//alert(this.parentNode.recrd[0]);
						
						this.parentNode.parentNode.removeChild(this.parentNode);
						
						choicea.loadGallery(choicea.galtable.tcells[0][1].code);	//reload currview of gallery
						choicea.loadSearchResults(choicea.dattable.rows[0].code);	//and data table
						if (choicea.markrrefs[this.parentNode.recrd[0]])
						{
							var mrkrimg = choicea.visited[this.parentNode.recrd[0]].viewed ? 'imgs/map-4.png' : 'imgs/map-2.png';
							choicea.markrrefs[this.parentNode.recrd[0]].setImageCA(mrkrimg);	//markr has own reference
						}
						
						var clkwhat = this;
						var idx = 0;
						ironbox.forEach(choicea.favsarray, function(x)
						{
							var xarr = eval(x);
							if (xarr[0] == clkwhat.parentNode.recrd[0])
								choicea.favsarray[idx] = null;
							idx++;	
						});
						choicea.favsarray = ironbox.packArray(choicea.favsarray);
						
					};
				ximg.style.visibility = 'hidden';
				nufav.insertBefore(ximg, nufav.firstChild);
			}
			
			var maxht = document.getElementById('contents1').offsetHeight - 80;
			if (choicea.favs.offsetHeight > maxht)
				choicea.favs.style.height = maxht + 'px';
			
			choicea.slug.innerHTML = 'none';
			
			return (success);			//true or false
		
		},
		onDragSlider: function(offset)
		{
			choicea.clearAlerts();
			
			var sldrpos = Math.round((offset + 4) / choicea.ticksp);		
			document.getElementById('range1').innerHTML = choicea.priceranges[sldrpos].caption;  // + '  ' + sldrpos;
			choicea.currpriceidx = sldrpos;
			
		},
		onEndDragSlider: function()
		{
			//TODO: Fix bug -- setting slider after fetch causes new fetch
			//initial autoset also causes a fetch (aborted if zip 00000)
			
			//if (!choicea.firstime && !choicea.ignoreslider)
			if (!choicea.ignoreslider)
				choicea.fetchNewResults(true);
				
			choicea.ignoreslider = false;
		},
		showMapThumb: function(e, whatmap)
		{
			var xy = ironbox.readMousePos(e, true);
			var xpos = xy[0];
			var ypos = xy[1];

			var mapthumb = document.getElementById('util2');
			mapthumb.style.top = (ypos - 200)+ 'px';
			mapthumb.style.left = (xpos - 220) + 'px';
			mapthumb.style.display = 'block';
			
	
			if (suppress_maps) return;

			if (!choicea.thumbmap)
			{
      			if (GBrowserIsCompatible())
				{
        			choicea.thumbmap = new GMap2(document.getElementById("thmap1"));
			 		//choicea.thumbmap.addControl(new GSmallMapControl());			
	 				//choicea.thumbmap.addControl(new GMapTypeControl());			
				}
			}
			
			var point = new GLatLng(Number(choicea.currlongrec[8]), Number(choicea.currlongrec[9]));
			choicea.thumbmap.setCenter(point, 13);

			var marker = new GMarker(point);
			var micon = marker.getIcon();
			micon.image = 'imgs/map-2.png';
			micon.iconSize = new GSize(29, 29);
			micon.shadowSize = new GSize(37, 29);
			micon.iconAnchor = new GPoint(5, 29);
			

			//choicea.thumbmap.addOverlay(new GMarker(point));
			choicea.thumbmap.addOverlay(marker);

		},
		hideMapThumb: function(e, whatmap)
		{
			var mapthumb = document.getElementById('util2');
			mapthumb.style.display = 'none';
		},
		showHint: function(e, hintstr)
		{
			var xy = ironbox.readMousePos(e, true);
			var xpos = xy[0];
			var ypos = xy[1];

			var hintdiv = document.getElementById('util3');
			hintdiv.innerHTML = hintstr;
			hintdiv.style.top = (ypos - 68)+ 'px';
			hintdiv.style.left = (xpos + 20) + 'px';
			hintdiv.style.display = 'block';

		},
		moveHint: function(e)
		{			
			var xy = ironbox.readMousePos(e, true);
			var xpos = xy[0];
			var ypos = xy[1];
								
			var hintdiv = document.getElementById('util3');
			hintdiv.style.top = (ypos - 68)+ 'px';
			hintdiv.style.left = (xpos + 20) + 'px';
			
		},
		hideHint: function(e)
		{
			var hintdiv = document.getElementById('util3');
			hintdiv.style.display = 'none';
		},
		makeMoney: function(oldstr)
		{	
			if (oldstr.length < 4) return ('$' + oldstr);
			var nustr = '';
			do
			{
				nustr = ',' + oldstr.substring(oldstr.length - 3) + nustr;
				oldstr = oldstr.slice(0, -3);
			}
			while (oldstr.length > 3);
			
			return ('$' + oldstr + nustr);
		},
		clearAlerts: function()
		{
			var alrt = document.getElementById('infoalert');
			alrt.style.display = 'none';;		
		},
		onEnterZip: function(e)
		{
			ironbox.stopPropag(e);
		}

	};

	