function Readmark(){

	this.parseint=function(v){
		return v>0 ? parseInt(v) : 0;
	}

	this.read=function(post,topic,subject){
		if(!(post && topic && subject && post>this.prevmaxread))return;
		if(post>this.maxread) this.setvalue('maxread', post);
		if(!(this.topicread[topic]>=post)) this.updatereadlist('topicread', topic, post);
		if(!(this.subjectread[subject]>=post)) this.updatereadlist('subjectread', subject, post);
	}

	this.parsereadlist=function(name){
		var c=getCookie(name);
		var r={};
		c=c.split('-');
		for(i=0;i<c.length;i++){
			c1=c[i].split('_');
			if(c1.length>1){
				r[c1[0]]=c1[1];
			}
			;
		}
		return r;
	}

	this.updatereadlist=function(name, k, v){
		this[name][k]=v;
		obj=this[name];
		r=[];
		for(i in obj){
			r.push(''+i+'_'+obj[i]);
		}
		setCookie(name, r.join('-'));
	}

	this.setvalue=function(name, v){
		this[name]=v;
		setCookie(name, v);
	}

	this.isnewtopic=function(topic, post){
		return this.prevmaxread && post>this.prevmaxread && !(this.topicread[topic]>=post);
	}
	this.isnewsubject=function(subject, post){
		return this.prevmaxread &&  post>this.prevmaxread && !(this.subjectread[subject]>=post);
	}

	this.maxread=this.parseint(getCookie('maxread'));
	this.prevmaxread=this.parseint(getCookie('prevmaxread'));
	this.topicread=this.parsereadlist('topicread');
	this.subjectread=this.parsereadlist('subjectread');
	this.activetime=this.parseint(getCookie('activetime'));
	this.prevactive=this.parseint(getCookie('prevactive'));
	this.expire=7200;
	var d=new Date();
	d=Math.floor(d/1000);
	if(d-this.expire>this.activetime){
		this.setvalue('prevactive', this.activetime);
		this.setvalue('prevmaxread', this.maxread);
		this.topicread={};
		this.subjectread={};
		setCookie('topicread', '');
		setCookie('subjectread', '');
	}
	this.setvalue('activetime', d);

}
