function map24(sid, mid)
{
	this.sid = sid;
	this.mid = mid;
	this.id = "map24_"+sid;
	this.name = this.id;
	this.system = "maptp15.map24.com";
	this.lang = "nl-NL";
	this.agentID = "map24/webservices1.5/map24agent";
	this.skin = "map24portal_2006";
	this.pprop = "map24portal_2006/NT_EUROPE/NT";
	this.psym = "map24portal_2006/nt_EUROPE/symNT";
	this.codebase = "http://"+this.system+"/MAP24_v3.7.03_20070612";
	this.archive = this.codebase+"/map24portal_2006_NT_EUROPE_en-GB.zip";
	this.code = "com.mapsolute.map24.Map24.class";
	this.basemap = "NT_EUROPE";
}

map24.prototype.setMap = function( width, height, dest, callback )
{
	this.width = width;
	this.height = height;
	
	if(isset(dest))
	{
		dest.innerHTML = "De kaart wordt geladen.";
		
		//Via ajax api
		var mapcopy = this;
		Map24.loadApi( ["core_api", "wrapper_api"] , function()
				{
					dest.style.height = mapcopy.height+'px';
					dest.style.width = mapcopy.width+'px';
					
				    Map24.MapApplication.setStartMapView( { 
				      UpperLeftLongitude: 263.8849223326349,
				      UpperLeftLatitude: 3110.007130929225,
				      LowerRightLongitude: 274.8849223326349,
				      LowerRightLatitude: 3118.007130929225
				    } );
					
					Map24.MapApplication.init( { NodeName: dest.id, SessionId: mapcopy.sid } );
										
					removeAllMapObjects();
					if(isset(callback))
					{
						callback();
					}
					
				}
		);
		return Map24;
	}
	else
	{
		alert("destination doesn't exist!");
	}
}




function removeAllMapObjects() {	
	//Get Ids of All MapObjects on the Map
	var MapObjects = Map24.MapApplication.Map.Session.MapObjects;
	var objIds = [];
	for (var o in MapObjects) {
		var MapObject = MapObjects[o];
		objIds.push(MapObject.Command.MapObjectID);
	}
	//Generate removing command
	var cmd = new Map24.WebServices.XMLCommandWrapper({
		RemoveMapObject: new Map24.WebServices.RemoveMapObject({
			MapObjectIDs: objIds
		})
	});
	//Establish connection to the Webservices and execute the command
	conn = Map24.MapApplication.Map.WebServices.openConnection();
	conn.mapletRemoteControl( 
		new Map24.WebServices.Message.mapletRemoteControlRequest({
			MapletRemoteControlRequest: new Map24.WebServices.MapletRemoteControlRequest({
				Map24MRC: new Map24.WebServices.Map24MRC({
					Commands: [cmd]
				})
			})
		})
	);
}

function isset(a)
{
	var bReturn = (typeof(a) != 'undefined');
	if(bReturn)
	{
		bReturn = (a != null);
	}

	return bReturn; 
}