//toggle{ id , n|b|i|t , b|i}
function tog(id,typ,tog){
	var o = document.getElementById(id);
	var x = o.style.display;
	switch(typ){
		case 'n':
			x="none";
			break;
		case 'b':
			x="block";
			break;
		case 'i':
			x="inline";
			break;
		default:
			if(tog=="b"&&x!="block"){x="block"}
			else if(tog=="i"&&x!="inline"){x="inline"}
			else{x="none"};
	}
	o.style.display=x;
}
//emotion
function grin(tag) {
    	var myField;
    	tag = ' ' + tag + ' ';
        if (document.getElementById('comment') && document.getElementById('comment').type == 'textarea') {
    		myField = document.getElementById('comment');
    	} else {
    		return false;
    	}
    	if (document.selection) {
    		myField.focus();
    		sel = document.selection.createRange();
    		sel.text = tag;
    		myField.focus();
    	}
    	else if (myField.selectionStart || myField.selectionStart == '0') {
    		var startPos = myField.selectionStart;
    		var endPos = myField.selectionEnd;
    		var cursorPos = endPos;
    		myField.value = myField.value.substring(0, startPos)
    					  + tag
    					  + myField.value.substring(endPos, myField.value.length);
    		cursorPos += tag.length;
    		myField.focus();
    		myField.selectionStart = cursorPos;
    		myField.selectionEnd = cursorPos;
    	}
    	else {
    		myField.value += tag;
    		myField.focus();
    	}
    }
		
			//reply
if(!$.browser.msie){
	$(".thdrpy").fadeOut();
	
	$(".comment").hover(
	function(){
		$(this).find(".thdrpy").stop().attr("style","");
	}
	,function(){
		$(this).find(".thdrpy").hide("slow");
	})
	
	$(".allowTags span").click(function(){
		$(".allowTags code").toggle();
	})
}	
//konami code
	$(function(){
		var k = []; //建立一个空的数组
		$(document).keydown(function(e){
								k.push(e.keyCode); //把每一次按下的键码加入到数组k当中
								if(k.toString().indexOf('89,89')>=0){ //判断如果数组k中可以查找到指定的字符串 即返回值大于等于0
										if(confirm("要看悍妇请点ok,想看衰哥请点cancel!")){
											window.location = "http://luan.in/baby";
										}
										else {
											window.location = "http://luan.in/about";
										}
									k = [];//清空数组k 以便再次触发事件
								}
							});
		
	})


	//ctrl+enter=submit
	$("#comment").keydown(
		function (moz_ev){
			var ev = null;
			if (window.event){
				ev = window.event;
			}else{
				ev = moz_ev;
			}
			if (ev != null && ev.ctrlKey && ev.keyCode == 13){
				$("#submit").click();
			}
		}
	)
	//current Time
	function now(){
		var now=new Date();
		str=now.getFullYear()+"年"+(now.getMonth()+1)+"月"+now.getDate()+"日<small>"+now.getHours()+":"+now.getMinutes()+":"+now.getSeconds()+"</small>";
		$('#now').html(str);
	}
	if($("#now")[0]){setInterval(now,1000);}
$().ready(function(){
		//feedMe
	$("#feedAll").hover(
		function() {
			$("#feedMe").show("fast");
		}
		,function() {
			$("#feedMe").hide("slow");
		}
		);
	//loading state
	$("#loading").fadeOut(2000);
	//strict.dtd
	$("a[rel='external']").attr("target","_blank");
	})

//initial

//taotao http://www.taotao.com/cgi-bin/msgj?qq=18958069&num=5&t=0
$.ajax({
		type: "GET",
		url: 'http://taotao.qq.com/v1/qz_first/firstjson?uin=81954070',
		success: callback,
		dataType: 'script',
		scriptCharset:'GB2312'
	});
var callback = function(json) {
	if (json && typeof json === 'object') {
		var title = "话说：" + json.items[0].title || '';
		$('#taotao').slideUp('slow', function() {$(this).text(title).slideDown()});
	}
}

//try
try {} catch(err) {
	var txt;
	txt = "Error description: " + err.description;
	alert(txt);
}

//ready
$().ready(function() {

})