function DLUsers(geoCoder, viewLoc) 
{
	this._arguments = null;
	this._geoCoder=geoCoder;
	//alert(document.getElementById(viewLoc));
	this._mulSelect = document.getElementById(viewLoc);
	//this.hidingElements = hele;
}

/* function hele() 
{
	this._arguments = hele.arguments;
}
*/

DLUsers.prototype.hidingElements = function() 
{
	this._arguments = arguments;
}

DLUsers.prototype.loadResults = function() 
{
    with (this) 
    {
	    // If an error code has been produced, display the explanation
	   	if (_DLError(_geoCoder)) return;
		
		// Remove existing options from the Dropdown which shows multiple user addresses. 
		_cleanUp();		
		
		// Hide user search form elements & other specified elements in the Search page
	    _hide();		
	    
	    // Loop through each record set:
	    var ballons = new DLBalloons('mapviewer');
		//alert("Inside Load Results Function");
	    for ( var count=0; count<_geoCoder.result_set.length; count++ ) 
	    {    
			//alert(count);
			//alert(_geoCoder.result_set[count]);
			var record = _geoCoder.result_set[count];
			//alert(record.address);
			//alert(record.coords);
			_addOption(record.address.display_name, (count+1));
			// ballons.addUser(record, (count+1)); 
			// Marker is not required in MAP as per the requirement...
	    }
	     //var mapViewer = new MultimapViewer( document.getElementById( 'mapviewer' ) );
	  //addEventHandlers (mapViewer);
		// ballons.loadAll(); 
		// Marker is not required in MAP as per the requirement...
    }
}

DLUsers.prototype.searchDealers = function() 
{
    with (this) 
    {
	    // If an error code has been produced, display the explanation:
	   	if (_DLError(_geoCoder)) return;
		_cleanUp();
		
	    // Loop through each record set:
	    var ballons = new DLBalloons('mapviewer');
	    for ( var count=0; count<_geoCoder.result_set.length; count++ ) 
	    {    
			var record = _geoCoder.result_set[count];
			_addOption(record.address.display_name, (count+1));
			ballons.add(record, record.address.display_name, (count+1));
	    }
	    ballons.loadAll();
	   //var mapViewer = new MultimapViewer( document.getElementById( 'mapviewer' ) );
	    //addEventHandlers (mapViewer);
	    if(_geoCoder.result_set.length == 1) 
	    {
	    	//obj.options[i].selected = true;
	    	_mulSelect.selectedIndex = 1;
	    }
	    else
	    { 
	    	_mulSelect.selectedIndex = 0;
	    }
    }
}

DLUsers.prototype.getAddress = function(pos) 
{
	var rec=null;
    with (this) 
    {
		rec = _geoCoder.result_set[pos].address;
    }
    return rec;
}

DLUsers.prototype.getUser = function(pos) 
{
	var rec=null;
    with (this) 
    {
		rec = _geoCoder.result_set[pos];
		//alert("dlusers.getuser");
		//alert(rec.coords);
    }
	//alert(rec);
    return rec;
}

DLUsers.prototype.getCity = function(city) 
{
	var crec=null;
    with (this) 
    {
		//alert("Inside Get City");
		//alert(city);
		//alert(city.indexOf(","));
		if(city.indexOf(",")==-1) {
			crec = city;
		} else {
			crec = city.substr(0,city.indexOf(",")-1);
		}
		//crec = _geoCoder.result_set[pos];
		//alert("dlusers.getuser");
		//alert(rec.address.qs);
    }
	//alert("Displaying the new value of the city");
	//alert(crec);
    return crec;
}

DLUsers.prototype.size = function(pos) 
{
	var len=null;
    with (this) 
    {
		len = _geoCoder.result_set.length;
    }
    return len;
}

DLUsers.prototype._addOption = function(txt, val)
{
	with (this) 
	{
		var opt=new Option(txt, val);
		//alert(opt);
		//alert(txt);
		//alert(val);
		//alert(_mulSelect.options.length);
		_mulSelect.options[_mulSelect.options.length]=opt;
	}
}

DLUsers.prototype._removeOptions = function() 
{
	with (this) 
	{
   		_mulSelect.options.length = 1;
   	}
}

DLUsers.prototype._cleanUp = function ()
{
	with (this) 
	{
		_removeOptions();
	}
}

DLUsers.prototype._removeAll = function(clElement)
{
	var recEle = document.getElementById(clElement);
	while (recEle.firstChild) 
	{
		recEle.removeChild(recEle.firstChild);
	}       
}

DLUsers.prototype._DLError=function(errRec) 
{

	var flag=false;
	
	
    if (errRec.error_code && errRec.error_code != 'MM_GEOCODE_MULTIPLE_MATCHES') 
    {
        //var err='We are sorry - the following error occurred: '+errRec.error_code;
		//alert(err);
		document.getElementById('diverrcodemsg').style.display = "none";
		with(this)
		{
			_removeAll('diverr');
			
		}
		with(this)
		{
			_removeAll('diverrcity');
		}
		var tblBody = document.getElementById('diverr');	    
        var row = document.createElement('tr');
		var cell = document.createElement('td');
		cell.style.backgroundColor = "#cccccc";
		cell.style.color = "RED";
		cell.setAttribute('align','left');
		cell.appendChild(document.createTextNode('Sorry we could not find any result please redefine your search criteria')); 
		row.appendChild(cell);
		tblBody.appendChild(row);
		document.getElementById('errmsgdiv').style.display = "inline";
		document.getElementById('loading').style.display = "none";
		flag=true;
    }
    return flag;
}
/*
DLUsers.prototype._doIt=function (flag) {
	with (this) {
	//alert(_arguments.length);
		for(var i=0; i<_arguments.length; i++) {
			document.getElementById(_arguments[i]).disabled = flag;     
		}
	}
}
*/

DLUsers.prototype._hide=function () 
{
	with (this) 
	{
		if(_arguments) 
		{
			for(var i=0; i<_arguments.length; i++) 
			{
				document.getElementById(_arguments[i]).disabled = true;     
			}
		}
	}
}

DLUsers.prototype._show=function () 
{
	with (this) 
	{
		if(_arguments) 
		{
			for(var i=0; i<_arguments.length; i++) 
			{
				document.getElementById(_arguments[i]).disabled = false;     
			}
		}
	}
}

