﻿$(function(){
	prettyPrint();
})

$(function(){
	$('pre').hoverIntent({
		sensitivity: 3,   //滑鼠滑動的敏感度,最少要設定為1    
		interval: 400,   //滑鼠滑過後要延遲的秒數    
		over: widthAuto,  //滑鼠滑過要執行的函式   
		timeout: 700,    //滑鼠滑出前要延遲的秒數    
		out: widthFixed  //滑鼠滑出要執行的函式
	})
})

function widthAuto(){
	//var oDiv = document.getElementById('box');
	//var $oDiv = $('#box');
	var auto = this.scrollWidth;
	if(this.scrollWidth > this.offsetWidth){
		if(!$(this).is(':animated')){
			$(this).animate({width:auto},500);
		}
	}
}

function widthFixed(){
	if(!$(this).is(':animated')){
		$(this).animate({width:684},500);
	}
}

(function(){
	$('.reply').click(function(){
		var reply = '\u56de\u5e94\u0020' + $(this).parent().parent().prev().find('em:first').text() + '\u0020\u7684\u53d1\u8a00';
		$('#commentform').prev().text(reply);
		$('#comment').select();
		$('html, body').animate({
			scrollTop: $('#comment').offset().top
		}, 'slow');
		$('#comment_parent').val($(this).attr('rel'));
		return false;
	});
	$('.reply-to').click(function(){
		$('html, body').animate({
			scrollTop: $($(this).attr('href')).offset().top
		}, 'slow');
	});

})();
