function DLBalloons(mapID)
{
	this._mapViewer = new MultimapViewer(document.getElementById(mapID));
		
	this._cleanUp();
	
	//this._blnMarkers = new Array();
	
}

DLBalloons.prototype.addTargetUser = function(rec, txt) 
{
	with (this) 
	{
		var dispText = rec.address.display_name;
		var headText = '<h1>User location ' + '<' + '/h1><p>' + dispText + '<' + '/p>';
		_addDOIT(rec, headText, dispText, txt);
		
	}
}

DLBalloons.prototype.addUser = function(rec, num) 
{
	with (this) 
	{
		var dispText = rec.address.display_name;
		var headText = '<h1>User location #' + num + '<' + '/h1><p>' + dispText + '<' + '/p>';
		_addDOIT(rec, headText, dispText, num);
		
	}
}

DLBalloons.prototype._addDOIT = function(location, tabs, tooltipTxt, shortTxt) 
{
	with (this) 
	{
					
        var icon = new MMIcon( '/DealerLocator/images/Images_New_Set/After_Work/icon_target/target_red_30_30.gif' );
        icon.iconSize = new MMDimensions( 32, 32 );
        icon.iconAnchor = new MMPoint( 16, 16 );
		var shortTxt ='<B><font size="1" color="black" align="center">' + shortTxt +'</font></B>';
		var marker = _mapViewer.createMarker(location, { 'label' : tooltipTxt, 'text' : shortTxt,'icon' : icon });
		
		marker.setInfoBoxContent(tabs);  //add an infobox for each result
		_blnMarkers.push(marker);
		
			
	}	
	//marker.openInfoBox () ; 
}
DLBalloons.prototype.addDealer = function(record, num,sTel,sEmail,sAddress,sDealerinfo,sImage,sManager,sWebsite,s24Phn)
{	
       var cid=record.client_id;
       var dkm=record.distance.km;
       var clat=record.point.lat;
       var clon=record.point.lon;
	   var manager,website,phone,image;
	   var rurl=record.url;
	   var toolTip = ''+record.name +', ' + record.street +', ' + record.town +', ' + record.pc;
	   var rpoint=record.point;
	   var tabs;
		var  markerInfo;var markerImage;
	with (this)
	{
	  // var headText = '<h1>Dealer #' + num + '<' + '/h1><p>' + markerText + '<' + '/p>';
	    var markerText ='<B><font size="1" color="blue"><a href="#" onClick="callForDLInfo('+cid+', '+dkm+','+clat+','+clon+')">'+record.name +'</a></font></B><BR>' + record.street +', ' + record.town +', ' + record.pc+'<BR>'+sTel+' : '+record.telephone+'<BR>'+sEmail+' : '+record.email ;
	   
		 DealerBean.getDWRDealerInfo(cid,
		{ 	
			callback:function(str) { 
				website = str[0];
				manager = str[1];
				image = str[2];
				phone = str[3];
				
				var hourlist=str[4];
				if(phone!=null&&phone!="NULL")
					phone =phone;
				else phone='';
				if(manager!=null&&manager!="NULL")
					manager =manager;
				else  manager='';
				if(website!=null&&website!="NULL")
					website =website;
				else website='';
				if(image!=null&&image!="NULL")
					image =image;
				else image='noImage_small_70.gif';
				//markerInfo = '<B><a href="#">'+rurl+'</a></B><BR>' + manager +', ' + image+'<BR>24 phone : '+phone;
				markerInfo = '<B>'+sWebsite+ ':<a href='+website+'>'+website+'</a></B><BR>'+sManager+ ': ' +manager +'<BR>'+s24Phn+': '+phone;
				markerImage = '<B><a href="javascript:funEnlarger(\''+image+'\')" ><img name="normalImage" id="normalImage" src="/DealerLocator/images/'+image+'" alt="Dealer image" width="70" height="70"></a><br>';
				
				var markerHour='<BR><B>Opening Times:</B><BR><table>';
				
				if(hourlist!=null && hourlist.length>0){
					for(var loop=0;loop<hourlist.length;loop++){
						markerHour+='<tr><td>'+hourlist[loop]+'</td></tr>'
					}
				}
				markerHour+='</table>'
				//alert(markerHour);
				tabs = [
					new MMInfoBoxTab( sAddress, '<font size="2" color="black">'+markerText+'<' + '/font>' ),
					new MMInfoBoxTab( sDealerinfo, '<font size="2" color="black">'+markerInfo+'<' + '/font><br>' ),
					new MMInfoBoxTab( sImage, '<h1>'+markerImage+'<' + '/h1>'),
					];
				_addDOIT(rpoint, tabs, toolTip, num);
				loadAll();
				
			}
		});
		
	 
		
	}
	
}

DLBalloons.prototype.loadAll = function() 
{
	with (this) 
	{   	
	   	var location = _mapViewer.getAutoScaleLocation(_blnMarkers);

	   	_mapViewer.goToPosition(location);
		addPanZoomWidget(false,_mapViewer);
		addMMMapTypeWidget(false,_mapViewer);
		//addEventHandlers (_mapViewer);
	}
	
}

DLBalloons.prototype._cleanUp = function ()  
{
	with (this) 
	{
		_mapViewer.removeAllOverlays();
		_blnMarkers = new Array();
	}
}

DLBalloons.prototype.getTab2 = function (clientid)  
{	info=null;
	with (this) 
	{
	//	alert('Inside getTab2');
   
	}

}

DLBalloons.prototype.loadDetails = function (data)  
{
	with (this) 
	{
	//alert('Inside loadDetails');
	
	}
}

