var elm;
elm = document.createElement("link");
elm.rel = "stylesheet";
elm.href = "http://image.fotoever.com/imageserver/css/PopupWin.css";
if ((headArr = document.getElementsByTagName("head")) != null && headArr.length > 0)
headArr[0].appendChild(elm);

var infoCookieName = "feonline=";
var AllCookies = unescape(document.cookie);
var vstart = AllCookies.indexOf(infoCookieName);
var vend = AllCookies.indexOf("{%}", vstart);
AllCookies = AllCookies.substring(vstart, vend);    
var IsOnline = (AllCookies.indexOf(infoCookieName) >= 0);       

var _window = new _Window("_window", "VISTA");

function _Window(codeName, className, width, height)
{
    this.CodeName = codeName;
    this.ClassName = className;
    this.Width = width || 400;
    this.Height = height || 300;
    this.ActTimer = 1;
    this.Clocks = new Array();
    this.zIndex = 1000;
    wIndex = 0;
    this.Copy = null;
    this.onmousemove = document.onmousemove;
    this.onmouseup = document.onmouseup;
    this.onselectstart = document.onselectstart;
}

_Window.prototype.GetAttribute = function(source, name)
{
    var reg = new RegExp("(^|,|\\s)"+ name +"\\s*=\\s*([^,]*)(\\s|,|$)", "i");
    if (reg.test(source)) return RegExp.$2;
    return "";
}

_Window.prototype.GetMaxNumber = function()
{
    var num = 0;
    for(var i=0; i<arguments.length; i++) if(arguments[i] > num) num = arguments[i];
    return num;
}

_Window.prototype.Open = function(body, title, features)
{
    var className = this.GetAttribute(features, "class") || this.ClassName;
    if(!className)return null;
    var width  = parseInt(this.GetAttribute(features, "width")) || this.Width;
    var height = parseInt(this.GetAttribute(features, "height")) || this.Height;
    var left   = this.GetAttribute(features, "left") || "50%";
    var top    = this.GetAttribute(features, "top") || "50%";
    var resize = this.GetAttribute(features, "resize").toLowerCase() || "resize";
    var move   = this.GetAttribute(features, "move").toLowerCase() || "move";

    var NewWin = document.createElement("div");
    NewWin.setAttribute("id", "_W_" + (++wIndex));
    NewWin.className = className;
    NewWin.style.position = "absolute";
    NewWin.style.zIndex = ++this.zIndex;
    NewWin.style.left = left;
    NewWin.style.top = top;
    document.body.appendChild(NewWin);

    var styles = new Array("LEFT_TOP","TOP","RIGHT_TOP","RIGHT","RIGHT_BOTTOM","BOTTOM","LEFT_BOTTOM","LEFT","CENTER","CLOSE");
    var sizes = new Array();
    for(var i=0;i<10;i++)
    {
        var obj = document.createElement("div");
        obj.className = styles[i];
        obj.style.position = "absolute";
        NewWin.appendChild(obj);
        sizes[i*2] = obj.offsetWidth;
        sizes[i*2+1] = obj.offsetHeight;
        if(i > 7 || move == "no") eval("obj.onmousedown = function(e){ " + this.CodeName + ".Show(this.parentNode); };");
        else eval("obj.onmousedown = function(e){ " + this.CodeName + ".PreMove(this.parentNode, e ? e : window.event, move); };");
    }

    NewWin.childNodes[8].style.width = width + "px";
    NewWin.childNodes[8].setAttribute("NowWidth", width);

    height = this.Body(NewWin, body, height);
    NewWin.childNodes[8].style.height = height + "px";
    NewWin.childNodes[8].setAttribute("NowHeight", height);

    NewWin.childNodes[8].style.left = (sizes[14] + NewWin.childNodes[8].offsetLeft) + "px";
    NewWin.childNodes[8].style.top = (sizes[3] + NewWin.childNodes[8].offsetTop) + "px";

    NewWin.style.width = (width + sizes[6] + sizes[14]) + "px";
    NewWin.style.height = (height + sizes[3] + sizes[11]) + "px";
    NewWin.setAttribute("MinWidth", this.GetMaxNumber(sizes[0] + sizes[4], sizes[6] + sizes[14] + sizes[18], sizes[8] + sizes[12]) + 20);
    NewWin.setAttribute("MinHeight", this.GetMaxNumber(sizes[1] + sizes[13], sizes[3] + sizes[11], sizes[5] + sizes[9]) + 2);

    NewWin.childNodes[1].style.width = (width + sizes[6] + sizes[14] - sizes[0] - sizes[4]) + "px";
    NewWin.childNodes[3].style.height = (height + sizes[3] + sizes[11] - sizes[5] - sizes[9]) + "px";
    NewWin.childNodes[5].style.width = (width + sizes[6] + sizes[14] - sizes[8] - sizes[12]) + "px";
    NewWin.childNodes[7].style.height = (height + sizes[3] + sizes[11] - sizes[13] - sizes[1]) + "px";
    NewWin.childNodes[0].style.left = "0px";
    NewWin.childNodes[0].style.top = "0px";    
    NewWin.childNodes[1].style.left = sizes[0] + "px";
    NewWin.childNodes[1].style.top = "0px";
    NewWin.childNodes[2].style.right = "0px";
    NewWin.childNodes[2].style.top = "0px";
    NewWin.childNodes[3].style.right = "0px";
    NewWin.childNodes[3].style.top = sizes[5] + "px";
    NewWin.childNodes[4].style.right = "0px";
    NewWin.childNodes[4].style.bottom = "0px";
    NewWin.childNodes[5].style.left = sizes[12] + "px";
    NewWin.childNodes[5].style.bottom = "0px";
    NewWin.childNodes[6].style.left = "0px";
    NewWin.childNodes[6].style.bottom = "0px";
    NewWin.childNodes[7].style.left = "0px";
    NewWin.childNodes[7].style.top = sizes[1] + "px";

    if(resize != "no")
    {
        this.AppendResize(NewWin, "se-resize", "width:15px;height:15px;right:" + (sizes[6] - 13) + "px;bottom:" + (sizes[11] - 13) + "px;", resize, 0);
        this.AppendResize(NewWin, "sw-resize", "width:15px;height:15px;left:" + (sizes[14] - 13) + "px;bottom:" + (sizes[11] - 13) + "px;", resize, 1);
        if(resize != "resize-y")
        {
            this.AppendResize(NewWin, "w-resize", "width:5px;height:" + (height - 2) + "px;left:" + (sizes[14] - 5) + "px;bottom:" + (sizes[11] + 2) + "px;", "resize-x", 1);
            this.AppendResize(NewWin, "e-resize", "width:5px;height:" + (height - 2) + "px;right:" + (sizes[6] - 5) + "px;bottom:" + (sizes[11] + 2) + "px;", "resize-x", 0);
        }
        if(resize != "resize-x")
            this.AppendResize(NewWin, "s-resize", "width:" + (width - 4) + "px;height:5px;left:" + (sizes[14] + 2) + "px;bottom:" + (sizes[11] - 5) + "px;", "resize-y", 0);
    }

    this.Title(NewWin, title);
    eval("NewWin.childNodes[9].onclick = function(e){ " + this.CodeName + ".Close(this.parentNode); };");
    return(NewWin);
}

_Window.prototype.Title = function(o, title)
{
    o.childNodes[1].innerHTML = "<div class=\"TITLE\">" + title + "</div>";
}

_Window.prototype.Body = function(o, body, height)
{
    if(body.slice(0, 5) == "[url]")
    {
        var str = (height < 0) ? "onload=\"" + this.CodeName + ".ResizeBy(this.parentNode.parentNode, 0, frames[frames.length-1].document.documentElement.scrollHeight)\"" : "";
        o.childNodes[8].innerHTML = "<iframe " + str + " onfocus=\"" + this.CodeName + ".Show(this.parentNode.parentNode)\" src=\"" + body.slice(5) + "\" frameBorder='0' marginHeight='0' marginWidth='0' width='100%' height='100%'></iframe>";
        return((height < 0) ? 0 : height);
    }
    else
    {
        o.childNodes[8].innerHTML = "<div class=\"BODY\">" + body + "</div>";
        return((height < 0) ? o.childNodes[8].firstChild.offsetHeight + 1 : height);
    }        
}

_Window.prototype.AppendResize = function(o, cursor, shape, resize, origin)
{
    var obj = document.createElement("DIV");
    o.appendChild(obj);
    obj.style.cssText = "position:absolute;cursor:" + cursor + ";" + shape;
    eval("obj.onmousedown = function(e){ " + this.CodeName + ".PreResize(this.parentNode, e ? e : window.event, \"" + cursor + "\", \"" + resize + "\", " + origin + "); };");
}

_Window.prototype.Duplicate = function(o)
{
    this.Copy = document.createElement("DIV");
    document.body.appendChild(this.Copy);
    this.Copy.style.cssText = "position:absolute;left:" + (o.offsetLeft - 2) + "px;top:" + (o.offsetTop-2) + "px;width:" + o.offsetWidth + "px;height:" + o.offsetHeight + "px;border:2px dotted #000000;";
    this.Copy.style.zIndex = this.zIndex + 1;
}

_Window.prototype.DetachEvent = function(o, e)
{
    document.body.style.cursor = "default";
	document.onmousemove = this.onmousemove;
	document.onmouseup = this.onmouseup;
	document.onselectstart = this.onselectstart;
    if(o.releaseCapture) o.releaseCapture();
}

_Window.prototype.AttachEvent = function(o, e)
{
    if(e.preventDefault) e.preventDefault();
    else
    {
        document.onselectstart = function() { return false; };
        if(o.setCapture) o.setCapture();
    }
}

_Window.prototype.Show = function(o)
{
    if(o.style.zIndex < this.zIndex) o.style.zIndex = ++this.zIndex;
}

_Window.prototype.Close = function(o)
{
    var oid = o.id;
    if (typeof(this.Clocks["M" + oid]) != "undefined") clearTimeout(this.Clocks["M" + oid]);
    if (typeof(this.Clocks["R" + oid]) != "undefined") clearTimeout(this.Clocks["R" + oid]);
    document.body.removeChild(o);
}

_Window.prototype.PreResize = function(o, e, cursor, t, z)
{
    if (typeof(this.Clocks["R" + o.id]) != "undefined") clearTimeout(this.Clocks["R" + o.id]);
    this.Show(o);
    this.Duplicate(o);
    var x, y = e.clientY - this.Copy.offsetHeight;;
    if(z)
    {
        o.style.right = (document.documentElement.scrollWidth - o.offsetWidth - o.offsetLeft) + "px";
        o.style.left = null;
        this.Copy.style.right = (document.documentElement.scrollWidth - this.Copy.offsetWidth - this.Copy.offsetLeft) + "px";
        this.Copy.style.left = null;
        x = e.clientX + this.Copy.offsetWidth;
    }
    else
    {
        o.style.left = o.offsetLeft + "px";
        this.Copy.style.left = this.Copy.offsetLeft + "px";
        x = e.clientX - this.Copy.offsetWidth;
    }
    document.body.style.cursor = cursor;
    eval("document.onmousemove = function(e) { " + this.CodeName + ".Resize(o, e ? e : window.event, x, y, t, z); };");
    eval("document.onmouseup = function(e) { " + this.CodeName + ".Resized(o, e ? e : window.event, x, y, t, z); };");
    this.AttachEvent(o, e);
}

_Window.prototype.Resize = function(o, e, x, y, t, z)
{
    if(t != "resize-y")
    {
        var min_w = parseInt(o.getAttribute("MinWidth"));
        var w = z ? x - e.clientX : e.clientX - x;
        if(w >= min_w) this.Copy.style.width = w + "px";
    }
    if(t != "resize-x")
    {
        var min_h = parseInt(o.getAttribute("MinHeight"));
        var h = e.clientY - y;
        if(h >= min_h) this.Copy.style.height = h + "px";
    }
}

_Window.prototype.Resized = function(o, e, x, y, t, z)
{
    this.DetachEvent(o, e);
    var dx = 0, dy = 0;
    if(t != "resize-y")
    {
        var min_w = parseInt(o.getAttribute("MinWidth"));
        var w = z ? x - e.clientX - 4 : e.clientX - x -4;
        w = (w > min_w) ? w : min_w;
        dx = w - o.offsetWidth;
    }
    if(t != "resize-x")
    {
        var min_h = parseInt(o.getAttribute("MinHeight"));
        var h = (e.clientY - y - 4 > min_h) ? (e.clientY - y - 4) : min_h;
        dy = h - o.offsetHeight;
    }
    if(this.ActTimer > 0) this.ActResizeBy(o.id, dx, dy, t);
    else this.ResizeBy(o, dx, dy, t);
    document.body.removeChild(this.Copy);
    this.Copy = null;
}

_Window.prototype.ResizeBy = function(o, dx, dy, t)
{
    if(dx)
    {        
        o.style.width = (o.offsetWidth + dx) + "px";
        o.childNodes[1].style.width = (o.childNodes[1].offsetWidth + dx) + "px";
        o.childNodes[5].style.width = (o.childNodes[5].offsetWidth + dx) + "px";
        if(o.childNodes[14]) o.childNodes[14].style.width = (o.childNodes[14].offsetWidth + dx) + "px";
        var width  = parseInt(o.childNodes[8].getAttribute("NowWidth")) + dx;
        o.childNodes[8].setAttribute("NowWidth", width);
        o.childNodes[8].style.width = width + "px";
    }
    if(dy)
    {    
        o.style.height = (o.offsetHeight + dy) + "px";
        o.childNodes[3].style.height = (o.childNodes[3].offsetHeight + dy) + "px";
        o.childNodes[7].style.height = (o.childNodes[7].offsetHeight + dy) + "px";
        if(o.childNodes[13])
        {
            o.childNodes[12].style.height = (o.childNodes[12].offsetHeight + dy) + "px";
            o.childNodes[13].style.height = (o.childNodes[13].offsetHeight + dy) + "px";
        }
        var height = parseInt(o.childNodes[8].getAttribute("NowHeight")) + dy;
        o.childNodes[8].setAttribute("NowHeight", height);
        o.childNodes[8].style.height = height + "px"; 
    }
}

_Window.prototype.ActResizeBy = function(oid, dx, dy, t)
{
    if(dx || dy)
    {
        var x = dx/10; x = (x > 0) ? Math.ceil(x) : Math.floor(x);
        var y = dy/10; y = (y > 0) ? Math.ceil(y) : Math.floor(y);
        var o = document.getElementById(oid);
        this.ResizeBy(o, x, y, t);
        dx -= x; dy -= y;
        this.Clocks["R" + oid] = window.setTimeout(this.CodeName + ".ActResizeBy(\"" + oid + "\"," + dx + "," + dy + ",\"" + t + "\")", this.ActTimer);
    }
}

_Window.prototype.PreMove = function(o, e, t)
{ 
    if (typeof(this.Clocks["M" + o.id]) != "undefined") clearTimeout(this.Clocks["M" + o.id]);
    this.Show(o);
    this.Duplicate(o);
    var x = e.clientX - this.Copy.offsetLeft;
    var y = e.clientY - this.Copy.offsetTop;
    document.body.style.cursor = "move";
    eval("document.onmousemove = function(e) { " + this.CodeName + ".Move(o, e ? e : window.event, x, y, t); };");
    eval("document.onmouseup = function(e) { " + this.CodeName + ".Moved(o, e ? e : window.event, x, y, t); };");
    this.AttachEvent(o, e);
}

_Window.prototype.Move = function(o, e, x, y, t)
{
    if(t != "move-y") this.Copy.style.left = (e.clientX - x) + "px";
    if(t != "move-x") this.Copy.style.top = (e.clientY - y) + "px";
}

_Window.prototype.Moved = function(o, e, x, y, t)
{
    this.DetachEvent(o, e);
    var tx = (t == "move-y") ? null : (e.clientX - x + 2);
    var ty = (t == "move-x") ? null : (e.clientY - y + 2);
    if(this.ActTimer > 0) this.ActMoveTo(o.id, tx, ty, o.offsetLeft, o.offsetTop);
    else this.MoveTo(o, tx, ty);
    document.body.removeChild(this.Copy);
    this.Copy = null;
}

_Window.prototype.MoveTo = function(o, tx, ty)
{
    if(tx != null) o.style.left = tx + "px";
    if(ty != null) o.style.top = ty + "px";
}

_Window.prototype.ActMoveTo = function(oid, tx, ty, ix, iy)
{
    if((tx == null || tx == ix) && (ty == null || ty == iy)) return;
    if(tx != null)
    {
        var dx = (tx - ix)/10; dx = (dx > 0) ? Math.ceil(dx) : Math.floor(dx);
        ix += dx;
    }
    if(ty != null)
    {
        var dy = (ty - iy)/10; dy = (dy > 0) ? Math.ceil(dy) : Math.floor(dy);
        iy += dy;
    }
    var o = document.getElementById(oid);
    this.MoveTo(o, ix, iy);
    this.Clocks["M" + oid] = window.setTimeout(this.CodeName + ".ActMoveTo(\"" + oid + "\"," + tx + "," + ty + "," + ix + "," + iy + ")", this.ActTimer);
}

function GetIeVersion()
{
    var reg = new RegExp("MSIE ([^;]*);", "i");
    if (reg.test(navigator.appVersion)) return parseInt(RegExp.$1);
    return 0;
}

function InitPos()
{
    if(window.pageXOffset){DL=window.pageXOffset;}
    else if(document.documentElement&&document.documentElement.scrollLeft){
    DL=document.documentElement.scrollLeft;}
    else if(document.body){DL=document.body.scrollLeft;}

    if(window.pageYOffset){DT=window.pageYOffset;}
    else if(document.documentElement&&document.documentElement.scrollTop){
    DT=document.documentElement.scrollTop;}
    else if(document.body){DT=document.body.scrollTop;}
          
    if(window.innerWidth){DW=window.innerWidth;}
    else if(document.documentElement&&document.documentElement.clientWidth){ 
    DW=document.documentElement.clientWidth;}
    else if(document.body){DW=document.body.clientWidth;}

    if(window.innerHeight){DH=window.innerHeight;}
    else if(document.documentElement&&document.documentElement.clientHeight){ 
    DH=document.documentElement.clientHeight;}
    else if(document.body){DH=document.body.clientHeight;}

}

function UseVistaInIE6(obj)
{
    var BaseUrl="http://image.fotoever.com/imageserver/NewVerImage/PopupWin/";
	obj.childNodes[0].style.cssText += ";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+BaseUrl+"LEFT_TOP.png', sizingMethod='scale');background-image:url('"+BaseUrl+"LEFT_TOP.png') !important;background-image:none;";
	obj.childNodes[1].style.cssText += ";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+BaseUrl+"TOP.png', sizingMethod='scale');background-image:url('"+BaseUrl+"TOP.png') !important;background-image:none;";
	obj.childNodes[2].style.cssText += ";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+BaseUrl+"RIGHT_TOP.png', sizingMethod='scale');background-image:url('"+BaseUrl+"RIGHT_TOP.png') !important;background-image:none;";
	obj.childNodes[3].style.cssText += ";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+BaseUrl+"RIGHT.png', sizingMethod='scale');background-image:url('"+BaseUrl+"RIGHT.png') !important;background-image:none;";
	obj.childNodes[4].style.cssText += ";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+BaseUrl+"RIGHT_BOTTOM.png', sizingMethod='scale');background-image:url('"+BaseUrl+"RIGHT_BOTTOM.png') !important;background-image:none;";
	obj.childNodes[5].style.cssText += ";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+BaseUrl+"BOTTOM.png', sizingMethod='scale');background-image:url('"+BaseUrl+"BOTTOM.png') !important;background-image:none;";
	obj.childNodes[6].style.cssText += ";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+BaseUrl+"LEFT_BOTTOM.png', sizingMethod='scale');background-image:url('"+BaseUrl+"LEFT_BOTTOM.png') !important;background-image:none;";
	obj.childNodes[7].style.cssText += ";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+BaseUrl+"LEFT.png', sizingMethod='scale');background-image:url('"+BaseUrl+"LEFT.png') !important;background-image:none;";
}

var ieVersion = GetIeVersion();

function Open(id,title,width)
{
    var _windows = new Array();
    _windows[id] = { name:title, features:"width="+width+",height=-1", painted:false, object:null, x:335, y:parseInt(Math.random() * 300) };

    if(_windows[id].object)
    {
        if(!(document.getElementById(_windows[id].object.id)))
        {
        	if(_windows[id].painted)
        	{
        		document.body.appendChild(_windows[id].object);
        	}	
        	else
        	{
        		_windows[id].object = null; OpenText(id); return;
        	}
        }
        _window.Show(_windows[id].object);
        return;
    }
    var sBody = document.getElementById(id).innerHTML;
    _windows[id].object = _window.Open(sBody, _windows[id].name, _windows[id].features);
    _windows[id].painted = true;
    if(ieVersion > 0 && ieVersion < 7 && _window.ClassName == "VISTA") UseVistaInIE6(_windows[id].object);
    if(_window.ActTimer > 0) _window.ActMoveTo(_windows[id].object.id, _windows[id].x, _windows[id].y, _windows[id].object.offsetLeft, _windows[id].object.offsetTop);
    else _window.MoveTo(_windows[id].object, _windows[id].x, _windows[id].y);
}


//全站短信
function OpenMsg(title,content)
{
    InitPos();
    if(!IsOnline)return;
    var _windows = new Array();
    var id = "msg";
    var flag = document.createElement("div");
    flag.setAttribute("id", "MsgBox");
    flag.innerHTML = content;
    var width=360;
    _windows[id] = { name:title, features:"resize=no,width="+(width-30)+",height=-1,left="+(DW+DL-width)+",top="+(DH+DT), painted:false, object:null, x:0, y:0  };
    var sBody = flag.outerHTML;
    
    if(!document.getElementById("MsgBox"))
    {
    _windows[id].object = _window.Open(sBody, _windows[id].name, _windows[id].features);
    _windows[id].painted = true;
    if(ieVersion > 0 && ieVersion < 7 && _window.ClassName == "VISTA") UseVistaInIE6(_windows[id].object);

    var OH=_windows[id].object.offsetHeight;

    if(_window.ActTimer > 0) _window.ActMoveTo(_windows[id].object.id, DW+DL-width, DT+DH-OH, _windows[id].object.offsetLeft, _windows[id].object.offsetTop);
    else 
    _window.MoveTo(_windows[id].object, DW+DL-width, DT+DH-OH);
    }
    
}

//发送短信
function OpenSend(username)
{
    InitPos();
    if(!IsOnline)
    {OpenLogin();return;}
    var _windows = new Array();
    var id = "sendmsg";
    var flag = document.createElement("div");
    flag.setAttribute("id", "MsgBox");
    flag.innerHTML="<table cellpadding=\"4\" cellspacing=\"0\" width=\"100%\" border=\"0\" class=\"popup_content\"><tr><td>用户名：<input type=\"text\" id=\"txtName\" class=\"popup_import\" size=\"10\" value=\""+username+"\" onblur=\"CheckUserName(this.value)\" onfocus=\"CleanMsg()\"></td></tr><tr><td>留言内容：</td></tr><tr><td><textarea id=\"txtContent\" rows=\"5\" cols=\"40\" class=\"popup_textarea\"></textarea></td></tr><tr><td ><input type=\"button\" class=\"popup_btn\" value=\"确认\" id=\"btnsend\" onclick=\"SendMsg(document.getElementById('txtName').value, document.getElementById('txtContent').value);\">&nbsp;&nbsp;<input type=\"button\" class=\"popup_btn\" value=\"取消\" onclick=\"CloseObj()\">&nbsp;&nbsp;<span id=\"ErrorMsg\"></span></td></tr></table>"
    var width=360;
    _windows[id] = { name:"发送即时短信", features:"resize=no,width="+(width-30)+",height=-1,left="+(DW+DL-width)+",top="+(DH+DT), painted:false, object:null, x:0, y:0 };
    sBody=flag.outerHTML;
    if(!document.getElementById("MsgBox"))
    {
    _windows[id].object = _window.Open(sBody, _windows[id].name, _windows[id].features);
    _window.Show(_windows[id].object);
    _windows[id].painted = true;
    if(ieVersion > 0 && ieVersion < 7 && _window.ClassName == "VISTA") UseVistaInIE6(_windows[id].object);
    var OH=_windows[id].object.offsetHeight;
    if(_window.ActTimer > 0) _window.ActMoveTo(_windows[id].object.id, DW+DL-width, DT+DH-OH, _windows[id].object.offsetLeft, _windows[id].object.offsetTop);
    else _window.MoveTo(_windows[id].object, DW+DL-width, DT+DH-OH);
    }
   
}

function CheckUserName(UserName)
{
    if(UserName == "")
    {
       return false;
    }
    var _obj = eval("FotoEver.BlogLibrary.MessageAjax");
    var result = _obj.CheckUserName(UserName).value;
    if(result.toLowerCase() == "true")
    {
        document.getElementById("ErrorMsg").innerHTML = "<font color='#ff6600'>该用户不存在</font>" ;
        document.getElementById("txtName").value = ""; 
    }                
}

function OpenLogin()
{ 
    InitPos();
    var _windows = new Array();
    var id = "div";
    var flag = document.createElement("div");
    flag.setAttribute("id", "MsgBox");

    flag.innerHTML="<table cellpadding=\"4\" cellspacing=\"0\" width=\"100%\" border=\"0\" class=\"popup_content\"><tr><td>用户名：<input type=\"text\" id=\"txtName\" class=\"popup_import\" size=\"10\" onblur=\"CheckUserName(this.value)\" onfocus=\"CleanMsg()\"></td></tr><tr><td>密　码：<input type=\"password\" id=\"txtPassword\" class=\"popup_import\" size=\"10\"></input>&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"checkbox\" id=\"chkRemember\" size=\"10\" ></input>记住我</td></tr><tr><td ><input type=\"button\" class=\"popup_btn\" value=\"确认\" id=\"btnsend\" onclick=\"UserLogin(document.getElementById('txtName').value, document.getElementById('txtPassword').value,document.getElementById('chkRemember').checked);\">&nbsp;&nbsp;<input type=\"button\" class=\"popup_btn\" value=\"取消\" onclick=\"CloseObj()\">&nbsp;&nbsp;<span id=\"ErrorMsg\"></span></td></tr></table>";
    var width=240;
    _windows[id] = { name:"用户登录", features:"width="+width+",height=-1", painted:false, object:null, x:0, y:0};
    var sBody = flag.outerHTML;
    if(!document.getElementById("MsgBox"))
    {
    _windows[id].object = _window.Open(sBody, _windows[id].name, _windows[id].features);
    _windows[id].painted = true;
    var OH=_windows[id].object.offsetHeight;
    if(ieVersion > 0 && ieVersion < 7 && _window.ClassName == "VISTA") UseVistaInIE6(_windows[id].object);
    _window.MoveTo(_windows[id].object, (DL+(DW/2)-(width/2)), (DT+(DH/2)-(OH/2)));
    }
}

function UserLogin(UserName,Password,Remember)
{
    var tmpUserName = UserName.replace(/\s*/g,'');
    if (tmpUserName == '' || Password == '')
    {
        document.getElementById("ErrorMsg").innerHTML = "<font color=red>用户名或密码不能为空</font>";
        document.getElementById("txtName").focus();
        return;
    }
    else
    {
        CheckUserName(tmpUserName);
        var _obj = eval("FotoEver.BlogLibrary.MessageAjax");
        var result = _obj.LoginUser(UserName,Password,Remember).value;
        if(result.toLowerCase() == "true")
        {if (top.document.getElementById('leftmenu')){
        top.frames['leftmenu'].location.reload();
        top.frames['main'].location.reload();}
        else
        {
        top.frames.location.reload();
        }
        }
        else
        {
        alert('登录失败');
        }
        CloseObj();
    }
}

function CleanMsg()
{
document.getElementById("ErrorMsg").innerHTML = "" ;
}

function SendMsg(UserName,Content)
{
    var tmpUserName = UserName.replace(/\s*/g,'');
    var tmpContent = Content.replace(/\s*/g,'');
    if (tmpUserName == '' || tmpContent == '')
    {
        document.getElementById("ErrorMsg").innerHTML = "<font color='#ff6600'>用户名或内容不能为空</font>";
        return ;
    }
    else
    {
        CheckUserName(tmpUserName);
        var _obj = eval("FotoEver.BlogLibrary.MessageAjax");
        var msg = _obj.SendMessage(UserName,Content).value;
        if(msg == "0")
        {
        alert('即时短信发送失败');
        }
        CloseObj();
    }
}

function DelMsg(id)
{
    var _obj = eval("FotoEver.BlogLibrary.MessageAjax");
    var msg = _obj.DelMessage(id).value;
}

function UpdateMsg(id)
{
    var _obj = eval("FotoEver.BlogLibrary.MessageAjax");
    var msg = _obj.UpdateMessage(id).value;
}


function OpenDiv(title,content,width)
{
    InitPos();
    var _windows = new Array();
    var id = "div";
    var flag = document.createElement("div");
    flag.setAttribute("id", "MsgBox");
    flag.innerHTML=content;
    _windows[id] = { name:title, features:"width="+width+",height=-1", painted:false, object:null, x:0, y:0};
    var sBody = flag.outerHTML;
    if(!document.getElementById("MsgBox"))
    {
    _windows[id].object = _window.Open(sBody, _windows[id].name, _windows[id].features);
    _windows[id].painted = true;
    var OH=_windows[id].object.offsetHeight;
    if(ieVersion > 0 && ieVersion < 7 && _window.ClassName == "VISTA") UseVistaInIE6(_windows[id].object);
    _window.MoveTo(_windows[id].object, (DL+(DW/2)-(width/2)), (DT+(DH/2)-(OH/2)));
    }
}

function OpenPM(username)
{
    InitPos();
    if(!IsOnline)
    {OpenLogin();return;}
    var _windows = new Array();
    var id = "url";
    url="http://www.fotoever.com/spacemanage/message/postpm.aspx?username="+username;
    name="站内邮件";
    var flag = document.createElement("div");
    flag.setAttribute("id", "MsgBox");

    _windows[id] = { name:name, features:"resize=no,width=500,height=500,left="+(DL+(DW/2)-(500/2))+",top="+(DT+(DH/2)-(500/2)), painted:false, object:null, x:0, y:0 };

    if(_windows[id].object)
    {
        if(!(document.getElementById(_windows[id].object.id)))
        {
        	if(_windows[id].painted)
        	{
        		document.body.appendChild(_windows[id].object);
        	}	
        	else
        	{
        		_windows[id].object = null; OpenUrl(url, name); return;
        	}
        }
        if(_windows[id].name != name)
        {
            _window.Body(_windows[id].object, "[url]" + url, 0);
            _window.Title(_windows[id].object, name);
        }
        _window.Show(_windows[id].object);
        return;
    }
    if(!document.getElementById("MsgBox"))
    {
    _windows[id].object = _window.Open("[url]" + url, name, _windows[id].features);
    _windows[id].painted = true;
    if(ieVersion > 0 && ieVersion < 7 && _window.ClassName == "VISTA") UseVistaInIE6(_windows[id].object);
    }
}

function CloseObj() { 
var obj=document.getElementById("_W_"+wIndex);
document.body.removeChild(obj); }

function GetMsg()
{
    var _obj = eval("FotoEver.BlogLibrary.MessageAjax");
    _obj.GetMessage(Callback);
} 

function Callback(res)
{
     var result=res.value;
        if(result!=null&&result.indexOf("$$")!=-1)
        {
        var arrTmp = result.split("$$");
        OpenMsg(arrTmp[0],arrTmp[1]);
        }

}

function Msg(){
if(!IsOnline)return;
window.setInterval("GetMsg();",30000);
}

Msg();
