/*唉 发现长时间不看 自己写的代码都不认识了 这次不偷懒了老老实实把注释写上*/

	$(function(){	
			   
		
		$('.post a:has(img)').lightBox(); //LightBox效果
		 
		function stc(){
			var tar = $(this).attr('href');
		 	$.scrollTo(tar,1000);
			return false;
		}
		 
		function reply(){
			var tar = $(this).attr('href');
		 	$.scrollTo(tar,1000);
			setTimeout(function(){$('textarea').focus();},1000);
			return false;
		}
		 
		$('.commentlist a[href!="#commentform"][class!="comment-edit-link"][class!="url"]').click(stc); //@someone平滑移动
		$('.commentlist a[href="#commentform"]').click(reply); //回复添加留言平滑移动
		 
		 
		$('#back').click(function(){
							$.scrollTo('#header',1000);
							return false;
						}); //返回顶部
	
/*这里开始是隐藏老用户输入框 增加了一些功能 希望可以改善一点用户体验 没有使用淡入淡出是因为IE下会有轻微的对齐Bug 如果对此功能有任何改的地方 还请与我分享*/


		if($('#author').length>0 && $('#author').val().length>0){ //判断ID="author"是否存在 值不为空执行以下代码
	
			$('<p id="welcome">欢迎回来<span id="username"></span></p>').insertBefore('#author_info');
			$('#author_info').slideUp();
		
		
		var ss = $('input[id="author"]').attr("value");
		$('#username').html(" "+ss+"：");
		
		$('#welcome').append("<span id=\"change\">修改资料<\/span><span id=\"update\">点击这里更新资料<\/span><span id=\"hint\">资料修改成功<\/span")
		
		$('#change').click(function(){
							$('#author_info').slideDown(); //显示资料框
							$(this).hide(); //隐藏 修改资料
							$('#update').show(); //显示 更新资料
						});
		
		$('#update').click(function(){
							$('#author_info').slideUp(); //隐藏资料框
							$(this).hide(); //隐藏 更新资料
							$('#hint').show(); //显示 资料修改成功
							setTimeout(function(){$('#hint').hide();},2000); //隐藏 资料修改成功
							setTimeout(function(){$('#change').show();},2000); //还原 修改资料
							var s = $('input[id="author"]').attr("value");
							$('#username').html(" "+s+"：");
						});
		}
		

		/*回复按钮 鼠标悬停显示*/
		
		$('.commentlist li').hover(function(){$(this).find('.reply').fadeIn();},function(){$(this).find('.reply').fadeOut();});
		
		
		/*这里没什么可说的 为input增加focus效果 */
		
		$('input[type="text"][class!="input"],textarea').focus(function(){
			$(this).addClass('typing');
		})


		$('input[type="text"][class!="input"],textarea').blur(function(){
			$(this).removeClass('typing');
		})
		
		/*Ctrl+Enter提交评论*/
		
		$('#comment').focus(function(){
								$(document).keydown(function(e){
														if( e.ctrlKey && e.keyCode == 13 ){
															$('#submit').click();
														}
													});
							});
	})