function changePos(a, d) {
	if ($("#uploadPicSale").length > 0) { 
		var e = $("#uploadPicSale li");
		if (e.length != 1)  {
			var f = $(a).parent();
			g = e.index(f);
			h = g + d;
			if (h < 0) h = e.length - 1;
			else if (h == $("#uploadPicSale li").length) h = 0;
			h = $("#uploadPicSale li:eq(" + h + ")");
			f.css("opacity", 0.5);
			if (d < 0) g == 0 ? $(h).after(f) : $(h).before(f);
			else g == e.length - 1 ? h.before(f) : $(h).after(f);
			f.animate({
				opacity: 1
			},
			450);
			markCover();
		}
	}
	else if ($("#uploadPic").length > 0) { 
		var e = $("#uploadPic li");
		if (e.length != 1)  {
			var f = $(a).parent();
			g = e.index(f);
			h = g + d;
			if (h < 0) h = e.length - 1;
			else if (h == $("#uploadPic li").length) h = 0;
			h = $("#uploadPic li:eq(" + h + ")");
			f.css("opacity", 0.5);
			if (d < 0) g == 0 ? $(h).after(f) : $(h).before(f);
			else g == e.length - 1 ? h.before(f) : $(h).after(f);
			f.animate({
				opacity: 1
			},
			450);
			markCover();
		}
	}
	else if ($("#uploadPicNews").length > 0) { 
		var e = $("#uploadPicNews li");
		if (e.length != 1)  {
			var f = $(a).parent();
			g = e.index(f);
			h = g + d;
			if (h < 0) h = e.length - 1;
			else if (h == $("#uploadPicNews li").length) h = 0;
			h = $("#uploadPicNews li:eq(" + h + ")");
			f.css("opacity", 0.5);
			if (d < 0) g == 0 ? $(h).after(f) : $(h).before(f);
			else g == e.length - 1 ? h.before(f) : $(h).after(f);
			f.animate({
				opacity: 1
			},
			450);
			markCover();
		}
	}
}
function markCover() {
	 var listimg="";
	 if ($("#uploadPicSale").length > 0) { 
		 $("#uploadPicSale .front-cover").html("&nbsp;");
		$("#uploadPicSale .front-cover:eq(0)").html("封面")
		if($("#uploadPicSale li").length >0)
			$("#AntFirstImages").val( $("#uploadPicSale li img:eq(0)").attr("src") );
		else
			$("#AntFirstImages").val("");
		for(var jj=0;jj<$("#uploadPicSale li").length;jj++){
			if(listimg!="")
				listimg +=",";
			listimg +=$("#uploadPicSale li img:eq("+jj+")").attr("src");
		}
	 }
	 else if ($("#uploadPic").length > 0) { 
		 $("#uploadPic .front-cover").html("&nbsp;");
		$("#uploadPic .front-cover:eq(0)").html("封面")
		if($("#uploadPic li").length >0)
			$("#AntFirstImages").val( $("#uploadPic li img:eq(0)").attr("src") );
		else
			$("#AntFirstImages").val("");
		for(var jj=0;jj<$("#uploadPic li").length;jj++){
			if(listimg!="")
				listimg +=",";
			listimg +=$("#uploadPic li img:eq("+jj+")").attr("src");
		}
    }
	 else if ($("#uploadPicNews").length > 0) { 
		 $("#uploadPicNews .front-cover").html("&nbsp;");
		$("#uploadPicNews .front-cover:eq(0)").html("封面")
		if($("#uploadPicNews li").length >0)
			$("#AntFirstImages").val( $("#uploadPic li img:eq(0)").attr("src") );
		else
			$("#AntFirstImages").val("");
		for(var jj=0;jj<$("#uploadPicNews li").length;jj++){
			if(listimg!="")
				listimg +=",";
			listimg +=$("#uploadPicNews li img:eq("+jj+")").attr("src");
		}
    }
	$("#AntAllImages").val(listimg);
}
function UploaderClient(b) {
    if (!b.containerId) {
        alert("请指定显示上传插件的容器元素id号。 ")
    }
    var a = $("#" + b.containerId);
    if (a.length == 0) {
        alert(a + "不有效的网页元素。 ")
    }
    if (!b.saveInfoInputId) {
        alert("请指定保存图片信息的表单元素id号。 ")
    }
    this.saveInfoInput = $("#" + b.saveInfoInputId);
    if (this.saveInfoInput.length == 0) {
        alert(b.saveInfoInputId + "不有效的表单元素。 ")
    }
    this.saveInfoInput.val("");
    this.id = "uploader_" + UploaderClient.countNum++;
    UploaderClient.instances[this.id] = this;
    this.loaded = false;
    this.uploadedCount = b.uploadedCount || 0;
    this.uploadFiles = {};
    this.deleteFiles = {};
    this.settings = {
        uploadDir: b.uploadDir || "Upload/images/",
        uploaderUrl: b.uploaderUrl || "/SWFupload/swfupload.aspx",
        maxNum: b.maxNum || 5,
        maxSize: b.maxSize || 1024 * 1024 * 2,
        type: b.type || "gif,jpg,jpeg,png,bmp",
        typeDescription: b.typeDescription || "图片",
        resizeWidth: b.resizeWidth || 600,
        resizeHeight: b.resizeHeight || 450,
        resizeCutEnable: b.resizeCutEnable ? true : false,
        createMiddle: b.createMiddle ? true : false,
        middleWidth: b.middleWidth || 334,
        middleHeight: b.middleHeight || 208,
        createThumb: b.createThumb ? true : false,
        thumbWidth: b.thumbWidth || 0,
        thumbHeight: b.thumbHeight || 0,
        watermark: b.watermark ? true : false,
        watermarkMiddle: b.watermarkMiddle ? true : false,
        onAddFile: b.onAddFile || null,
        onDeleteFile: b.onDeleteFile || null,
        onLoad: b.onLoad,
        debug: b.debug,
        from: b.from
    };
    this.attachmentRootUrl = b.attachmentRootUrl || "";
    if (this.attachmentRootUrl) {
        this.setAttachmentRootUrl(this.attachmentRootUrl)
    }
    
    var c = this.settings.uploaderUrl.split("/");
    delete c[c.length - 1];
    this.uploaderDir = c.join("/");
    this.addIframe(a)
}
UploaderClient.IframeInfo = function () {
    this.container = null;
    this.iframe = null;
    this.window = null;
    this.document = null;
    this.setHeight = function (b) {
        try {
            if (!b) {
                var e = this.document;
                this.iframe.css({
                    height: $(e.body).outerHeight()
                });
                var a = e.body.scrollHeight;
                var d = e.documentElement.scrollHeight;
                this.iframe.css({
                    height: "100%"
                });
                b = Math.max(a, d)
            }
            this.container.css({
                height: b
            })
        } catch (c) {}
    }
};
UploaderClient.prototype.addIframe = function (e) {
    var a = $("<div></div>");
    a.css({
        overflow: "hidden",
        position: "relative",
        height: 24
    });
    var c = $("<iframe></iframe>");
    var d = new UploaderClient.IframeInfo();
    this.iframeInfo = d;
    d.iframe = c;
    d.container = a;
    c.attr({
        frameBorder: 0,
	allowTransparency:"true",
        scrolling: "no"
    });
	
    c.css({
        border: 0,
        padding: 0,
        margin: 0,
        width: "100%",
        height: "100%",
	
        visibility: "hidden"
    });
    var b = this;
    c.load(function () {
        c.css({
            visibility: "visible" 
        });
        try {
            d.document = c.get(0).contentDocument || c.get(0).contentWindow.document;
            c.get(0).contentWindow.iframeIdInParent = b.id;
            d.window = c.get(0).contentWindow
        } catch (f) {}
    });
    e.append(a);
    a.append(c);
    c.attr("src", this.settings.uploaderUrl + "?randtime=" + Math.random())
	/*alert($(a).html());*/
};
UploaderClient.prototype.getUploadedCount = function () {
    return this.uploadedCount
};
UploaderClient.prototype.setLoaded = function () {
    if (this.loaded) {
        return
    }
    this.loaded = true;
    if (typeof this.settings.onLoad == "function") {
        this.settings.onLoad.apply(this)
    }
};
UploaderClient.prototype.getSettings = function () {
    return this.settings
};
UploaderClient.prototype.setAttachmentRootUrl = function (a) {
    if (a.substr(a.length - 1, 1) != "/") {
        a += "/"
    }
    this.attachmentRootUrl = a
};
UploaderClient.prototype.getFullAttachmentUrl = function (a) {
    return this.attachmentRootUrl + a
};
UploaderClient.prototype.getAttachmentHtml = function (f, b, h) {
    if (!f || (!f.thumb_image && !f.image)) {
        return ""
    }
    var e = "";
    b = b || this.settings.thumbWidth;
    h = h || this.settings.thumbHeight;
    
    var d = ' width="' + b + '" height="' + h + '"';
    var a = this.getFullAttachmentUrl(f.thumb_image || f.image);
    var g = a.split(".");
    var i = g[g.length - 1];
    i = i.toLowerCase();
    if ((f.thumb_image && f.thumb_image != "undefined") || i in {
        gif: 1,
        jpg: 1,
        jpeg: 1,
        png: 1,
        png: 1
    }) {
        e += '<img src="' + a + '" ' + d + ">"
    } else {
        if (i == "swf") {
            e += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" ' + d + ">";
            e += '	<param name="movie" value="' + a + '" />';
            e += '	<param name="quality" value="high" />';
            e += '	<param name="wmode" value="transparent" />';
            e += '	<embed src="' + a + '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ' + d + "></embed>";
            e += "</object>"
        } else {
            if (i == "pdf") {
                e += '<img src="' + this.uploaderDir + '/images/files/pdf.gif" ' + d + ">"
            } else {
                var c = (f.thumb_image || f.image).split("/");
                e += "<strong>" + c[c.length - 1] + "</strong>"
            }
        }
    }
    return e
};
UploaderClient.prototype.tellUploadedCount = function (a) {
    if (this.loaded && this.iframeInfo.window) {
        this.iframeInfo.window.UploaderServer.setUploadedCount(a)
    }
};
UploaderClient.prototype.tellDeleteFile = function (a) {
    if (this.loaded && this.iframeInfo.window) {
        this.iframeInfo.window.UploaderServer.deleteImage(a)
    }
};
UploaderClient.prototype.addFile = function (a) {
    if (!a.id) {
        a.id = "tmp" + new Date().getTime();
        a.is_new = true
    } else {
        if (isNaN(a.id)) {
            a.is_new = true
        } else {
            a.is_new = false
        }
    }
    this.uploadFiles[a.id] = a;
    if (this.deleteFiles[a.id]) {
        this.deleteFiles[a.id] = null
    }
    this.uploadedCount++;
    this.tellUploadedCount(this.uploadedCount);
    this.save(true);
    if (typeof this.settings.onAddFile == "function") {
        this.settings.onAddFile.apply(this, [a])
    }
};
UploaderClient.prototype.deleteFileById = function (a,b) {
    if (!this.uploadFiles[a]) {
        return
    }
    if (this.uploadFiles[a].is_new == false) {
        this.deleteFiles[a] = this.uploadFiles[a]
    }
    this.tellDeleteFile(this.uploadFiles[a]);
    this.uploadedCount--;
    this.tellUploadedCount(this.uploadedCount);
    this.uploadFiles[a] = null;
    this.save(true);
    if (typeof this.settings.onDeleteFile == "function") {
        this.settings.onDeleteFile.apply(this, [a])
    }
	$.ajax({
		url: "/Public/ajax.aspx?action=delfile&f="+escape(b),
		cache: false,
		success:function(data)
		{
			
		}
	});
};
UploaderClient.prototype.deleteFile = function (a) {
    if (!a.id || a.is_new) {
        return
    }
    this.deleteFiles[a.id] = a;
    if (this.uploadFiles[a.id]) {
        this.tellDeleteFile(a);
        this.uploadedCount--;
        this.tellUploadedCount(this.uploadedCount);
        this.uploadFiles[id] = null;
    }
    this.save(true);
    if (typeof this.settings.onDeleteFile == "function") {
        this.settings.onDeleteFile.apply(this, [id])
    }
};
UploaderClient.prototype.save = function (d) {
    if (d == true) {
        var a = {};
        for (var e in this.uploadFiles) {
            if (this.uploadFiles[e] != null) {
                a[e] = this.uploadFiles[e]
            }
        }
        this.uploadFiles = a;
        var c = {};
        for (var e in this.deleteFiles) {
            if (this.deleteFiles[e] != null) {
                c[e] = this.deleteFiles[e]
            }
        }
        this.deleteFiles = c
    }
    var b = this.jsonEncode([this.uploadFiles, this.deleteFiles]);
    this.saveInfoInput.val(b)
};
UploaderClient.prototype.setFileInfo = function (c, a, b) {
    if (this.uploadFiles[c]) {
        this.uploadFiles[c][a] = b;
        this.save(false)
    }
};
UploaderClient.prototype.jsonEncode = function (arr) {
    var Json = new
    function () {
        var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
            escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
            meta = {
                "\b": "\\b",
                "\t": "\\t",
                "\n": "\\n",
                "\f": "\\f",
                "\r": "\\r",
                '"': '\\"',
                "\\": "\\\\"
            };

        function quote(string) {
            escapable.lastIndex = 0;
            return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
                var c = meta[a];
                return typeof c === "string" ? c : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4)
            }) + '"' : '"' + string + '"'
        }
        function str(value) {
            var i, k, v, partial, is_list;
            switch (typeof value) {
            case "string":
                return quote(value);
            case "number":
                return isFinite(value) ? String(value) : "null";
            case "boolean":
            case "null":
                return String(value);
            case "object":
                if (!value) {
                    return "null"
                }
                value = value.valueOf();partial = [];is_list = (Object.prototype.toString.apply(value) === "[object Array]");
                for (k in value) {
                    if (Object.hasOwnProperty.call(value, k)) {
                        v = str(value[k]);
                        if (is_list) {
                            partial.push(v || "null")
                        } else {
                            if (v) {
                                partial.push(quote(k) + ":" + v)
                            }
                        }
                    }
                }
                return is_list ? "[" + partial.join(",") + "]" : "{" + partial.join(",") + "}"
            }
        }
        return {
            encode: function (value) {
                return str(value)
            },
            decode: function (text) {
                cx.lastIndex = 0;
                if (cx.test(text)) {
                    text = text.replace(cx, function (a) {
                        return "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4)
                    })
                }
                if (/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]").replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) {
                    return eval("(" + text + ")")
                }
                alert("JSON decode error")
            }
        }
    };
    return Json.encode(arr)
};
UploaderClient.countNum = 0;
UploaderClient.instances = {};
UploaderClient.getUploaderClient = function (a) {
    return UploaderClient.instances[a]
};
