<!--

// Remind
// Code By Mudoo 2008.8.1


// 用ID获取元素
function $(element) {
	return typeof(element) == 'object' ? element : document.getElementById(element);
}

// 判断浏览器
function brower() {
	var ua = navigator.userAgent.toLowerCase();
	var os = new Object();
	os.isFirefox = ua.indexOf ('gecko') != -1;
	os.isOpera = ua.indexOf ('opera') != -1;
	os.isIE = !os.isOpera && ua.indexOf ('msie') != -1;
	os.isIE7 = os.isIE && ua.indexOf ('7.0') != -1;
	return os;
}

// 返回两个日期的天数差
function getDateDiff(sDate, eDate){
	var re = /^(\d{4})\S(\d{1,2})\S(\d{1,2})$/;
	var dt1, dt2;
	if (re.test(sDate)) {
		dt1 = new Date(RegExp.$1,RegExp.$2 - 1,RegExp.$3);
	}
	if (re.test(eDate)) {
		dt2 = new Date(RegExp.$1,RegExp.$2 - 1,RegExp.$3);
	}
	return Math.floor((dt2-dt1)/(1000 * 60 * 60 * 24));
}

var remind = {
	// 参数设置
	startDate	: '2008-10-24',	// 开始日期
	remDate		: 15,			// 提前提示天数
	timeLeft	: 10,			// 定时关闭时间(秒)
	doTimeout	: null,			// 计时关闭
	remTitle	: '系统提示',		// 弹出框标题
	remText		: '您的网站将于$date$到期。<br />为不影响网站正常访问，请尽快与我们联系。',
	
	// 初始化
	init : function() {
		remind.setStyle();
		var date = new Date()
		var now = date.getFullYear() +'-'+ (date.getMonth()+1) +'-'+ date.getDate();
		var diff = 365-getDateDiff(remind.startDate, now);
		if(diff<=remind.remDate && diff>=0) remind.show(now, diff);
	},
	
	// 设置样式
	setStyle : function() {
		var os = brower();
		var styleStr = ""+
			"<style type=\"text\/css\">"+
			"<!--"+
			"html, body {height: auto !important; height: 100%; overflow: auto; margin: 0}"+
			"#Remind {position: fixed !important; position: absolute; width: 260px; right: 10px; bottom: 10px; background: #f1f7f8; padding: 2px;}"+
			((os.isIE && !os.isIE7) ? "* html #Remind {right: 26px}" : "") +
			"#Remind .remTitle {font-size: 12px; font-weight: bold; color: #2c71af; height: 28px; line-height: 28px; padding: 0 10px; overflow: hidden; background: url(RemindImages\/Rem_TitleBg.gif) repeat-x; border: #7b9fba solid 1px; border-bottom: none}"+
			"#Remind a.remClose {float: right; height: 10px; margin-top: 10px}"+
			"#Remind a.remClose img {width: 10px; height: 10px; border: none; background: url(RemindImages\/Rem_Close.gif) 0 0 no-repeat}"+
			"#Remind a.remClose:hover img {background: url(RemindImages\/Rem_Close.gif) -10px 0 no-repeat}"+
			"#Remind .remContWarp {background: url(RemindImages\/Rem_CongBg.gif) #fbfeff left bottom repeat-x; padding: 1px; border: #7b9fba solid 1px; border-top: none}"+
			"#Remind #remCont {height: 100px; font-size: 13px; font-weight: bold; color: #265e90; line-height: 20px; padding: 12px 10px 0 90px}"+
			((os.isIE && !os.isIE7) ? "#Remind #remCont {filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src=\"RemindImages\/Rem_Icon.png\"); background: none;}" : "#Remind #remCont {background: url(RemindImages\/Rem_Icon.png) left top no-repeat;}") +
			"#Remind .remCont a {position: relative}"+
			"-->"+
			"<\/style>";
		document.write(styleStr);
	},
	
	// 弹出
	show : function(now, dateLeft) {	
		// 生成弹出框
		var remObj = $("Remind");
		var dateText = dateLeft==0 ? "明天" : (" <span style=\"color: #ff6600\">"+ dateLeft +"</span> 天后");
		
		if(remObj==null) {
			var html = ""+
				//"<div id=\"Remind\">"+
				"	<div class=\"remTitle\"><a href=\"###\" onclick=\"remind.hide();\" class=\"remClose\"><img src=\"RemindImages\/Space.gif\" \/><\/a>"+ remind.remTitle +"<\/div>"+
				"	<div class=\"remContWarp\">"+
				"		<div id=\"remCont\">"+ remind.remText.replace('$date$', dateText) +"<\/div>"+
				"	<\/div>";
				//"<\/div>";
			var remindEle = document.createElement("div");
			remindEle.id = "Remind";
			remindEle.innerHTML = html;
			document.body.appendChild(remindEle);
		}else{
			$("remCont").innerHTML = remind.remText.replace('$date$', dateText);
		}
		
		// 显示
		remindEle.style.display = '';
		// 定时关闭
		clearTimeout(remind.doTimeout);
		remind.doTimeout = setTimeout(remind.hide, remind.timeLeft*1000);
		
		// 设置事件
		remindEle.onmouseover = function() {
			clearTimeout(remind.doTimeout);
		}
		remindEle.onmouseout = function() {
			remind.doTimeout = setTimeout(remind.hide, remind.timeLeft*1000);
		}
	},
	
	// 关闭
	hide : function() {
		clearTimeout(remind.doTimeout);
		var remObj = $("Remind");
		remObj.style.display = 'none';
	}
};

try{
	remind.init();
}catch(e){}
//-->
