/**
	Powered By 湖南地税廉政网络监督系统 Copyright © 2008-2009 All rights reserved.
	23:25 2008-5-3
**/
var msgbox_scripts = document.getElementsByTagName("script"); 
var msgbox_path = msgbox_scripts.item(msgbox_scripts.length-1).getAttribute('src').replace('\\', '/');
msgbox_path = msgbox_path.substring(0, msgbox_path.lastIndexOf('/')+1);
document.write('<link href="' + msgbox_path + 'msgbox.css" rel="stylesheet" type="text/css" />');

var CMSMsgBox = function(oWidth, oHeight, oSkin, oTitle){
	this.Id = 'msgbox_'+Math.random().toString().replace('\.', '_');
	/*
	 * 位置
	 * =================
	 * ===== 1 2 3 =====
	 * ===== 4 5 6 =====
	 * ===== 7 8 9 =====
	 * =================
	 */
	this.Position = 5;

	this.Skin = oSkin || 'default';
	this.Width = oWidth || 600;
	this.Height = oHeight || 300;
	
	this.Title = oTitle || '湖南地税廉政网络监督系统:';
	this.Value = '';
	this.Float = true;
	this.Mask = false;
	this.Drag = true;
	this.Return = false;
	this.BoxDiv = null;
};

CMSMsgBox.prototype.show = function(){
	if(this.$(this.Id))return false;
	this.Return = true;
	this.BoxDiv = this.createDiv(document.body, 'div', 'block', this.Id, 'msgbox_main_div');	
	if(this.Mask)this.createMask();	
	this.showBox();
};

CMSMsgBox.prototype.showBox = function(){
	var self = this;
	var div = new Array();
	
	div['box'] = this.createDiv(this.BoxDiv, 'div', 'block', this.Id+'bgcolor_div', 'msgbox_box msgbox_box_'+this.Skin);
	if(this.Width)div['box'].style.width = this.Width+'px';
	if(this.Height && this.Skin != 'loading')div['box'].style.height = this.Height+'px';
	
	div['title'] = this.createDiv(div['box'], 'div', null, null, 'msgbox_title');

	/* =====================================
	 * 拖曳效果
	 *=====================================**/
	if(this.Drag){
		div['move'] = this.createDiv(this.BoxDiv, 'div', 'none', null, 'msgbox_move_div');		
		div['title'].style.cursor = 'move';
		div['title'].onmousedown = function(e){
			var X = document.all ? event.clientX : e.pageX;
			var Y = document.all ? event.clientY : e.pageY;
			var T = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
			var cLeft = div['code'].offsetLeft + div['box'].offsetLeft;
			var cTop = div['code'].offsetTop + div['box'].offsetTop - T;
			if((X > cLeft && X < (cLeft + div['code'].offsetWidth)) && (Y > cTop && Y < (cTop + div['code'].offsetHeight)))
			return;
			this.style.zIndex += 10;	
			this.setAttribute('MD', '1');
			this.setAttribute('XCX', parseInt(X - div['box'].offsetLeft).toString());
			this.setAttribute('XCY', parseInt(Y - div['box'].offsetTop).toString());
			div['move'].style.width = parseInt(div['box'].offsetWidth-10) + 'px';
			div['move'].style.height = parseInt(div['box'].offsetHeight - 10) + 'px';
			div['move'].style.left = div['box'].offsetLeft + 'px';
			div['move'].style.top = div['box'].offsetTop + 'px';
			div['move'].style.display = 'block';
		};

		function document_mousemove(e){
			if(div['title'].getAttribute('MD')!='1')return;
			var XCX = div['title'].getAttribute('XCX');
			var XCY = div['title'].getAttribute('XCY');
			var X = document.all ? event.clientX : e.pageX;
			var Y = document.all ? event.clientY : e.pageY;
			div['move'].style.left = parseInt(X - XCX) + 'px';
			div['move'].style.top = parseInt(Y - XCY) + 'px';
		}

		function document_mouseup(e){
			if(div['title'].getAttribute('MD')!='1')return;
			div['title'].setAttribute('MD', '0');
			div['title'].setAttribute('XCX', '0');
			div['title'].setAttribute('XCY', '0');
			div['box'].style.left = div['move'].offsetLeft + 'px';
			div['box'].style.top = div['move'].offsetTop + 'px';
			if(self.IsObject(div['mask'])){
				div['mask'].style.left = div['move'].offsetLeft + 'px';
				div['mask'].style.top = div['move'].offsetTop + 'px';
			}	
			div['move'].style.display = 'none';
		}

		if(document.addEventListener){
			document.addEventListener('mousemove', document_mousemove, false);
			document.addEventListener('mouseup', document_mouseup, false);
		}else{
			document.attachEvent('onmousemove', document_mousemove);
			document.attachEvent('onmouseup', document_mouseup);
		}
	}
	div['span'] = this.createDiv(div['title'], 'span', 'block', this.Id+'_msgTitle');
	div['span'].innerHTML = this.Title;

	/* =====================================
	 * 关闭按钮
	 *=====================================**/
	div['code'] = this.createDiv(div['title'], 'code', 'block');
	div['code'].setAttribute('title', '关闭');
	div['code'].style.position = 'relative';
	div['code'].innerHTML = "close";
	div['code'].onclick = function(){self.close();};
	
	/* =====================================
	 * 文本区域
	 *=====================================**/
	div['text'] = this.createDiv(div['box'], 'div', 'block', this.Id+'_msgContent', 'msgbox_content');
	div['value'] = this.createDiv(div['text'], 'div', 'block', this.Id+'_msgValue', 'msgbox_container');
	div['clear'] = this.createDiv(div['text'], 'div', 'block', null, 'msgbox_clear');
	if(this.Height && this.Skin != 'loading'){
		div['value'].style.height = (div['box'].offsetHeight - div['title'].offsetHeight - 16) + 'px';
		div['value'].style.overflowY = 'auto';
	}
	div['value'].innerHTML = this.Value;

	/* =====================================
	 * 创建一个iframe档住select 
	 *=====================================**/
	if(document.all && !this.Mask){
		div['mask'] = this.createDiv(this.BoxDiv, 'iframe', 'block', null, 'msgbox_frame');
		div['mask'].style.width = div['box'].offsetWidth+'px';
		div['mask'].style.height = div['box'].offsetHeight+'px';
	}	
	
	
	mDiv_Float();	
	if(this.Float){
		if(window.addEventListener){
			window.addEventListener('resize', mDiv_Float, false);
			window.addEventListener('scroll', mDiv_Float, false);
		}else{
			window.attachEvent('onresize', mDiv_Float);
			window.attachEvent('onscroll', mDiv_Float);
		}
	}

	/* =====================================
	 * 漂浮效果
	 *=====================================**/
	function mDiv_Float(){
		var t = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
		var h = document.documentElement.clientHeight ? Math.min(document.documentElement.clientHeight, document.body.clientHeight) : document.body.clientHeight;
		var w = document.documentElement.clientWidth ? document.documentElement.scrollWidth : document.body.scrollWidth;
		
		switch(self.Position){
			case 1:  {var l = 1;var r = t + 1;break;}
			case 2:  {var l = parseInt((w/2)-(div['box'].offsetWidth/2));var r = t + 1;break;}
			case 3:  {var l = parseInt(w-div['box'].offsetWidth-1);var r = t + 1;break;}
			case 4:  {var l = 1;var r = parseInt(t+((h/2)-(div['box'].offsetHeight/2)));break;}
			case 5:  {var l = parseInt((w/2)-(div['box'].offsetWidth/2));var r = parseInt(t+((h/2)-(div['box'].offsetHeight/2)));break;}
			case 6:  {var l = parseInt(w-div['box'].offsetWidth-1);var r = parseInt(t+((h/2)-(div['box'].offsetHeight/2)));break;}
			case 7:  {var l = 1;var r = parseInt(t+(h-div['box'].offsetHeight-1));break;}
			case 8:  {var l = parseInt((w/2)-(div['box'].offsetWidth/2));var r = parseInt(t+(h-div['box'].offsetHeight-1));break;}
			case 9:  {var l = parseInt(w-div['box'].offsetWidth-1);var r = parseInt(t+(h-div['box'].offsetHeight-1));break;}
			default: {var l = parseInt((w/2)-(div['box'].offsetWidth/2));var r = parseInt(t+((h/2)-(div['box'].offsetHeight/2)));break;}
		}
		
		div['box'].style.left = l+'px';
		div['box'].style.top = r+'px';
		if(document.all && !self.Mask){
			div['mask'].style.left = l+'px';
			div['mask'].style.top = r+'px';
		}
	}
};

/* 蒙板 */
CMSMsgBox.prototype.createMask = function(){
	var self = this;
	var div = new Array(1);
	if(document.all)
	div['mask_ifr'] = this.createDiv(this.BoxDiv, 'iframe', 'block', null, 'msgbox_mask_frame');
	div['mask_div'] = this.createDiv(this.BoxDiv, 'div', 'block', null, 'msgbox_mask_div');
	
	function window_onresize(){
		var h = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);		
		var w = document.all ? Math.min(document.documentElement.scrollWidth, document.body.scrollWidth) : 
				Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);
		
		div['mask_div'].style.width = w + 'px';
		div['mask_div'].style.height = h + 'px';
		if(document.all){
			div['mask_ifr'].style.width = div['mask_div'].offsetWidth + 'px';
			div['mask_ifr'].style.height = div['mask_div'].offsetHeight + 'px';
		}
	}
	
	if(window.addEventListener){
		window.addEventListener('scroll', window_onresize, false);
		window.addEventListener('resize', window_onresize, false);
	}else{
		window.attachEvent('onscroll', window_onresize);
		window.attachEvent('onresize', window_onresize);
	}
	if(this.Skin=='loading')div['mask_div'].ondblclick = function(){self.close();};
	window_onresize();
};

/* 创建一个元素  */
CMSMsgBox.prototype.createDiv = function(iParent, element, display, id, clsname){
	var ii = document.createElement(element);
	if(typeof(display)=='string')ii.style.display = display;
	if(typeof(clsname)=='string')ii.className = clsname;
	if(typeof(id)=='string')ii.setAttribute('id', id);
	iParent.appendChild(ii);
	return ii;
};

/* 关闭 */
CMSMsgBox.prototype.close = function(){	
	if(this.IsObject(this.BoxDiv) && this.BoxDiv.parentNode){
		this.BoxDiv.parentNode.removeChild(this.BoxDiv);
	}
};

CMSMsgBox.prototype.$ = function(o){
	return document.getElementById(o);
};

CMSMsgBox.prototype.IsObject = function(o){
	return typeof(o)!='undefined' && o!=null;
};

CMSMsgBox.prototype.setBackgroundColor=function(iColor){
	if(!this.$(this.Id+'bgcolor_div'))return;
	this.$(this.Id+'bgcolor_div').style.backgroundColor = iColor;
};

CMSMsgBox.prototype.setColor=function(iColor){
	if(!this.$(this.Id+'_msgValue'))return;
	this.$(this.Id+'_msgValue').style.color = iColor;
};

CMSMsgBox.prototype.setValue=function(iValue){
	if(!this.$(this.Id+'_msgValue'))return;
	this.$(this.Id+'_msgValue').innerHTML = iValue;
};

CMSMsgBox.prototype.setTitle=function(iTitle){
	if(!this.$(this.Id+'_msgTitle'))return;
	this.$(this.Id+'_msgTitle').innerHTML = iTitle;
};


var box1;
function show(){
	var box = new CMSMsgBox(300);
	box.Skin = 'loading'
	box.Mask = true;
	box.Value = '正在加载数据，请稍后...<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;双击页面空白处可关闭。';
	box.show();
}
function close(){
	box1.close();
}
function show1(){
	box1 = new CMSMsgBox(256);
	box1.Skin = 'loading'
	box1.Mask = true;
	box1.Value = '正在加载数据，请稍后...<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;双击页面空白处可关闭。';
	box1.show();
}
//提示信息
function show2(MsgStr){
	box2 = new CMSMsgBox(500);
	box2.Title = "系统提示信息"
	box2.Skin = 'msg'
	box2.Mask = true;
	box2.Value = MsgStr// '&nbsp;&nbsp;操作成功!<br/><br/><br/>&nbsp;&nbsp;<input type="button" value="改变颜色" onclick="box1.setColor(\'green\');" /><input type="button" value="改变背景颜色" onclick="box1.setBackgroundColor(\'eeeeee\');" />';
	box2.show();
}
function show3(MsgStr){
	box3 = new CMSMsgBox(600);
	box3.Title = "查看信息"
	//box.close();
	//box3.Skin = 'loading'
	box3.Mask = true;
	box3.Value = MsgStr
	box3.show();
}
function show4(MsgStr){
	box4 = new CMSMsgBox(560,500);
	box4.Title = "区域地图"
	//box4.Skin = 'loading'
	box4.Mask = true;
	box4.Value = MsgStr
	box4.show();
}
function show5(MsgStr){
	box5 = new CMSMsgBox(770,500);
	box5.Title = "开始测评"
	//box4.Skin = 'loading'
	box5.Mask = true;
	box5.Value = MsgStr
	
	box5.show();
}
function show6(MsgStr){
	box6 = new CMSMsgBox(778,580);
	box6.Title = "述廉测评"
	//box4.Skin = 'loading'
	box6.Mask = true;
	box6.Value = MsgStr
	
	box6.show();
}