function get_center_coord(width, height){
    var return_obj  = new Object();
    return_obj.x    = 0;
    return_obj.y    = 0;
    if(window.screenLeft && document.body.offsetWidth){
        return_obj.x        += window.screenLeft + Math.ceil(document.body.offsetWidth/2) - Math.ceil(width/2);
        return_obj.y        += window.screenTop + Math.ceil(document.body.offsetHeight/2) - Math.ceil(height/2);
    }else{
        return_obj.x        += Math.ceil(screen.width/2) - Math.ceil(width/2);
        return_obj.y        += Math.ceil(screen.height/2) - Math.ceil(width/2);
    }
    return return_obj;
}

function openWindow(str_url,width,height,scrolls){
    var center_coord        = get_center_coord(width, height);
    if (!scrolls) scrolls = "no";
    else scrolls="yes";
    wnd = window.open(""+str_url, "wnd", "width="+width+",height="+height+", top=" + center_coord.y + ", left=" + center_coord.x + ", titlebar=no, scrollbars="+scrolls+", dependent=no, resizable=yes");
//  wnd.moveTo(center_coord.x, center_coord.y);
    wnd.focus();
    return wnd;
}

function openSndDialog(str_url,width, height){
    var center_coord        = get_center_coord(width, height);
    snd_wnd = window.open(""+str_url, "snd_wnd", "width="+width+",height="+height+", top=" + center_coord.y + ", left=" + center_coord.x + ", titlebar=no, scrollbars=no, dependent=no, resizable=yes");
    snd_wnd.focus();
    return snd_wnd;
}

function openPicWindow(str_url,width,height,title,scrolls){
    var center_coord        = get_center_coord(width, height);
    if (!scrolls) scrolls = "no";
    else scrolls="yes";
    if (!title) title="Picture Window";
    pic_wnd = window.open(""+str_url, "wnd", "width="+width+",height="+height+", top=" + center_coord.y + ", left=" + center_coord.x + ", titlebar=no, scrollbars="+scrolls+", dependent=no, resizable=yes");
    pic_wnd.document.open();
    pic_wnd.document.writeln("<html><head><title>",title,"</title></head>");
    pic_wnd.document.writeln("<body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 bgcolor=#FFFAF0>");
    pic_wnd.document.writeln("<center><a href='javascript: this.window.close();' onMouseOut='window.status=\"\"' onMouseOver='window.status=\"Закрыть окно\"; return true'><img src=",str_url," border=0 width=",width," height=",height," alt='Закрыть окно'></center>");
    pic_wnd.document.writeln("</body></html>");
    pic_wnd.focus();
    return pic_wnd;
}

function _getElementById(id){
  var item = null;

  if (document.getElementById){
    item = document.getElementById(id);
  } else if (document.all){
    item = document.all[id];
  } else if (document.layers){
    item = document.layers[id];
  }

  return item;
}

function DoDiv(id) {
  var item = _getElementById(id);

  if (!item){
  } else if (item.style){
    if (item.style.display == 'none'){
        item.style.display = '';
    } else {
        item.style.display = 'none';
      }
  } else {
      item.visibility = 'show';
  }
}

function ShowOrHide(d1, d2) {
  if (d1 != ''){
      DoDiv(d1);
  }

  if (d2 != ''){
      DoDiv(d2);
  }
}

function show_login () {
	var login=document.getElementById("login");
	if (login.style.display == "none") {
		login.style.display = "block"; 
	} else { 
		login.style.display = "none";  
	}	
	return false;
}

