var ie=document.all;
var nn6=document.getElementById&&!document.all;

var isdrag=false;
var x,y;
var dobj;

function select_drag_type(e) 
{
  var fobj       = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "BODY";

  while (fobj.tagName != topelement && fobj.className != "scroll2" && fobj.className != "scroll")
  {
    fobj = nn6 ? fobj.parentNode : fobj.parentElement;
  }
  if (fobj.className=="scroll")
  {
    isdrag = true;
    dobj = fobj;
    tx = parseInt(dobj.style.left+0);
    ty = parseInt(dobj.style.top+0);
    x = nn6 ? e.clientX : event.clientX;
    y = nn6 ? e.clientY : event.clientY;
    document.onmousemove=scrolling;
    return false;
  }
  
  if (fobj.className=="scroll2")
  {
    isdrag = true;
    dobj = fobj;
    tx = parseInt(dobj.style.left+0);
    ty = parseInt(dobj.style.top+0);
    x = nn6 ? e.clientX : event.clientX;
    y = nn6 ? e.clientY : event.clientY;
    document.onmousemove=scrolling2;
    return false;
  }
  
}

document.onmousedown=select_drag_type;
document.onmouseup=new Function("isdrag=false");


function scrolling(e)
{
  if (isdrag)
  {
    dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
    if (parseInt(dobj.style.top)<=5) dobj.style.top  = 5;
    if (parseInt(dobj.style.top)>=270) dobj.style.top  = 270;

    //calculam si pozitia div-ului
    r=(parseInt(dobj.style.top))/265;
    o=document.getElementById('content');
    o.style.top=-927-(o.offsetHeight-321)*r;
    return false;
  }
}

function scrolling2(e)
{
  if (isdrag)
  {
    dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
    if (parseInt(dobj.style.top)<=5) dobj.style.top  = 5;
    if (parseInt(dobj.style.top)>=270) dobj.style.top  = 270;

    //calculam si pozitia div-ului
    r=(parseInt(dobj.style.top))/265;
    o=document.getElementById('content2');
    o.style.top=-617-(o.offsetHeight-321)*r;
    return false;
  }
}

