base_class_empty = function () {};

base_class = function () {};
base_class.prototype = new base_class_empty;

base_class.prototype.host = "http://" + top.location.host + "/";

base_class.prototype.isNumber = function (n) {
    return !isNaN(parseFloat(n)) && isFinite(n);
}
base_class.prototype.load_info = function (element, url) {
    $.ajax ({
        async: false,
        url: url + "?v1",
        success: function (html) {
            $("#" + element).html(html);
        }
    });
}

base_class.prototype.disable_css_file = function (url) {
    var styleSheets = document.styleSheets;
        var href = url;
        for (var i = 0; i < styleSheets.length; i++) {
         if (styleSheets[i].href == href) {
                styleSheets[i].disabled = true;
                break;
                }
        }
}

base_class.prototype.add_css_file = function (url) {
    $("<link/>", {
        rel: "stylesheet",
        type: "text/css",
        href:   url
    }).appendTo("head");
}


modal_form = function (id, zindex) {
    if (!(this instanceof modal_form)) return new modal_form();
    var $_modal_form = new base_class ();
    
    $_modal_form.id = id ? id : "modal_window";
    $_modal_form.zindex = zindex ? zindex : 999;
    
    $_modal_form.initialize = function () {
        if ($("#" + $_modal_form.id).size() == 0) {
          var html = "<div id=" +  $_modal_form.id +  "></div>"
            $("body").append(html)
        }
        
        $("#" + $_modal_form.id).css ({
             "position": "absolute",
             "z-index": $_modal_form.zindex,
             "background-color":"black"
        })
        
        $("#" + $_modal_form.id).fadeTo(100,0.5);
        
        $("#" + $_modal_form.id).animate ({
            top:"0px",
            left: "0px",
            width: $(document).width(),
            height: $(document).height()
        },10)   
        
        window.onscroll = function () {
            $("#" + $_modal_form.id).animate ({
            top:"0px",
            left: "0px",
            width: $(document).width(),
            height: $(document).height()
        },10) 
        }
    }
    
    $_modal_form.initialize ();
}
