var window__ = null;
var window_ = function(title, body_, className) {
    window_close();
	if(isSuxx()) {
        $$('select').each(function(t) { t.style.visibility = "hidden" });

    }

    var w = new Element('div', {'class': className + ' win'});
    
    var t = new Element('div', {'class': 'name'});
    var close = new Element('a', {'href': '#', 'class': 'close'});
    Event.observe(close, 'click', function(e) { e.stop(); window_close(); });
    t.appendChild(close);
    t.appendChild(document.createTextNode(title));
    w.appendChild(t);

    $$('body')[0].appendChild(w);
    
    var body = new Element('div', {'class': 'body'});
    body.appendChild(body_)
    body.appendChild(new Element('div', {'class': 'clear'}));
    w.appendChild(body);
    if(isSuxx()) {
	    w.addClassName('win_ie6');
        w.scrollTo();
    }

    
    try {
        $$('.win textarea, .win input')[0].focus();
    }
    catch(e) { }
    


	window_resize();
	window__ = w;
}

var window_resize = function() {
   /* window__.style.marginTop = -parseInt(window__.getHeight()/2) + 'px';
    window__.style.marginLeft = -parseInt(window__.getWidth()/2) + 'px';*/
}
// специально для небраузера
var window_ie_scroll = function() {
    
}
var window_close = function() {
    $$('select').each(function(t) { t.style.visibility = "visible" });
	try {
        window__.remove();
    }
    catch(e) { }

	if(isSuxx()) {
        $$('select').each(function(t) { t.style.visibility = "visible" });

    }
}

Event.observe(window, 'load', function() { 
    var link = new Element('link', {href: '/css/blocks/window.css?2', type: 'text/css', rel: 'stylesheet'});
    $$('head')[0].appendChild(link);
});
