MyOtzivCl = function() {
    var siteAdr = 'http://reformal.ru/';
    var domain = "obeder";
    
    this.mo_get_win_width = function() {
        var myWidth = 0;
        if( typeof( window.innerWidth ) == 'number' ) //Non-IE
            myWidth = window.innerWidth;
        else if( document.documentElement && document.documentElement.clientWidth ) //IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
        else if( document.body && document.body.clientWidth) //IE 4 compatible
            myWidth = document.body.clientWidth;
        return myWidth;
    }
    
    this.mo_get_win_height = function() {
        var myHeight = 0;
        if( typeof( window.innerHeight ) == 'number' ) //Non-IE
            myHeight = window.innerHeight;
        else if( document.documentElement && document.documentElement.clientHeight ) //IE 6+ in 'standards compliant mode'
            myHeight = document.documentElement.clientHeight;
        else if( document.body && document.body.clientHeight) //IE 4 compatible
            myHeight = document.body.clientHeight;
        return myHeight;
    }

    this.mo_get_scrol = function() {
        var yPos = 0;
        if (self.pageYOffset) {
            yPos = self.pageYOffset;
        } else if (document.documentElement && document.documentElement.scrollTop){
            yPos = document.documentElement.scrollTop;
        } else if (document.body) {
            yPos = document.body.scrollTop;
        }
        return yPos;
    }

    this.open = function() {
        this.mo_checkframe();
        if (document.getElementById("fthere").innerHTML == "") {
            document.getElementById("fthere").innerHTML = "<iframe src=\""+siteAdr+"wdg.php?domain=" + domain + "\" width=\"627\" height=\"250\" align=\"left\" style=\"border: 0; position:relative;\" frameborder=\"0\" scrolling=\"no\">Frame error</iframe>";
        }
        var l = this.mo_get_win_width()/2 - 350;
        var t = this.mo_get_win_height()/2 - 200 + this.mo_get_scrol();
        document.getElementById('myotziv_box').style.top  = t+'px';
        document.getElementById('myotziv_box').style.left = l+'px'; 
        document.getElementById('myotziv_box').style.display='block';
    }

    this.mo_hide_box = function() {
        document.getElementById('myotziv_box').style.display='none';
    }

    
    this.mo_checkframe = function() {
        if(document.getElementById("myotziv_box"))
            return;
            
        var div = document.createElement("div");
        div.innerHTML = 

        
            "<div style=\"position:absolute; display: none; top: 0px; left: 0px;\" id=\"myotziv_box\">" +
            "<div class=\"widsnjx\"><div id=\"poxupih\"><div class=\"poxupih_top\"></div><div class=\"poxupih_center\"><div class=\"poxupih1\">" +
            "<div class=\"gertuik\"><a class=\"pokusijy\" title=\"закрыть\" onClick=\"MyOtziv.mo_hide_box();\"></a>" +
            "<div class=\"fdsrrel\"><a href=\""+siteAdr+"\" target=\"_blank\"><img src=\""+siteAdr+"tmpl/images/widget_logo.jpg\" width=\"109\" height=\"23\" alt=\"\" border=\"0\" /></a></div>Обедер.ру</div>" +
            "<div id=\"hretge\"><form target=\"_blank\" action=\"http://" + domain + ".reformal.ru/proj/\" method=\"get\"><input type=\"hidden\" name=\"charset\" value=\"utf-8\" /><fieldset><div class=\"i_prop\">Я предлагаю вам...</div><input id=\"bulbulh\" name=\"idea\" type=\"text\" /><input type=\"submit\" value=\"\" id=\"adihet\" /></fieldset></form></div>" +
            "<div class=\"bvnmrte\" style=\"height: 250px;\" id=\"fthere\">" +
            //  тут будет ифрейм
            "</div>" +
            "</div></div><div class=\"poxupih_bt\"></div></div></div>" +        
            "</div>";
        document.body.appendChild(div);
    }
}

var MyOtziv = new MyOtzivCl();
