/**
 * 
 * @param locationid
 * @param name
 * @param numPOI
 * @param numPub
 * @param numRestaurant
 * @param numShop
 * @param numStreet
 * @param latMarker
 * @param lonMarker
 * @param latlonlist
 * @param polygoncolor
 * @param polylinecolor
 * @return
 */
function CBPolyItem(locationid, countrycode, names, nelatitude, nelongitude, swlatitude, swlongitude, numPOI, numPub, numRestaurant, numShop, numStreet, latlonlist, latmarker, lonmarker, polygoncolor, polylinecolor) {

	
	this.id = locationid;
	this.countrycode = countrycode;
	//countains an assoziative array with translations for given countrycodes
	this.names = JSON.parse(names);	
	this.numPOI = numPOI;
	this.numPub = numPub;
	this.numRestaurant = numRestaurant;
	this.numShop = numShop;
	this.numStreet = numStreet;
	this.latlonlist = latlonlist;
	this.latmarker = latmarker;
	this.lonmarker = lonmarker;
	this.polygonColor = polygoncolor;
	this.polylineColor = polylinecolor;
    this.sw = new CM.LatLng(swlatitude, swlongitude);
    this.ne = new CM.LatLng(nelatitude, nelongitude);
    this.bounds = new CM.LatLngBounds(this.sw, this.ne);
	
	this.getID = function() {
		return this.id;
	};
	
	this.getCountryCode = function() {
		return this.countrycode;
	};
	
	this.getBounds = function() {
		return this.bounds;
	};
	
	this.getName = function() {
		/**
		 * Try to get the translation for the 
		 * language selected on the webpage. Otherwise
		 * return the name given for the defaultlanguage.
		 * If this does not work either, get the name
		 * given in the native language if the country.
		 */
		if(this.names[lang]) return this.names[lang];
		if(this.names[defaultlang]) return this.names[defaultlang];
		if(this.names[this.countrycode]) return this.names[this.countrycode];
		
		//e.g. US_NY
		if(this.names[this.countrycode.substr(0,2)]) return this.names[this.countrycode.substr(0,2)];
	};
	
	
	this.getPolygon = function() {
		return this.polygon;
	};
	
	this.getPolyline = function() {
		return this.polyline;
	};
	
	this.getMarker = function() {
		return this.marker;
	};
	
	this.getnumPOI = function() {
		return this.numPOI;
	};
	
	this.getnumRestaurant = function() {
		return this.numRestaurant;
	};
	
	this.getnumPub = function() {
		return this.numPub;
	};
	
	this.getnumShop = function() {
		return this.numShop;
	};
	
	this.getnumStreet = function() {
		return this.numStreet;
	};
	
	
	this.setPolygonColor = function(color) {
		this.polygonColor = color;
	};
		
	this.setPolylineColor = function(color) {
		this.polylineColor = color;
	};
	
	
	
	/* 
	 * create a permanent marker/polygon/polyline object. it need to be permanent in
	 * order to remove it from the map via a pointer given to map.removeOverlay
	 */
	
	this.polygon = new CM.Polygon(this.latlonlist, this.polygonColor);
	
	/*
		this.polyline = new CM.Polyline(this.latlonlist, this.polylineColor);
	var markerLatLng = new CM.LatLng(this.latmarker, this.lonmarker);
	this.marker = new CM.Marker(markerLatLng, { title: this.getName()});
	
	CM.Event.addListener(this.marker, 'click', function() {
		alert(this.getTitle());
	});
	*/
	

}
