function replace_string(txt,cut_str,paste_str)

{

  var f=0;

  var ht='';

  ht = ht + txt;

  f=ht.indexOf(cut_str);

  while (f!=-1)

  {

    //цикл для вырезания всех имеющихся подстрок

    f=ht.indexOf(cut_str);

    if (f>0)

    {

      ht = ht.substr(0,f) + paste_str + ht.substr(f+cut_str.length);

    };

  };

return ht

};

var lastTop=0;
var lastLeft=0;

 var z = 100;

function zIndex(obj){
z++
obj=document.getElementById(obj);
obj.style.zIndex=z;
}

function NI(obj) {
objN=obj;
obj=document.getElementById(obj);

		 t=document.body.scrollTop+100+lastTop;
         obj.style.top=t;
		 
		 dw=replace_string(obj.style.width,'px','');
         w=document.body.clientWidth/2-dw/2+lastLeft;
         obj.style.left=w+'px'; 

if(obj.style.display=='none'){
	obj.style.display = 'inline';
     lastTop=lastTop+10; lastLeft=lastLeft+10;
	 zIndex(objN);
	}
	else {
	obj.style.display = 'none';
	lastTop=lastTop-10; lastLeft=lastLeft-10;

		}
		

}

/* Перемещения дива  */

function $(v) {
  return(document.getElementById(v));
}

function agent(v) {
  return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0));
}
function xy(e,v) {

  return(v?(agent('msie')?event.clientY+document.body.scrollTop:e.pageY):(agent('msie')?event.clientX+document.body.scrollTop:e.pageX));

}
function dragOBJ(d,e) {

  function drag(e) {
    if(!stop) {
      d.style.top=(tX=xy(e,1)+oY-eY+'px'); d.style.left=(tY=xy(e)+oX-eX+'px');
    }
  }
 // alert(d.style.left);
 //document.getElementById('text').innerHTML = d.style.left;
  d=document.getElementById(d);
  var oX=parseInt(d.style.left),
      oY=parseInt(d.style.top),
      eX=xy(e),
      eY=xy(e,1),
      tX,tY,stop;

  document.onmousemove=drag;
  document.onmouseup=function(){ stop=1; document.onmousemove=''; document.onmouseup=''; };
}

/* Перемещения дива  */

function ShowIN(obj) {
objN=obj;
obj=document.getElementById(obj);



if(obj.style.display=='none'){
	obj.style.display = 'inline'

	}
	else {
	obj.style.display = 'none'

		}
zIndex(objN);

}

function MinMaxIMG(imgID,obj2d,objMaini){
         objMain=document.getElementById(objMaini);
         objd=document.getElementById(obj2d);
	 if((objd.style.display=='inline') || (objd.style.display=='')){imgID.src='_system/img/max.gif'; imgID.title='развернуть'; }else{imgID.src='_system/img/min.gif'; imgID.title='свернуть';}

}