/*
	New Posts
	Show new posts since last login
	Wrighty (c) 2010+
*/

var lp = {
	init: function(){
		if(vf_username != 'guest' && location.href.match(/\/action\/new/))
			this.getPosts();
	},
	getPosts: function(){
		var d = (document.cookie.match("lp_" + vf_username + "=(.+?)(;|$)")? RegExp.$1 : 0);
		var s = document.createElement('script');
		s.src = 'http://vf.wserver.co.uk/new-posts/posts.php?user=' + vf_username + '&login=' + d + '&forum=' + location.host;
		document.getElementsByTagName('head')[0].appendChild(s);
		document.cookie = "lp_" + vf_username + "=" + Math.round(new Date().getTime() / 1000) + ";expires="+((new Date()).toGMTString().replace(/\d{4}/, "2050"));
		this.handle();
	},
	handle: function(){
		get('span', 'tag', get('error_message_table', 'id'))[0].innerHTML = 'Posts Since Last Visit';
		get('nav_tree', 'id').innerHTML = get('nav_tree', 'id').innerHTML.replace(/An Error Has Occurred/, 'Posts Since Last Visit');
		document.title = document.title.replace(/An Error Has Occurred/, 'Posts Since Last Visit');
		get('error_message', 'id').innerHTML = 'Loading posts....';
	}
};
lp.init();
