// JavaScript Document

	
/*
	var iceDrag={
		mX:0,mY:0,
		actObj:null,actScr:null,actScrCo:null,actType:0,actNum:0,
		scrList:[],
		x:0,x_off:0,x_min:0,x_max:0,
		y:0,y_off:0,y_min:0,y_max:0,
		z:0,off:0,
		mouseMoveOld:null,mouseMoveAction:null,mouseMoveUp:null,
		parentOut:"",parentMoveOut:0,parentHide:null,
		init:function(){
			if(document.onmousemove!=null){
				iceDrag.mouseMoveOld=document.onmousemove;
			}
			document.onmousemove=iceDrag.mouseMoveXY;
		},
		mouseMoveXY:function(e){
			iceDrag.mX=(e) ? e.pageX : event.clientX;
			iceDrag.mY=(e) ? e.pageY : event.clientY;
			if(iceDrag.actObj!=null){iceDrag.objDrag();}
			if(iceDrag.mouseMoveOld!=null){iceDrag.mouseMoveOld();}
		},
		newScr:function(pWidth,pStepCnt,pValMin,pValMax){
			var aMax=iceDrag.scrList.length;
			iceDrag.scrList.push(new iceDragSlider());
			var aScr=iceDrag.scrList[aMax];
			aScr.scrNum=aMax;
			aScr.scrWidth=pWidth;
			aScr.scrCount=pStepCnt;
			aScr.scrMin.val=pValMin;
			aScr.scrMax.val=pValMax;
			aScr.init();
			return aScr;
		},
		newScrFromArray:function(pWidth,pArray,pValMin,pValMax){
			pArray = window[pArray];
			var pStepCnt = pArray.length;
			var pValStepMin = 0;
			var pValStepMax = pStepCnt;
			
			
			for(i=0;i<pArray.length;i++){
				if(pArray[i][0]==pValMin)pValStepMin=i;
				else 
					if (pArray[i][0]==pValMax)pValStepMax=i;
			}
			var newABox = iceDrag.newScr(pWidth,pStepCnt,pValStepMin,pValStepMax);
			newABox.scrValueArray=pArray;
			return newABox;
		},
		objDrag:function(){
			var newX=(iceDrag.x_off+iceDrag.mX-iceDrag.x);
			if(newX<iceDrag.x_min){newX=iceDrag.x_min;}
			if(newX>iceDrag.x_max){newX=iceDrag.x_max;}
			if(iceDrag.actScr.scrStepBy==1){
				newX=iceDrag.getVal(newX)*iceDrag.actScr.scrStep;
			}
			iceDrag.actScrCo.x=newX;
			iceDrag.actScrCo.val=iceDrag.getVal(newX);
			iceDrag.actObj.style.left=newX+"px";
			iceDrag.actScr.setMid();
			if(iceDrag.actScr.scrFunctionOnMove==1){
				iceDrag.callFunction();
			}
//			showInfo(iceDrag.actScr.scrMin.val+" : "+iceDrag.actScr.scrMax.val);
		},
		parentMouseOut:function(){
			iceDrag.parentMoveOut=1;
		},
		getVal:function(pX){
			return Math.round(pX/iceDrag.actScr.scrStep);
		},
		getX:function(pVal){
			return pVal*iceDrag.actScr.scrStep;
		},
		callFunction:function(){
			if(iceDrag.actScr.scrFunction!=null){
				//eval(aTxt);
				
				var k1 = "";
				var v1 = "";
				var k2 = "";
				var v2 = "";
				if(iceDrag.actScr.scrValueArray){
					if(iceDrag.actScr.scrMin.val>0){
						k1=iceDrag.actScr.scrValueArray[iceDrag.actScr.scrMin.val][0];
						v1=iceDrag.actScr.scrValueArray[iceDrag.actScr.scrMin.val][1];
					}
					if(iceDrag.actScr.scrMax.val<iceDrag.actScr.scrValueArray.length){
						k2=iceDrag.actScr.scrValueArray[iceDrag.actScr.scrMax.val][0];
						v2=iceDrag.actScr.scrValueArray[iceDrag.actScr.scrMax.val][1];
					}
				}
				iceDrag.actScr.scrFunction(k1,v1,k2,v2,iceDrag.actScr.scrSliderId);
			}
		},


		moveStart:function(pScrNum,pType){
			var newX=0;
			iceDrag.actNum=pScrNum;
			iceDrag.actType=pType;
			iceDrag.actScr=iceDrag.scrList[pScrNum];
			if(iceDrag.actType==1){
				iceDrag.actScrCo=iceDrag.actScr.scrMin;
				iceDrag.actObj=iceDrag.actScr.scrMin.obj;
				iceDrag.actScr.scrMax.val==iceDrag.actScr.scrCount? newX=iceDrag.getX(iceDrag.actScr.scrCount-1):newX=iceDrag.actScr.scrMax.x;
				if(iceDrag.actScr.scrMax.act==0){newX=iceDrag.actScr.scrMax.x;}
				iceDrag.x_max=newX;
				iceDrag.x_min=iceDrag.actScrCo.min;
			}
			if(iceDrag.actType==2){
				iceDrag.actScrCo=iceDrag.actScr.scrMax;
				iceDrag.actObj=iceDrag.actScr.scrMax.obj;
				iceDrag.actScr.scrMin.val==0? newX=iceDrag.getX(1):newX=iceDrag.actScr.scrMin.x;
				if(iceDrag.actScr.scrMin.act==0){newX=0;}
				iceDrag.x_min=newX;
				iceDrag.x_max=iceDrag.actScrCo.max;
			}
			if(iceDrag.actObj==null){return false;}
			iceDrag.parentMoveOut=0;
			iceDrag.parentOut=iceDrag.actScr.scrParent.onmouseout;
			iceDrag.actScr.scrParent.onmouseout=iceDrag.parentMouseOut;
			iceDrag.z=iceDrag.actObj.style.zIndex;
			iceDrag.actObj.style.zIndex=10000;
			iceDrag.actObj.style.backgroundPosition="bottom";
			iceDrag.x=iceDrag.mX;
			iceDrag.x_off=parseInt(iceDrag.actObj.style.left);
			iceDrag.y=iceDrag.mY;
			iceDrag.y_off=parseInt(iceDrag.actObj.style.top);
			iceDrag.mouseMoveAction=this.mouseMove;
			document.body.focus();
			document.onselectstart = function () { return false; };
			iceDrag.actObj.ondragstart = function() { return false; };
			iceDrag.mouseMoveUp=document.onmouseup;
			document.onmouseup=iceDrag.moveEnd;
			document.body.style.cursor="w-resize";
			
		},
		moveEnd:function(){
			if(iceDrag.actObj==null){return false;}
			document.body.style.cursor="";
			document.onmouseup=iceDrag.mouseMoveUp;
			iceDrag.actObj.style.zIndex=iceDrag.z;
			iceDrag.actScr.setImages();
			if(this.scrStepMag==1){
				iceDrag.actScrCo.x=iceDrag.actScrCo.val*iceDrag.actScr.scrStep;
				iceDrag.actObj.style.left=iceDrag.actScrCo.x+"px";
			}
			iceDrag.actScr.setMid();
			iceDrag.actObj=null;
			iceDrag.actScr.scrParent.onmouseout=iceDrag.parentOut;
			if(iceDrag.parentMoveOut==1&&iceDrag.parentOut!=null){
				iceDrag.parentOut();
			}
			iceDrag.callFunction();
		},
		initSliders:function(){
			var colect=$$('#searchformcont div.slider');
			
			
			colect.each(function(obj){
				var arrayName = "";
				var lowVal="";
				var highVal="";
				var colect2=$$('#'+obj.id+' input');
				//for(var j=0;j<colect2.length;j++){
				$$('#'+obj.id+' input').each(function(obj2){
					//var obj2 = colect2[j];
					switch (obj2.className) {
					case 'jsarray':
						arrayName=obj2.value;
						break;
					case 'lowval':
						lowVal=obj2.value;
						break;
					case 'highval':
						highVal=obj2.value;
						break;
					default:
						break;
					}
				});
				var aBox=iceDrag.newScrFromArray(200,arrayName,lowVal,highVal);
				
				
				aBox.scrFunctionOnMove=1;
				//aBox.scrFunction="writeVal('$k1','$v1','$k2','$v2','"+obj.id+"')";
				aBox.scrFunction=writeVal;
				aBox.scrSliderId=obj.id;
				aBox.generateHTML(obj.id);
				//alert(i+"konec");
				iceDrag.actScr=aBox;
				iceDrag.callFunction();
				
			});
		}
	};
	
	
	function iceDragSlider()
	{
		this.scrNum=0;
		this.scrMin={act:1,obj:null,ind:1,x:0, val:0, min:0, max:0, width:16,height:16,img:"/xchanger/cars/img/iceSliderMin.png"	};
		this.scrMax={act:1,obj:null,ind:2,x:0,	val:0, min:0, max:0, width:16,height:16,img:"/xchanger/cars/img/iceSliderMax.png" };
		this.scrMid={act:1,obj:null,height:16};
		this.scrLine={act:1,obj:null,height:16};
		this.scrObj=null;
		this.scrStep=0;
		this.scrStepBy=1;
		this.scrStepMag=1;
		this.scrCount=10;
		this.scrWidth=200;
		this.scrHeight=16;
		this.scrParent=null;
		this.scrFunction=null;
		this.scrSliderId="";
		this.scrFunctionOnMove=0;
		this.scrValueArray = null;

		this.init=function(){
			this.scrStep=(this.scrWidth-this.scrMin.width)/this.scrCount;
			if(this.scrMax.val==-1){
				this.scrMax.val=this.scrCount;
				this.scrMax.act=0;
				this.scrMid.act=0;
			}
			if(this.scrMin.val==-1){
				this.scrMin.val=0;
				this.scrMin.act=0;
				this.scrMid.act=0;
			}
			this.scrMin.x=this.scrMin.val*this.scrStep;
			this.scrMax.x=this.scrMax.val*this.scrStep;
			this.scrMin.min=0;
			this.scrMin.max=this.scrWidth-this.scrMin.width;
			this.scrMax.min=0;
			this.scrMax.max=this.scrWidth-this.scrMax.width;
		};
		
		this.setImages=function(){
			if(this.scrMin.act==1){
				this.scrMin.val==0?nPos="center center":nPos="center top";
				if(this.scrMax.act==0){nPos="center top";}
				this.scrMin.obj.style.backgroundPosition=nPos;
			}
			if(this.scrMax.act==1){
				this.scrMax.val==this.scrCount?nPos="center center":nPos="center top";
				if(this.scrMin.act==0){nPos="center top";}
				this.scrMax.obj.style.backgroundPosition=nPos;
			}
		};
		this.setMid=function()
		{
			if(this.scrMid.act==0){return false;}
			var aMid=this.scrMid.obj;
			aMid.style.left=(this.scrMin.x+(this.scrMin.width/2))+"px";
			aMid.style.width=(this.scrMax.x-this.scrMin.x)+"px";
		};

		this.generateHTML=function(aObjID){
			var aObj=document.getElementById(aObjID);
			if(aObj==null){return false;}
			var aID=this.scrNum;
			var xMin=this.scrMin.x;
			var xMax=this.scrMax.x;
			var newY=0;
			this.scrObj=document.createElement("div");
			this.scrObj.setAttribute("id","iceDragBox"+aID);
			this.scrObj.setAttribute("class","iceSliderBox");
			this.scrObj.style.width=this.scrWidth+"px";
			this.scrObj.style.height=this.scrHeight+"px";
			this.scrObj.style.display="none";

			if(this.scrMin.act==1){
				this.scrMin.obj=document.createElement("div");
				this.scrMin.obj.setAttribute("class","iceSliderArrow");
				this.scrMin.obj.setAttribute("onmousedown","iceDrag.moveStart("+aID+",1);");
				this.scrMin.obj.style.left=xMin+"px";
				this.scrMin.obj.style.top="0px";
				this.scrMin.obj.style.backgroundImage="url("+this.scrMin.img+")";
				this.scrObj.appendChild(this.scrMin.obj);
				newY-=this.scrMin.height;
			}

			if(this.scrMax.act==1){
				this.scrMax.obj=document.createElement("div");
				this.scrMax.obj.setAttribute("class","iceSliderArrow");
				this.scrMax.obj.setAttribute("onmousedown","iceDrag.moveStart("+aID+",2);");
				this.scrMax.obj.style.left=xMax+"px";
				this.scrMax.obj.style.top=newY+"px";
				this.scrMax.obj.style.backgroundImage="url("+this.scrMax.img+")";
				this.scrObj.appendChild(this.scrMax.obj);
				newY-=this.scrMax.height;
			}

			if(this.scrMid.act==1){
				this.scrMid.obj=document.createElement("div");
				this.scrMid.obj.setAttribute("class","iceSliderMid");
				this.scrMid.obj.style.left=(xMin+(this.scrMin.width/2))+"px";
				this.scrMid.obj.style.top=Math.round(newY)+"px";
				this.scrMid.obj.style.width=xMax+"px";
				this.scrObj.appendChild(this.scrMid.obj);
				newY-=this.scrMid.height;
			}

			if(this.scrLine.act==1){
				this.scrLine.obj=document.createElement("div");
				this.scrLine.obj.setAttribute("class","iceSliderLine");
				this.scrLine.obj.style.top=Math.round(newY)+"px";
				this.scrObj.appendChild(this.scrLine.obj);
				newY-=this.scrMid.height;
			}
			
//			document.body.appendChild(this.scrObj);
			aObj.appendChild(this.scrObj);
			this.scrParent=aObj;
			
			this.setImages();
			this.setMid();
			this.scrObj.style.display="";
		};
	}
	
	function writeVal(pK1,pV1,pK2,pV2,objId){
		var labelId = objId.replace('_flashBar','_label');
		var lowVal = ""; 
		var highVal = "";
		var valueType = "";
		
		$$('#'+objId+' input.lowval').each(function(obj){lowVal = obj;});
		$$('#'+objId+' .highval').each(function(obj){highVal = obj;});
		$$('#'+objId+' .valuetype').each(function(obj){valueType = obj.getValue();});

		pV1=(pV1.length>0)?("od: "+pV1+valueType):("");
		pV2=(pV2.length>0)?("do: "+pV2+valueType):("");
		if($(labelId))$(labelId).update(pV1+" "+pV2);
		if($(lowVal))$(lowVal).value=pK1;
		if($(highVal))$(highVal).value=pK2;
	}
	
	document.observe('dom:loaded', iceDrag.init);
*/
