
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function ini() {
 oh=MM_findObj('manast'); oh.onmousedown=capth;
 oh.style.left='111px';
 oh=MM_findObj('manadr'); oh.onmousedown=captv;
 oh.style.top='179px';
}

function capth(e) {
 e = e ? e : window.event;
 document.hx0=e.clientX;
 oh=MM_findObj('manast'); x=oh.style.left; document.hxcurent=parseInt(x.substr(0,x.length-2));
 document.oldonmousemove = document.onmousemove;
 document.oldonmouseup = document.onmouseup;
 document.onmousemove = moveh;
 document.onmouseup = gatah;
 return false;
}

function moveh(e) {
 e = e ? e : window.event;
 dx=parseInt(e.clientX-document.hx0);
 oh=MM_findObj('manast');
 if ((document.hxcurent+dx)<111) oh.style.left='111px';
 else if ((document.hxcurent+dx)>557) oh.style.left='557px';
 else oh.style.left=(document.hxcurent+dx)+'px';
 oh=MM_findObj('blocst');
 if ((document.hxcurent+dx)<111) oh.style.left='0px';
 else if ((document.hxcurent+dx)>557) oh.style.left='-4200px';
 else oh.style.left=Math.round((466200-4200*(document.hxcurent+dx))/446)+'px';
 return false;
}

function gatah() {
 document.onmousemove = document.oldonmousemove;
 document.onmouseup = document.oldonmouseup;
 return false;
}

function captv(e) {
 e = e ? e : window.event;
 document.hy0=e.clientY;
 oh=MM_findObj('manadr'); y=oh.style.top; document.hycurent=parseInt(y.substr(0,y.length-2));
 document.oldonmousemove = document.onmousemove;
 document.oldonmouseup = document.onmouseup;
 document.onmousemove = movev;
 document.onmouseup = gatav;
 return false;
}

function movev(e) {
 e = e ? e : window.event;
 dy=parseInt(e.clientY-document.hy0);
 oh=MM_findObj('manadr');
 if ((document.hycurent+dy)<179) oh.style.top='179px';
 else if ((document.hycurent+dy)>475) oh.style.top='475px';
 else oh.style.top=(document.hycurent+dy)+'px';
 oh=MM_findObj('blocdr');
 if ((document.hycurent+dy)<179) oh.style.top='0px';
 else if ((document.hycurent+dy)>475) oh.style.top='-10350px';
 else oh.style.top=Math.round((179*10350-10350*(document.hycurent+dy))/296)+'px';
 return false;
}

function gatav() {
 document.onmousemove = document.oldonmousemove;
 document.onmouseup = document.oldonmouseup;
 return false;
}

// http://www.webtoolkit.info/javascript-drag-and-drop.html
