﻿	var ardmeSkinNum={
		actionId:'num',
		totalNum:200,
		timeNum:6,
		cookieKey : "ardme_skin_num_13",
		cookieKey2 : "ardme_skin_T_13",
		ini:function(){
			var a=this.getCookie(this.cookieKey);
			var b=this.getCookie(this.cookieKey2);
			if (typeof(a) == "string"){
				a=parseInt(a);
				b=this.getTimes()-b;
				if (b<0){b=0}
				b=Math.round((b)*this.getRandom(this.timeNum))
				a-=b
			}else{
				a=this.NormalNum();
				b=this.getTimes();
			}
			if (a<1){a=0}
			this.setCookie(this.cookieKey, a, 24-this.getTimes(), "/","", false);
			this.setCookie(this.cookieKey2, this.getTimes(), 24-this.getTimes(), "/","", false);
			document.getElementById(this.actionId).innerHTML=a;
		},
		NormalNum:function(){
			var a=this.getTimes();
			if (a<10){
				this.timeNum=7;
				a=(a*(this.timeNum-1))+this.getRandom(2);
			}else if(a>16){
				a-=16;
				this.timeNum=7;
				a=(a*(this.timeNum-1))+this.getRandom(2)+160;
			}else{
				a-=10;
				this.timeNum=24;
				a=(a*(this.timeNum-1))+this.getRandom(2)+60;
			}
			a=this.totalNum-Math.round(a);
			return a;
		},
		getTimes:function(){
			var d=new Date();
			var s=d.getHours();
			s+=parseInt(d.getMinutes())/60;
			return s;
		},
		getRandom:function(num){
			var a=Math.round((Math.random()*num)+1);
			return a;
		},
		getCookie : function(name) {
			var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
			if (arr != null) {
				return unescape(arr[2]);
			}
			return null;
		},
		setCookie : function(sName,sValue,objHours,sPath,sDomain,bSecure){
			var sCookie = sName + "=" + encodeURIComponent(sValue);
			if (objHours) {
				var date = new Date();
				var ms = objHours * 3600 * 1000;
				date.setTime(date.getTime() + ms);
				sCookie += ";expires=" + date.toGMTString();
			}
			if (sPath) {
				sCookie += ";path=" + sPath;
			}
			if (sDomain) {
				sCookie += ";domain=" + sDomain;
			}
			if (bSecure) {
				sCookie += ";secure";
			}
			document.cookie=sCookie;
		}
	}
	window.onload=function(){ardmeSkinNum.ini()};