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();'><img src=",str_url," border=0 width=",width," height=",height," alt='Закрыть окно'></center>");
    pic_wnd.document.writeln("</body></html>");
    pic_wnd.focus();
    return pic_wnd;
}

// Show Picture when MouseOver from object
function show_pic(text, evt) {
evt = (evt) ? evt : event;
    if (evt) {
var elem = document.getElementById("picblock");
  elem.innerHTML = text;
  elem.style.display = 'block';
  elem.style.position = 'absolute';
  var coords = getEventCoords(evt);
  elem.style.left = coords.left;
  elem.style.top = coords.top;
    }
}
function getEventCoords(evt) {
    var coords = {left:0, top:0};
    if (evt.pageX) {
        coords.left = evt.pageX;
        coords.top = evt.pageY;
    } else if (evt.clientX) {
        coords.left = evt.clientX + document.body.scrollLeft - document.body.clientLeft;
        coords.top = evt.clientY + document.body.scrollTop - document.body.clientTop;
        if (document.body.parentElement && document.body.parentElement.clientLeft) {
            var bodParent = document.body.parentElement;
            coords.left += bodParent.scrollLeft - bodParent.clientLeft;
            coords.top += bodParent.scrollTop - bodParent.clientTop;
        }
    }
    return coords;
}
function hide_pic() {
 var elem = document.getElementById("picblock").style;
 elem.display = 'none';
}
