window.onload = Laduj;
var timer				= null;
var active_id 			= ""; 
var d 					= document;
var click_pos_x			= 0;
var click_pos_y 		= 0;

function Laduj()
	{
		d.body.onmouseup = desactive;
		d.getElementById('slider_button').onmousedown = active;
		d.getElementById('slider_button').onmouseup = desactive;
		

	}
function testuj()
	{
	alert("test");
	}
	
function desactive(){
	active_id="";	
	}
function active(){
	active_id=this.id;
	click_pos_x	= tempX;
	click_pos_y	= tempY;
	element_pos_x = parseInt(d.getElementById(this.id).style.left);
	element_pos_y = parseInt(d.getElementById(this.id).style.top);
	child_width = document.getElementById(this.id).offsetWidth;
	child_height = parseInt(document.getElementById(this.id).offsetHeight) - 10; 
	parent_width = document.getElementById(this.id).parentNode.offsetWidth;
	parent_height = document.getElementById(this.id).parentNode.offsetHeight;
	}
	
var IE = document.all?true:false;
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
	if (IE) { // grab the x-y pos.s if browser is IE
	tempX = event.clientX + document.body.scrollLeft;
	tempY = event.clientY + document.body.scrollTop;
	}
else { // grab the x-y pos.s if browser is NS
	tempX = e.pageX;
	tempY = e.pageY;
	} 
dnd(active_id);
slider_text('container_slid', 'slider_button' , 'slider');
}
function dnd(id){
	if(id!=""){
		if((element_pos_x + (tempX - click_pos_x))	< 0)
			x = 0;
		else if((element_pos_x + (tempX - click_pos_x)) > (parent_width - child_width))
			x = parent_width - child_width;
		else
			x = element_pos_x + (tempX - click_pos_x);
		if((element_pos_y + (tempY - click_pos_y))	< 0)
			y = 0;
		else if((element_pos_y + (tempY - click_pos_y)) > (parent_height - child_height))
			y = parent_height - child_height;
		else
			y = element_pos_y + (tempY - click_pos_y);
			

			d.getElementById(id).style.top	= y + "px"; 
		}
	}
function slider_text(id, id2, id3){
	if(id2==active_id){
			d.getElementById(id).scrollTop = (d.getElementById(id).scrollHeight-d.getElementById(id).offsetHeight)*(parseInt(d.getElementById(id2).style.top)/(d.getElementById(id3).offsetHeight-10)); 
		}
	}

