﻿function index_zhongjiansigeFN(){
	$(".zhongjiansige").prepend('<ul class="hd"><li class="lo">日志</li><li class="hi">话题</li><li class="hi">照片</li><li class="hi">心情</li><span></span></ul>');
	$(".zhongjiansige > div").addClass("hidDiv").eq(0).removeClass("hidDiv").addClass("viewDiv");
	$(".hd").children("li").click(function(){
	var i = $(".hd").children("li").siblings().index($(this));
	$(".hd").children("li").removeClass().addClass("hi");
	$(this).removeClass().addClass("lo");
	$(".hd ~ div").removeClass("viewDiv").addClass("hidDiv").eq(i).removeClass("hidDiv").addClass("viewDiv");
	});
	
}
function sidebarFN(){

	$(".say").before('<div class="fuzhu"><div class="left"></div><div class="right"></div></div>');
	$(".sidebar  ul").prev("h2").prepend("<em></em>");
	$(".sidebar  h2 em").click(function(){
				$(this).toggleClass("emup");
				$(this).parent("h2").next("ul").toggle();
		});
  
	
}


///////////////////////////////jQuery////////////////
$(document).ready(function() {

    index_zhongjiansigeFN();
sidebarFN();
$(".header").before('<div class="yuncai"></div>');


 $("dd input:text").focus(function(){
		$(this).css("background","#CBFE9F").next("em").css("display","inline");
	 }).blur(function(){
		$(this).css("background","#FFF").next("em").css("display","none");
	 }); 



})


//获取表情参数值
function getFaceValue(para, i, txtName) {
    var str = para.id;
    var strFace = "[em:" + i + ":]";
    var textId;
    var textId = str.replace("ImageButton" + i, txtName);
    var strText = document.getElementById(textId).value + strFace;
    document.getElementById(textId).value = strText;
    return false;

}

//检查心情框不能为空
function CheckMood(para) {
    var result = true;
    var str = para.id;
    var strText = str.replace("btn_BianJiXinQing", "txtHeart");
    var lbId = str.replace("btn_BianJiXinQing", "lbError_BianJiXinQing");
    if (document.getElementById(strText).value.length < 1) {
        document.getElementById(lbId).innerHTML = "至少表达一下心情吧！";
        document.getElementById(strText).focus();
        result = false;
    }
    return result;
}

//检查用户记录表单是否为空
function CheckUserRecord(para) {
    var result = true;
    var str = para.id;
    var strText = str.replace("btn_xiejilu", "txtRecord");
    var lbId = str.replace("btn_xiejilu", "lbjilu_Error");


    if (document.getElementById(strText).value.length < 1) {
        document.getElementById(lbId).innerHTML = "记录内容不能为空！";
        document.getElementById(strText).focus();
        result = false;
    }
    return result;
}

//检查输入表单是否为空的函数
//para是this
//btnText是button控件
//txtText是输入表单
//txtLabel是错误输出控件
function CheckTextNull(para, btnText, txtText, txtLabel) {
    var result = true;
    var str = para.id;
    var strText = str.replace(btnText, txtText);
    var lbId = str.replace(btnText, txtLabel);
    if (document.getElementById(strText).value.length < 1) {
        document.getElementById(lbId).innerHTML = "表单不能为空！";
        document.getElementById(strText).focus();
        result = false;
    }
    return result;
}

//点击按钮获得焦点
function getFocus(para, txtName) {
    var str = para.id;
    var strText = str.replace("lbtnPost", txtName);
    document.getElementById(strText).focus();
    return false;
}

////////////////////////////jQuery////////////////////
			var scrollSpeed = 1; 		// Speed in milliseconds
			var step = 1; 				// How many pixels to move per step
			var current = 0;			// The current pixel row
			var imageWidth = 621;		// Background image width/2247
			var headerWidth = 950;		// How wide the header is./1280
			
			//The pixel row where to start a new loop
			var restartPosition = -(imageWidth - headerWidth);
			
			function scrollBg(){
				//Go to next pixel row.
				current -= step;
				
				//If at the end of the image, then go to the top.
				if (current == restartPosition){
					current = 0;
				}
				
				//Set the CSS of the header.
				$('.yuncai').css("background-position",current+"px 0");
			}
			
			//Calls the scrolling function repeatedly
			var init = setInterval("scrollBg()", scrollSpeed);


