//-----------------------------------------------
// ÊËÀÑÑ ÄËß ÐÀÁÎÒÛ Ñ ÏËÀÂÀÞÙÈÌÈ ÔÐÅÉÌÀÌÈ
//-----------------------------------------------

// êîíñòðóêòîð êëàññà
function FrameObj(v_fr_name, v_width, v_height, v_title, v_is_modal, v_css) {
    this.Name = v_fr_name;
    this.ID = v_fr_name + "_id";
    this.Width = parseInt(v_width);
    this.Height = parseInt(v_height);
    this.Title = v_title;
    this.IsModal = (v_is_modal!=null)?v_is_modal:false;
    this.CSS = v_css;

    this.Init = function Init() {
        if (this.Name != null && document.getElementById(this.ID) == null) {

            var strVal = "";
            var _CSS = (this.CSS != null && this.CSS != '') ? this.CSS : ((isIE_OLD) ? "fr_dialog_IE_OLD" : "fr_dialog");
            
            if (v_is_modal) {
                var style_modal = 'style="height:' + window.screen.height + 'px;"';
                var css_modal = "fr_modal";
                if (isIE_OLD) {
                    css_modal = "fr_modal_IE_OLD";
                    style_modal = "";
                }
                strVal += '<div class="' + css_modal + '" id="' + this.ID + '_modal" ' + style_modal + '>&nbsp;</div>';
            }
            strVal +=
		        '<div id="' + this.ID + '" class="' + _CSS + '">'
		        + '<table cellpadding="0" cellspacing="0" width="100%">'
		        + '<tr class="menu">'
		        + ' <td width="100%"><div id="' + this.ID + '_title">' + this.Title + '</div></td>'
		        + '	<td><a href=\'javascript:FrameClose("' + this.ID + '")\'><img src="/i/ic_close.gif" width="16" height="16" border="0" alt=""></a></td>'
		        + '</tr>'
		        + '<tr>'
		        + '	<td colspan="2">'
		        + '     <iframe marginheight="0" marginwidth="0" width="100%" name="' + this.Name + '" id="' + this.ID + '_fr" src="" frameborder="no" scrolling="auto"></iframe>'
		        + ' </td>'
		        + '</tr>'
		        + '</table>'
		        + '</div>';

            document.write(strVal);
        }
    };

    this.Show = function Show(v_url, v_title) {

        var fr = document.getElementById(this.ID);
        var i_fr = document.getElementById(this.ID + "_fr");

        if (fr != null && v_url != '') {

            if (fr.style.display != "block") {
                if (this.CSS != null && this.CSS != '') {
                    fr.setAttribute("className", this.CSS);
                    fr.className = this.CSS;
                }
                else {
                    var c_width = 0, c_height = 0;

                    if (self.innerWidth && self.innerHeight) { // Mozilla, Firefox etc
                        c_width = self.innerWidth;
                        c_height = self.innerHeight;
                    }
                    else if (document.body) { // MS IE
                        c_width = window.screen.width;
                        c_height = window.screen.height - 100;
                    }

                    if (!isNaN(this.Width) && this.Width > 0) {
                        var p_left = (c_width - this.Width) / 2;
                        fr.style.width = this.Width + "px";
                        //i_fr.style.width = this.Width + "px";
                        fr.style.left = p_left + "px";
                    }

                    if (!isNaN(this.Height) && this.Height > 0) {
                        fr.style.height = this.Height + "px";
                        i_fr.style.height = (this.Height - 25) + "px";
                        if (!isIE_OLD) {
                            var p_top = (c_height - this.Height) / 2;
                            fr.style.top = p_top + "px";
                        }
                    }
                } //end else if (this.CSS != null && this.CSS != '') {
            } //end if (fr.style.display != "block") 

            if (i_fr.contentDocument != null) {
                i_fr.contentDocument.open();
            }

            if (v_title != null && v_title != '') {
                set_message(this.ID + "_title", v_title);
            }

            fr.style.display = "block";
            i_fr.src = v_url;

            if (this.IsModal) {
                var fr_modal = document.getElementById(this.ID + "_modal");
                if (fr_modal != null) fr_modal.style.visibility = "visible";
            }
        }
        return false;
    };

    this.Init();
}

function FrameClose(fr_id) {
    var fr = document.getElementById(fr_id);
    if (fr != null) fr.style.display = "none";
    var fr_modal = document.getElementById(fr_id + "_modal");
    if (fr_modal != null) fr_modal.style.visibility = "hidden";
}

