	function init()
	{
		DWRUtil.useLoadingMessage();
		DWREngine._errorHandler =  errorHandler;
	}	
	function checkBrand(id,this_checked) {
		this_class = 'class_' + id;
		this_brand = 'brand_' + id;
		oInputs = document.getElementsByTagName('input');
		j = 0;
		for ( i = 0; i < oInputs.length; i++ ) { 
			if (oInputs[i].type == 'checkbox' && oInputs[i].id == this_class){
				if(oInputs[i].checked == true) { 
					j++;
				}							
			}
		}
		if (j > 0) {			
			this_check = document.getElementById(this_brand);
			this_check.checked = false;
		}		
	}
	function checkClass(id,this_checked) {
		this_class = 'class_' + id;
		this_brand = 'brand_' + id;
		oInputs = document.getElementsByTagName('input');
		j = 0;
		if (this_checked == true)
		for ( i = 0; i < oInputs.length; i++ ) { 
			if (oInputs[i].type == 'checkbox' && oInputs[i].id == this_class){
				if(oInputs[i].checked == true) { 
					oInputs[i].checked = false;
				}							
			}
		}		
	}
	function isIE() {
		var thisBrowser = navigator.userAgent;
		ie = thisBrowser.indexOf('MSIE');
		if (ie == -1) {
			return false;
		}
		else {
			return true;
		}
	}
	function fillEcho_byID(ID){
		var mytable=document.getElementById("locations");
		var zipcode = document.forms.frm.zipcode.value;
		var mylocator=document.getElementById("dealerProfile");
		var searchbutton=document.getElementById("searchButton");
		while (mytable.hasChildNodes())	{
			mytable.removeChild(mytable.firstChild);
		}		
		DWREngine._execute(_cfscriptLocation, null, 'fillResults', zipcode, ID, fillEchoResult);
		mylocator.className = 'dealerProfileShow';
		mylocator.src = 'dealer_profile.cfm?id=' + ID;
		searchbutton.innerHTML = '&lt;&lt; Back';		
		mylocator.focus();
	}
	function switchButton() {
		var searchbutton=document.getElementById("searchButton");
		searchbutton.innerHTML = 'Search';
	}
	function checkEnter(e){ 
		var characterCode;
		if(e && e.which) { 
			e = e;
			characterCode = e.which; 
		}
		else {
			e = event;
			characterCode = e.keyCode; 
		}
		if(characterCode == 13){ 
			return false; 
		}
		else {
			return true; 
		}
	}

	function fillEcho(){
		var zipcode = document.forms.frm.zipcode.value;
		var miles = document.forms.frm.miles.value;
		var book = document.getElementsByName('intDealerBrand');
		var mylocator=document.getElementById("dealerProfile");
		var thishidden=document.getElementById("newSearch");
		mylocator.className = 'dealerProfileHidden';	
		var this_book = '';
		j = 0;
		for (i = 0; i < book.length; i++) {
			if (book[i].checked == true) {
				thisval = book[i].value.toString();
				if (thisval != '') {					
					this_book = book[i].value.toString();
					j++;
				}								
			}		
		}

		if (zipcode != '' && this_book != '') {
			var mytable=document.getElementById("locations");
			while (mytable.hasChildNodes())	{
			  		mytable.removeChild(mytable.firstChild);
				}
						
			DWREngine._execute(_cfscriptLocation, null, 'echo', zipcode, miles, this_book, fillEchoResult); 										
		}
		else {
			alert("You must select miles, zip code, and dealer type.");
		}		
	}
	function fillEcho_fromIndex(zipcode){
		var miles = 10;
		var mylocator=document.getElementById("dealerProfile");
		mylocator.className = 'dealerProfileHidden';	
		
		if (zipcode != '') {
			var mytable=document.getElementById("locations");
			while (mytable.hasChildNodes())	{
			  		mytable.removeChild(mytable.firstChild);
				}		
			DWREngine._execute(_cfscriptLocation, null, 'fillEchoIndex', zipcode, miles, fillEchoResult); 										
		}
		else {
			alert("You must select miles AND zipcode.");
		}		
	}
	function fillEchoResult(result) {
		var input;
		var newcell;
		var newrow;
		var celltext;
		var form = document.getElementById('frm');					
		var mytable=document.getElementById("locations");
		var mydiv=document.getElementById("mDiv");
		mydiv.style.display="block";
			
		if (result.length==0){
			if (isIE()) {
				for(i=mytable.rows.length-1; i > -1; i--) {
		     		  mytable.deleteRow(i); 
					}
			}
			else {
				len = mytable.childNodes.length;
	   			while (mytable.hasChildNodes()) {
					  mytable.removeChild(mytable.firstChild);
				}
			}		
			for (var i = 0; i < 1; i++){
				var newrow = mytable.insertRow(-1); 
				var newcell = newrow.insertCell(0); 
				newcell.innerHTML = "";
				newcell.width='10';
				var newcell=newrow.insertCell(1); 
				newcell.innerHTML = "No results for that search.";
				newcell.nowrap='true';
				newrow.style.background="#ffffff";
			}
		}
		else {
			if (isIE()) {
				for(i=mytable.rows.length-1; i > -1; i--) {
	     		  mytable.deleteRow(i); 
				}
				var input;
				
				var newrow = mytable.insertRow(-1); 
				var newcell = newrow.insertCell(0); 
				newcell.innerHTML = '<strong>DEALER NAME</strong>';
				newcell.nowrap='true';
				newcell.align = 'center'
				newrow.style.background="#c0c0c0";
				var newcell=newrow.insertCell(1); 
				newcell.innerHTML = '<strong>CITY</strong>';
				newcell.nowrap='true';
				newcell.align = 'center'
				newrow.style.background="#c0c0c0";	
				var newcell=newrow.insertCell(2); 
				newcell.innerHTML = '<strong>STATE</strong>';
				newcell.nowrap='true';
				newcell.align = 'center'
				newrow.style.background="#c0c0c0";	
				var newcell=newrow.insertCell(3); 
				newcell.innerHTML = '<strong>DISTANCE</strong>';
				newcell.nowrap='true';
				newcell.align = 'center'
				newrow.style.background="#c0c0c0";		
				
				for (var i = 0; i < result.length; i++){					
					var newrow = mytable.insertRow(-1); 
					var newcell = newrow.insertCell(0); 
					newrow.setAttribute("className", "normal");
					newrow.onmouseover = function() { this.className='hilite'; }
					newrow.onmouseout = function() { this.className='normal'; }

					newcell.innerHTML = '<a href="#profile" onclick="fillEcho_byID(' + result[i].ID + ')">' + result[i].TXTDEALERNAME + '</a>'
		            newcell.nowrap='true';
					var newcell=newrow.insertCell(1); 
					newcell.innerHTML = result[i].TXTDEALERCITY;
					newcell.nowrap='true';
					newcell.align = 'center'
						
					var newcell=newrow.insertCell(2); 
					newcell.innerHTML = result[i].TXTDEALERSTATE;
					newcell.nowrap='true';
					newcell.align = 'center'
						
					var newcell=newrow.insertCell(3); 
					newcell.innerHTML = result[i].DIST;
					newcell.nowrap='true';
					newcell.align = 'center';													
									
				}
			}
			else {
				len = mytable.childNodes.length;
	   			while (mytable.hasChildNodes())	{
			  		mytable.removeChild(mytable.firstChild);
				}
				newrow = document.createElement('tr');						            
				
				newcell = document.createElement('td');
				cellText = document.createTextNode('DEALER NAME');
		        newcell.appendChild(cellText);
		        newcell.setAttribute('class','headerCell');
		        newrow.appendChild(newcell);
		        
		        newcell = document.createElement('td');
				cellText = document.createTextNode('CITY');
		        newcell.appendChild(cellText); 
		        newcell.setAttribute('class','headerCell');
		        newcell.setAttribute('align','center');               
		        newrow.appendChild(newcell);
		        
		        newcell = document.createElement('td');
				cellText = document.createTextNode('STATE');
		        newcell.appendChild(cellText); 
		        newcell.setAttribute('class','headerCell');
		        newcell.setAttribute('align','center');                
		        newrow.appendChild(newcell);
		        
		        newcell = document.createElement('td');
				cellText = document.createTextNode('DIST');
		        newcell.appendChild(cellText); 
		        newcell.setAttribute('class','headerCell');  
		        newcell.setAttribute('align','center');              
		        newrow.appendChild(newcell);
		        	
				mytable.appendChild(newrow);
						
				for (var i = 0; i < result.length; i++){
					newrow = document.createElement('tr');						            
					newcell = document.createElement('td');
					newcell.innerHTML = '<a href="#profile" onclick="fillEcho_byID(' + result[i].ID + ')">' + result[i].TXTDEALERNAME + '</a>'
		            newcell.setAttribute('class','resultCell');
		            newrow.appendChild(newcell);
		            
		            newcell = document.createElement('td');
					cellText = document.createTextNode(result[i].TXTDEALERCITY);
		            newcell.appendChild(cellText); 
		            newcell.setAttribute('class','resultCell');
		            newcell.setAttribute('align','center');                 
		            newrow.appendChild(newcell);
		            
		            newcell = document.createElement('td');
					cellText = document.createTextNode(result[i].TXTDEALERSTATE);
		            newcell.appendChild(cellText); 
		            newcell.setAttribute('class','resultCell');
		            newcell.setAttribute('align','center');                
		            newrow.appendChild(newcell);
		            
		            newcell = document.createElement('td');
					cellText = document.createTextNode(result[i].DIST);
		            newcell.appendChild(cellText); 
		            newcell.setAttribute('class','resultCell');
		            newcell.setAttribute('align','center');                
		            newrow.appendChild(newcell);
		            
		            newrow.setAttribute("className", "normal");
					newrow.onmouseover = function() { this.className='hilite'; }
					newrow.onmouseout = function() { this.className='normal'; }
					
					mytable.appendChild(newrow);	
				}
			}
		}	
	}
	function highlight(obj) {
		obj.style.background = '#c0cce6';
	}
	function unhighlight(obj) {
		obj.style.background = '#ffffff';
	}