var ye_dialog = {
    Counter: 0,
    init: function(isladding/*锁定窗口时不显示loading图片，如参数为ture*/){
        $("select").css("visibility", "hidden");
		if(isladding){
        var a = '<div id="ye_dialog_overlay"></div>												<div id="ye_dialog_window">							<a id="ye_dialog_close" href="#" title="\u5173\u95ed"></a>							<div id="ye_dialog_title">\u8bf7\u7a0d\u5019...</div>							<div id="ye_dialog_body"></div>						</div>';
        }else{//默认锁定窗口时显示loading图片
        var a = '<div id="ye_dialog_overlay"></div>						<div id="ye_dialog_loading"></div>						<div id="ye_dialog_window">							<a id="ye_dialog_close" href="#" title="\u5173\u95ed"></a>							<div id="ye_dialog_title">\u8bf7\u7a0d\u5019...</div>							<div id="ye_dialog_body"></div>						</div>';
		}
	   $("body").append(a);
        var b = this.closeFun ? this.closeFun : function(){
        };
        $("#ye_dialog_close").click(function(){
            b();
            ye_dialog.close();
            return false
        });
        $("#ye_dialog_overlay").show();
        $("#ye_dialog_loading").show();
        this.position();
        return this
    },
    openHtml: function(b, e, a, d, c, f){
		/*
		 (
		    b:html,
			e:title,
			a:width,
			d:height,
			c:callback,
			f:closeFun
		  )
		*/
        if (f && $.isFunction(f.closeFun)) {
            this.closeFun = f.closeFun
        }
        this.init();
        if (b != undefined) {
        	if (typeof b=='object'){
        		$("#ye_dialog_body").append(b.children());
        		this.close_fun2 = function () {
						b.append( $("#ye_dialog_body").children() ); // move elements back when you're finished
				};
        	}else {
            	$("#ye_dialog_body").html(b)
            }
        }
        this.title(e == undefined ? "\u540C\u5B66" : e);
        this.resize(a ? a : 300, d ? d : 150);
        $("#ye_dialog_loading").remove();
        $("#ye_dialog_window").show();
        if ($.isFunction(c)) {
            c()
        }
        return this
    },
    openUrl: function(c, a, e, g, scrolling){
		/*
		(
		   c:url,
		   a:width,
		   e:height,
		   g:title,
		   f:scroll
		 )
		*/
        this.init();
        var b = a != undefined ? a : 300;
        var f = e != undefined ? e : 150;
		var s = scrolling != undefined ? scrolling : 'no';
        var d = (new Date).getTime();
        if (c.indexOf("?") == -1) {
            c = c + "?_t=" + d
        }
        else {
            c = c + "&_t=" + d
        }
        this.title(g == undefined ? "\u540C\u5B66" : g);
        $("#ye_dialog_body").html('<iframe id="ye_dialog_iframe" scrolling="'+s+'" frameborder="0"></iframe>');
        $("#ye_dialog_iframe").attr("src", c);
        this.resize(b, f);
        $("#ye_dialog_loading").remove();
        $("#ye_dialog_window").show()
    },
    close: function(){
    	if (typeof this.close_fun2=='function'){
    		this.close_fun2();
    	}
        $("#ye_dialog_window").remove();
        $("#ye_dialog_overlay").remove();
        $("select").css("visibility", "visible");
        return this
    },
    resize: function(a, c){//(a:width---int, b:height----int)
        var d = a ? a : 300;
        var b = c ? c : 150;
        $("#ye_dialog_window").css({
            width: d + "px",
            height: b + "px"
        });
        $("#ye_dialog_body").css("height", "99%").css("height", c - 28 + "px");
        this.position();
        return this
    },
    position: function(){
        var b = $("#ye_dialog_window").width();
        var a = $("#ye_dialog_window").height();
        $("#ye_dialog_window").css({
            marginLeft: "-" + parseInt(b / 2) + "px"
        });
        if (!($.browser.msie && $.browser.version < 7)) {
            $("#ye_dialog_window").css({
                marginTop: "-" + parseInt(a / 2) + "px"
            })
        }
        return this
    },
    title: function(a){
        if (a != undefined) {
            $("#ye_dialog_title").text(a);
            return this
        }
        else {
            return $("#ye_dialog_title").text()
        }
    }
};
var ye_msg = {
    Counter: 0,
    open: function(e, d, c, b){//(e:html,d:timer,c:type(int),b:callback)
        this.Counter++;
        var a = '<div id="ye_msg_' + this.Counter + '" class="ye_msg_window"><div class="ye_msg_wrap">' + e + "</div></div>";
        $("body").append(a);
        $("#ye_msg_" + this.Counter + " > .ye_msg_wrap").addClass("ye_msg_ico_" + c);
        this.position(this.Counter);
        if (typeof b == "function") {
            b()
        }
        if (d != undefined && d != 0) {
            $("#ye_msg_" + this.Counter + " > .ye_msg_wrap").append('<div class="ye_msg_autoclose">(' + d + "\u79d2\u540e\u8fd4\u56de)</div>");
            setTimeout('$("#ye_msg_' + this.Counter + '").remove()', d * 1000)
        }
    },
    position: function(c){//(c:this.Counter)
        var b = $("#ye_msg_" + c).width();
        var a = $("#ye_msg_" + c).height();
        $("#ye_msg_" + c).css({
            marginLeft: "-" + parseInt(b / 2) + "px"
        })
    }
};
//ajax提交，马上出现锁定窗口和loadding图片，然后成功后消失
var ye_msg_2={
    open: function(e, d, c, b){//(e:html为了和ye_msg保持一至暂保留参数占位符，可传递空字符串，可扩展,d:timer,c:type(int)暂无，可扩展,b:callback暂无，可扩展)
		ye_dialog.init(true/*不显示锁定窗口loading图片*/);
        var a = '<div id="ye_msg_ajax" class="ye_msg_window"><div class="ye_msg_wrap" style="text-align:center; color:#333;">'+e+'...<br/><img src="http://site.tongxueimg.com/v4/k/images/Loadingye_msg_2.gif" /></div></div>"';
        $("body").append(a);
        this.position('ajax');
        if (typeof b == "function") {
            b()
        }
        if (d != undefined && d != 0) {
            setTimeout(ye_msg_2.closer, d * 1000)
        }
    },
    position: function(c){//(c:this.Counter)
        var b = $("#ye_msg_" + c).width();
        var a = $("#ye_msg_" + c).height();
        $("#ye_msg_" + c).css({
            marginLeft: "-" + parseInt(b / 2) + "px"
        })
    },
	closer:function(timer/*成功后关闭延时,单位秒*/){
		if($('#ye_msg_ajax') && $("#ye_dialog_overlay")){
			$('#ye_msg_ajax').remove();
			setTimeout(function(){
				$("#ye_dialog_overlay").remove();				
			},timer*1000)
		}
	}
}
function ye_tips_show(h, c, f){//(h:element,c:html,f:$("#tx_tips").width)
    if (document.getElementById("ye_tips") == null) {
        var g = '<div id="ye_tips">							<div id="ye_tips_arr"></div>							<div class="ye_tips_u ye_tips_u_left"></div>							<div id="ye_tips_body">' + c + '</div>							<div class="ye_tips_u ye_tips_u_right"></div>						</div>';
        $("body").append(g)
    }
    else {
        $("#ye_tips_body").text(c)
    }
    $("#ye_tips").css("width", f + "px");
    $("#ye_tips_body").css("width", (f - 20) + "px");
    var e = $("#" + h).width();
    var b = $("#" + h).offset().left;
    var a = $("#" + h).offset().left + e;
    var d = $("#" + h).offset().top - 27;
    $("#ye_tips").css("top", d + "px");
    if (b < f / 2) {
        $("#ye_tips").css("left", b + "px");
        $("#ye_tips_arr").attr("class", "ye_tips_arr_left")
    }
    else {
        if ($("body").innerWidth() - a < f / 2) {
            $("#ye_tips").css({
                right: ($("body").innerWidth() - a) + "px",
                left: "auto"
            });
            $("#ye_tips_arr").attr("class", "ye_tips_arr_right")
        }
        else {
            $("#ye_tips").css("left", (b - f / 2 + e / 2) + "px");
            $("#ye_tips_arr").attr("class", "ye_tips_arr_center")
        }
    }
    $("#ye_tips").css({
        visibility: "visible"
    })
}

function ye_tips(e, c, a, b, d, f){
    b = b != undefined ? b : 150;
    $("#" + e).hover(function(){
        ye_tips_show(c, a, b)
    }, function(){
        $("#ye_tips").css("visibility", "hidden")
    })
}

function ye_formTips(a, d, e){
    e = e != undefined ? e : 0;
    if (document.getElementById(a + "_msg") == null) {
        $("body").append('<div id="' + a + '_msg" class="formTips"></div>')
    }
    if (e == 0) {
        $("#" + a + "_msg").attr("class", "formTips formTips_tips")
    }
    else {
        if (e == 1) {
            $("#" + a + "_msg").attr("class", "formTips formTips_err")
        }
        else {
            if (e == 2) {
                $("#" + a + "_msg").attr("class", "formTips formTips_ok")
            }
        }
    }
    var b = $("#" + a).offset().left + $("#" + a).width();
    var c = $("#" + a).offset().top;
    $("#" + a + "_msg").html(d);
    $("#" + a + "_msg").css("left", b + "px");
    $("#" + a + "_msg").css("top", c + "px");
    $("#" + a + "_msg").css("display", "block")
}

function ye_formTips_remove(a){
    $("#" + a + "_msg").css("display", "none")
};


var popup_order_XY={
	init:function(conid,evt){
		var e=(evt)?evt:window.event;  
		if (window.event) {  
			 e.cancelBubble=true;  
		} else {  
			 e.stopPropagation();  
		}  
		$(document).bind("click",function(){popup_order_XY.closer(conid)});
		var con=document.getElementById(conid);
		con.style.display=''
	},
	closer:function(conid){
			var box=document.getElementById(conid);
			box.style.display='none';
	}
}