// JavaScript Document


function IValueRenderer()
{
	this.name = "Unknown";
	this.map;
	this.visible = false;
	this.axl = '';
	this.layerId
	this.lookupfield;
	this.type;
	this.AddRange = AddRange;
	this.AddExact = AddExact;
	this.AddSimpleSymbol = AddSimpleSymbol;
	this.ranges = new Array();
	this.exacts = new Array();
	this.simpleSymbols = new Array();
	this.rangeCount = 0
	this.changeRenderer = changeRenderer;
	
	this.render = render;
	
}


function render()
{
	
	var xml ='';
	
	this.type = getLayerShapeType(this.layerId)
	
		
	if (this.ranges.length > 0)
	{
		xml +='<VALUEMAPRENDERER lookupfield="'+this.lookupfield+'">\n'
	for (var i in this.ranges)
		{
			xml += '<RANGE lower="'+this.ranges[i].lower+'" upper="'+this.ranges[i].upper+'" label="'+this.ranges[i].label+'">\n'
			
			if (this.type == "point")
			{
				xml += '<SIMPLEMARKERSYMBOL transparency="'+this.ranges[i].transparency+'" usecentroid="true" color="'+this.ranges[i].fillColor+'" width="12" /> '
			}
			if (this.type =="line")
			{
				xml +='  <SIMPLELINESYMBOL transparency="'+this.ranges[i].transparency+'" type="solid" width="1" captype="round" jointype="round" color="'+this.ranges[i].fillColor+'" />';
			}
			if (this.type =="polygon")
			{
				xml += '<SIMPLEPOLYGONSYMBOL boundary="'+this.ranges[i].boundary+'"  filltransparency="'+this.ranges[i].transparency+'" fillinterval="6"  fillcolor="'+this.ranges[i].fillColor+'" filltype="'+this.ranges[i].fillType+'" boundarytype="'+this.ranges[i].boundaryType+'" boundarywidth="'+this.ranges[i].boundaryWidth+'" boundarycolor="'+this.ranges[i].boundaryColor+'" />\n'	
			}
			xml += '</RANGE>\n'
		}
		xml += '</VALUEMAPRENDERER>\n'
	}
	
	
	if (this.exacts.length > 0)
	{
		xml +='<VALUEMAPRENDERER lookupfield="'+this.lookupfield+'">\n'
		for (var i in this.exacts)
		{
			xml += '<EXACT value="'+this.exacts[i].value+'" label="'+this.exacts[i].label+'">\n'
			
			if (this.type =="point")
			{
				xml += ' <SIMPLEMARKERSYMBOL transparency="'+this.exacts[i].transparency+'" usecentroid="true" color="'+this.exacts[i].fillColor+'" width="12" /> '
			}			
			if (this.type =="line")
			{
				xml +=' <SIMPLELINESYMBOL transparency="'+this.exacts[i].transparency+'" type="solid" width="1" captype="round" jointype="round" color="'+this.exacts[i].fillColor+'" />';
			}
			if (this.type =="polygon")
			{
				xml += '<SIMPLEPOLYGONSYMBOL boundary="'+this.exacts[i].boundary+'" filltransparency="'+this.exacts[i].transparency+'"  fillinterval="6"  fillcolor="'+this.exacts[i].fillColor+'" filltype="'+this.exacts[i].fillType+'" boundarytype="'+this.exacts[i].boundaryType+'" boundarywidth="'+this.exacts[i].boundaryWidth+'" boundarycolor="'+this.exacts[i].boundaryColor+'" />\n'	
			}
			
			xml += '</EXACT>\n'
		}
		xml += '</VALUEMAPRENDERER>\n'
	}
	
	if (this.simpleSymbols.length > 0)
	{
		for (var i in this.simpleSymbols)
		{
			xml+='<SIMPLERENDERER>'
			if (this.type =="point")
			{
				xml += ' <SIMPLEMARKERSYMBOL transparency="'+this.simpleSymbols[i].transparency+'" usecentroid="true" color="'+this.simpleSymbols[i].fillColor+'" width="12" /> '
			}			
			if (this.type =="line")
			{
				xml +=' <SIMPLELINESYMBOL transparency="'+this.simpleSymbols[i].transparency+'" type="solid" width="1" captype="round" jointype="round" color="'+this.simpleSymbols[i].fillColor+'" />';
			}
			if (this.type =="polygon")
			{
				xml += '<SIMPLEPOLYGONSYMBOL boundary="'+this.simpleSymbols[i].boundary+'" filltransparency="'+this.simpleSymbols[i].transparency+'"  fillinterval="6"  fillcolor="'+this.simpleSymbols[i].fillColor+'" filltype="'+this.simpleSymbols[i].fillType+'" boundarytype="'+this.simpleSymbols[i].boundaryType+'" boundarywidth="'+this.simpleSymbols[i].boundaryWidth+'" boundarycolor="'+this.simpleSymbols[i].boundaryColor+'" />\n'
			}
			xml+='</SIMPLERENDERER>'
		}
	}	
	
	

	
	this.axl += xml;

	this.map.addRenderer(this)

}



function changeRenderer(id)
{
	this.visible = true;
	
	// How large should the lenged be in height
	 //var height = this.ranges.length -1;
	var layerIndex = findLayerIndex(id)
	RESPONSE.LAYER[layerIndex].visible = "true";
	this.map.getMap();
}




function IExact()
{
	this.value;
	this.label;
	this.fillColor;
	this.transparency = 1;
	
	
	this.boundary = true;
	this.fillType = "solid";
	this.boundaryType = "solid";
	this.boundaryWidth = "1";
	this.boundaryColor = "0,0,0";
}
function AddExact(exact) {	this.exacts.push(exact);	}
	
function IRange()
{
	this.lower; 
	this.upper;
	this.label;
	this.fillColor;
	this.transparency =1;
	
	this.boundary = true;
	this.fillType = "solid";
	this.boundaryType = "solid";
	this.boundaryWidth = "1";
	this.boundaryColor = "0,0,0";
}
function AddRange(range){ this.ranges.push(range); }

	




function ISimpleSymbol()
{	
	this.fillColor = "255,22,22";
	this.transparency = 1;
	
	this.boundary = true;
	this.fillType = "solid";
	this.boundaryType = "solid";
	this.boundaryWidth = "1";
	this.boundaryColor = "0,0,0";

}
function AddSimpleSymbol(simpleSymbol){ this.simpleSymbols.push(simpleSymbol); }



function getLayerShapeType(layerId)
{
	for (i  in RESPONSE.LAYER)
	{
		if (RESPONSE.LAYER[i].id == layerId)
		{
			return RESPONSE.LAYER[i].FCLASS.type;	
		}
	}
}

	
