function DLDealers(srcher)
{
	this._arguments = null;
	this._vSearcher=srcher;
	//this._viewLoc = viewLoc;
	this.hidingElements = hele;
	//this.cleanUp = cleanEle; //VIP method, but it is not in use...
}
function hele() 
{
	this._arguments=hele.arguments;
}

//VIP method, but it is not in use...
/*
function cleanEle()
{
	var _cleanElements=cleanEle.arguments;
	if(_cleanElements) 
	{
		for(var i=0; i<_cleanElements.length; i++) 
		{
			var recEle = document.getElementById(_cleanElements[i]);
			while (recEle.firstChild) 
			{
				recEle.removeChild(recEle.firstChild);
			}       
		}		
	}
}
*/
DLDealers.prototype.loadResults = function() 
{
    with (this) 
    {
	    // Results are now loaded, so re-enable form elements, and remove spinning icon:
	    _hide();
	
	    // If an error code has been produced, display the explanation:
	    if (_DLError(_vSearcher)) return;
	
	    // Loop through each record set:
	    for ( var count=0, l = _vSearcher.record_sets.length; count < l; count++ ) 
	    {    
	        // If an error was returned for the record set, display details and return:
	        if (_DLError(_vSearcher.record_sets[count].error)) return ;
	        
	        // If not, check to see if individual records have been returned
	        if ( _vSearcher.record_sets[count].records ) 
	        {
	            // Loop through each record in the record set, and add it to the list below the map, and populate the infobox text
			
  				//document.getElementById('topper1').style.display = "inline";
 				//document.getElementById('legendd').style.display ="block";
				document.getElementById('loading').style.display = "none";
				document.getElementById('loadingmulti').style.display = "none";
				document.getElementById('mapviewer').style.display ="block";
				document.getElementById('imgDiv').style.display = "none";
			
				document.getElementById('resDiv').style.display = "inline";
				document.getElementById('headerlogo').style.display = "inline";

				document.getElementById('legend').style.display ="inline";
			
					            
	            //viewRecord(_vSearcher.record_sets[count].records);
	            viewRecord(_vSearcher.record_sets[count]);
	        }
	        else 
	        {		// document.getElementById('topper1').style.display = "inline";
			
			var textnode;
			with(this)
		{
			_removeAll('diverrcity');
		}
				document.getElementById('diverrcodemsg').style.display = "none";
				document.getElementById('resDiv').style.display = "none";
				document.getElementById('loading').style.display = "none";
				document.getElementById('loadingmulti').style.display = "none";	
				document.getElementById('diverrcode').style.display = "none";			
				//alert('No results returned.');
				var tblBody = document.getElementById('diverrcity');	    
                var row = document.createElement('tr');
		    	var cell = document.createElement('td');
				cell.style.backgroundColor = "#cccccc";
				cell.style.color = "RED";
				cell.setAttribute('align','left');
                 if(document.getElementById('txtCity').value!='')
				{
					 textnode=document.createTextNode('Sorry, we could not find any dealers in  city '+ document.getElementById('txtCity').value+ ' Within a distance of '+document.getElementById('maxDist').value+' Km Please redefine your search criteria' );
					cell.appendChild(textnode);
				}
				 if(document.getElementById('txtStreet').value!='')
				{
					 textnode=document.createTextNode('Sorry, we could not find any dealers in  Street '+ document.getElementById('txtStreet').value+ ' Within a distance of '+document.getElementById('maxDist').value+' Km Please redefine your search criteria' );
					cell.appendChild(textnode);
				} 
				if(document.getElementById('txtPC').value!='')
				{
					 textnode=document.createTextNode('Sorry, we could not find any dealers with postal code '+ document.getElementById('txtPC').value+ ' Within a distance of '+document.getElementById('maxDist').value+' Km Please redefine your search criteria' );
					cell.appendChild(textnode);
				}
				row.appendChild(cell);
				tblBody.appendChild(row);
				//document.getElementById('errmsgdiv1').style.display = "inline";
				//document.getElementById('diverrcodemsg').style.display = "inline";
					
				document.getElementById('mapviewer').style.display = "none";
				document.getElementById('legend').style.display = "none";
		 		document.getElementById('imgDiv').style.display = "inline";

				
	        }    
	    } 
		_show();
	}
}
DLDealers.prototype._removeAll = function(clElement)
{
	var recEle = document.getElementById(clElement);
	while (recEle.firstChild) 
	{
		recEle.removeChild(recEle.firstChild);
	}       
}
/*
DLDealers.prototype.cleanUp = function ()  
{
	with (this) 
	{
		//var record_list = document.getElementById(_viewLoc);
		//while (record_list.firstChild) 
		//{
		//	record_list.removeChild(record_list.firstChild);
		//}       
	}
}
*/

DLDealers.prototype._DLError=function(errRec) 
{
	var flag=false;
    document.getElementById('loadingmulti').style.display = "none";	
	document.getElementById('diverrcodemsg').style.display = "none";
	
    if (errRec && errRec.error_code) 
    {
        var err='';
        
        if (errRec.error_explanation) 
        {
            err=errRec.error_explanation;
      	}
        else 
        {
        with(this)
		{
			_removeAll('diverrcode');
		}
            //err='Your request failed. Error code: '+errRec.error_code;
           //document.getElementById('loadingmulti').style.display = "none";
           // document.getElementById('diverrcodemsg').style.display = "none";
            
				//alert('No results returned.');
				var tblBody = document.getElementById('diverrcode');	    
                var row = document.createElement('tr');
		    	var cell = document.createElement('td');
				cell.style.backgroundColor = "#cccccc";
				cell.style.color = "RED";
				cell.setAttribute('align','left');
				textnode=document.createTextNode('Sorry, we could not find requested address please change search criteria.' );
				cell.appendChild(textnode);
				row.appendChild(cell);
				tblBody.appendChild(row);
				
				document.getElementById('diverrcodemsg').style.display = "block";
					
				document.getElementById('mapviewer').style.display = "none";
				document.getElementById('legend').style.display = "none";
		 document.getElementById('loading').style.display = "none";
				document.getElementById('imgDiv').style.display = "inline";			
		}
		//alert(err);
		flag=true;
    }
    return flag;
}
/*
DLDealers.prototype._doIt=function (flag) {
	with (this) {
	alert(_arguments.length);
		for(var i=0; i<_arguments.length; i++) {
			document.getElementById(_arguments[i]).disabled = flag;     
		}
	}
}
*/

DLDealers.prototype._hide=function () 
{
	with (this) 
	{
		if(_arguments) 
		{
			for(var i=0; i<_arguments.length; i++) 
			{
				document.getElementById(_arguments[i]).disabled = true;     
			}
		}
	}
}

DLDealers.prototype._show=function () 
{
	with (this) 
	{
		if(_arguments) 
		{
			for(var i=0; i<_arguments.length; i++) 
			{
				document.getElementById(_arguments[i]).disabled = false;     
			}
		}
	}
}

/*
DLDealers.prototype.targetUser = function(userRec) 
{
	this._userRec=userRec;
}    
*/
