var nav=document.getElementById&&!document.all;
var target, b_scroll,cont_txt;
var tx,ty,x_sc,y_sc;
var drag_activo=false;

function play_drag(e) {
 if(drag_activo) {
    var posy= nav ? ty-y_sc+e.clientY:  ty-y_sc+event.clientY;
    if(posy>parseInt(b_scroll.offsetHeight-target.offsetHeight)) { posy=b_scroll.offsetHeight-target.offsetHeight; }
    if(posy<0) { posy=0;  }	  
	target.style.top  = posy +"px"; 
	
	cont_todo = nav ? cont_txt.parentNode : cont_txt.parentElement;
	cposy=-Math.round(posy*((cont_txt.offsetHeight-cont_todo.offsetHeight)/(b_scroll.offsetHeight-target.offsetHeight)));
	
	cont_txt.style.top  = cposy +"px"; 
  }
}

function drag(e) {
    drag_activo=true;
    target = nav ? e.target : event.srcElement;
    ty = valor_num(target.style.top); 
    y_sc = nav ? e.clientY : event.clientY;
    document.onmousemove=play_drag;
    return false;

}
function drop(e) {
	 drag_activo=false;
     return false;
}
function valor_num(value) { var n = parseInt(value); return n == null || isNaN(n) ? 0 : n; } 

function iniciar_scroll(slider,barra,contenedor) {
    sc=document.getElementById(slider);
    cont_txt=document.getElementById(contenedor);
	b_scroll=document.getElementById(barra);
	cont_txt.style.top="0px";
	sc.style.top="0px";
	if(cont_txt.offsetHeight>b_scroll.offsetHeight) {
	
		sc.style.display="block";	
		document.onmousedown=drag;
		document.onmouseup=drop;
	}
	else {
	 sc.style.display="none";	
  	}
}
