function iOverlayOn(txt){
	var text = txt ? txt : "正在更新请稍后...";
	var $overlay = "<div style='display:none;'>";
	$overlay += "<div style=\"background-color:#3e3e3e;top:0;left:0;height:0;width:0;z-index:1000;position:absolute\" id='overlay'></div>";
	$overlay += "<div style=\"color:#fff;position:absolute;top:30px;right:10px;z-index:1001;width:120px;height:25px;";
	$overlay += "background-color:#707070;line-height:25px;background:transparent url(/images/loading.gif) 0px 3px no-repeat;";
	$overlay += "text-indent:20px;text-align:left;\">"+text+"</div></div>";
	if (!$("#overlay").size()){$("body").append($overlay);}
	var b_width  = $("body").width();
	var b_height = $("body").height();
	var d_width  = $(document).width();
	var d_height = $(document).height();

	var cur_width  = b_width > d_width ? b_width : d_width;
	var cur_height = b_height > d_height ? b_height : d_height;

	$("#overlay").css({"width":cur_width+"px", "height":cur_height+"px"}).animate({'opacity':.7}, 100).parent().show();
}

function iOverlayOff(){
	if ($("#overlay").size()){$("#overlay").parent().fadeOut(500)};
}


jQuery.fn.iButton = function(o){
	$(this).css({
		"background" : "transparent url(/images/buttons.gif) 1px 1px  no-repeat",
		"borderWidth": "0px",
		"margin": "0px 5px",
		"padding": "0px",
		"width": "80px",
		"height": "26px"
		}).bind("mouseover", function(){
			$(this).css({"background" : "transparent url(/images/buttons.gif) 1px -29px  no-repeat"});
		}).bind("mouseout", function(){
			$(this).css({"background" : "transparent url(/images/buttons.gif) 1px 1px  no-repeat"});
		}).bind("mousedown", function(){
			$(this).css({"background" : "transparent url(/images/buttons.gif) 1px -59px  no-repeat"});
		}).bind("click", function(){
			$(this).css({"background" : "transparent url(/images/buttons.gif) 1px -29px  no-repeat"});
		});
}

jQuery.fn.iNumber = function(o){
	$(this).bind("keydown", function(e){
		if ((e.keyCode >47 && e.keyCode < 58) || (e.keyCode > 95 && e.keyCode < 106) || 
			e.keyCode == 8 || e.keyCode == 46 || (e.keyCode < 41 && e.keyCode > 36)){
			return true;
		}else{
			return false;
		}
	}).bind("blur", function(){
		$(this).val($(this).val().replace(/\D/ig, ""));
	});
}

$(window).bind("resize", function(){
	if ($("#overlay").size() && $("#overlay").is(":visible")){
		var b_width  = $("body").width();
		var b_height = $("body").height();
		var d_width  = $(document).width();
		var d_height = $(document).height();

		var cur_width  = b_width > d_width ? b_width : d_width;
		var cur_height = b_height > d_height ? b_height : d_height;

		$("#overlay").css({"width":cur_width+"px", "height":cur_height+"px"});
	}
});

// debug
function debug(args){
	if (window.console){
		window.console.log(args);
	}else{
		window.alert(args);
	}
}