if(typeof window.GS_alert=="undefined"){
	GS_alert=new function(){
		this.title="袋鼠邮提醒你";
		this.body="默认的提示信息";
		this.icon=0;
		this.links=null;
		this.closeType=0;
		this.defaultScript="";
		this.focused=true;
		var iconI=0;

		var icons=Array("/image/alert01.gif","/image/alert02.gif","/image/alert03.gif","/image/alert04.gif","/image/alert05.gif");
		var timeout=null;

		this.close=function(){
			if(GS_alert.defaultScript!=""){
				eval(GS_alert.defaultScript);
			}
			AB_remove();
			nowP=0;//发件时 当前选择的省
            nowC=0;//当前选择的市
            nowD=0;//当前选择的区
		}

		this.create=function(){
			formatIcon(this.icon);
			if (document.getElementById("AB_HideSelect") == null) {
				$("body").append("<iframe id='AB_HideSelect'></iframe><div id='AB_overlay'></div>");
			}

			if (document.getElementById("AB_window") != null) {
				$("#AB_window").remove();
			}
			$("body").append("<div id='AB_window'></div>");

			if(this.closeType==0){
				$("#AB_overlay").click(this.close);
			}
			

			AB_overlaySize();
			
			//在window中添加标题栏

			$("#AB_window").append("<h2 id='AB_titles'><span id='AB_title'>"+this.title+"</span></h2>");
			if(this.closeType!=2 ){
				$("#AB_titles").append("<button id='AB_close' title='关闭提示'>&nbsp;</button>");
				$("#AB_close").click(this.close);			
			}

			//在window中添加图片
			if(this.closeType!=5)
			{
			    $("#AB_window").append("<div id='AB_icon'><img src='http://www.guaishow.com/"+icons[iconI]+"' /></div>");
			}

			//在window中添加文字
			$("#AB_window").append("<div id='AB_body'>"+this.body+"</div>");

			//在链接区域添加链接
			if(this.links!=null){
				$("#AB_window").append("<div id='AB_links'>您可以:</div>");
				for(i=0;i<this.links.length;i++){
					if(this.links[i][1]==0){
						$("#AB_links").append("<a id='AB_link_"+i+"' href='javascript:"+this.links[i][2]+"'>"+this.links[i][0]+"</a>");
					}else if(this.links[i][1]==1){
						$("#AB_links").append("<a id='AB_link_"+i+"' href='"+this.links[i][2]+"'>"+this.links[i][0]+"</a>");
					}
				}
			
			}

			//添加按钮
			if(this.closeType!=2 && this.closeType!=5){
				$("#AB_window").append("<div id='AB_buttons'></div>");
				if(this.closeType==3){
					$("#AB_buttons").append("<div id='AB_timer'>提示将在10秒后关闭</div>");					
					function timetoclose(mtimes){
						if(mtimes<=1){
							GS_alert.close();
						}else{
							mtimes--;
							document.getElementById("AB_timer").innerHTML="提示将在"+mtimes+"秒后关闭";
							timeout=setTimeout(function(){timetoclose(mtimes);},1000);
						}
					}
					timetoclose(10);
				}
				$("#AB_buttons").append("<button id='AB_iknow'>我知道了</button>");
				$("#AB_iknow").click(this.close);
			}
	
			$("#AB_window").append("<div id='AB_bottom'></div>");
		  
			

//			//调整高度
//			if($("#AB_body").height()>$("#AB_icon").height()){
//				$("#AB_icon").css({"height":$("#AB_body").height() +"px"});
//			}else{
//				$("#AB_body").css({"height":$("#AB_icon").height() +"px"});
//			} 

			//设置窗口大小
			AB_WIDTH=$("#AB_window").width();
			AB_HEIGHT=$("#AB_window").height();

			//设置
			AB_position();

			//显示窗口
			$("#AB_window").css({display:"block"});

			//让窗口获得焦点
			if(this.focused){
				$("#AB_window")[0].focus();
			}			

			//窗口滚动调整位置
			$(window).scroll(AB_position);

			//窗口变动大小
			$(window).resize(AB_position);
			
			//alert(document.getElementById('AB_window').outerHTML);
		}

		//格式话提示
		function formatIcon(icon){
			switch (icon)
			{
			case "hint":iconI=0;break;
			case "ask":iconI=1;break;
			case "warn":iconI=2;break;
			case "err":iconI=3;break;
			case "wait":iconI=4;break;
			default:iconI=parseInt(icon);if(iconI<0 || iconI>=icons.length){iconI=0;}break;
			}
		
		}

		//设置覆盖层的尺寸
		function AB_overlaySize(){
			if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) {	
				yScroll = window.innerHeight + window.scrollMaxY;
				xScroll = window.innerWidth + window.scrollMaxX;
				var deff = document.documentElement;
				var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
				var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
				xScroll -= (window.innerWidth - wff);
				yScroll -= (window.innerHeight - hff);
			} else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac
				yScroll = document.body.scrollHeight;
				xScroll = document.body.scrollWidth;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				yScroll = document.body.offsetHeight;
				xScroll = document.body.offsetWidth;
			}
			$("#AB_overlay").css({"height":(yScroll+200)+"px", "width":(xScroll+20) +"px"});
			$("#AB_HideSelect").css({"height":(yScroll+200) +"px","width":(xScroll+20) +"px"});
			
			$("#AB_overlay").css({"height":(yScroll)+"px", "width":(xScroll) +"px"});
			$("#AB_HideSelect").css({"height":(yScroll) +"px","width":(xScroll) +"px"});
		}

		//移除所有对象
		function AB_remove() {
			if(timeout){clearTimeout(timeout);}
			$("#AB_overlay").unclick();
			$("#AB_window").fadeOut("fast",function(){$('#AB_window,#AB_overlay,#AB_HideSelect').remove();});
			return false;
		}

		//定位窗口
		function AB_position() {
			var pagesize = AB_getPageSize();	
			var arrayPageScroll = AB_getPageScrollTop();	
			$("#AB_window").css({width:AB_WIDTH+"px",left: (arrayPageScroll[0] + (pagesize[0] - AB_WIDTH)/2)+"px", top: (arrayPageScroll[1] + (pagesize[1]-AB_HEIGHT)/2)+"px" });
		}

		//获得窗口尺寸
		function AB_getPageSize(){
			var de = document.documentElement;
			var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
			var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight
			arrayPageSize = new Array(w,h) 
			return arrayPageSize;
		}
		//获得滚动条定位
		function AB_getPageScrollTop(){
			var yScrolltop;
			var xScrollleft;
			if (self.pageYOffset || self.pageXOffset) {
				yScrolltop = self.pageYOffset;
				xScrollleft = self.pageXOffset;
			} else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft ){	 // Explorer 6 Strict
				yScrolltop = document.documentElement.scrollTop;
				xScrollleft = document.documentElement.scrollLeft;
			} else if (document.body) {// all other Explorers
				yScrolltop = document.body.scrollTop;
				xScrollleft = document.body.scrollLeft;
			}
			arrayPageScroll = new Array(xScrollleft,yScrolltop) 
			return arrayPageScroll;
		}
	}
}
