loadjs=false;
commentuser=$.cookie('comment_user');
if (commentuser){
 //[user,email,url]=commentuser.split('#@#');
var tuple=commentuser.split('#@#');
var user,email,url;
user=tuple[0];
email=tuple[1];
url=tuple[2];
$('#author').val(user);
$('#email').val(email);
$('#url').val(url);



}

$(document).ready(function(){

var $author = $('#author');
var $author_email = $('#email');
setStyleDisplay('author_info','');
 if ($author.val() != '' && $author_email.val() != '') {
//$author = $author.parent().css('display', 'none');
//$author_email = $author_email.parent().css('display', 'none');
//var $author_url = $('#url').parent().css('display', 'none');
setStyleDisplay('author_info','none');
$('#author_info').parent().prepend('<div class="row">Welcome back,&nbsp; <strong>' + $author.val() + '</strong>&nbsp; !&nbsp; &nbsp; <span id="show_author_info" style="text-decoration:blink;"><a href="javascript:void(0);" onclick="setStyleDisplaySlide(\'author_info\',\'\');setStyleDisplay(\'show_author_info\',\'none\');setStyleDisplay(\'hide_author_info\',\'\');">Change &raquo;</a></span><span id="hide_author_info" style="text-decoration:blink;display:none;"><a href="javascript:void(0);" onclick="setStyleDisplaySlide(\'author_info\',\'none\');setStyleDisplay(\'show_author_info\',\'\');setStyleDisplay(\'hide_author_info\',\'none\');">Close &raquo;</a></span></div>');
};
});


function showemotion(){
document.getElementById("emotion").style.display="block";
$("#emotion img").each(function(){$(this).attr("src",$(this).attr("alt"));});return true;}
function setStyleDisplaySlide(id,status) {if (!status){/*getid(id).style.display = status;*/$("#"+id).slideDown(500);} else {$("#"+id).slideUp(500);/*getid(id).style.display = status;*/}}
function setStyleDisplay(id, status) {document.getElementById(id).style.display = status;}
function switchTab(showPanels, hidePanels, activeTab, activeClass, fadeTab, fadeClass) {
document.getElementById(activeTab).className = activeClass;
document.getElementById(fadeTab).className = fadeClass;
var panel, panelList;
panelList = showPanels.split(',');
for (var i = 0; i < panelList.length; i++) {
var panel = panelList[i];
if ($('#'+panel).length) {setStyleDisplay(panel, 'block');$('#'+panel).hide().fadeIn("slow");}}
panelList = hidePanels.split(',');
for (var i = 0; i < panelList.length; i++) {
panel = panelList[i];
if ($('#'+panel).length) {
setStyleDisplay(panel, 'none');}}}
$('#cmtswitcher a').bind('focus', function(){
if(this.blur){this.blur();}});

function getid(id){return document.getElementById(id);}
function showCheckImage(){
var img = document.getElementById('checkimg');
img.style.display='inline';}
function reloadCheckImage(){
var img = document.getElementById('checkimg');
img.src = "/checkstr/?t="+GetRandomNum(1,10000);
}
function GetRandomNum(Min,Max){
var Range = Max - Min;
var Rand = Math.random();
return(Min + Math.round(Rand * Range));
}
function showinfo(msg)
{ alert(msg);}
function backcomment(name,id){
backdb=document.getElementById('comment');
backdb.value+='<a href='+'\"#comment-'+id+'\">'+"@"+name+'</a>'+"\n";
return true;}
function quote(name,id){
var quoteMsg=document.getElementById(id).innerHTML;
document.getElementById("comment").value+='引用'+name+'<blockquote>'+quoteMsg+'</blockquote>\n';
return true;}
var fontSizeTimer = null;
var fontSizePoints = 11;
function increaseFontSize(what) {
var theTestText = document.getElementById(what);
if (fontSizePoints < 18) {fontSizePoints += 0.5;theTestText.style.fontSize = fontSizePoints.toString() + "px";}
else if (fontSizeTimer != null) {window.clearInterval(fontSizeTimer);fontSizeTimer = null;}
}
function growFontSize(what) {
what1=what;
if (fontSizeTimer == null)
fontSizeTimer = window.setInterval("increaseFontSize(what1)", 1000.0 / 200.0);}
function resetSizes(what) {
var theTestText = document.getElementById(what);
if (fontSizeTimer != null) {window.clearInterval(fontSizeTimer);fontSizeTimer = null;}
fontSizePoints = 11;
theTestText.style.fontSize = fontSizePoints.toString() + "px";}
function add_comment(msg){
comment=$(msg)
if (!loadjs){
$("#thecomments").append(comment).show();
$.getScript("/static/js/jquery.color.js", function(){
comment.show().animate( { backgroundColor: 'white' }, 5).animate( { opacity: 0.02 }, 5).animate( { opacity: 1 }, 800).animate( { opacity: 0.02 }, 5).animate( { opacity: 1 }, 1200)
loadjs=true;});}else{
$("#thecomments").append(comment);
comment.hide().animate( { backgroundColor: 'white' }, 5).fadeIn("slow").animate( { opacity: 0.02 }, 5).animate( { opacity: 1 }, 800).animate( { opacity: 0.01 }, 400).animate( { opacity: 1 }, 400).animate( { opacity: 0.02 }, 5).animate( { opacity: 1 }, 1200)}}

$('#commentform').ajaxForm({
type:'post',
dataType:  'json',
beforeSubmit:function(formData,jqForm,options){
var form = jqForm[0];
if (form.author){
if (!form.author.value){resetSizes("check_author");getid("check_author").innerHTML="<font color='#FF0000'>请填写名字</font>";setStyleDisplay('author_info','');form.author.focus();growFontSize("check_author");return false;}else{resetSizes("check_author");getid("check_author").innerHTML="<font color='#00CC00'><strong>√</strong></font>";}
if (!form.email.value){getid("check_email").innerHTML="<font color='#FF0000'>请输入邮箱地址</font>";setStyleDisplay('author_info','');form.email.focus();resetSizes("check_email");growFontSize("check_email");return false;}
str=form.email.value;
var str_reg=/^\w+((-\w+)|(\.\w+))*\@{1}\w+\.{1}\w{2,4}(\.{0,1}\w{2}){0,1}/ig;
if (str.search(str_reg) == -1){resetSizes("check_email");getid("check_email").innerHTML="<font color='#FF0000'>请输入正确的邮件地址</font>";setStyleDisplay('author_info','');form.email.value='';form.email.focus();growFontSize("check_email");return false;}else{resetSizes("check_email");getid("check_email").innerHTML="<font color='#00CC00'><strong>√</strong></font>";}
}
if ($('#checkarea').css('display')!='none'){if(form.checkret.value.length==0){resetSizes("disp_check");getid("disp_check").innerHTML="<font color='#FF0000'>请输入验证码</font>";form.checkret.focus();growFontSize("disp_check");return false;} else if(form.checkret.value.length!=4){resetSizes("disp_check");getid("disp_check").innerHTML="<font color='#FF0000'>验证码错误,请重新输入!</font>";form.checkret.value='';form.checkret.focus();growFontSize("disp_check");return false;}else{resetSizes("disp_check");getid("disp_check").innerHTML="验证码(不区分大小写)";}}
if (!form.comment.value){$('#s_msg').text('o(︶︿︶)o 唉，我不赞成发空文哦，写上你要说的话吧!').show();form.comment.focus();growFontSize("s_msg");return false;}
if ($('#checkarea').css('display')!='none'){$('#reply_notify').css('display','none');}
$('#respond .button').css('margin-top','-20px');resetSizes("s_msg");
getid('s_msg').innerHTML='<img src="/static/images/load.gif" />正在提交留言...';
$('#s_msg').show().fadeIn(2000);
//$('#s_msg').show();
//$('#s_msg').text('正在提交留言...').show();
$("#submit").attr("value","正在提交，请稍候...");$("#submit").attr('disabled',true);return true;},
success:function(data){
$("#submit").attr('disabled',false);$("#submit").attr("value","提交评论(Ctrl+Enter)");
if (data[0])
{/*document.cookie=data[2];*/
add_comment(data[1]);
$('#s_msg').text('留言提交成功！');
if (getid('author_info').style.display !='none' && !($('#respond').find('#show_author_info').length) ){
setStyleDisplay('author_info','none');
$('#author_info').parent().prepend('<div class="row">Hello,&nbsp;  <strong> ' + $('#author').val() + '</strong> &nbsp; !&nbsp; &nbsp; <span id="show_author_info"><a href="javascript:void(0);" onclick="setStyleDisplaySlide(\'author_info\',\'\');setStyleDisplay(\'show_author_info\',\'none\');">Change &raquo;</a></span></div>');
}
//alert('留言提交成功！');
$('#comment').val('');
//location="#comments";
}
else if (data[1]==-102)
{showinfo(data[2]);
reloadCheckImage();
$('#s_msg').text('留言提交失败！');
$('#checkret').focus();}
else if (data[1]==-101)
{showinfo(data[2]);
reloadCheckImage();
$('#s_msg').text('留言提交失败！网络可能有问题哦，留言提交失败啦！如果真想联系我，那就到导航栏"关于"页面给我发送邮件吧!P.S.或者……，o(∩_∩)o 哈哈，实话告诉我，你可能在恶意灌水啊，留言被Spam了哦!');}}});