function Range(oValues,iIndexValue,iDistance,id,sInputID,sID,iWidth) {

	var This = this;
	this.onRelease = null;
	this.oValues = oValues;
	this.iIndexValue = iIndexValue || 0;
	this.sID = sID || null;
	this.iWidth = iWidth || 108;
	this.iDistance = iDistance || 1;
	this.iArrowWidth = 9;
	this.iID = id;
	this.iDeskWidth = 0;
	this.iMarginLeft = Math.floor(this.iArrowWidth/2);
	this.sInputID = sInputID;
	this.iFirstIndex = this.iIndexValue;
	this.iFirstDistance = this.iDistance;
	this.iLastIndex = iIndexValue;
	this.iLastDistance = iDistance;
	this.onchange = null;
	this.bDisposed = false;

	this.Dispose = function() {

		this.bDisposed = true;
		var sCode = "";

		sCode += "<div id=\""+this.iID+"\" class=\"Range\" style=\"width:"+(this.iWidth)+"px\">";
			sCode += "<div class=\"range-left\"></div>";

				var iContentWidth = this.iWidth - (7*2);
				this.iDeskWidth = Math.floor((iContentWidth - (this.iArrowWidth - 1)) / (This.oValues.aVisual.length - 1)*1);

				sCode += "<div class=\"range-content\" style=\"width:"+(iContentWidth)+"px;\">";
				sCode += "<div class=\"range-arrow\" id=\""+this.iID+"_range-arrow1\"></div><div class=\"range-arrow\" id=\""+this.iID+"_range-arrow2\"></div>";
				sCode += "<div class=\"range-content-active\" id=\""+this.iID+"_range-activecontent\"></div>";
				
					for (var i=0;i<This.oValues.aVisual.length;i++) {
						sCode += "<div class=\"range-value\" style=\"margin-left:"+(this.iMarginLeft + i*this.iDeskWidth)+"px\">";
							sCode += "<span class=\"rval\">"+ This.oValues.aVisual[i] + "</span>";
						sCode += "</div>";
					}

				sCode += "</div>";
			sCode += "<div class=\"range-right\"></div>";
		sCode += "</div>";

		if (this.sID)
			document.getElementById(this.sID).innerHTML = sCode;
		else
			document.write(sCode);

		oSpans = document.getElementById(this.iID).getElementsByTagName("SPAN");
		for (var i=0;i<oSpans.length;i++)
			oSpans[i].style.marginLeft = (oSpans[i].offsetWidth/2)*-1 + "px";

		
		document.getElementById(this.iID+"_range-arrow1").onmousedown = function() {
			This.down(This.iID,true);
			return false;
		}

		document.getElementById(this.iID+"_range-arrow2").onmousedown = function() {
			This.down(This.iID,false);
			return false;
		}

		this.update();
	}

	this.SetRange =  function(iIndex,iDistance) {
		This.iLastIndex =  This.iIndexValue;
		This.iLastDistance = This.iDistance;

							
		This.iIndexValue = iIndex;
		This.iDistance = iDistance;
		This.update();

	}


	this.down = function(sID,bFirstArrow) {

		if (This.onRelease) {
			document.body.style.cursor = document.getElementById(sID+"_range-arrow1").style.cursor = document.getElementById(sID+"_range-arrow2").style.cursor = "e-resize";
		}

		document.body.onselectstart = function() {
			return false;
		}
		document.body.onmousemove = function() {
			var ev = Browser.IE ? event : arguments[0];
			

			oSpans = document.getElementById(sID).getElementsByTagName("SPAN");
			
			for (var i=0;i<oSpans.length;i++) {
				if (ev.clientX > (getLeft(oSpans[i],Browser.IE) - (This.iDeskWidth/2)) && ev.clientX < (getLeft(oSpans[i],Browser.IE) + (This.iDeskWidth/2)))
				{

					This.iLastIndex =  This.iIndexValue;
					This.iLastDistance = This.iDistance;

					if (bFirstArrow) {
						if ((This.iDistance + (This.iIndexValue - i)) > 0)
						{
							This.iDistance += (This.iIndexValue - i);
							This.iIndexValue = i;
						}
					} else {
						if (i > This.iIndexValue)
						{
							This.iDistance = i - This.iIndexValue;
						}
					}

					This.update();
					if (This.onchange && (This.iLastIndex != This.iIndexValue || This.iLastDistance != This.iDistance))
						This.onchange();

					break;
				}
			}
		}

		document.body.onmouseup = function() {
			document.body.onselectstart = function() {
				return true;
			}
			document.body.onmousemove = null;
			document.body.onmouseup = null;
			if (This.onRelease) {
				This.onRelease();
				document.getElementById(sID+"_range-arrow1").style.cursor = document.getElementById(sID+"_range-arrow2").style.cursor = "pointer";
				document.body.style.cursor = "default";
			}
		}
	}
	
	this.update = function() {
		if (This.bDisposed)
		{
			document.getElementById(this.iID+"_range-arrow1").style.marginLeft = (this.iIndexValue * this.iDeskWidth) + "px";
			document.getElementById(this.iID+"_range-arrow2").style.marginLeft = ((this.iIndexValue + this.iDistance) * this.iDeskWidth) + "px";
			document.getElementById(this.iID+"_range-activecontent").style.marginLeft = (this.iIndexValue * this.iDeskWidth + this.iMarginLeft) + "px";
			document.getElementById(this.iID+"_range-activecontent").style.width = (((this.iIndexValue + this.iDistance) * this.iDeskWidth) -  (this.iIndexValue * this.iDeskWidth)) + "px"; //(document.getElementById(this.iID+"_range-arrow2").offsetLeft - document.getElementById(this.iID+"_range-arrow1").offsetLeft) + "px";
			document.getElementById(this.sInputID).value = this.oValues.aValues[this.iIndexValue] + "-" + this.oValues.aValues[this.iIndexValue+this.iDistance];
		}

	}

	this.Reset = function() {
		this.iIndexValue = this.iFirstIndex;
		this.iDistance = this.iFirstDistance;
		This.update();
	}

}