function selectColor(controlName,color) {
	var control=Control.controls[controlName];
	if(control)
		control.selectColor(color);
}

function colorTableToggle(controlName) {
	var control=Control.controls[controlName];
	if(control)
		control.colorTableToggle();
}

function rgbDialogToggle(controlName) {
	var control=Control.controls[controlName];
	if(control)
		control.rgbDialogToggle();
}

function rgbDialogApply(controlName) {
	var control=Control.controls[controlName];
	if(control)
		control.rgbDialogApply();
}

function controlClicked(controlName) {
	var control=Control.controls[controlName];
	if(control)
		control.clicked();
}

function Control_initControl(name,renderer,endHandler) {
	this.name=name;
	this.renderer=renderer;
	this.endHandler=endHandler;
	Control.controls[this.name+this.type+'Control']=this;
}

function Control() {
}

Control.controls=new Array();

function VisibilityControl_setProperty(property,value) {
	if(document.getElementById(this.name+this.type+'Control'))
		document.getElementById(this.name+this.type+'Control').checked=value;
}

function VisibilityControl_draw(container) {
	
	var checked='';
	
	if(this.renderer.getProperty('visibility'))
		checked='checked';
	document.getElementById(container).innerHTML='<input type="checkbox" id="'+this.name+'VisibilityControl" '+checked+' onClick="controlClicked(\''+this.name+'VisibilityControl\')"/>';
}

function VisibilityControl_clicked() {
	this.renderer.setProperty('visibility',document.getElementById(this.name+'VisibilityControl').checked);
	if(this.endHandler)
		eval(this.endHandler+'()');
}

function VisibilityControl(name,renderer,endHandler) {
	this.type='Visibility';
	this.initControl(name,renderer,endHandler);
}

VisibilityControl.prototype.initControl=Control_initControl;
VisibilityControl.prototype.draw=VisibilityControl_draw;
VisibilityControl.prototype.setProperty=VisibilityControl_setProperty;
VisibilityControl.prototype.clicked=VisibilityControl_clicked;

function OpacityControl_setProperty(property,value) {
	if(document.getElementById(this.name+this.type+'Control'))
		document.getElementById(this.name+this.type+'Control').checked=value;
}

function OpacityControl_draw(container) {
	this.container=container;
	var opacity=parseInt(this.renderer.getProperty('opacity'));
	this.slider.valueDefault  = opacity;
	document.getElementById(this.container).control=this;
	this.slider.draw(this.container);
}

function OpacityControl_changed(value) {
	this.renderer.setProperty('opacity',parseInt(value));
	if(this.endHandler)
		eval(this.endHandler+'()');
}

function opacitySliderChange(slider,newValue) {
	var control=document.getElementById(slider).control;
	control.changed(newValue);
	//doCommand('opacityChange',newValue);
}

function OpacityControl(name,renderer,endHandler,containerDiv) {
	this.type='Opacity';
	this.container=null;
	this.initControl(name,renderer,endHandler);

	var mySlider = new Slider(containerDiv);
	mySlider.attachOnSlideMove(opacitySliderChange);
	mySlider.width         = 30;
	mySlider.height        = 15;
	mySlider.minVal        = 0;
	mySlider.maxVal        = 100;
	mySlider.valueDefault  = 100;
	mySlider.setBackgroundImage('sliderBack.gif');
	mySlider.setSliderIcon('slider.gif', 7, 15);
	this.slider=mySlider;
}

OpacityControl.prototype.initControl=Control_initControl;
OpacityControl.prototype.draw=OpacityControl_draw;
OpacityControl.prototype.setProperty=OpacityControl_setProperty;
OpacityControl.prototype.changed=OpacityControl_changed;

function TooltipControl_setProperty(property,value) {
	if(document.getElementById(this.name+this.type+'Control'))
		document.getElementById(this.name+this.type+'Control').checked=value;
}

function TooltipControl_draw(container) {
	var checked='';
	
	if(mapInfo.getProperty('tooltipMode')!='smart' && mapInfo.getProperty('tooltipFeature')==this.feature)
		checked='checked';
	
	document.getElementById(container).innerHTML='<input type="radio" id="'+this.name+'TooltipControl" '+checked+' onClick="controlClicked(\''+this.name+'TooltipControl\')"/>';
}

function TooltipControl_clicked() {
	if(mapInfo.getProperty('tooltipMode')=='smart' || mapInfo.getProperty('tooltipFeature')!=this.feature) {
		mapInfo.setProperty('tooltipMode','single');
		mapInfo.setProperty('tooltipFeature',this.feature);
	} else {
		mapInfo.setProperty('tooltipMode','smart');
		mapInfo.setProperty('tooltipFeature',null);
	}

	redrawLegend();
	if(this.endHandler)
		eval(this.endHandler+'()');
}

function TooltipControl(name,renderer,endHandler,feature) {
	this.feature=feature;
	this.type='Tooltip';
	this.initControl(name,renderer,endHandler);
}

TooltipControl.prototype.initControl=Control_initControl;
TooltipControl.prototype.draw=TooltipControl_draw;
TooltipControl.prototype.setProperty=TooltipControl_setProperty;
TooltipControl.prototype.clicked=TooltipControl_clicked;

function ColorControl_setProperty(property,value) {
	//NOTHING TO DO
}

function ColorControl_draw(container) {
	
	this.container=container;
	
	var i=0;
	var col='';
	var r=0;
	var g=0;
	var b=0;
	for(r=0;r<256;r+=85)
		for(g=0;g<256;g+=85)
			for(b=0;b<256;b=b+85)
			{
				col=DecToHex(r,g,b)
				if (i<16)
				{
					this.colorsTableRow1[i]=col;
				}
				if (i>15 && i<32)
				{
					this.colorsTableRow2[i-16]=col;
				}
				if (i>31 && i<48)
				{
					this.colorsTableRow3[i-32]=col;
				}
				if (i>47)
				{
					this.colorsTableRow4[i-48]=col;
				}
				i++;
			}

	var html='';
	html   +='<table width=" style="cursor:hand" onClick="colorTableToggle(\''+this.name+'ColorControl\')" cellspacing="1" bgcolor="white" cellpadding="1" style="border:black solid 1px"><tr><td id="currentColor'+this.name+'" style="background-color:black" width="15" height="15">&nbsp;</td><td><img style="cursor:hand" src="immagini/combofreccia.gif" width="11" height="15"/></td></tr></table>';
	html   +='<div id="colorTablePosDiv'+this.name+'" style="position:relative;left:0px;top:0px;width:1px;height:1px"><img src="immagini/spacer.gif"/ width="1" height="1"></div>';
	html   +='<div id="colorTableDiv'+this.name+'" style="position:absolute;left:0px;top:0px;visibility:hidden;z-index:10000">';
	html   +='<table width="150"><tr><td>';
	html   +='<table id="colorTable'+this.name+'" style="border:black solid 1px" cellspacing="0" cellpadding="0" bgcolor="white">';
	html   +='<tr>';
	for(var pos in this.colorsTableRow1) {
		var color=this.colorsTableRow1[pos];
		html   +='<td id="colorCell'+this.name+pos+'" onclick="selectColor(\''+this.name+'ColorControl\',this.style.backgroundColor)" style="cursor:hand;background-color: '+color+'" width="15" height="15">&nbsp;</td>';
	}
	html   +='<td></td>';
	html   +='</tr><tr>';
	for(var pos in this.colorsTableRow2) {
		var color=this.colorsTableRow2[pos];
		html   +='<td id="colorCell'+this.name+(pos+this.colorsTableRow1.length)+'" onclick="selectColor(\''+this.name+'ColorControl\',this.style.backgroundColor)" style="cursor:hand;background-color: '+color+'" width="15" height="15">&nbsp;</td>';
	}
	html   +='<td></td>';
	html   +='</tr><tr>';
	for(var pos in this.colorsTableRow3) {
		var color=this.colorsTableRow3[pos];
		html   +='<td id="colorCell'+this.name+(pos+this.colorsTableRow1.length+this.colorsTableRow2.length)+'" onclick="selectColor(\''+this.name+'ColorControl\',this.style.backgroundColor)" style="cursor:hand;background-color: '+color+'" width="15" height="15">&nbsp;</td>';
	}
	html   +='<td></td>';
	html   +='</tr><tr>';
	for(var pos in this.colorsTableRow4) {
		var color=this.colorsTableRow4[pos];
		html   +='<td id="colorCell'+this.name+(pos+this.colorsTableRow1.length+this.colorsTableRow2.length+this.colorsTableRow3.length)+'" onclick="selectColor(\''+this.name+'ColorControl\',this.style.backgroundColor)" style="cursor:hand;background-color: '+color+'" width="15" height="15">&nbsp;</td>';
	}
	html   +='<td id="rgbButtonCell" onclick="rgbDialogToggle(\''+this.name+'ColorControl\',this.style.backgroundColor)" style="cursor:hand;background-color: '+color+'" width="15" height="15">>></td>';
	html   +='</tr>';
	html   +='</table>';
	html   +='</td>';
	html   +='<td valign="bottom">';
	html   +='  <div id="rgbDialogDiv'+this.name+'" style="visibility:hidden"> ';
	html   +='      <div align="left"><table cellspacing="1" bgcolor="white" cellpadding="1" style="border:black solid 1px">';
	html   +='      <tr><td>Red</td><td><input type="text" id="rgbred'+this.name+'" size="4"/></td><td></td></tr>';
	html   +='      <tr><td>Green</td><td><input type="text" id="rgbgreen'+this.name+'" size="4"/></td><td></td></tr>';
	html   +='      <tr><td>Blue</td><td><input type="text" id="rgbblue'+this.name+'" size="4"/></td><td><input type="button" id="rgbsubmit" value="Apply" onclick="rgbDialogApply(\''+this.name+'ColorControl\',this.style.backgroundColor)"/></td></tr>';
	html   +='      </table></div>';
	html   +='  </div>';
	html   +='</td></tr></table>';
	html   +='</div>';


	document.getElementById(this.container).innerHTML=html;
	var actualColor=this.renderer.getProperty(this.propertyName).replace('#','');
	document.getElementById('currentColor'+this.name).style.backgroundColor=actualColor;
}

function ColorControl_selectColor(color) {
	this.renderer.setProperty(this.propertyName,color);
	document.getElementById('currentColor'+this.name).style.backgroundColor=color;
	this.colorTableToggle();
	if(this.endHandler)
		eval(this.endHandler+'()');
}

function ColorControl_rgbDialogToggle() {

	var actualColor=this.renderer.getProperty(this.propertyName).replace('#','');
	var red=HexToDecRed(actualColor);
	var green=HexToDecGreen(actualColor);
	var blue=HexToDecBlue(actualColor);

	document.getElementById('rgbred'+this.name).value=red;
	document.getElementById('rgbgreen'+this.name).value=green;
	document.getElementById('rgbblue'+this.name).value=blue;
	
	if (document.getElementById('rgbDialogDiv'+this.name).style.visibility=='hidden')
		document.getElementById('rgbDialogDiv'+this.name).style.visibility='visible';
	else
		document.getElementById('rgbDialogDiv'+this.name).style.visibility='hidden';
}

function ColorControl_rgbDialogApply() {
	var red=0;
	var green=0;
	var blue=0;
	var color='';

	red=document.getElementById('rgbred'+this.name).value;
	green=document.getElementById('rgbgreen'+this.name).value;
	blue=document.getElementById('rgbblue'+this.name).value;
	color=DecToHex(red,green,blue);
	this.selectColor(color);
}


function ColorControl_colorTableToggle() {
	var refDiv=document.getElementById('colorTablePosDiv'+this.name);
	var div=document.getElementById('colorTableDiv'+this.name);
	div.style.pixelLeft=refDiv.offsetLeft-3-this.position;
	div.style.pixelTop=refDiv.offsetTop-10;

	if(document.getElementById('colorTableDiv'+this.name).style.visibility=='hidden')
	{
		document.getElementById('colorTableDiv'+this.name).style.visibility='visible';

		var currentColor=this.renderer.getProperty(this.propertyName);
//		alert(currentColor);
		for(var pos in this.colorsTableRow1) {
			var color=this.colorsTableRow1[pos];
			var colorCell=document.getElementById('colorCell'+this.name+pos);
			
			if(color.toLowerCase()==currentColor.toLowerCase())
				colorCell.style.border='#404040 solid 2px';
			else
				colorCell.style.border='white solid 2px';
		}
		
		for(var pos in this.colorsTableRow2) {
			var color=this.colorsTableRow2[pos];
			var colorCell=document.getElementById('colorCell'+this.name+(pos+this.colorsTableRow1.length));
			
			if(color.toLowerCase()==currentColor.toLowerCase())
				colorCell.style.border='#404040 solid 2px';
			else
				colorCell.style.border='white solid 2px';
		}	

		for(var pos in this.colorsTableRow3) {
			var color=this.colorsTableRow3[pos];
			var colorCell=document.getElementById('colorCell'+this.name+(pos+this.colorsTableRow1.length+this.colorsTableRow2.length));
			
			if(color.toLowerCase()==currentColor.toLowerCase())
				colorCell.style.border='#404040 solid 2px';
			else
				colorCell.style.border='white solid 2px';
		}

		for(var pos in this.colorsTableRow4) {
			var color=this.colorsTableRow4[pos];
			var colorCell=document.getElementById('colorCell'+this.name+(pos+this.colorsTableRow1.length+this.colorsTableRow2.length+this.colorsTableRow3.length));
			
			if(color.toLowerCase()==currentColor.toLowerCase())
				colorCell.style.border='#404040 solid 2px';
			else
				colorCell.style.border='white solid 2px';
		}
	}
	else
	{
		document.getElementById('rgbDialogDiv'+this.name).style.visibility='hidden';
		document.getElementById('colorTableDiv'+this.name).style.visibility='hidden';
	}
}


function ColorControl(name,renderer,endHandler,propertyName,position) {
	this.type='Color';
	this.container=null;
	this.initControl(name,renderer,endHandler);
	this.propertyName=propertyName;
	this.colorsTableRow1=new Array();
	this.colorsTableRow2=new Array();
	this.colorsTableRow3=new Array();
	this.colorsTableRow4=new Array();
	this.position=position;

}

ColorControl.prototype.initControl=Control_initControl;
ColorControl.prototype.draw=ColorControl_draw;
ColorControl.prototype.setProperty=ColorControl_setProperty;
ColorControl.prototype.selectColor=ColorControl_selectColor;
ColorControl.prototype.colorTableToggle=ColorControl_colorTableToggle;
ColorControl.prototype.rgbDialogToggle=ColorControl_rgbDialogToggle;
ColorControl.prototype.rgbDialogApply=ColorControl_rgbDialogApply;




function GiveHex(Dec)
{
   if(Dec == 10)
      Value = "A";
   else
   if(Dec == 11)
      Value = "B";
   else
   if(Dec == 12)
      Value = "C";
   else
   if(Dec == 13)
      Value = "D";
   else
   if(Dec == 14)
      Value = "E";
   else
   if(Dec == 15)
      Value = "F";
   else
      Value = "" + Dec;

   return Value;
}

function GiveDec(Hex)
{
   if(Hex == "A")
      Value = 10;
   else
   if(Hex == "B")
      Value = 11;
   else
   if(Hex == "C")
      Value = 12;
   else
   if(Hex == "D")
      Value = 13;
   else
   if(Hex == "E")
      Value = 14;
   else
   if(Hex == "F")
      Value = 15;
   else
      Value = eval(Hex);

   return Value;
}

function DecToHex(Red,Green,Blue)
{

   a = GiveHex(Math.floor(Red / 16));
   b = GiveHex(Red % 16);
   c = GiveHex(Math.floor(Green / 16));
   d = GiveHex(Green % 16);
   e = GiveHex(Math.floor(Blue / 16));
   f = GiveHex(Blue % 16);

   z = '#'+a + b + c + d + e + f;

	return z;
}


function HexToDecRed(Input)
{
   Input = Input.toUpperCase();

   a = GiveDec(Input.substring(0, 1));
   b = GiveDec(Input.substring(1, 2));
   c = GiveDec(Input.substring(2, 3));
   d = GiveDec(Input.substring(3, 4));
   e = GiveDec(Input.substring(4, 5));
   f = GiveDec(Input.substring(5, 6));

   red = (a * 16) + b;
   green = (c * 16) + d;
   blue = (e * 16) + f;

   return red;
}

function HexToDecGreen(Input)
{
   Input = Input.toUpperCase();

   a = GiveDec(Input.substring(0, 1));
   b = GiveDec(Input.substring(1, 2));
   c = GiveDec(Input.substring(2, 3));
   d = GiveDec(Input.substring(3, 4));
   e = GiveDec(Input.substring(4, 5));
   f = GiveDec(Input.substring(5, 6));

   red = (a * 16) + b;
   green = (c * 16) + d;
   blue = (e * 16) + f;

   return green;
}

function HexToDecBlue(Input)
{
   Input = Input.toUpperCase();

   a = GiveDec(Input.substring(0, 1));
   b = GiveDec(Input.substring(1, 2));
   c = GiveDec(Input.substring(2, 3));
   d = GiveDec(Input.substring(3, 4));
   e = GiveDec(Input.substring(4, 5));
   f = GiveDec(Input.substring(5, 6));

   red = (a * 16) + b;
   green = (c * 16) + d;
   blue = (e * 16) + f;

   return blue;
}



function StrokeControl(name,renderer,endHandler,propertyName,position) {
	this.type='Stroke';
	this.container=null;
	this.initControl(name,renderer,endHandler);
	this.propertyName=propertyName;
	this.position=position;
	this.strokesTable=new Array(1,2,3,4);
}

function StrokeControl_draw(container) {
	this.container=container;
	
	var html='';
	html   +='<table style="cursor:hand" onClick="strokeTableToggle(\''+this.name+'StrokeControl\')" cellspacing="1" bgcolor="white" cellpadding="1" style="border:black solid 1px"><tr><td id="currentStroke'+this.name+'" style="background-color:white" width="25" height="15"><table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="7" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black"><img width="25" height="1" src="images/spacer.gif"/></td></tr><tr><td bgcolor="white"><img width="25" height="7"  src="images/spacer.gif"/></td></tr></table></td><td><img src="immagini/combofreccia.gif" width="11" height="15"/></td></tr></table>';
	html   +='<div id="strokeTablePosDiv'+this.name+'" style="position:relative;left:0px;top:0px;width:1px;height:1px"><img src="immagini/spacer.gif"/ width="1" height="1"></div>';
	html   +='<div id="strokeTableDiv'+this.name+'" style="position:absolute;left:8px;top:160px;height;15px;visibility:hidden;z-index:10000">';
	html   +='<table style="border:none"><tr><td>';
	html   +='<table style="border:black solid 1px" cellspacing="0" cellpadding="0" bgcolor="white" ><tr>';
	html   +='<td id="strokeCell0'+this.name+'" onclick="selectStroke(\''+this.name+'StrokeControl\',1)" style="cursor:hand;border:black solid 1px"><table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="7" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black"><img width="25" height="1" src="images/spacer.gif"/></td></tr><tr><td bgcolor="white"><img width="25" height="7"  src="images/spacer.gif"/></td></tr></table></td>';
	html   +='<td id="strokeCell1'+this.name+'" onclick="selectStroke(\''+this.name+'StrokeControl\',2)" style="cursor:hand;border:black solid 1px"><table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="6" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black"><img width="25" height="2" src="images/spacer.gif"/></td></tr><tr><td bgcolor="white"><img width="25" height="7"  src="images/spacer.gif"/></td></tr></table></td>';
	html   +='<td id="strokeCell2'+this.name+'" onclick="selectStroke(\''+this.name+'StrokeControl\',3)" style="cursor:hand;border:black solid 1px"><table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="6" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black"><img width="25" height="3" src="images/spacer.gif"/></td></tr><tr><td bgcolor="white"><img width="25" height="6"  src="images/spacer.gif"/></td></tr></table></td>';
	html   +='<td id="strokeCell3'+this.name+'" onclick="selectStroke(\''+this.name+'StrokeControl\',4)" style="cursor:hand;border:black solid 1px"><table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="5" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black"><img width="25" height="4" src="images/spacer.gif"/></td></tr><tr><td bgcolor="white"><img width="25" height="6"  src="images/spacer.gif"/></td></tr></table></td>';
	html   +='<td id="strokeButtonCell" onclick="strokeDialogToggle(\''+this.name+'StrokeControl\')" style="cursor:hand;background-color:white" width="15" height="15">>></td>';
	html   +='</tr></table>';
	html   +='</td>';
	html   +='<td valign="bottom">';
	html   +='  <div id="strokeDialogDiv'+this.name+'" style="visibility:hidden;z-index:10000"> ';
	html   +='      <div align="left"><table cellspacing="1" bgcolor="white" cellpadding="1" style="border:black solid 1px">';
	html   +='      <tr><td>Stroke</td><td><input type="text" id="strokestroke'+this.name+'" size="2"/></td><td><input type="button" id="strokesubmit" value="Apply" onclick="strokeDialogApply(\''+this.name+'StrokeControl\')"/></td></tr>';
	html   +='      </table></div>';
	html   +='  </div>';
	html   +='</td>';
	html   +='</tr></table>';
	html   +='</div>';


	document.getElementById(this.container).innerHTML=html;
	var actualStroke=this.renderer.getProperty(this.propertyName);
	updateCurrentStroke(actualStroke,this);
}

function updateCurrentStroke(newStroke,object) {
	var exampleStroke=document.getElementById('currentStroke'+object.name);
	var html='<table cellpadding="0" cellspacing="0">';
	var upPart=Math.ceil((15-newStroke)/2);
	var downPart=15-newStroke-upPart;
	html+='<tr><td bgcolor="white"><img width="25" height="'+upPart+'" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td bgcolor="black"><img width="25" height="'+newStroke+'" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td bgcolor="white"><img width="25" height="'+downPart+'" src="images/spacer.gif"/></td></tr>';
	exampleStroke.innerHTML=html;
}

function selectStroke(controlName,newStroke) {
	var control=Control.controls[controlName];
	if(control)
		control.selectStroke(newStroke);
}

function StrokeControl_selectStroke(stroke) {
	this.renderer.setProperty(this.propertyName,stroke);
	updateCurrentStroke(stroke,this);
	this.strokeTableToggle();
	if(this.endHandler)
		eval(this.endHandler+'()');
}

function strokeTableToggle(controlName) {
	var control=Control.controls[controlName];
	if(control)
		control.strokeTableToggle();
}

function StrokeControl_strokeTableToggle() {
	var refDiv=document.getElementById('strokeTablePosDiv'+this.name);
	var div=document.getElementById('strokeTableDiv'+this.name);
	div.style.pixelLeft=refDiv.offsetLeft-this.position;
	div.style.pixelTop=refDiv.offsetTop-10;

	var currentStroke=this.renderer.getProperty(this.propertyName);

	for(var pos in this.strokesTable) {
		var stroke=this.strokesTable[pos];
		var strokeCell=document.getElementById('strokeCell'+pos+this.name);
		
		if(stroke==currentStroke)
			strokeCell.style.border='#404040 solid 2px';
		else
			strokeCell.style.border='white solid 2px';
	}

	document.getElementById('strokestroke'+this.name).value=currentStroke;

	if (document.getElementById('strokeTableDiv'+this.name).style.visibility=='hidden')
	{
		document.getElementById('strokeTableDiv'+this.name).style.visibility='visible';
	}
	else
	{
		document.getElementById('strokeTableDiv'+this.name).style.visibility='hidden';
		document.getElementById('strokeDialogDiv'+this.name).style.visibility='hidden';
	}
}

function strokeDialogApply(controlName) {
	var control=Control.controls[controlName];
	if(control)
		control.strokeDialogApply();
}

function StrokeControl_strokeDialogApply() {

	var stroke=document.getElementById('strokestroke'+this.name).value;
	this.selectStroke(stroke);
}

function strokeDialogToggle(controlName) {
	var control=Control.controls[controlName];
	if(control)
		control.strokeDialogToggle();
}

function StrokeControl_strokeDialogToggle() {

	var actualStroke=this.renderer.getProperty(this.propertyName);

	document.getElementById('strokestroke'+this.name).value=actualStroke;
	
	if (document.getElementById('strokeDialogDiv'+this.name).style.visibility=='hidden')
		document.getElementById('strokeDialogDiv'+this.name).style.visibility='visible';
	else
		document.getElementById('strokeDialogDiv'+this.name).style.visibility='hidden';
}

StrokeControl.prototype.initControl=Control_initControl;
StrokeControl.prototype.draw=StrokeControl_draw;
StrokeControl.prototype.selectStroke=StrokeControl_selectStroke;
StrokeControl.prototype.strokeTableToggle=StrokeControl_strokeTableToggle;
StrokeControl.prototype.strokeDialogApply=StrokeControl_strokeDialogApply;
StrokeControl.prototype.strokeDialogToggle=StrokeControl_strokeDialogToggle;

function SizeControl(name,renderer,endHandler,propertyName,position) {
	this.type='Size';
	this.container=null;
	this.initControl(name,renderer,endHandler);
	this.propertyName=propertyName;
	this.position=position;
	this.sizesTable=new Array(1,2,3,4);
}

function SizeControl_draw(container) {
	this.container=container;
	/*
	var html='';
	html   +='<table style="cursor:hand" onClick="sizeTableToggle(\''+this.name+'SizeControl\')" cellspacing="1" bgcolor="white" cellpadding="1" style="border:black solid 1px"><tr><td id="currentSize'+this.name+'" style="background-color:white" width="15" height="15"><table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="7" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black"><img width="25" height="1" src="images/spacer.gif"/></td></tr><tr><td bgcolor="white"><img width="25" height="7"  src="images/spacer.gif"/></td></tr></table></td><td><img src="immagini/combofreccia.gif" width="11" height="15"/></td></tr></table>';
	html   +='<div id="sizeTablePosDiv'+this.name+'" style="position:relative;left:0px;top:0px;width:1px;height:1px"><img src="immagini/spacer.gif"/ width="1" height="1"></div>';
	html   +='<div id="sizeTableDiv'+this.name+'" style="position:absolute;left:8px;top:160px;height;15px;visibility:hidden;z-index:5">';
	html   +='<table style="border:none"><tr><td>';
	html   +='<table style="border:black solid 1px" cellspacing="0" cellpadding="0" bgcolor="white" ><tr>';
	html   +='<td id="sizeCell0" onclick="selectSize(\''+this.name+'SizeControl\',1)" style="cursor:hand;border:black solid 1px">'; //<table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="7" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black">'; //<img width="25" height="1" src="images/spacer.gif"/>

	html+='<table>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td><img width="7" height="1" src="images/spacer.gif"/><img width="1" height="1" src="immagini/pallino.gif"/><img width="7" height="1" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='</table>';
	html+='</td>';	

	html   +='<td id="sizeCell1" onclick="selectSize(\''+this.name+'SizeControl\',2)" style="cursor:hand;border:black solid 1px">';//<table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="6" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black"><img width="25" height="2" src="images/spacer.gif"/></td></tr><tr><td bgcolor="white"><img width="25" height="7"  src="images/spacer.gif"/></td></tr></table></td>';

	html+='<table>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td><img width="6" height="1" src="images/spacer.gif"/><img width="2" height="2" src="immagini/pallino.gif"/><img width="7" height="1" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='</table>';
	html+='</td>';	
	

	html   +='<td id="sizeCell2" onclick="selectSize(\''+this.name+'SizeControl\',3)" style="cursor:hand;border:black solid 1px">';//<table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="6" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black"><img width="25" height="3" src="images/spacer.gif"/></td></tr><tr><td bgcolor="white"><img width="25" height="6"  src="images/spacer.gif"/></td></tr></table></td>';

	html+='<table>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td><img width="6" height="1" src="images/spacer.gif"/><img width="3" height="3" src="immagini/pallino.gif"/><img width="6" height="1" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='</table>';
	html+='</td>';	


	html   +='<td id="sizeCell3" onclick="selectSize(\''+this.name+'SizeControl\',4)" style="cursor:hand;border:black solid 1px">';//<table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="5" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black"><img width="25" height="4" src="images/spacer.gif"/></td></tr><tr><td bgcolor="white"><img width="25" height="6"  src="images/spacer.gif"/></td></tr></table></td>';

	html+='<table>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td><img width="5" height="1" src="images/spacer.gif"/><img width="4" height="4" src="immagini/pallino.gif"/><img width="6" height="1" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='</table>';
	html+='</td>';	
	
	
	html   +='<td id="sizeButtonCell" onclick="sizeDialogToggle(\''+this.name+'SizeControl\')" style="cursor:hand;background-color:white" width="15" height="15">>></td>';
	html   +='</tr></table>';
	html   +='</td>';
	html   +='<td valign="bottom">';
	html   +='  <div id="sizeDialogDiv" style="visibility:hidden"> ';
	html   +='      <div align="left"><table cellspacing="1" bgcolor="white" cellpadding="1" style="border:black solid 1px">';
	html   +='      <tr><td>Size</td><td><input type="text" id="sizesize" size="2"/></td><td><input type="button" id="sizesubmit" value="Apply" onclick="sizeDialogApply(\''+this.name+'SizeControl\')"/></td></tr>';
	html   +='      </table></div>';
	html   +='  </div>';
	html   +='</td>';
	html   +='</tr></table>';
	html   +='</div>';


	document.getElementById(this.container).innerHTML=html;
	var actualSize=this.renderer.getProperty(this.propertyName);
	updateCurrentSize(actualSize,this);

	*/
	var html='';
	html   +='<table style="cursor:hand" onClick="sizeTableToggle(\''+this.name+'SizeControl\')" cellspacing="1" bgcolor="white" cellpadding="1" style="border:black solid 1px"><tr><td id="currentSize'+this.name+'" style="background-color:white" width="15" height="15"><table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="7" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black"><img width="25" height="1" src="images/spacer.gif"/></td></tr><tr><td bgcolor="white"><img width="25" height="7"  src="images/spacer.gif"/></td></tr></table></td><td><img src="immagini/combofreccia.gif" width="11" height="15"/></td></tr></table>';
	html   +='<div id="sizeTablePosDiv'+this.name+'" style="position:relative;left:0px;top:0px;width:1px;height:1px"><img src="immagini/spacer.gif"/ width="1" height="1"></div>';
	html   +='<div id="sizeTableDiv'+this.name+'" style="position:absolute;left:8px;top:160px;height;15px;visibility:hidden;z-index:10000">';
	html   +='<table style="border:none"><tr><td>';
	html   +='<table style="border:black solid 1px" cellspacing="0" cellpadding="0" bgcolor="white" ><tr>';
	html   +='<td id="sizeCell0'+this.name+'" onclick="selectSize(\''+this.name+'SizeControl\',1)" style="cursor:hand;border:black solid 1px">';//<table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="7" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black"><img width="25" height="1" src="images/spacer.gif"/></td></tr><tr><td bgcolor="white"><img width="25" height="7"  src="images/spacer.gif"/></td></tr></table></td>';

	html+='<table>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td><img width="7" height="1" src="images/spacer.gif"/><img width="1" height="1" src="immagini/pallino.gif"/><img width="7" height="1" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='</table>';
	html+='</td>';	

	html   +='<td id="sizeCell1'+this.name+'" onclick="selectSize(\''+this.name+'SizeControl\',2)" style="cursor:hand;border:black solid 1px">';//<table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="6" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black"><img width="25" height="2" src="images/spacer.gif"/></td></tr><tr><td bgcolor="white"><img width="25" height="7"  src="images/spacer.gif"/></td></tr></table></td>';

	html+='<table>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td><img width="6" height="1" src="images/spacer.gif"/><img width="2" height="2" src="immagini/pallino.gif"/><img width="7" height="1" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='</table>';
	html+='</td>';	

	html   +='<td id="sizeCell2'+this.name+'" onclick="selectSize(\''+this.name+'SizeControl\',3)" style="cursor:hand;border:black solid 1px">';//<table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="6" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black"><img width="25" height="3" src="images/spacer.gif"/></td></tr><tr><td bgcolor="white"><img width="25" height="6"  src="images/spacer.gif"/></td></tr></table></td>';

	html+='<table>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td><img width="6" height="1" src="images/spacer.gif"/><img width="3" height="3" src="immagini/pallino.gif"/><img width="6" height="1" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='</table>';
	html+='</td>';	

	html   +='<td id="sizeCell3'+this.name+'" onclick="selectSize(\''+this.name+'SizeControl\',4)" style="cursor:hand;border:black solid 1px">';//<table cellpadding="0" cellspacing="0"><tr><td bgcolor="white"><img width="25" height="5" src="images/spacer.gif"/></td></tr><tr><td bgcolor="black"><img width="25" height="4" src="images/spacer.gif"/></td></tr><tr><td bgcolor="white"><img width="25" height="6"  src="images/spacer.gif"/></td></tr></table></td>';

	html+='<table>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td><img width="5" height="1" src="images/spacer.gif"/><img width="4" height="4" src="immagini/pallino.gif"/><img width="6" height="1" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td bgcolor="white"><img width="15" height="2" src="images/spacer.gif"/></td></tr>';
	html+='</table>';
	html+='</td>';	

	html   +='<td id="sizeButtonCell" onclick="sizeDialogToggle(\''+this.name+'SizeControl\')" style="cursor:hand;background-color:white" width="15" height="15">>></td>';
	html   +='</tr></table>';
	html   +='</td>';
	html   +='<td valign="bottom">';
	html   +='  <div id="sizeDialogDiv'+this.name+'" style="visibility:hidden;z-index:10000"> ';
	html   +='      <div align="left"><table cellspacing="1" bgcolor="white" cellpadding="1" style="border:black solid 1px">';
	html   +='      <tr><td>Size</td><td><input type="text" id="sizesize'+this.name+'" size="2"/></td><td><input type="button" id="sizesubmit" value="Apply" onclick="sizeDialogApply(\''+this.name+'SizeControl\')"/></td></tr>';
	html   +='      </table></div>';
	html   +='  </div>';
	html   +='</td>';
	html   +='</tr></table>';
	html   +='</div>';


	document.getElementById(this.container).innerHTML=html;
	var actualSize=this.renderer.getProperty(this.propertyName);
	updateCurrentSize(actualSize,this);
}

function updateCurrentSize(newSize,object) {
	var exampleSize=document.getElementById('currentSize'+object.name);
	var html='<table cellpadding="0" cellspacing="0">';
	var upPart=Math.ceil((15-newSize)/2);
	var downPart=15-newSize-upPart;
	html+='<tr><td bgcolor="white"><img width="15" height="'+upPart+'" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td><img width="'+((15-newSize)/2)+'" height="'+newSize+'" src="images/spacer.gif"/><img width="'+newSize+'" height="'+newSize+'" src="immagini/pallino.gif"/><img width="'+((15-newSize)/2)+'" height="'+newSize+'" src="images/spacer.gif"/></td></tr>';
	html+='<tr><td bgcolor="white"><img width="15" height="'+downPart+'" src="images/spacer.gif"/></td></tr>';
	exampleSize.innerHTML=html;
}

function selectSize(controlName,newSize) {
	var control=Control.controls[controlName];
	if(control)
		control.selectSize(newSize);
}

function SizeControl_selectSize(size) {
	this.renderer.setProperty(this.propertyName,size);
	updateCurrentSize(size,this);
	this.sizeTableToggle();
	if(this.endHandler)
		eval(this.endHandler+'()');
}

function sizeTableToggle(controlName) {
	var control=Control.controls[controlName];
	if(control)
		control.sizeTableToggle();
}

function SizeControl_sizeTableToggle() {
	
	var refDiv=document.getElementById('sizeTablePosDiv'+this.name);
	var div=document.getElementById('sizeTableDiv'+this.name);
	div.style.pixelLeft=refDiv.offsetLeft-this.position;
	div.style.pixelTop=refDiv.offsetTop-10;

	var currentSize=this.renderer.getProperty(this.propertyName);

	for(var pos in this.sizesTable) {
		var size=this.sizesTable[pos];
		var sizeCell=document.getElementById('sizeCell'+pos+this.name);
		
		if(size==currentSize)
			sizeCell.style.border='#404040 solid 2px';
		else
			sizeCell.style.border='white solid 2px';
	}

	document.getElementById('sizesize'+this.name).value=currentSize;

	if (document.getElementById('sizeTableDiv'+this.name).style.visibility=='hidden')
	{
		document.getElementById('sizeTableDiv'+this.name).style.visibility='visible';
	}
	else
	{
		document.getElementById('sizeTableDiv'+this.name).style.visibility='hidden';
		document.getElementById('sizeDialogDiv'+this.name).style.visibility='hidden';
	}
}

function sizeDialogApply(controlName) {
	var control=Control.controls[controlName];
	if(control)
		control.sizeDialogApply();
}

function SizeControl_sizeDialogApply() {

	var size=document.getElementById('sizesize'+this.name).value;
	this.selectSize(size);
}

function sizeDialogToggle(controlName) {
	var control=Control.controls[controlName];
	if(control)
		control.sizeDialogToggle();
}

function SizeControl_sizeDialogToggle() {

	var actualSize=this.renderer.getProperty(this.propertyName);

	document.getElementById('sizesize'+this.name).value=actualSize;
	
	if (document.getElementById('sizeDialogDiv'+this.name).style.visibility=='hidden')
		document.getElementById('sizeDialogDiv'+this.name).style.visibility='visible';
	else
		document.getElementById('sizeDialogDiv'+this.name).style.visibility='hidden';
}

SizeControl.prototype.initControl=Control_initControl;
SizeControl.prototype.draw=SizeControl_draw;
SizeControl.prototype.selectSize=SizeControl_selectSize;
SizeControl.prototype.sizeTableToggle=SizeControl_sizeTableToggle;
SizeControl.prototype.sizeDialogApply=SizeControl_sizeDialogApply;
SizeControl.prototype.sizeDialogToggle=SizeControl_sizeDialogToggle;

