document.onmousedown=dragLayer
document.onmouseup=new Function("dragMe=false")

var dragMe=false, kObj, yPos,direction

function dragLayer() 
{
if (event.srcElement.className=="drag")
		{
		dragMe=true;
		kObj=event.srcElement;
		temp2=kObj.style.pixelLeft;
		yPos=event.clientX; 
		document.onmousemove=moveLayer;/////////////////***movelayer()***///////////////////////		
		}
}

function moveLayer() 
{
if (event.button==1 && dragMe)
	{
	oldX = event.srcElement.style.pixelLeft;
	kObj.style.pixelLeft=temp2+event.clientX-yPos; 		
	if (kObj.style.pixelLeft > oldX) direction="lft"; else direction="rht";
	if (kObj.style.pixelLeft < 2 && direction=="rht"){kObj.style.pixelLeft=2; direction="lft";}
	if (kObj.style.pixelLeft > 522 && direction=="lft"){kObj.style.pixelLeft=522; direction="rht";}
	x=kObj.style.pixelLeft;
	//x=x-2;//making x as 0 - 520
	
i=Math.ceil(x/20)
//document.form1.textfield.value=x+"\n"+i //for checking perposes

	mywrk(i-1); 
	return false; 
	}
}

function moveByButton(lrb)
{

var chk=parseInt(document.knobImg2.style.pixelLeft)
if(chk%20!=0)
	{
	chk=chk-chk%20+1;
	document.knobImg2.style.pixelLeft=chk
	}

	chk=chk+lrb
	
	if(chk>=522){chk=521}
	else if(chk<=2){chk=2}
	document.knobImg2.style.pixelLeft=chk

	xx=parseInt(document.knobImg2.style.pixelLeft)
	ii=Math.ceil(xx/20)
	//document.form1.textfield.value=xx+"\n"+ii //for checking perposes
	

mywrk(ii-1)
}










