/**
 * @author Administrator
 */
 var UIVSlider = function()
 {
 this.initialize.apply(this,arguments);
 }
 
 UIVSlider.prototype = 
 {
 oTarget : null,
 oSliderbut : null,
 oSliderback : null,
 bActive: false,
 iWidth: 20,
 iHeight: 100,
 iMax:100,
 iMin:0,
 dFactor:0,
 iDelta:0,
 iOffsetX:0,
 iSliderHeight: 6,
 onSliderUp:null,
 onSliderMove:null,
 Value:null,
 initialize: function(oTarget,oInput,oOptions)
 {
 for(sOption in oOptions)
 {
 if(this[sOption]!=undefined || this[sOption]==null)
 {
 this[sOption] = oOptions[sOption];
 
 
 }
 }
 
 this.oTarget = oInput;
 
 this.oSliderback = document.createElement('div');
 this.oSliderback.className = 'vsliderback';
 this.oSliderback.style.height = this.iHeight+'px';
 this.oSliderback.style.width = this.iWidth+'px';
 
 this.oSliderbut = document.createElement('div');
 this.oSliderbut.className = 'vsliderbut';
 this.oSliderbut.style.width = this.iWidth+'px';
 this.oSliderbut.style.height = this.iSliderHeight+'px';
 
 this.iDelta = (this.iMax - this.iMin);
 
 this.oSliderback.appendChild(this.oSliderbut)
 
 oTarget.appendChild(this.oSliderback)
 var oThis = this;
 this.oSliderbut.onmousedown = function(event)
 {
 oThis.sliderDown(event);
 }
 this.oSliderbut.onmouseup = function()
 {
 oThis.sliderUp();
 }
 
 this.oSliderback.onmousemove = function(event)
 {
 oThis.sliderMove(event);
 }
 this.oSliderback.onmouseup = function()
 {
 oThis.sliderUp();
 }
 
 }
 
 ,
 sliderMove: function (event)
 {
 if(!event) event = window.event;
 if(this.bActive)
 {
 var iMouseY = (event.screenY - (this.oSliderback.offsetTop+this.iOffsetY));
 
 if(this.iStepSize!=null)
 {
 iSliderY = Math.round(iMouseY / this.iStepSize) *this.iStepSize ; 
 }
 else{
 iSliderY = (event.screenY - (this.oSliderback.offsetTop+this.iOffsetY));
 }
 if(iSliderY<0)
 {
 iSliderY = 0;
 }
 if(iSliderY > (this.iHeight))
 {
 iSliderY = (this.iHeight);
 }
 
 
 this.oSliderbut.style.top = iSliderY + 'px';
 var iVal = this.iMin + Math.ceil(this.dFactor * iSliderY);
 this.Value = iVal;
 if(this.oTarget!=null)
 {
 this.oTarget.value = iVal;
 }
 
 if(this.onSliderMove!=null)
 {
 this.onSliderMove.apply(this,[this]);
 }
 
 }
 
 }
 ,
 sliderDown:function(event)
 {
 if(!event) event = window.event;
 this.iOffsetY = event.screenY - (this.oSliderback.offsetTop + this.oSliderbut.offsetTop);
 
 this.dFactor = this.iDelta/(this.iHeight);
 
 this.bActive = true;
 }
 ,
 sliderUp:function()
 {
 if(this.bActive==true && this.onSliderUp!=null)
 {
 this.onSliderUp.apply(this,[this]);
 }
 this.bActive=false;
 }
 
 }
 var UISlider = function()
 {
 this.initialize.apply(this,arguments);
 }
 
 UISlider.prototype = 
 {
 oTarget : null,
 oInput : null,
 oSliderbut : null,
 oSliderback : null,
 oSliderFill : null,
 bActive: false,
 iWidth: 100,
 iHeight: 20,
 iMax:100,
 iMin:0,
 iSteps:null,
 iStepSize:1,
 iValue: null,
 iPrecision: null,
 dFactor:0,
 iDelta:0,
 iOffsetX:0,
 iSliderWidth: 6,
 iSliderX:0,
 bEnabled: true, 
 onSliderUp:null,
 onSliderMove:null,
 Value:null,
 initialize: function(oTarget,oInput,oOptions)
 {
 for(sOption in oOptions)
 {
 if(this[sOption]!=undefined || this[sOption]==null)
 {
 this[sOption] = oOptions[sOption];
 
 
 }
 }
 
 this.oInput = oInput;
 
 this.oSliderback = document.createElement('div');
 this.oSliderback.className = 'sliderback';
 this.oSliderback.style.height = this.iHeight+'px';
 this.oSliderback.style.width = this.iWidth+'px';
 
 this.oSliderFill = document.createElement('div');
 this.oSliderFill.className = 'sliderfill';
 this.oSliderFill.style.height = this.iHeight+'px';
 this.oSliderFill.style.width ='1px';
 this.oSliderbut = document.createElement('div');
 this.oSliderbut.className = 'sliderbut';
 this.oSliderbut.style.width = this.iSliderWidth+'px';
 this.oSliderbut.style.height = this.iHeight+'px';
 
 this.oSliderback.appendChild(this.oSliderFill);
 this.oSliderback.appendChild(this.oSliderbut);
 
 this.iDelta = (this.iMax - this.iMin);
 if(this.iSteps!=null)
 {
 this.iStepSize = this.iDelta/this.iSteps;
 }
 
 
 oTarget.appendChild(this.oSliderback)
 var oThis = this;
 this.oSliderbut.onmousedown = function(event)
 {
 oThis.sliderDown(event);
 }
 this.oSliderbut.onmouseup = function()
 {
 oThis.sliderUp();
 }
 
 oTarget.onmousemove = function(event)
 {
 oThis.sliderMove(event);
 }
 oTarget.onmouseup = function()
 {
 oThis.sliderUp();
 }
 
 if(this.iValue != null && oInput!=null)
 {
 oInput.value = this.iValue.toString().replace('.',',');
 this.updatePosition();
 }
 
 if(oInput !=null)
 {
 this.oInput.oSlider = oThis;
 this.oInput.onchange = this.inputChanged;
 }
 
 }
 ,
 inputChanged:function()
 {
 
 if(this.value > this.oSlider.iMax)
 {
 this.value = this.oSlider.iMax; 
 }
 
 if(this.value < this.oSlider.iMin)
 {
 this.value = this.oSlider.iMin; 
 }
 
 this.oSlider.iValue = this.value;
 this.oSlider.updatePosition(); 
 }
 ,
 sliderMove: function (event)
 {
 if(!event) event = window.event;
 if(this.bActive)
 {
 var iMouseX = (event.screenX - (this.oSliderback.offsetLeft+this.iOffsetX));
 
 if(this.iStepSize!=null)
 {
 iSliderX = Math.round(iMouseX);
 }
 else{
 iSliderX = (event.screenX - (this.oSliderback.offsetLeft+this.iOffsetX));
 }
 
 if(iSliderX<0)
 {
 iSliderX = 0;
 }
 if(iSliderX > (this.iWidth))
 {
 iSliderX = (this.iWidth);
 }
 
 this.iSliderX = iSliderX;
 
 this.oSliderbut.style.left = iSliderX + 'px';
 this.oSliderFill.style.width = iSliderX + 'px';
 
 
 var iVal = this.iMin + Math.ceil(this.dFactor * iSliderX)*this.iStepSize;
 if(this.iPrecision!=null)
 {
 iVal = iVal.toPrecision(this.iPrecision);
 }
 this.Value = iVal;
 if(this.oInput!=null)
 {
 this.oInput.value = iVal.toString().replace('.',',');
 }
 
 if(this.onSliderMove!=null)
 {
 this.onSliderMove.apply(this,[this]);
 }
 
 }
 
 }
 ,
 updatePosition: function ()
 {
 this.dFactor = (this.iDelta/this.iWidth)/this.iStepSize;
 iSliderX = ((this.iValue-this.iMin)/(this.iStepSize*this.dFactor));
 //alert(this.iValue);
 this.oSliderbut.style.left = iSliderX + 'px';
 this.oSliderFill.style.width = iSliderX + 'px';
 
 }
 ,
 sliderDown:function(event)
 {
 if(this.bEnabled)
 {
 if(!event) event = window.event;
 this.iOffsetX = event.screenX - (this.oSliderback.offsetLeft + this.oSliderbut.offsetLeft);
 this.dFactor = (this.iDelta/this.iWidth)/this.iStepSize;
 
 
 this.bActive = true;
 }
 }
 ,
 sliderUp:function()
 {
 if(this.bActive==true && this.onSliderUp!=null)
 {
 this.onSliderUp.apply(this,[this]);
 }
 this.bActive=false;
 }
 
 }
 
 var sActiveTooltip=null;
 
 function showTooltip(sName,sText)
 {
 document.getElementById(sName+'_container').style.display = 'block';
 document.getElementById(sName+'_content').innerHTML = sText;
 sActiveTooltip = sName;
 }
 
 function hideTooltip()
 {
 if(sActiveTooltip!=null)
 {
 document.getElementById(sActiveTooltip+'_container').style.display = 'none';
 }
 }