/* Identifier Constructor */
function MapIdentifier(contextPath) {
	this.layerName = null;
	this.setLayerName = setLayerName;
	this.getLayerName = getLayerName;
	this.identify = identify;
	this.createParameter = createParameter;
    this.contextPath = contextPath;
    this.getFeatureProperty = getFeatureProperty;
    
	function setLayerName(name) {
		layerName = name;
	}

	function getLayerName() {
		return layerName;
	}

	function getFeatureProperty() {
		var layer = getLayerName();
		if (layer && layer != "") {
			var mapFunction = new MapFunction(layer);
			var prop = mapFunction.findInDinoIdentify("property");
			if (prop) return prop;
		}
		return "NOPROPERTY";
	}
	
	function identify(identifiers) {
		var layer = getLayerName();
		if (layer && layer != "") {
			var mapFunction = new MapFunction(layer);
			
			var url = mapFunction.findInDinoIdentify("url");
			var form = document.createElement('form');
			document.body.appendChild(form);
			
			form.setAttribute("method", "post");
            form.setAttribute("action", this.contextPath + url);
            form.setAttribute("target", "_blank");
            var hField = createParameter("id", "" + identifiers);
			form.appendChild(hField);
			
			form.submit();
			
			//url = url + "&id=" + identifiers;
			//window.open(url, "DinoMap Identification", "");			
		} else {
			alert("MapIdentifier has identified: " + identifiers);
		}
	}

	/*Creates a parameter for a post request as hidden input field*/
	function createParameter(name, value){
		var hField = document.createElement("INPUT");
		hField.type = "hidden";
		hField.name = name;
		hField.value = value;
		return hField;
	}
}

