var LanauageFile = "../Language/index.lang.xml";			//语言包路径


function GiveFlower(ID,obj){
	if(confirm('您确定要献花吗？')){
		var url = "Article/PostComment.asp";
		var pars = "Action=addflowers&SelectID="+ ID;
		var myAjax = new Ajax.Request(
					url,
					{
					method: "post", 
					parameters: pars,
					onSuccess: function(t) {
						if(t.responseText == "suc"){
							alert("恭喜，鲜花已送出!");
							$(obj).innerHTML = parseInt($(obj).innerHTML) + 1;
							//window.location.reload();
						}else{
							alert("抱歉，鲜花时发生错误!");
						}
					},
					onFailure: function(t) {
						alert("抱歉，鲜花时发生错误!");
					}
					});
	}
	return ;
}


function GiveEgg(ID,obj){
	if(confirm('您确定要扔Ta鸡蛋吗？')){
		var url = "Article/PostComment.asp";
		var pars = "Action=addegg&SelectID="+ ID;
		var myAjax = new Ajax.Request(
					url,
					{
					method: "post", 
					parameters: pars,
					onSuccess: function(t) {
						if(t.responseText == "suc"){
							alert("哈哈，鸡蛋正中目标!");
							$(obj).innerHTML = parseInt($(obj).innerHTML) + 1;
							//window.location.reload();
						}else{
							alert("抱歉，扔Ta鸡蛋时系统发生错误!");
						}
					},
					onFailure: function(t) {
						alert("抱歉，扔Ta鸡蛋时系统发生错误!");
					}
					});
	}
	return ;
}

function GiveArticleFlower(ID,obj){
	if(confirm('您确定要献花吗？')){
		var url = "Article/PostComment.asp";
		var pars = "Action=articleaddflowers&SelectID="+ ID;
		var myAjax = new Ajax.Request(
					url,
					{
					method: "post", 
					parameters: pars,
					onSuccess: function(t) {
						if(t.responseText == "suc"){
							alert("恭喜，鲜花已送出!");
							$(obj).innerHTML = parseInt($(obj).innerHTML) + 1;
							//window.location.reload();
						}else{
							alert("抱歉，鲜花时发生错误!");
						}
					},
					onFailure: function(t) {
						alert("抱歉，鲜花时发生错误!");
					}
					});
	}
	return ;
}


function GiveArticleEgg(ID,obj){
	if(confirm('您确定要扔Ta鸡蛋吗？')){
		var url = "Article/PostComment.asp";
		var pars = "Action=articleaddegg&SelectID="+ ID;
		var myAjax = new Ajax.Request(
					url,
					{
					method: "post", 
					parameters: pars,
					onSuccess: function(t) {
						if(t.responseText == "suc"){
							alert("哈哈，鸡蛋正中目标!");
							$(obj).innerHTML = parseInt($(obj).innerHTML) + 1;
							//window.location.reload();
						}else{
							alert("抱歉，扔Ta鸡蛋时系统发生错误!");
						}
					},
					onFailure: function(t) {
						alert("抱歉，扔Ta鸡蛋时系统发生错误!");
					}
					});
	}
	return ;
}


function CheckPostComment(obj)
{
	ClearInfo();
	if (obj.Title.value==""){
		$('ChkTitle').innerHTML = "<font color=\"red\">请输入评论标题!</font>";
		obj.Company.focus();
		return false;
	}
	if (obj.UserName.value==""){
		$('ChkUserName').innerHTML = "<font color=\"red\">请输入您的名字!</font>";
		obj.UserName.focus();
		return false;
	}
	if (obj.Content.value==""){
		$('ChkContent').innerHTML = "<font color=\"red\">请输入评论内容!</font>";
		obj.UserPassword.focus();
		return false;
	}
	  
	PostForm(obj,'postcomment.asp','msginfo',myReturnFun);
	return false; 
}
function ClearInfo()
{
	$('ChkTitle').innerHTML = "";
	$('ChkUserName').innerHTML = "";
	$('ChkContent').innerHTML = "";
	return;
}

function CheckPostEmail(obj)
{
	if (obj.SendEmail.value==""){
		alert("请填写您的“邮件地址”！")
		obj.SendEmail.focus();
		return false;
	}
	if (obj.SendUserName.value==""){
		alert("请填写你的姓名！")
		obj.SendUserName.focus();
		return false;
	}
	if (obj.EmailContent.value==""){
		alert("请填写“邮件内容”！")
		obj.EmailContent.focus();
		return false;
	}
	if (obj.CodeStr.value==""){
		alert("请填写“验证码”！")
		obj.CodeStr.focus();
		return false;
	}

	var EmailTitle,EmailContent;
	EmailTitle = getPageLanguage(LanauageFile, "ToAuthorEmailTitle");
	EmailTitle = replace(EmailTitle, "{$LeaveWordUser}", obj.SendUserName.value);
	EmailTitle = replace(EmailTitle, "{$InfoTitle}", obj.InfoTitle.value);

	EmailContent = getPageLanguage(LanauageFile, "ToAuthorEmailContent");
	EmailContent = replace(EmailContent, "{$window.location}", window.location);
	EmailContent = replace(EmailContent, "{$InfoTitle}", obj.InfoTitle.value);
	EmailContent = replace(EmailContent, "{$LeaveWordUser}", obj.SendUserName.value);
	EmailContent = replace(EmailContent, "{$LeaveWordContent}", obj.EmailContent.value);
	EmailContent = replace(EmailContent, "{$LeaveWordEmail}", obj.SendEmail.value);

	$("PostEmailInfo").innerHTML = "正在发送，请稍候...";
	//var url = "../Common/Module/Common/PostEmail.asp";
	//var pars = "InceptEmail="+ obj.InceptEmail.value +"&EmailTitle="+ encodeURIComponent(EmailTitle) +"&EmailContent="+ encodeURIComponent(EmailContent) +"&CodeStr="+ obj.CodeStr.value + "&chkcode=1";
	var url = "EmailToAuthor.ajax.asp";
	var pars = "EmailTitle="+ encodeURIComponent(EmailTitle) +"&EmailContent="+ encodeURIComponent(EmailContent) +"&ContentID="+ obj.InfoID.value  +"&CodeStr="+ obj.CodeStr.value;
	var myAjax = new Ajax.Request(
				url,
				{
				method: "post", 
				postBody: pars,
				onSuccess: function(t) {
					if(t.responseText == "suc"){
						alert("恭喜，邮件已发送给作者。");
					}else if(t.responseText=="codeerr"){
						alert("验证码错误！");
					}else{
						alert("邮件发送时发生错误，您可以尝试再次发送。");
						//alert(t.responseText);
					}
					$("PostEmailInfo").innerHTML = "";
				}
				});
	return false; 
}

function TellFriend(msgid){
	Element.show(msgid);
}

function PostTellFriend(obj){
	
	try{
		var EmailTitle;
		EmailTitle = getPageLanguage(LanauageFile, "TellFriendEmailTitle");
		EmailTitle = replace(EmailTitle, "{$SendUserName}", obj.SendUserName.value);

		if (obj.SendEmail.value==""){
			alert("请填写您的好友的邮件地址！")
			obj.SendEmail.focus();
			return false;
		}
		if (obj.SendUserName.value==""){
			alert("请填写你的姓名！")
			obj.SendUserName.focus();
			return false;
		}
		if (obj.EmailContent.value==""){
			alert("请填写“邮件内容”！")
			obj.EmailContent.focus();
			return false;
		}
		if (obj.CodeStr.value==""){
			alert("请填写“验证码”！")
			obj.CodeStr.focus();
			return false;
		}

	}catch(e){
		self_debug(e.message);
	}

	$("TellFriend_PostInfo").innerHTML = "正在发送，请稍候...";
	var url = "../Common/Module/Common/PostEmail.asp";
	var pars = "InceptEmail="+ encodeURIComponent(obj.SendEmail.value) +"&EmailTitle="+ EmailTitle +"&EmailContent="+ encodeURIComponent(obj.EmailContent.value) +"&CodeStr="+ obj.CodeStr.value + "&chkcode=1";
	var myAjax = new Ajax.Request(
				url,
				{
				method: "post", 
				postBody: pars,
				onSuccess: function(t) {
					if(t.responseText == "suc"){
						alert("恭喜，邮件已成功发送。");
					}else if(t.responseText=="codeerr"){
						alert("验证码错误！");
					}else{
						alert("邮件发送时发生错误，您可以尝试再次发送。");
						//alert(t.responseText);
					}
					$("TellFriend_PostInfo").innerHTML = "";
				}
				});
	return false; 
}


function TopIndexShowTabs(obj,t_value){

document.forms[0].SearchType.value=t_value;
if(typeof(obj) == "object"){
	var num;
	for (var i=0; i<TopIndexTabNames.length; i++){
		if(TopIndexTabNames[i] == obj.id){
			num = i;
			document.getElementById(TopIndexTabNames[i]).className = 'search_menu_nonce';
		}else{
			document.getElementById(TopIndexTabNames[i]).className = 'search_menu';
		}
	}
	if(num > 0)document.getElementById(TabNames[num-1]).className = 'search_menu';
}else{
	for (var i=0; i<TopIndexTabNames.length; i++){
		if(i == obj){
			document.getElementById(TopIndexTabNames[i]).className = 'search_menu_nonce';
		}else{
			document.getElementById(TopIndexTabNames[i]).className = "search_menu";
		}
	}
}
}
function SetTemplateID(f_value){
	document.forms[0].TemplateID.value=f_value;
}
