/**
 * 生成DIV提示层 
 * @return
 */
function boxmessage()
{
	this.initDiv();
}
/**
 * 工厂方法 调用其他方法
 */
boxmessage.prototype.doing = function (string){
	this.resizewindow();
	this.showmessagebox(string);
	}
/**
 * 第一次生成DIV层 并定位
 */
boxmessage.prototype.showmessagebox = function (string) {
	
	var height = $(window).height();
	var width = $(window).width();
	var top  = $(document).scrollTop();
	var left = $(document).scrollLeft();
	$('#pigBox').height(height);
	$('#pigBox').width(width);
	$('#pigBox').css("top",top);
	$('#pigBox').css("left",left);
	$('#pigBox').show();
	//$('#pigBox').fadeTo(100,0.5);
	
	//$('#pigBox').show();
	$('#pigBox').animate({opacity:0.5},0); 
	var newheight = ($(window).height() - 15) /2+top;
	var newwidth = ($(window).width() - 250) /2+left;
	$('#pigmessage').css("top",newheight);
	$('#pigmessage').css("left",newwidth);
	$('#pigmessage').show();
	$('#pigmessage').html('<span style="font-family:\'宋\'; font-size:12px;color:#000">'+string+'</span>');
	
}
/**
 * 当滚动条移动或窗口改变是调用的方法
 */
boxmessage.prototype.resizewindow = function (){
	$(window).resize(function (){boxmessage.resetdiv();});
	$(window).scroll(function (){boxmessage.resetdiv();});
}
/**
 * 重置DIV层尺寸和位置
 */
boxmessage.prototype.resetdiv = function (){
var top  = $(document).scrollTop();
	var left = $(document).scrollLeft();
	$('#pigBox').css("top",top);
	$('#pigBox').css("left",left);
	var newheight = ($(window).height() - 15) /2+top;
	var newwidth = ($(window).width() - 250) /2+left;
	$('#pigmessage').css("top",newheight);
	$('#pigmessage').css("left",newwidth);
}
/**
 * 取消层
 */
boxmessage.prototype.cancel = function(){
	setTimeout("$('#pigBox').hide();$('#pigmessage').hide();",1000);
}
/**
 * 初始化层
 */
boxmessage.prototype.initDiv = function () {
document.writeln('<div id="pigBox" style="background-color:#000;position:absolute; z-index:1000;display:none; top:0px; left:0px"></div><div id="pigmessage" style=" display:none;margin:0 auto; background-color: #FFF; position:absolute; z-index:1001; height:60px;width:250px;line-height:60px; border:3px #999 solid; text-align:center"></div>');
}
/**
 * 改变层提示文字信息
 */
boxmessage.prototype.changetext = function (string) {
	$('#pigmessage').html('<span style="font-family:\'宋\'; font-size:12px;color:#000">'+string+'</span>');
}
var boxmessage = new boxmessage();