var Root = vRoot + "/Scripts/dynaformthem1/";
document.write("<link href=\"" + Root + "DynaForm.css\" rel=\"stylesheet\"  type=\"text/css\" />");
function DynaForm(obj) {
    if (obj == null)
        obj = { id: "DynaForm1", title: "&nbsp;", width: "500px", height: "300px", top: null, left: null, innerhtml: "", src: "", scrolling: "auto" };
    else {
        if (obj.id == null)
            obj.id = "DynaForm1";
        if (obj.title == null)
            obj.title = "&nbsp;";
        if (obj.width == null)
            obj.width = "500px";
        if (obj.height == null)
            obj.height = "300px";
        if (obj.innerhtml == null)
            obj.innerhtml = "";
        if (obj.src == null)
            obj.src = "";
        if (obj.scrolling == null)
            obj.scrolling = "auto";
    }
    this.ID = obj.id;
    this.Title = obj.title;
    this.Top = obj.top;
    this.Left = obj.left;
    this.Width = obj.width;
    this.Height = obj.height;
    this.InnerHTML = obj.innerhtml;
    this.Src = obj.src;
    this.Scrolling = obj.scrolling;
    this.close = function (callfun) {
        if ($("#" + this.ID).length != 0)
            $("#" + this.ID).animate({ "top": "-=50px", "opacity": "toggle" }, { speed: 1000, complete: function () { $(this).remove(); $("select").show(); if ($('#bgdiv').length != 0) $('#bgdiv').css('display', 'none'); if (Obj != '') { Obj = ''; } if (DynaForm.OverFlowStyle != "") $("html").css("overflow-y", DynaForm.OverFlowStyle); if (callfun != null) callfun(); } });
    };
    this.showModalDialog = function (callback) {
        var innerHTML = "";
        innerHTML += "<div id=\"" + this.ID + "\" class=\"divfram\" style=\"width:" + (parseInt((this.Width + "").replace("px", "")) + 6) + "px;top:" + this.Top + "\">";
        innerHTML += "<table id='DynaFormInstance' cellpadding=\"0\" cellspacing=\"0\" padding=\"0\" border=\"0\" >";
        innerHTML += "<tr>";
        innerHTML += "<td style=\"\" class=\"lefttop\">";
        innerHTML += "</td>";
        innerHTML += "<td style=\"width;" + this.Width + "px;\" class=\"top\" onmousedown=\"" + $SelectMoveMethod(this.ID) + "\">";
        innerHTML += "<table style=\"text-align: left;width:" + this.Width + "\"><tr><td style=\"color:#ffffff;font-weight:bold;cursor:move;font-size:12px;\">"; innerHTML += this.Title + "</td>"; innerHTML += "<td style=\"width:21px;cursor:move;\" onmousedown=\"" + $SelectMoveMethod(this.ID) + "\">";
        innerHTML += "<div class=\"close\" style=\"\" onmouseover=\"this.className='closeover';\" onmouseout=\"this.className='close';\" onclick=\"$('select').show();if($('#" + this.ID + "').length != 0)  $('#" + this.ID + "').animate({ 'top': '-=50px', 'opacity':'toggle' }, { speed: 1000, complete: function() { $('#" + this.ID + "').remove(); if ($('#bgdiv').length != 0) $('#bgdiv').css('display', 'none');if (Obj != '') Obj = '';if (DynaForm.OverFlowStyle !='') {$('html').css('overflow-y', DynaForm.OverFlowStyle);}}});\"  onmousedown=\"" + $SelectMoveMethod(this.ID) + "\">X</div>";
        innerHTML += "</td></tr>";
        innerHTML += "</table>";
        innerHTML += "</td>";
        innerHTML += "<td style=\"\" class=\"righttop\">";
        innerHTML += " </td>";
        innerHTML += "</tr>";
        innerHTML += " <tr>";
        innerHTML += "<td style=\"\" class=\"left\">";
        innerHTML += "&nbsp;";
        innerHTML += "</td>";
        innerHTML += "<td style=\"height:" + this.Height + ";width:" + this.Width + "px;background-color: White;\" >";
        if (this.Src != null && this.Src != "")
            innerHTML += "<iframe id=\"iframe" + this.ID + "\" width=\"" + this.Width + "px\" height=\"100%\"  src=\"" + this.Src + "\" scrolling=\"" + this.Scrolling + "\" frameborder=\"0\" style=\"overflow-x:hidden;\"></iframe>";
        else
            innerHTML += this.InnerHTML;
        innerHTML += "</td>";
        innerHTML += "<td style=\"\" class=\"right\">";
        innerHTML += "&nbsp;";
        innerHTML += "</td>";
        innerHTML += "</tr>";
        innerHTML += "<tr>";
        innerHTML += "<td style=\"\" class=\"bottomleft\">";
        innerHTML += "</td>";
        innerHTML += "<td style=\"\" class=\"bottom\">";
        innerHTML += "</td>";
        innerHTML += "<td style=\"\" class=\"bottomright\">";
        innerHTML += "</td>";
        innerHTML += " </tr>";
        innerHTML += " </table>";
        innerHTML += "</div>";
        $("body").css("border", "0").css("margin", "0").css("padding", "0").css("height", "100%");
        $(innerHTML).appendTo("body");
        var middletop = 0;
        if ($.browser.msie && $.browser.version == "6.0")
            middletop = (document.documentElement.clientHeight - parseInt(this.Height.replace("px", ""))) / 2 + DynaForm.ScrollTopHeight() - 15;
        else
            middletop = (document.documentElement.clientHeight - parseInt(this.Height.replace("px", ""))) / 2 - 15;
        var width = this.Width;
        var height = this.Height;
        var top = this.Top;
        var id = this.ID;
        var src = this.Src;
        $("#" + this.ID).css("left", (this.Left == null ? (pageWidth() - parseInt(this.Width.replace("px", ""))) / 2 : this.Left))
            .css("top", ((top == null ? middletop : top) - 40))
            .animate({ "top": "+=20px", "opacity": "toggle" }, { speed: 500, complete: function () {
                $('select').hide();
                if ($("#iframe" + id).length != 0)
                    $("#iframe" + id).attr("src", src);
                if ($.browser.msie && ($.browser.version == "6.0")) {
                    h = 0;
                    if ($.browser.msie)
                        h = document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight : document.body.clientHeight;
                    else
                        h = self.innerHeight;
                    if ($("#bgdiv").length == 0) {
                        $("<div id=\"bgdiv\" style=\"position:absolute;display:block;background-color:#777777;z-index:0;top:0px;left:0px;opacity: 0.70;filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=70,finishOpacity=100);width:100%;\"></div>").appendTo("body");
                        $("#bgdiv").css("height", h + "px").css("width", "100%").css("display", "block").css("top", DynaForm.ScrollTopHeight());
                    } else
                        $("#bgdiv").css("height", h + "px").css("width", "100%").css("display", "block").css("top", DynaForm.ScrollTopHeight());
                }
                $(this).css("top", (top == null ? middletop : top) + "px");
                if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
                    DynaForm.OverFlowStyle = $("html").css("overflow-y");
                    $("html").css("overflow-y", "hidden");
                } else
                    $(".divfram").css("position", "fixed");
                if (callback) callback();
            }
            });
    }
};
DynaForm.OverFlowStyle = "";
var Obj = "";
function MDownIE(Object) {
    if ($.trim(Object) != "") {
        Obj = Object; document.all(Obj).setCapture();
        pX = event.x - document.all(Obj).style.pixelLeft;
        pY = event.y - document.all(Obj).style.pixelTop;
    }
};
var posX;
var posY;
var popDiv;
var dragable;
function MDownFF(ID, e) {
    if (ID && ID != "") {
        popDiv = document.getElementById(ID);
        e = e || window.event;
        posX = e.clientX - parseInt(popDiv.style.left);
        posY = e.clientY - parseInt(popDiv.style.top);
        dragable = true;
    }
}
function pageHeight() {
    if ($.browser.msie)
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight : document.body.clientHeight;
    else
        return self.innerHeight;
};
function $SelectMoveMethod(ID) {
    if ($.browser.msie)
        return "MDownIE('" + ID + "')";
    else
        return "MDownFF('" + ID + "',event);";
}
$(function () {
    if ($.browser.msie) {
        $("html").mousemove(function () {
            if ($.trim(Obj) != "") {
                if ((event.x - pX) > 0)
                    $("#" + Obj).css("left", event.x - pX);
                if ((event.y - pY) > 0)
                    $("#" + Obj).css("top", event.y - pY);
            }
        });
        $("html").mouseup(function () {
            if ($.trim(Obj) != "")
                document.all(Obj).releaseCapture(); Obj = "";
        });
    } else {
        $("html").mousemove(function (ev) {
            if (dragable == true) {
                ev = ev || window.event;
                popDiv.style.left = (ev.clientX - posX) + "px";
                popDiv.style.top = (ev.clientY - posY) + "px";
            }
        });
        $("html").mouseup(function () {
            dragable = false;
        });
    }
});
DynaForm.closeAll = function (callback) {
    $(window).unbind("scroll");
    var id = $("#DynaFormInstance").parent().attr("id");
    if (id != "")
        $("#" + id).animate({ "top": "-=50px", "opacity": "toggle" }, { speed: 1000, complete: function () {
            if (callback) callback();
            $(this).remove();
            $("select").show();
            if ($('#bgdiv').length != 0)
                $('#bgdiv').css('display', 'none');
            if (Obj != '')
                Obj = '';
        }
        });
};
DynaForm.ScrollTopHeight = function () {
    if (document.documentElement && document.documentElement.scrollTop)
        return document.documentElement.scrollTop;
    else if (document.body && document.body.scrollTop)
        return document.body.scrollTop;
    else return $(document).scrollTop();
};
function pageHeight() {
    if ($.browser.msie)
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight : document.body.clientHeight;
    else
        return self.innerHeight;
};
function pageWidth() {
    if ($.browser.msie)
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth : document.body.clientWidth; else return self.innerWidth;
}