function Box(id,title,content,wid,hei,func){
var d_w = 300;
var self = this;
this.handler = func;
this.HasOver = true;
this.Moveable = true;
this.Id = id;
//this.CloseHandler = func;
this.SetCloseHandler = function(f) { handler = f; }
this.GetBox = function() { return JQ("#blockWin_"+id); }
this.GetBlock = function() { return JQ("#blockOver_"+id); }
this.GetCloseBtn = function() { return JQ("#closeWin_"+id); }
this.GetHeader = function() { return JQ("#winHead_"+id); }
this.GetTitle = function() { return JQ("#winTitle_"+id); }
this.SetTitle = function(new_title) { this.GetTitle().html(new_title); }
this.GetContent = function() { return JQ("#winContent_"+id); }
this.SetContent = function(new_content) { this.GetContent().html(new_content); }
this.Show = function() {
var self = this;
if(this.HasOver){
JQ("body").append('
'.format(id));
this.GetBlock().css({ width: JQ(document).width(), height: JQ(document).height() }).fadeTo(0,0.3);
}
var win = JQ(window);
var win_position = { w : win.width(), l: win.scrollLeft(), h: win.height(), t: win.scrollTop() };
JQ("body").append('{1}![关闭窗口]()
{2}
'.format(id,title,content));
var box_h = this.GetBox().height();
var box_w = (typeof wid == "undefined" || wid == null || wid==0)?d_w:wid;
var box_l = (win_position.w - box_w) * 0.5 + win_position.l;
var box_t = (win_position.h - box_h) * 0.5 + win_position.t;
this.GetBox().css({ left: box_l+"px", top: box_t+"px", width: box_w+"px" });
//this.GetContent().css({ height: box_h+"px" });
this.GetCloseBtn().bind("click",function() { self.Close(); });
if(this.Moveable) {
this.GetHeader().bind("mousedown",function(event) { self.Move.Start(event); });
JQ("body").bind("mousemove", function(event) { event = event || window.event; self.Move.Go(event); });
JQ("body").bind("mouseup", function() { self.Move.Stop(); });
}
}
this.Close = function() {
if(self.HasOver) JQ("#blockOver_"+id).fadeOut("normal").remove();
JQ("#blockWin_"+id).fadeOut("fast").remove();
if(typeof(this.handler) != "undefined" && this.handler != null) {
eval(this.handler);
}
}
this.Move = {
isStart : false,
Offset : { x:0, y:0 },
Start : function(event) {
this.isStart = true;
event = event || window.event;
this.Offset.x = self.GetBox().offset().left - event.clientX;
this.Offset.y = self.GetBox().offset().top - event.clientY;
},
Stop : function() {
this.isStart = false;
self.GetBox().css("cursor","auto");
},
Go : function(event) {
if(!this.isStart) return;
var box = self.GetBox();
box.css("cursor","move");
box.css("left",event.clientX+this.Offset.x+"px");
box.css("top",event.clientY+this.Offset.y+"px");
}
}
}
function ConfirmBox(id,title,content,wid,hei,func){
content += "
".format(id);
this.temp = Box;
this.temp(id,title,content,wid,hei,func);
delete this.temp;
this.confirm = false;
var self = this;
this.GetConfirmT = function() { return JQ("#confirm_"+id+"_t"); }
this.GetConfirmF = function() { return JQ("#confirm_"+id+"_f"); }
}
function Div(id,content,top,left,width,height) {
var self = this;
this.timeoutHide = 0;
this.timeoutClose = 0;
var div;
var time;
this.Init = function(id,content,top,left,width,height) {
var _top = 0, _left = 0, _width = 300, _height = "auto";
div = JQ("");
div.attr("id",id);
if(!NaN2(top)) _top = top;
if(!NaN2(left)) _left = left;
if(!NaN2(width)) _width = width;
if(!NaN2(height)) _height = height;
div.css({ position: "absolute", top: _top, left: _left, width: _width, height: _height });
div.html(content);
}
this.Show = function() {
if(!NaN2(JQ("#"+id))) { div = JQ("#"+id); }
else {
self.Init(id,content,top,left,width,height);
div.appendTo("body");
}
self.ResetInfo();
div.show();
// self.Init(id,content,top,left,width,height);
// div.appendTo("body");
// self.ResetInfo();
// div.show();
}
this.Hide = function() {
if(!NaN2(JQ("#"+id))) div.hide();
}
this.Close = function() {
div.remove();
}
this.MouseOver = function() {
clearTimeout(self.time);
}
this.MouseOut = function() {
self.SetTimeout();
}
this.SetTimeout = function() {
var timeout = false;
if(!NaN2(self.timeoutClose) && self.timeoutClose != 0) {
clearTimeout(self.time);
self.time = setTimeout(self.Close,self.timeoutClose);
timeout = true;
}
else if(!NaN2(self.timeoutHide) && self.timeoutHide != 0) {
clearTimeout(self.time);
self.time = setTimeout(self.Hide,self.timeoutHide);
timeout = true;
}
}
this.ResetInfo = function() {
var timeout = false;
if(!NaN2(self.timeoutClose) && self.timeoutClose != 0) { timeout = true; }
else if(!NaN2(self.timeoutHide) && self.timeoutHide != 0) { timeout = true; }
if(timeout) {
div.bind("mouseover",function() {
self.MouseOver();
});
div.bind("mouseout",function() {
self.MouseOut();
});
}
}
}