﻿//移动浮动窗
function moveDiv(event, _sId)
{　 var GetObj = function (_sId) {return "string" == typeof _sId ? document.getElementById(_sId) : _sId;};
    var oObj = GetObj(_sId);	
    oObj.onmousemove = mousemove;
    oObj.onmouseup = mouseup;
    oObj.setCapture ? oObj.setCapture() : function(){};
    oEvent = window.event ? window.event : event;
    var dragData = {x : oEvent.clientX, y : oEvent.clientY};
    var backData = {x : parseInt(oObj.style.top), y : parseInt(oObj.style.left)};
    function mousemove(){　
        var oEvent = window.event ? window.event : event;
        var iLeft=oEvent.clientX-dragData["x"]+(isNaN(parseInt(oObj.style.left))?0:parseInt(oObj.style.left));
        var iTop=oEvent.clientY-dragData["y"]+(isNaN(parseInt(oObj.style.top))?0:parseInt(oObj.style.top));;
        oObj.style.left = iLeft;
        oObj.style.top = iTop;
        dragData = {x: oEvent.clientX, y: oEvent.clientY}; 
    }
    function mouseup(){  
        var oEvent = window.event ? window.event : event;
        oObj.onmousemove = null;
        oObj.onmouseup = null;
        if(oEvent.clientX < 1 || oEvent.clientY < 1){
	        oObj.style.left = backData.y;
	        oObj.style.top = backData.x;
        }
	        oObj.releaseCapture ? oObj.releaseCapture() : function(){};
    }
}
//设置PopBox尺寸
function SetPopBox(iwidth,iheight)
{   
    var BoxBorder=14;
    $("#PopBox").css("height",iheight+"px");
    $("#PopBox").css("width",iwidth+"px");
    $("#BoxTransparentLayer").css("height",iheight+"px");
    $("#BoxTransparentLayer").css("width",iwidth+"px");     
    $("#BoxBody").css("height",iheight-BoxBorder +"px");
    $("#BoxBody").css("width",iwidth-BoxBorder +"px");                     
    $("#PopBox a.popMov").css("width",iwidth+"px")
}
//关闭浮动窗
function ClosePopBox()
{
    //移除内容
    $("#View").html="";
    $("#View").remove();
    $("#BoxBody img").remove();
    $("#PopBox").hide("slow");
}
//显示浮动窗
function ShowView(obj,id){
    if (obj=="LoadBoxBody") {id="AjaxLogin.aspx";}
    $("#BoxBody").append("<img class=Loadimg src=../images/ajax-loader2.gif />")
    $.post(obj+".aspx", { Action: "post", Pams: id },
    function (data, textStatus){
        $("#BoxBody .Loadimg").remove();
        if(!document.all.View){
        $("#BoxBody").append("<div id='View'>"+data.result+"</div>");
        }else{
            $("#View").html(data.result);
        }
    },
     "json");       
} 
$(function(){
$("img.pop_close").click(function(){ClosePopBox();}).css("cursor","hand").mouseover(function(){$(this).attr("src","../images/Close_1.gif");}).mouseout(function(){$(this).attr("src","../images/Close_.gif");});
});