/**
 * Routepoint - einzelner Routenpunkt.
 * @author Andreas Bethge
 * @copyright 2009, Andreas Bethge | it consulting
 */
function Routepoint(){
	this.id = -1;
	this.tempId = -1; // vom Client vergebene ID; wichtig, solange der RP nicht in der DB existiert
	this.title = "";
	this.description = "";	
	this.country = "";
	this.marker = null; /* GMarker */
	this.latitude = null;
	this.longitude = null;
	this.order = 65000;
	this.imageId = -1;
	this.route = -1;
	this.parent = -1;
	
	this.fromJson = function(json){
		this.id = json.id;
		this.tempId = json.tempId;
		this.title = json.title;
		this.description = json.description;
		this.latitude = 1 * json.latitude;
		this.longitude = 1 * json.longitude;
		this.country = json.country;
		this.order = 1 * json.order;
		this.marker = null;
		this.imageId = json.imageId;
		this.route = json.route;
		this.parent = json.parent;
		return this;
	}
	/*
	this.toJSON = function(){
		var ret = "";
		ret += "{id: \"" + this.id + "\", ";
		ret += "tempId: \"" + this.tempId + "\", ";
		ret += "title: \"" + this.title + "\", ";
		ret += "description: \"" + this.description + "\", ";
		ret += "latitude: \"" + this.latitude + "\", ";
		ret += "longitude: \"" + this.longitude + "\", ";
		ret += "country: \"" + this.country + "\", ";
		ret += "order: \"" + this.order + "\", ";
		ret += "imageId: \"" + this.imageId + "\"}";
		return ret;
	}	
	*/
	this.getLatitude = function(){
		var ret = null;
		if(this.marker != null){
			ret = this.marker.getLatLng().lat();
		}
		return ret;
	}
	this.getLongitude = function(){
		var ret = null;
		if(this.marker != null){
			ret = this.marker.getLatLng().lng();
		}
		return ret;
	}


	this.cloneWithoutMarker = function(){
		var ret = new Routepoint();
		ret.marker = null;
		ret.id = this.id;
		ret.tempId = this.tempId;
		ret.title = this.title;
		ret.country = this.country;
		ret.order = this.order;
		ret.description = this.description;
		ret.latitude = this.getLatitude();
		ret.longitude = this.getLongitude();
		ret.imageId = this.imageId;
		ret.route = this.route;
		ret.parent = this.parent;
		return ret;
	}
	
}
