//彩票业务类
function iMsg(name){
	var self = this;
	this.name = name;  //实例名称
	this.IE = (document.getElementById && document.all);
	this.NS = (document.getElementById && !document.all); 
	this.img_path = 'images/';
	
	this.msg_id = null;//提示框
	this.msg_init();
	this.msg_timer = null;
	this.msg_timeout = 12000;

	this.borderWidth = '1px';
	this.background = '#FFFFCC';
	
	this.icon = "alert.gif";
	this.icon_status = true;
	this.msg_style = 'color:#1C8200;font-weight:bold;';
}


//提示框初始化
iMsg.prototype.msg_init = function() {
	document.write("<style type=\"text/css\">");
	document.write("#iMsg_div{\n");
	document.write("POSITION: absolute;display:none; z-index:1000;\n");
	document.write("border:1px solid #F7D3D4;background:#FFFFCC;\n ");
	document.write("text-align:center;padding:0px;margin:0px;\n");
	document.write("left:130px;top:74px;width:200px;height:60px;\n");
	document.write("color:#FF0000;font-weight:bold;\n");	
	
	document.write("\n}");

	document.write("</style>");
	
	document.write("<div id='iMsg_div' class='iMsg_div'></div>");	
	this.msg_id = this.getID("iMsg_div");
	
}
iMsg.prototype.restore = function(l,r,t,b) {
	this.setPadding(0,0,0,0);
	this.icon_status = true;
	this.msg_timeout = 5000;
}
iMsg.prototype.setPadding = function(l,r,t,b) {
	if(typeof(l) == 'number')this.msg_id.style.paddingLeft = l + "px";
	if(typeof(r) == 'number')this.msg_id.style.paddingRight = r + "px";
	if(typeof(t) == 'number')this.msg_id.style.paddingTop = t + "px";
	if(typeof(b) == 'number')this.msg_id.style.paddingBottom = b + "px";
}
iMsg.prototype.setColor = function(border, bgcolor, msgStyle) {
	try{
		if(border){
			this.msg_id.style.borderColor = border;
		}
		if(bgcolor){
			this.background = bgcolor;
			this.msg_id.style.backgroundColor = bgcolor;
		}
		if(msgStyle)this.msg_style = msgStyle;
	}catch(e){

	}

}
iMsg.prototype.setAlpha = function ( alpha ){
	this.msg_id.style.filter = "alpha(opacity="+alpha+")"; /* IE用 */
	this.msg_id.style.mozOpacity = alpha / 100; /* FireFox用 */
	this.msg_id.style.opacity = alpha / 100; /* Safari用 */
}
//显示提示框
iMsg.prototype.msg_show2 = function(txt, id) {
	if (this.msg_timer) {
		window.clearTimeout(this.msg_timer);
		this.msg_timer = null;
	}
	if(this.msg_timeout)this.msg_timer = window.setTimeout(this.name + '.msg_hide()', this.msg_timeout); 
	this.msg_show(txt, 0, 0, 0, 0, this.getID(id));
}

iMsg.prototype.msg_show3 = function(txt, x, y, w, h) {
	if (this.msg_timer) {
		window.clearTimeout(this.msg_timer);
		this.msg_timer = null;
	}
	
	if(this.msg_timeout)this.msg_timer = window.setTimeout(this.name + '.msg_hide()', this.msg_timeout); 
	this.msg_show(txt, x, y, w, h);
}
iMsg.prototype.msg_show4 = function(txt, id) {
	if (this.msg_timer) {
		window.clearTimeout(this.msg_timer);
		this.msg_timer = null;
	}
	this.msg_show(txt, 0, 0, 0, 0, this.getID(id));
}

//显示提示框
iMsg.prototype.msg_show = function(txt, x, y, w, h, o) {
	var icon = this.img_path + this.icon;
	this.msg_id.innerHTML = "<table border=0 width=100% height=100% cellpadding=0 cellspacing=0><tr>" + (this.icon_status ? "<td width=20 valign=middle align=center><img src='" + icon + "' border=0></td>" : "") + "<td valign=middle align=left><span style='" + this.msg_style + "'>" + txt + "</span></td></table>";
	if(typeof(o) == 'object'){
		x = this.get_left(o);
		y = this.get_top(o);
		w = this.get_width(o);
		h = this.get_height(o);
		if(o.style.zIndex)this.msg_id.style.zIndex = parseInt(o.style.zIndex, 10) + 1;
	}else{
		var body_w = this.get_width(document.body);
		var body_h = this.get_height(document.body);
		if(!w){
			var w = 200;	
		}
		if(!h){
			var h = 60;	
		}
		if(!x){
			var x = (body_w - w) / 2;
		}
		if(!y){
			var y = (body_h - h) / 2;
		}
	}
	this.msg_id.style.left = x + "px";
	this.msg_id.style.top = y + "px";
	this.msg_id.style.width = (w+1) + "px";
	this.msg_id.style.height = h + "px";

	this.msg_id.style.borderWidth = this.borderWidth;
	this.msg_id.style.background = this.background;
	this.msg_id.style.display = 'block';
	
}
//隐藏提示框
iMsg.prototype.msg_hide = function() {
	try{
 		this.msg_id.style.display = 'none';
		this.msg_id.innerHTML = "";
		this.msg_id.style.borderWidth = "0px";
		this.msg_id.style.background = "transparent";
		imsg.restore();
	}catch(e){
	}
	
}
iMsg.prototype.get_left = function(obj) {
	return (obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft + this.get_left(obj.offsetParent));
}

iMsg.prototype.get_top = function(obj) {
	return (obj.offsetParent==null ? obj.offsetTop : obj.offsetTop + this.get_top(obj.offsetParent));
}

iMsg.prototype.get_width = function(obj) {
	var w = parseInt(obj.style.width, 10);
	if(!w){
		try{
			if(obj.width.indexOf('%') == -1)w = parseInt(obj.width, 10);
		}catch(e){
		}
	}
	if(!w){
		try{
			w = parseInt(obj.offsetWidth, 10);	
		}catch(e){
			w = 200;
		}
	}
	return w;
}
iMsg.prototype.get_height = function (obj){
	var h = parseInt(obj.style.height, 10);
	if(!h){
		try{
			if(obj.height.indexOf('%') == -1)h = parseInt(obj.height, 10);	
		}catch(e){
		}
	}

	if(!h){
		try{
			h = parseInt(obj.offsetHeight, 10);	
		}catch(e){
			h = 200;
		}
	}
	return h;
}
iMsg.prototype.getID = function (obj){
	var element = null;
	if(document.getElementById){
		element = document.getElementById(obj);
	}
	else if(document.all){
		element = document.all[obj];
	}
	else if(document.layers){
		element = document.layers[obj];
	} 
	return element;

} 
var imsg = new iMsg('imsg');
