/*-----------------------------------------------------------------------
Classes JavaScript File

version: 	4.0
author:		sebastian kupke
email:		sebastian.kupke@baral.de
website:	http://www.baral.de
-----------------------------------------------------------------------*/


/* =Map
-----------------------------------------------------------------------*/
function Layer(id,layer,copyrightText,copyrightUrl) {
	this.id = id;
	this.layer = layer;
	this.copyrightText = copyrightText;
	this.copyrightUrl = copyrightUrl;
}

function Level(id,minScale,maxScale,layers,currentLayer) {
	this.id = id;
	this.minScale = minScale;
	this.maxScale = maxScale;
	this.layers = layers;
	this.currentLayer = currentLayer;
	this.getLayer = function(layerId) {
		for (i = 0; i < layers.length; i++) {
			if (layers[i].id == layerId) {
				return layers[i];
			}
		}
	};
	this.hasLayer = function(layerId) {
		for (i = 0; i < layers.length; i++) {
			if (layers[i].id == layerId) {
				return true;
			}
		}
		return false;
	}
}

function Service(id,use,type,url,key,sessionId,levels) {
	this.id = id;
	this.use = use;
	this.type = type;
	this.url = url;
	this.key = key;
	this.sessionId = sessionId;
	this.levels = levels;
	this.getLevel = function(levelId) {
		for (i = 0; i < levels.length; i++) {
			if (levels[i].id == levelId) {
				return levels[i];
			}
		}
	}
	this.getLevelInScale = function(scaleNumber) {
		for (i = 0; i < levels.length; i++) {
			if (levels[i].minScale >= scaleNumber && levels[i].maxScale <= scaleNumber) {
				return levels[i];
			}
		}
	}
}

/* =Extent
-----------------------------------------------------------------------*/
function Extent(minx,miny,maxx,maxy) {
	this.minx = minx;
	this.miny = miny;
	this.maxx = maxx;
	this.maxy = maxy;
	
	this.round = function() {
		this.minx = Math.round(minx * 1000) / 1000;
		this.miny = Math.round(miny * 1000) / 1000;
		this.maxx = Math.round(maxx * 1000) / 1000;
		this.maxy = Math.round(maxy * 1000) / 1000;
	}
}

/* =View
-----------------------------------------------------------------------*/
function View(centerX,centerY,scaleFactor) {
	this.centerX = centerX;
	this.centerY = centerY;
	this.scaleFactor = scaleFactor;
}

/* =Object
-----------------------------------------------------------------------*/
function WebsisObject(id,group,groupName,logo,url,x,y,name,tooltip,content,dsn) {
	this.id = id;
	this.group = group;
	this.groupName = groupName;
	this.logo = logo;
	this.url = url;
	this.x = x;
	this.y = y;
	this.name = name;
	this.tooltip = tooltip;
	this.content = content;
	this.dsn = dsn;
}

/* =Geometry
-----------------------------------------------------------------------*/
function Point(x,y) {
	this.x = x;
	this.y = y;
}

function Rect(lowerLeftPoint,upperRightPoint) {
	this.lowerLeftPoint = lowerLeftPoint;
	this.upperRightPoint = upperRightPoint;
}

function Polygon() {
    this.points = new Array();
    this.dragVertexes = true;
}

function Circle(center,radius) {
    this.center = center;
    this.radius = radius;
}

/* =Dsn
-----------------------------------------------------------------------*/
function Dsn(id,maxResults,zoomtoScalefactor,imgScale) {
	this.id = id;
	this.maxResults = maxResults;
	this.zoomtoScalefactor = zoomtoScalefactor;
	this.imgScale = imgScale;
}

/* =Pin
-----------------------------------------------------------------------*/
function Pin(point,img,imgWidth,imgHeight,tooltipHeader,tooltipContent) {
	this.point = point;
	this.img = img;
	this.imgWidth = imgWidth;
	this.imgHeight = imgHeight;
	this.tooltipHeader = tooltipHeader;
	this.tooltipContent = tooltipContent;
}

/* =Bordermaps
-----------------------------------------------------------------------*/
function Bordermaps(use,pixel,minScale,maxScale) {
    this.use = use;
    this.pixel = pixel;
    this.minScale = minScale;
    this.maxScale = maxScale;
}

/* =Hash
-----------------------------------------------------------------------*/
function Hash()
{
	this.length = 0;
	this.items = new Array();
	for (var i = 0; i < arguments.length; i += 2) {
		if (typeof(arguments[i + 1]) != 'undefined') {
			this.items[arguments[i]] = arguments[i + 1];
			this.length++;
		}
	}
   
	this.remove = function(in_key)
	{
		var tmp_value;
		if (typeof(this.items[in_key]) != 'undefined') {
			this.length--;
			var tmp_value = this.items[in_key];
			delete this.items[in_key];
		}
	   
		return tmp_value;
	}

	this.get = function(in_key) {
		return this.items[in_key];
	}

	this.set = function(in_key, in_value)
	{
		if (typeof(in_value) != 'undefined') {
			if (typeof(this.items[in_key]) == 'undefined') {
				this.length++;
			}

			this.items[in_key] = in_value;
		}
	   
		return in_value;
	}

	this.has = function(in_key)
	{
		return typeof(this.items[in_key]) != 'undefined';
	}
}








