// JavaScript Document
var jslang = {

	'search_nowords'		: '您还没有填写关键字',
	'search_nodatas'		: '暂无符合您查询条件的文章',

	'email_process'			: '正在上传您的推荐, 请稍候...',
	'email_submit'			: '提交推荐',
	'email_unreceiver'		: '您还没有填写收件人地址',
	'email_inreceiver'		: '您的收件人地址不正确, 请检查后再试\n\n如: someone@example.com',
	'email_certid'			: '您还没有填写图形码或图形码错误\n\n单击图片: 替换图形码',
	'email_success'			: '您的推荐已经发送完成',

	'reply_nomessage'		: '您还没有填写评论内容',
	'reply_certid'			: '您还没有填写图形码或图形码错误\n\n单击图片: 替换图形码',
	'reply_process'			: '正在上传您的评论, 请稍候...',
	'reply_submit'			: '发表评论',
	'reply_success'			: '感谢您的参与, 您的评论已经上传完成\n\n提示: 您发表的评论需审核后才能在网页上显示'
}
function article_object(){
	this.toggle_id = 1;
	this.toggle_all = 8;
	this.toggle = function(id){
		this.toggle_id = id ? id : parseInt(this.toggle_id);
		this.toggle_all = parseInt(this.toggle_all);
		for (this.tmpid = 1; this.tmpid <= this.toggle_all; this.tmpid++){
			if ($('catetogglec' + this.tmpid) || $('catetogglel' + this.tmpid)){
				if (this.tmpid == this.toggle_id){
					$('catetogglec' + this.tmpid).src = Ajax_prefix + 'images/article/menus_tog_on.gif';
					$('catetogglel' + this.tmpid).style.display = '';
				}else{
					$('catetogglec' + this.tmpid).src = Ajax_prefix + 'images/article/menus_tog_off.gif';
					$('catetogglel' + this.tmpid).style.display = 'none';
				}
			}
		}
	}
	this.vsearch = function(results){
		var theform = document.wane_search;
		if (results){
			this.tmpmsg = '';
			this.focuser = '';
			switch (results){
				case 'words' 	: this.tmpmsg = jslang.search_nowords;	this.focuser = 'keywords';	break;
				case 'datas'	: this.tmpmsg = jslang.search_nodatas;	this.focuser = 'keywords';	break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
			}
			if (this.focuser != ''){
				eval('theform.' + this.focuser + '.focus()');
			}
		}else{
			if (theform.keywords.value == ''){
				this.vsearch('words');
				return false;
			}else{
				theform.Submit.disabled = true;
			}
		}
	}

	this.fontid = function(size,id){
		this.tmpid = id ? id : 'message';
		if (!$(this.tmpid)){
			return false;
		}
		if (!isNaN(size) && size > 0){
			this.sizeid = size;
		}else{
			this.sizeid = 24;
		}
		$(this.tmpid).style.fontSize = this.sizeid + 'px';
	}
	this.replid = 'switcherf';
	this.replyer = function(id,isc){
		if (!$('switchert') || !$('switcherf')){
			return false;
		}
		if (isc){
			$('switchert').style.display = '';
			$('switcherf').style.display = 'none';
		}else{
			if (isNaN(id) || id < 1){
				return false;
			}
			$('switchert').style.display = 'none';
			$('switcherf').style.display = '';
			this.replies(id);
		}
	}
	this.replies = function(id,page){
		Ajax.xml('article|replies||' + id + '|page=' + page,this.replid);
	}
	this.renumber = function(total){
		if (!$('myreplies')){
			return false;
		}
		if (isNaN(total) || total < 1){
			this.total = 0;
		}else{
			this.total = total;
		}
		 $('myreplies').innerHTML = this.total;
	}
	this.vreply = function(results){
		var theform = document.wane_replies;
		if (results){
			this.tmpmsg = '';
			this.focuser = '';
			switch (results){
				case 'message'	: this.tmpmsg = jslang.reply_nomessage;	this.focuser = 'message';	break;
				case 'certid'	: this.tmpmsg = jslang.reply_certid;	this.focuser = 'certid';	break;
				case 'success'	: this.tmpmsg = jslang.reply_success;								break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (theform.Submit.disabled){
					theform.Submit.value = jslang.reply_submit;
					theform.Submit.disabled = false;
				}
			}
			if (this.focuser != ''){
				eval('theform.' + this.focuser + '.focus()');
			}else{
				eval('theform.reset()');
			}
		}else{
			if (theform.message.value == ''){
				this.vreply('message');
				return false;
			}else if (theform.certid && theform.certid.value == ''){
				this.vreply('certid');
				return false;
			}else{
				theform.Submit.value = jslang.reply_process;
				theform.Submit.disabled = true;
			}
		}
	}
	this.email = function(id,isc){
		if (!$('switchert') || !$('switcherf')){
			return false;
		}
		if (isc){
			$('switchert').style.display = '';
			$('switcherf').style.display = 'none';
		}else{
			if (isNaN(id) || id < 1){
				return false;
			}
			$('switchert').style.display = 'none';
			$('switcherf').style.display = '';
			Ajax.xml('article|email||' + id,this.replid);
		}
	}
	this.vemail = function(results){
		var theform = document.wane_email;
		if (results){
			this.tmpmsg = '';
			this.focuser = '';
			switch (results){
				case 'unrecer'		: this.tmpmsg = jslang.email_unreceiver;	this.focuser = 'receiver';	break;
				case 'inrecer'		: this.tmpmsg = jslang.email_inreceiver;	this.focuser = 'receiver';	break;
				case 'certid'		: this.tmpmsg = jslang.email_certid;		this.focuser = 'certid';	break;
				case 'success'		: this.tmpmsg = jslang.email_success;									break;
			}
			if (this.tmpmsg != ''){
				alert(this.tmpmsg);
				if (theform.Submit.disabled){
					theform.Submit.value = jslang.email_submit;
					theform.Submit.disabled = false;
				}
			}
			if (this.focuser != ''){
				eval('theform.' + this.focuser + '.focus()');
			}else{
				this.email('',true);
			}
		}else{
			if (theform.receiver.value == ''){
				this.vemail('unrecer');
				return false;
			}else if (theform.certid && theform.certid.value == ''){
				this.vemail('certid');
				return false;
			}else{
				if ($('emailsubject')){
					theform.subject.value = $('emailsubject').innerHTML;
				}
				if ($('emailmessage')){
					theform.message.value = $('emailmessage').innerHTML;
				}
				theform.Submit.value = jslang.email_process;
				theform.Submit.disabled = true;
			}
		}
	}
	this.location = function(url){
		window.location = url;
	}
}
article = new article_object();
