// JavaScript Document
/*=====================================================================
'代码版权说明
'=====================================================================
' 文件名: MailPrompt.js
' 版本:	  1.0
' 日期:   2006-8-8
' 作者:	  笑咪咪
' 说明:	  
' 修改记录: 
' 版权所有：远方电脑网络科技公司
'=====================================================================
' Copyright (C) 2006 zydn.net All rights reserved.
' Web: http://www.zydn.net
' Need help? Contact: Hermit_Dragon@163.com
'=====================================================================*/

	var InspectTime=240000;					//每隔两分种检查一次
	
	function MailPrompt()
	{
		this.ProBox=window.createPopup();
		window.document.body.setAttribute("MailPrompt",this);
		this.ProBoxWidth=245;
		this.ProBoxHeight=132;
		this.Move=null;
		this.PageY=0;
		this.PageX=0;
		this.IsXp=(navigator.userAgent.toUpperCase().indexOf("NT 5.1")>-1)?true:false;
		this.Close=null;
		
		this.Show=function()
		{
			this.PageY=window.screen.Height;
			if(this.IsXp) this.PageY-=180;
			this.PageX=parseInt(window.screen.Width-280);
			this.ProBox.show(this.PageX,this.PageY,this.ProBoxWidth,this.ProBoxHeight);
			this.Close=setInterval("window.document.body.getAttribute(\"MailPrompt\").Hidden();",12000);
			
		}
		
		this.Hidden=function(){
			this.ProBox.hide();
			var doc=this.ProBox.document;
			doc.open();
			doc.writeln("<html>");
			doc.writeln("<head>");
			doc.writeln("</head>");
			doc.writeln("<body>");
			doc.writeln("</body>");
			doc.writeln("</html>");
			doc.close();
		}
			
		this.Update=function(Stream)
		{
			var doc=this.ProBox.document;
			doc.open();
			doc.writeln("<html>");
			doc.writeln("<head>");
			doc.writeln("</head>");
			doc.writeln("<body>");
			doc.writeln(Stream);
			doc.writeln("</body>");
			doc.writeln("</html>");
			doc.close();
		}
	}
	
	function GetMail(InspectPath)
	{
		var AjaxHttp=null;
		var Stream="";
		try{
				if (window.XMLHttpRequest)
				{
					AjaxHttp=new XMLHttpRequest();
				}
				else
				{
					AjaxHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}

				AjaxHttp.open("GET",InspectPath,false);
				AjaxHttp.setRequestHeader("Content-Length",InspectPath.length); 
				AjaxHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				AjaxHttp.send();
				Stream=BytesToBstr(AjaxHttp.ResponseBody);
				AjaxHttp=null;
				return Stream;
				
		}catch(Exception){
			clearInterval(InspectTimer);
			return "";
		}
	}
	
	function InspectMail()
	{
		var Stream=GetMail(InspectPath);
		if(Stream!="")
		{
			PromptPanel.Update(Stream);
			PromptPanel.Show();
		}
	}

	
	var PromptPanel=new MailPrompt();
	InspectMail();
	var InspectTimer=setInterval("InspectMail();",InspectTime);
	document.writeln("<a href=\"\" style=\"display:none;\" id=\"ClickMail\" target=\"_blank\"></a>");