/* Copyright © 2008 Deep Web Technologies, Inc.  All rights reserved. */

function hookEvent(B,A,C){if(typeof (B)=="string"){B=document.getElementById(B);}if(B===null){return ;}if(B.addEventListener){B.addEventListener(A,C,false);}else{if(B.attachEvent){B.attachEvent("on"+A,C);}}}function unhookEvent(B,A,C){if(typeof (B)=="string"){B=document.getElementById(B);}if(B===null){return ;}if(B.removeEventListener){B.removeEventListener(A,C,false);}else{if(B.detachEvent){B.detachEvent("on"+A,C);}}}function getEventTarget(A){A=A?A:window.event;return A.target?A.target:A.srcElement;}function cancelEvent(A){A=A?A:window.event;if(A.stopPropagation){A.stopPropagation();}if(A.preventDefault){A.preventDefault();}A.cancelBubble=true;A.cancel=true;A.returnValue=false;return false;}function SpinControlAcceleration(A,B){A=parseFloat(A);if(isNaN(A)||A<0){A=0;}B=parseInt(B,10);if(isNaN(B)||B<0){B=0;}this.GetIncrement=function(){return A;};this.GetMilliseconds=function(){return B;};}function SpinControlAccelerationCollection(){var A=[];this.GetCount=function(){return A.length;};this.GetIndex=function(B){if(B<0||B>=A.length){return null;}return A[B];};this.RemoveIndex=function(B){if(B<0||B>=A.length){return ;}newArray=[];for(var C=0;C<A.length;C++){if(C==B){continue;}newArray.push(A[C]);}A=newArray;};this.Clear=function(){A=[];};this.Add=function(F){if(F.constructor!=SpinControlAcceleration){return ;}if(A.length===0){A.push(F);return ;}var G=F.GetMilliseconds();if(G>A[A.length-1].GetMilliseconds()){A.push(F);return ;}var E=false;var B=[];var C;for(var D=0;D<A.length;D++){if(E){B.push(A[D]);}else{C=A[D].GetMilliseconds();if(C<G){B.push(A[D]);}else{if(C==G){B.push(F);E=true;}else{B.push(A[D]);B.push(F);E=true;}}}}A=B;return ;};}function SpinControl(){var F=this;var Z=new SpinControlAccelerationCollection();var K=[];var g=1;var N=100;var m=0;var S=1;var D=50;var A=0;var U=-1;var C=0;var n=false;var Q=document.createElement("DIV");Q.className="spinContainer";Q.id="spinContainer";var H=document.createElement("DIV");H.className="spinLeftRightEdge";H.style.left="0px";var B=document.createElement("DIV");B.className="spinTopBottomEdge";B.style.top="19px";var R=document.createElement("DIV");R.className="spinTopBottomEdge";R.style.top="0px";var d=document.createElement("DIV");d.className="spinLeftRightEdge";d.style.right="0px";var T=document.createElement("INPUT");T.type="text";T.id="spinInput";T.className="spinInput";T.value=g;T.maxLength=7;var c=document.createElement("DIV");c.id="spinUpBtn";c.className="spinUpBtn";var l=document.createElement("DIV");l.id="spinDownBtn";l.className="spinDownBtn";var M=true;if(document.body.filters){var E=navigator.appVersion.split("MSIE");var h=parseFloat(E[1]);if(h<7){M=false;l.style.backgroundImage="url(spin_control_buttons.gif)";c.style.backgroundImage="url(spin_control_buttons.gif)";l.style.backgroundColor="#FFFFFF";c.style.backgroundColor="#FFFFFF";}}Q.appendChild(H);Q.appendChild(B);Q.appendChild(R);Q.appendChild(d);Q.appendChild(T);Q.appendChild(c);Q.appendChild(l);function I(){if(A===0){return ;}var o=new Date().getTime()-C;var q=S;if(Z.GetCount()!==0){q=0;for(var p=0;p<Z.GetCount();p++){if(o<Z.GetIndex(p).GetMilliseconds()){break;}q=Z.GetIndex(p).GetIncrement();}}else{if(o<600){return ;}}W(q);}function L(){A=0;if(U!=-1){clearInterval(U);U=-1;}}function W(p){var o=g+p*A;O(o);}function i(o){if(A!==0){L();}A=o;W(S);C=new Date().getTime();U=setInterval(I,150);}function O(o){if(o<m){o=m;}if(o>N){o=N;}o=Math.round(1000*o)/1000;T.value=o;if(o==g){return ;}g=o;for(var p=0;p<K.length;p++){K[p](F,g);}}function V(o){c.className="spinUpBtnPress";l.className="spinDownBtn";i(1);T.focus();return cancelEvent(o);}function f(o){c.className="spinUpBtn";l.className="spinDownBtnPress";i(-1);T.focus();return cancelEvent(o);}function G(o){if(!n){hookEvent(document.body,"mouseover",a);}c.className="spinUpBtnHover";l.className="spinDownBtn";L();return cancelEvent(o);}function P(o){if(!n){hookEvent(document.body,"mouseover",a);}c.className="spinUpBtn";l.className="spinDownBtnHover";L();return cancelEvent(o);}function a(p){var o=getEventTarget(p);if(o==c||o==l){return ;}c.className="spinUpBtn";l.className="spinDownBtn";L();if(n){unhookEvent(document.body,"mouseover",a);n=false;}return cancelEvent(p);}function Y(){var o=parseFloat(T.value);if(isNaN(o)){o=g;}O(o);}function k(p){p=p?p:window.event;var o=p.detail?p.detail/-1:p.wheelDelta;O(g+S*o);return cancelEvent(p);}function j(o){hookEvent(window,"DOMMouseScroll",k);hookEvent(document,"mousewheel",k);return cancelEvent(o);}function J(o){unhookEvent(window,"DOMMouseScroll",k);unhookEvent(document,"mousewheel",k);return cancelEvent(o);}function X(o){O(g+1);return cancelEvent(o);}function e(o){O(g-1);return cancelEvent(o);}function b(o){o=o?o:window.event;var p;switch(o.keyCode){case 38:X(o);break;case 40:e(o);break;case 8:case 9:case 13:case 27:break;default:p=String.fromCharCode(o.keyCode);if(("0123456789").indexOf(p)==-1){return cancelEvent(o);}}}this.StartListening=function(){hookEvent(c,"mousedown",V);hookEvent(c,"mouseup",G);hookEvent(c,"mouseover",G);hookEvent(l,"mousedown",f);hookEvent(l,"mouseup",P);hookEvent(l,"mouseover",P);hookEvent(T,"change",Y);hookEvent(T,"focus",j);hookEvent(T,"blur",J);hookEvent(T,"keydown",b);};this.StopListening=function(){unhookEvent(c,"mousedown",V);unhookEvent(c,"mouseup",G);unhookEvent(c,"mouseover",G);unhookEvent(l,"mousedown",f);unhookEvent(l,"mouseup",P);unhookEvent(l,"mouseover",P);unhookEvent(T,"change",Y);unhookEvent(T,"focus",j);unhookEvent(T,"blur",J);unhookEvent(T,"keydown",b);if(n){unhookEvent(document.body,"mouseover",a);n=false;}};this.SetMaxValue=function(o){o=parseFloat(o);if(isNaN(o)){o=1;}N=o;O(g);};this.SetMinValue=function(o){o=parseFloat(o);if(isNaN(o)){o=0;}m=o;O(g);};this.SetCurrentValue=function(o){o=parseFloat(o);if(isNaN(o)){o=0;}O(o);};this.SetWidth=function(o){o=parseInt(o,10);if(isNaN(o)||o<25){o=25;}D=o;Q.style.width=D+"px";B.style.width=(D-1)+"px";R.style.width=(D-1)+"px";T.style.width=(D-20)+"px";};this.SetIncrement=function(o){o=parseFloat(o);if(isNaN(o)){o=0;}if(o<0){o=-o;}S=o;};this.SetBackgroundColor=function(o){Q.style.backgroundColor=o;T.style.backgroundColor=o;};this.SetButtonColor=function(o){if(!M){return ;}c.style.backgroundColor=o;l.style.backgroundColor=o;};this.SetFontColor=function(o){T.style.color=o;};this.SetBorderColor=function(o){R.style.backgroundColor=o;B.style.backgroundColor=o;H.style.backgroundColor=o;d.style.backgroundColor=o;};this.AttachValueChangedListener=function(p){for(var o=0;o<K.length;o++){if(K[o]==p){return ;}}K.push(p);};this.DetachValueChangedListener=function(p){newArray=[];for(var o=0;o<K.length;o++){if(K[o]!=p){newArray.push(K[o]);}}K=newArray;};this.GetContainer=function(){return Q;};this.GetCurrentValue=function(){return g;};this.GetMaxValue=function(){return N;};this.GetMinValue=function(){return m;};this.GetWidth=function(){return D;};this.GetIncrement=function(){return S;};this.GetAccelerationCollection=function(){return Z;};F.SetWidth(D);}