  window.onload = initValues;
  document.onmousedown=selectmouse;
  document.onmouseup=new Function("_isdrag=false");

  var _jg = null;
  var _ie = document.all;
  var _nn6 = document.getElementById&&!document.all;
  var _isdrag=false;
  var _x
  var _y;
  var _dobj;
  var _id;
  var _vmlEnabled = false;
  if(navigator.userAgent.indexOf("MSIE") != -1) _vmlEnabled = true;
  
  // ------------------------------------------------------
  function movemouse(e)
  {
    if (_isdrag)
    {
      var s = _dobj.id.substring(0,3);
      if(s=="top" || s=="bot")
      {
      
	var tophub      = document.getElementById('tophub');
	var topchassis  = document.getElementById('topchassis');
	var bothub      = document.getElementById('bothub');
	var botchassis  = document.getElementById('botchassis');

        var topchassis_x = (_dobj.id=='topchassis') ? parseInt(_nn6 ? tx + e.clientX - _x : tx + event.clientX - _x) : parseInt(topchassis.style.left);
        var topchassis_y = (_dobj.id=='topchassis') ? parseInt(_nn6 ? ty + e.clientY - _y : ty + event.clientY - _y) : parseInt(topchassis.style.top);
        var tophub_x = (_dobj.id=='tophub') ? parseInt(_nn6 ? tx + e.clientX - _x : tx + event.clientX - _x) : parseInt(tophub.style.left);
        var tophub_y = (_dobj.id=='tophub') ? parseInt(_nn6 ? ty + e.clientY - _y : ty + event.clientY - _y) : parseInt(tophub.style.top);
        var botchassis_x = (_dobj.id=='botchassis') ? parseInt(_nn6 ? tx + e.clientX - _x : tx + event.clientX - _x) : parseInt(botchassis.style.left);
        var botchassis_y = (_dobj.id=='botchassis') ? parseInt(_nn6 ? ty + e.clientY - _y : ty + event.clientY - _y) : parseInt(botchassis.style.top);
        var bothub_x = (_dobj.id=='bothub') ? parseInt(_nn6 ? tx + e.clientX - _x : tx + event.clientX - _x) : parseInt(bothub.style.left);
        var bothub_y = (_dobj.id=='bothub') ? parseInt(_nn6 ? ty + e.clientY - _y : ty + event.clientY - _y) : parseInt(bothub.style.top);

        if(topchassis_x >= (tophub_x-50)) return false;
        if(botchassis_x >= (bothub_x-50)) return false;
        if(topchassis_y >= (botchassis_y-50)) return false;
        if(tophub_y >= (bothub_y-50)) return false;
        if(topchassis_y < 6) return false;
        if(tophub_y < 6) return false;
        if(botchassis_y > 380) return false;
        if(bothub_y > 380) return false;
        if(topchassis_x < 6) return false;
        if(botchassis_x < 6) return false;
        if(tophub_x > 520) return false;
        if(bothub_x > 520) return false;

	
        // move the item
        _dobj.style.left = parseInt(_nn6 ? tx + e.clientX - _x : tx + event.clientX - _x)+"px";
        _dobj.style.top  = parseInt(_nn6 ? ty + e.clientY - _y : ty + event.clientY - _y)+"px";
    
        // redraw the area
        redraw(_dobj.id);

	setStandardValues();

	document.getElementById('vdeflection').value = "";
	document.getElementById('hdeflection').value = "";
	document.getElementById('cdeflection').value = "";

        _base_hub_x       = parseInt(hubX());
        _base_hub_y       = parseInt(hubY());
        _base_upper_hub_x = tophub_x;
        _base_upper_hub_y = tophub_y;
        _base_lower_hub_x = bothub_x;
        _base_lower_hub_y = bothub_y;

        generateLink();

      }
      else
      {
        _dobj.style.left = parseInt(_nn6 ? tx + e.clientX - _x : tx + event.clientX - _x)+"px";
        _dobj.style.top  = parseInt(_nn6 ? ty + e.clientY - _y : ty + event.clientY - _y)+"px";
      }
      return false;
    }
  }
  // ------------------------------------------------------
  function recalculateScale()
  {
	if(!isNaN(document.getElementById('camber').value))
	{

		var tophub      = document.getElementById('tophub');
		var topchassis  = document.getElementById('topchassis');
		var bothub      = document.getElementById('bothub');
		var botchassis  = document.getElementById('botchassis');

	        var topchassis_x = parseInt(topchassis.style.left);
        	var topchassis_y = parseInt(topchassis.style.top);
	        var tophub_x = parseInt(tophub.style.left);
        	var tophub_y = parseInt(tophub.style.top);
	        var botchassis_x = parseInt(botchassis.style.left);
        	var botchassis_y = parseInt(botchassis.style.top);
	        var bothub_x = parseInt(bothub.style.left);
        	var bothub_y = parseInt(bothub.style.top);
	
		setStandardValues();

		document.getElementById('vdeflection').value = "";
		document.getElementById('hdeflection').value = "";
		document.getElementById('cdeflection').value = "";

	        _base_hub_x       = parseInt(hubX());
        	_base_hub_y       = parseInt(hubY());
	        _base_upper_hub_x = tophub_x;
        	_base_upper_hub_y = tophub_y;
	        _base_lower_hub_x = bothub_x;
        	_base_lower_hub_y = bothub_y;
        
	        generateLink();	
	}
  }
  // ------------------------------------------------------
  function setStandardValues()
  {
    document.getElementById('camber').value = round(hubAngle());
    document.getElementById('ulen').value = round(wishboneLength('top'));
    document.getElementById('ulength').value = round(wishboneLength('top') * _base_scale);
    document.getElementById('uangle').value = round(wishboneAngle('top'));
    document.getElementById('llen').value = round(wishboneLength('bot'));
    document.getElementById('llength').value = round(wishboneLength('bot') * _base_scale);
    document.getElementById('langle').value = round(wishboneAngle('bot'));
    document.getElementById('hubdist').value = round(parseInt(hubLength())  * _base_scale);
    document.getElementById('chassisdist').value = round(parseInt(chassisLength()) * _base_scale);
    var sal = parseInt(SAL());
    document.getElementById('sal').value = (isNaN(sal)) ? "" : round(sal);
  }
  // ------------------------------------------------------
  function redraw(id)
  {
    if(id=="tophub")
    {
      drawWishbone('top');
      drawHub();
    }
    else if(id=="bothub")
    {
      drawWishbone('bot');
      drawHub();
    }
    if(id=="topchassis")
    {
      drawWishbone('top');
      drawChassis();
    }
    else if(id=="botchassis")
    {
      drawWishbone('bot');
      drawChassis();
    }
    else if(id=="hub")
    {
      drawWishbone('top');
      drawWishbone('bot');
      drawHub();
    }
    else
    {
      drawWishbone('top');
      drawWishbone('bot');
      drawChassis();
      drawHub();
    }
  }
  // ------------------------------------------------------
  function hubmovecalc()
  {
        var vdeflection = _base_hub_y - ( parseInt(document.getElementById('hubcentre').style.top) + 10 );
        document.getElementById('vdeflection').value = round(vdeflection * _base_scale);

        var topwishbone_length = round(document.getElementById('ulen').value);
        var botwishbone_length = round(document.getElementById('llen').value);

        moveWishbone('top',topwishbone_length,vdeflection);
        moveWishbone('bot',botwishbone_length,vdeflection);
        redraw("hub");
		
        if(vdeflection!=0)
        {
          document.getElementById('hdeflection').value = round((hubX() - _base_hub_x) * _base_scale);
          document.getElementById('cdeflection').value = round(round(hubAngle()) - round(document.getElementById('camber').value));
        }
        else
        {
          document.getElementById('hdeflection').value = 0;
          document.getElementById('cdeflection').value = 0;
       	}
  }
  // ------------------------------------------------------
  function hubmove(e)
  {
    if (_isdrag)
    {
        _dobj.style.top  = parseInt(_nn6 ? ty + e.clientY - _y : ty + event.clientY - _y)+"px";
		hubmovecalc();
       	return false;
	}
  }
  // ------------------------------------------------------
  function generateLink()
  {
    var linky = document.getElementById('link');
    if(linky)
    {
	  linky.value = "http://www.racingaspirations.com/suspensiongeometry.php" +
	    "?tcx=" + parseInt(document.getElementById('topchassis').style.left) +
	    "&tcy=" + parseInt(document.getElementById('topchassis').style.top) +
	    "&thx=" + parseInt(document.getElementById('tophub').style.left) +
	    "&thy=" + parseInt(document.getElementById('tophub').style.top) +
	    "&bcx=" + parseInt(document.getElementById('botchassis').style.left) +
	    "&bcy=" + parseInt(document.getElementById('botchassis').style.top) +
	    "&bhx=" + parseInt(document.getElementById('bothub').style.left) +
	    "&bhy=" + parseInt(document.getElementById('bothub').style.top) + 
	    "&scl=" + document.getElementById('scale').options[document.getElementById('scale').selectedIndex].value;
	}
  }
  // ------------------------------------------------------
  function selectmouse(e)
  {
    var fobj       = _nn6 ? e.target : event.srcElement;
    var topelement = _nn6 ? "HTML" : "BODY";
	
	
    if (fobj.getAttribute('draggable')=='true')
    {
	  _isdrag = true;
      _dobj = fobj;
      tx = parseInt(_dobj.style.left+0);
      ty = parseInt(_dobj.style.top+0);
      _x = _nn6 ? e.clientX : event.clientX;
      _y = _nn6 ? e.clientY : event.clientY;
      document.onmousemove=movemouse;
      return false;
    }
    else if (fobj.getAttribute('updown')=='true')
    {
      _isdrag = true;
      _dobj = fobj;
      ty = parseInt(_dobj.style.top+0);
      _y = _nn6 ? e.clientY : event.clientY;
      document.onmousemove=hubmove;
      return false;
    }
  }
  function moveWishbone(which,fixedlen,def)
  {
    var chassis_x  = parseInt(document.getElementById(which+'chassis').style.left);
    var chassis_y  = parseInt(document.getElementById(which+'chassis').style.top);
    var hub        = document.getElementById(which+'hub');
    var orig_x     = (which=="top") ? _base_upper_hub_x : _base_lower_hub_x;
    var orig_y     = (which=="top") ? _base_upper_hub_y : _base_lower_hub_y;
    var new_length = parseInt(distanceBetweenTwoPoints(chassis_x,chassis_y,orig_x,orig_y-def));
    fixedlen = parseInt(fixedlen);
    if(def==0)
    {
	      hub.style.left = parseInt((which=="top") ? _base_upper_hub_x : _base_lower_hub_x)+"px";
	      hub.style.top = parseInt((which=="top") ? _base_upper_hub_y : _base_lower_hub_y)+"px";
	}
    else
    {
	    if(new_length != fixedlen)
	    {
	      if(new_length > fixedlen)
	      {
	        while(new_length != fixedlen && orig_x > 10)
	        {
	          orig_x=orig_x-1;
	          new_length = parseInt(distanceBetweenTwoPoints(chassis_x,chassis_y,orig_x,orig_y-def));
	        }
	      }
	      else
	      {
	        while(new_length != fixedlen && orig_x < 600)
	        {
	          orig_x=orig_x+1;
	          new_length = parseInt(distanceBetweenTwoPoints(chassis_x,chassis_y,orig_x,orig_y-def));
	        }
	      }
	      hub.style.left = parseInt(orig_x)+"px";
	      hub.style.top = parseInt(orig_y-def)+"px";
	    }
	    else
	    {
			hub.style.top = parseInt(orig_y-def)+"px";
	    }
    }
  }
  // ------------------------------------------------------
  function drawWishbone(s)
  {
	var o1 = document.getElementById(s+'chassis');
	var o2 = document.getElementById(s+'hub');
	var left_x = parseInt(o1.style.left)+11;
	var left_y = parseInt(o1.style.top)+11;
	var right_x = parseInt(o2.style.left)+11;
	var right_y = parseInt(o2.style.top)+11;
	DrawLine("canvas", s+"wishbone", left_x,left_y,right_x,right_y,'#000000');
  }
  // ------------------------------------------------------
  function drawChassis()
  {
	var top   = document.getElementById('topchassis');
	var bot   = document.getElementById('botchassis');
	var top_x = parseInt(top.style.left)+11;
	var top_y = parseInt(top.style.top)+11;
	var bot_x = parseInt(bot.style.left)+11;
	var bot_y = parseInt(bot.style.top)+11;
	DrawLine("canvas", "chassis1", 0,top_y,top_x,top_y,'#0000ff');
	DrawLine("canvas", "chassis2", top_x,top_y,bot_x,bot_y,'#0000ff');
	DrawLine("canvas", "chassis3", 0,bot_y,bot_x,bot_y,'#0000ff');
  }
  // ------------------------------------------------------
  function drawHub()
  {
    // hub
	var top   = document.getElementById('tophub');
	var bot   = document.getElementById('bothub');
	var top_x = parseInt(top.style.left)+11;
	var top_y = parseInt(top.style.top)+11;
	var bot_x = parseInt(bot.style.left)+11;
	var bot_y = parseInt(bot.style.top)+11;
	DrawLine("canvas", "hub", top_x,top_y,bot_x,bot_y,'#ff0000');
    // centre
	var radius    = round(distanceBetweenTwoPoints(top_x,top_y,bot_x,bot_y) * 0.5);
	var bearing   = 180 + bearingBetweenTwoPoints(top_x,top_y,bot_x,bot_y);
	var centrex   = getXFromBearing(bearing,radius,bot_x);
	var centrey   = getYFromBearing(bearing,radius,bot_y);
	var hubcentre = document.getElementById('hubcentre');
	hubcentre.style.left = parseInt(parseInt(centrex) - 5)+"px";
	hubcentre.style.top = parseInt(parseInt(centrey) - 10)+"px";
  }
  // ------------------------------------------------------
  // return the distance between two points in space
  function distanceBetweenTwoPoints(x1,y1,x2,y2)
  {
	if(y1 > y2)
	{
	  return getC(y1 - y2,x2 - x1);
	}
	else if(y1 < y2)
	{
	  return getC(y2 - y1,x2 - x1);
	}
	else
	{
	  return x2 - x1;
	}
  }
  // ------------------------------------------------------
  // return the bearing between two points in space
  function bearingBetweenTwoPoints(x1,y1,x2,y2)
  {
	if(y1 > y2)
	{
	  return 0 - angleOfItem(y1 - y2,x2 - x1);
	}
	else if(y1 < y2)
	{
	  return angleOfItem(y2 - y1,x2 - x1);
	}
	else
	{
	  return 0;
	}
  }
  // ------------------------------------------------------
  // return the x pos of the hub centre
  function hubX()
  {
    var top     = document.getElementById('tophub');
    var bot     = document.getElementById('bothub');
    var top_x   = parseInt(top.style.left)+11;
    var top_y   = parseInt(top.style.top)+11;
    var bot_x   = parseInt(bot.style.left)+11;
    var bot_y   = parseInt(bot.style.top)+11;
    var radius  = round(distanceBetweenTwoPoints(top_x,top_y,bot_x,bot_y) * 0.5);
    var bearing = 180 + bearingBetweenTwoPoints(top_x,top_y,bot_x,bot_y);
    return      getXFromBearing(bearing,radius,bot_x);
  }
  // ------------------------------------------------------
  // return the y pos of the hub centre
  function hubY()
  {
    var top     = document.getElementById('tophub');
    var bot     = document.getElementById('bothub');
    var top_x   = parseInt(top.style.left)+11;
    var top_y   = parseInt(top.style.top)+11;
    var bot_x   = parseInt(bot.style.left)+11;
    var bot_y   = parseInt(bot.style.top)+11;
    var radius  = round(distanceBetweenTwoPoints(top_x,top_y,bot_x,bot_y) * 0.5);
    var bearing = 180 + bearingBetweenTwoPoints(top_x,top_y,bot_x,bot_y);
    return      getYFromBearing(bearing,radius,bot_y);
  }
  // ------------------------------------------------------
  // return the length between the chassis mounting points
  function SAL()
  {
	var top1   = document.getElementById('tophub');
	var top2   = document.getElementById('topchassis');
	var bot1   = document.getElementById('bothub');
	var bot2   = document.getElementById('botchassis');
	var top_x1 = parseInt(top1.style.left)+11+100000;
	var top_y1 = parseInt(top1.style.top)+11+100000;
	var top_x2 = parseInt(top2.style.left)+11+100000;
	var top_y2 = parseInt(top2.style.top)+11+100000;
	var bot_x1 = parseInt(bot1.style.left)+11+100000;
	var bot_y1 = parseInt(bot1.style.top)+11+100000;
	var bot_x2 = parseInt(bot2.style.left)+11+100000;
	var bot_y2 = parseInt(bot2.style.top)+11+100000;
    var x = getXIntersection(top_x1,top_y1,top_x2,top_y2,bot_x1,bot_y1,bot_x2,bot_y2);
    var y = getYIntersection(top_x1,top_y1,top_x2,top_y2,bot_x1,bot_y1,bot_x2,bot_y2);
    return distanceBetweenTwoPoints(x,y,hubX()+100000,hubY()+100000);
  }
  // ------------------------------------------------------
  // return the length between the chassis mounting points
  function chassisLength()
  {
    var topchassis   = document.getElementById('topchassis');
    var botchassis   = document.getElementById('botchassis');
    return distanceBetweenTwoPoints(parseInt(topchassis.style.left),parseInt(topchassis.style.top),parseInt(botchassis.style.left),parseInt(botchassis.style.top));
  }
  // ------------------------------------------------------
  // return the length between the hub mounting points
  function hubLength()
  {
    var tophub   = document.getElementById('tophub');
    var bothub   = document.getElementById('bothub');
    return distanceBetweenTwoPoints(parseInt(tophub.style.left),parseInt(tophub.style.top),parseInt(bothub.style.left),parseInt(bothub.style.top));
  }
  // ------------------------------------------------------
  // return the angle of the hub
  function hubAngle()
  {
    var tophub = document.getElementById('tophub');
    var bothub = document.getElementById('bothub');
    return bearingBetweenTwoPoints(parseInt(tophub.style.left),parseInt(tophub.style.top),parseInt(bothub.style.left),parseInt(bothub.style.top))-90;
  }
  // ------------------------------------------------------
  // return the length of the selected wishbone
  function wishboneLength(which)
  {
    var o1 = document.getElementById(which+'chassis');
    var o2 = document.getElementById(which+'hub');
    return distanceBetweenTwoPoints(parseInt(o1.style.left),parseInt(o1.style.top),parseInt(o2.style.left),parseInt(o2.style.top));
  }
  // ------------------------------------------------------
  // return the angle of the selected wishbone
  function wishboneAngle(which)
  {
    var o1 = document.getElementById(which+'chassis');
    var o2 = document.getElementById(which+'hub');
    return bearingBetweenTwoPoints(parseInt(o1.style.left),parseInt(o1.style.top),parseInt(o2.style.left),parseInt(o2.style.top));
  }
  // ------------------------------------------------------
  function round1(v)
  {
	return parseInt(v * 10) / 10;
  }
  // ------------------------------------------------------
  function round(v)
  {
	return parseInt(v * 100) / 100;
  }
  // ------------------------------------------------------
  function angleOfItem(a,b)
  {
    r = Math.atan2(a,b);
	d = r * 180 / Math.PI;
	return d;
  }
  // ------------------------------------------------------
  function getC(a,b)
  {
	return Math.sqrt((a * a) + (b * b));
  }
  // ------------------------------------------------------
  function getXFromBearing(angle,radius,x)
  {
     return x + radius * Math.cos(angle * Math.PI/180);
  }
  // ------------------------------------------------------
  function getYFromBearing(angle,radius,y)
  {
     return y + radius * Math.sin(angle * Math.PI/180);
  }
  // ------------------------------------------------------
  function getXIntersection(lineAx1,lineAy1,lineAx2,lineAy2,lineBx1,lineBy1,lineBx2,lineBy2)
  {
    var aM
    var bM
    var aB
    var bB
    var isX = 0
    var isY = 0
    if((lineAx2-lineAx1)==0)
    {
      isX=lineAx1;
      bM=(lineBy2-lineBy1)/(lineBx2-lineBx1);
      bB=lineBy2-bM*lineBx2;
      isY=bM*isX+bB;
    }
    else if((lineBx2-lineBx1)==0)
    {
      isX=lineBx1;
      aM=(lineAy2-lineAy1)/(lineAx2-lineAx1);
      aB=lineAy2-aM*lineAx2;
      isY=aM*isX+aB;
    }
    else
    {
      aM=(lineAy2-lineAy1)/(lineAx2-lineAx1);
      bM=(lineBy2-lineBy1)/(lineBx2-lineBx1);
      aB=lineAy2-aM*lineAx2;
      bB=lineBy2-bM*lineBx2;
      isX=Math.max(((bB-aB)/(aM-bM)),0);
      isY=aM*isX+aB;
    }
    return isX;
  }
  // ------------------------------------------------------
  function getYIntersection(lineAx1,lineAy1,lineAx2,lineAy2,lineBx1,lineBy1,lineBx2,lineBy2)
  {
    var aM
    var bM
    var aB
    var bB
    var isX = 0
    var isY = 0
    if((lineAx2-lineAx1)==0)
    {
      isX=lineAx1;
      bM=(lineBy2-lineBy1)/(lineBx2-lineBx1);
      bB=lineBy2-bM*lineBx2;
      isY=bM*isX+bB;
    }
    else if((lineBx2-lineBx1)==0)
    {
      isX=lineBx1;
      aM=(lineAy2-lineAy1)/(lineAx2-lineAx1);
      aB=lineAy2-aM*lineAx2;
      isY=aM*isX+aB;
    }
    else
    {
      aM=(lineAy2-lineAy1)/(lineAx2-lineAx1);
      bM=(lineBy2-lineBy1)/(lineBx2-lineBx1);
      aB=lineAy2-aM*lineAx2;
      bB=lineBy2-bM*lineBx2;
      isX=Math.max(((bB-aB)/(aM-bM)),0);
      isY=aM*isX+aB;
    }
    return isY;
  }
  // ------------------------------------------------------
  function initValues()
  {
      redraw();
      setStandardValues();
      _base_hub_x = round(hubX());
      _base_hub_y = round(hubY());
      generateLink();
  }
  // ------------------------------------------------------
  function DrawLinHor( container, name, x, y, size, color)
  {
    if (x>=0 && y>=0 && size>0)
    {
      if(!_vmlEnabled)
      {
	      var line = document.createElement("div");
	      line.setAttribute("name",name);
	      line.style.position = "absolute";
	      line.style.top = parseInt(y)+"px";
	      line.style.left = parseInt(x)+"px";
	      line.style.width = parseInt(size)+"px";
	      line.style.height = "1px";
	      line.style.backgroundColor = color;
	      line.style.zIndex = 0;
	      container.appendChild(line);
	  }
	  else
	  {
	    var line  = document.createElement('<v:line>');
        line.from = x + "," + y;
        line.to   = size + "," + 1;
        line.strokeColor = color;
        line.strokeWeight='2';
        container.appendChild(line);
	  }
    }
  }
  // ------------------------------------------------------
  function DrawLinVert( container, name, x, y, size, color)
  {
    if (x>=0 && y>=0 && size>0)
    {
      if(!_vmlEnabled)
      {
        var line = document.createElement("div");
        line.setAttribute("name",name);
        line.style.position = "absolute";
        line.style.top = parseInt(y)+"px";
        line.style.left = parseInt(x)+"px";
        line.style.width = "1px";
        line.style.height = parseInt(size)+"px";
        line.style.backgroundColor = color;
        line.style.zIndex = 0;
        container.appendChild(line);
	  }
	  else
	  {
	    var line  = document.createElement('<v:line>');
        line.from = x + "," + y;
        line.to   = 1 + "," + size;
        line.strokeColor = color;
        line.strokeWeight='2';
        container.appendChild(line);
      }
    }
  }
  // ------------------------------------------------------
  function DrawLine( container, name, x1, y1, x2, y2, color )
  {
    var con = document.getElementById(container);
    if(_vmlEnabled)
    {
      var line = document.getElementById(name);
      if(line)
      {
        line.from = x1 + "," + y1;
        line.to   = x2 + "," + y2;
        line.strokeColor = color;
        line.strokeWeight='2';
        line.style.position = "absolute";
      }
      else
      {
	    line  = document.createElement('<v:line>');
        line.from = x1 + "," + y1;
        line.to   = x2 + "," + y2;
        line.strokeColor = color;
        line.strokeWeight='2';
        line.id = name;
        line.style.position = "absolute";
        con.appendChild(line);
      }
    }
    else
    {
		// remove existing
		var objs = document.getElementsByName(name);
		for(var i=objs.length-1; i>-1;i--) con.removeChild(objs[i]);
		// recreate
		deltax=Math.abs(x2-x1);
		deltay=Math.abs(y2-y1);
		if (deltax>=deltay)
		{
		  if (y2<y1)
		  {
			help=x1;
			x1=x2;
			x2=help;
			help=y1;
			y1=y2;
			y2=help;
		  }
		  deltax=x2-x1;
		  deltay=y2-y1;
		  dstep=deltax/(deltay+1);
		  x=x1;
		  if (dstep<0)
		  {
			x=x+dstep;
		  }
		  for (y=y1;y<=y2;y++)
		  {
			size=((x+dstep)-(x));
			if (dstep<0)
			{
			  DrawLinHor( con, name, (x)-(dstep)+(size),(y),Math.abs(size),color );
			}
			else
			{
			  DrawLinHor( con, name, (x),(y),Math.abs(size),color );
			}
			x=x+dstep;
		  }
		}
		else
		{
		  if (x2<x1)
		  {
			help=x1;
			x1=x2;
			x2=help;
			help=y1;
			y1=y2;
			y2=help;
		  }
		  deltax=x2-x1;
		  deltay=y2-y1;
		  dstep=deltay/(deltax+1);
		  y=y1;
		  if (dstep<0)
		  {
			y=y+dstep;
		  }
		  for (x=x1;x<=x2;x++)
		  {
			size=((y+dstep)-(y))
			if (dstep<0)
			{
			  DrawLinVert( con, name, (x),(y)-(dstep)+(size),Math.abs(size),color );
			}
			else
			{
			  DrawLinVert( con, name, (x),(y),Math.abs(size),color );
			}
			y=y+dstep;
		  }
		}
    }
  }