﻿//字数统计
function textareaWords(textarea,num){	
$(textarea).bind('focus keyup input paste',function(){ 
	      var commentTextIndex=$(this).attr("value").length;
	 	  if(commentTextIndex>num){
			  $(this).parent().find(".textarea-words").html("超出<strong>"+(commentTextIndex-num)+"</strong>字")
			  $(this).parent().find(".textarea-words strong").css("color","#fb2f00")
			  }else{
			  $(this).parent().find(".textarea-words").html("还能输入<strong>"+(num-commentTextIndex)+"</strong>字")
			  $(this).parent().find(".textarea-words strong").css("color","#4ab800")
			  }
});
}


//文本域获得和失去焦点
function inputValue(){
$(".input-value").css("color","#ccc")
$(".input-value").focus(function(){
var inputValue=$(this).val();
if(inputValue==this.defaultValue){
	$(this).val("");}
	$(this).css("color","#666")
});
$(".input-value").blur(function(){
var inputValue=$(this).val();
if(inputValue==""){
	$(this).val(this.defaultValue);
	$(this).css("color","#666")
	}
	else {
	var inputNewValue= delWords(inputValue);
	$(this).val(inputNewValue);
	}
});
$(".form-box .input,.form-box .textarea").focus(function(){
	$(this).css({"border":"1px solid #88bf42"})
	})
$(".form-box .input,.form-box .textarea").blur(function(){
	$(this).css({"border":"1px solid #d2d2d2"})
	})	
}
function delinput(obj)
{
var inputValue=obj.val();
var inputNewValue= delWords(inputValue);
obj.val(inputNewValue);
}
function delWords(text){	
var words="粉嫩|色情|找小姐|小姐|裸聊|代开|包夜|色女|发票|髮票|發票|骚女|尻|骚|草泥马|骂人|裸体|虐死|私服|加盟|你大爷|鼅|夜情|Com|coM|cOm|com|COm|c0m|net|org|cn|http|class|href|色情|裸体|你妈|操你奶奶|操你|靠你|你他妈的|奶奶个雄|日你|干你|亲一个|操死你|虐死|靠你妈|藏比|裸图|应招女郎|3K|情色|成人影院|成人网|性奴|群交|色狼|猥亵|恋童|骚货|骚妹|春闺|春宫|乱伦|肛交|情欲|色情|成人电影|采花|成人游戏|A片|应召|口交|粗口|裸照|玉女心经|黄祸|交换夫妻|毛片|兽交|春药|精气|催情|合欢|男人乐园|金瓶梅|精液|媚术|媚药|虐恋|成人站|买春|卖春|人妖|摇头丸|白面|可卡因|白粉|毒品|嗑药|色友|色库|极品清纯网|神秘花园|希虎|花花公子|色狐|楚子|后宫电影院|欢乐搜寻|色网书库|色虎|性福|欢乐搜索|寻梦园|欢乐窝|正点妞|男男贴图|99色网|骚逼|欲女|屌|耻毛|鸡巴|狂干一夜|浪叫|肉棒|肉棍|骚穴|小穴|肉洞|两腿胯间|阳毛|搓弄|性虎|风月大陆|色域|爱女人|浪妹|成人卡通|后宫影院|性狐|亚洲成人|龙虎豹|阳具|浪笑|骚液|爱液|机巴|鸡八|肛温|荡女|叫床|恋物癖|肉蒲团|肉穴|吸精少女|援交|援助交际|幼齿|美穴|蜜穴|密穴|援交|援助交际|幼齿|美穴|蜜穴|密穴|爱液|暗娼|避孕套|藏独|娼妓|雏妓|荡女|法轮|反共|肛交|肛温|睾丸|鸡八|鸡巴|妓女|妓院|精液|口交|口淫|乱伦|轮奸|裸露|卖淫|毛片|美乳|美腿|迷奸|迷药|明慧|肉棒|肉穴|乳房|射精|生殖器|兽奸|兽交|性交|阳具|阴唇|阴道|阴蒂|阴核|阴茎|自慰|做爱|西北大学|方励之|北高联|市工联|高自联|反共|共匪|6·4|李旺阳|李志绥|民运|刘文胜|刘晓波|六四|六.四|暴乱|暴徒|暴政|石戈|苏晓康|鲍彤|温元凯|吾尔开希|天安门屠杀|天安门事件|魏京生|学联|学运|张京生|丁子霖|中国之春|洪吟|贝领|赤匪|赤化|党棍|李禄|苏晓康|太子党|天安门录影|天安门屠杀|万润南|柴玲|藏独|疆独|河殇|赵紫阳|红色恐怖|人民报|7·22|北京政权|4·25|维勒|南华|学潮|张京生|丁子霖|中国之春|洪吟|贝领|赤匪|赤化|陆委|严家其|党国|多维|7·22|反攻大陆|民进|民族问题|亡党|亡国|迫害|赤色|鸽派|达赖|天葬|鹰派|暴动|异见|天怒|党棍|共匪|狗官|国军|六、四|六.四|六四|疆独|台独|台湾独立|亡党|亡国|一党专政|一中一台|宏恩|明慧|大法|经文|法轮|洪治|宏治|宏志|洪志|李老师|李大师|红志|达赖|太石村|郭飞熊|晟智律师事务所|江泽民|朱镕基|台湾政权|法轮功|民主|人权|政权|屠杀|八九|天安门|西藏|文革|专制|独裁|共产|共产党|反人类|自焚|分裂|游行|抗议|主义|司徒华|胡锦涛| 温家宝|曾庆红|王丹|邓小平|毛泽东|BITCH|恩主|暴打|袭击|自杀|屠杀|法制|选举|套现#24320;|HONGZHI|NUDE|NAKED|AMATEUR|SEX|SEXHU|SEXGIRL|SEXY|SEXUAL|SEXPHOTO|PORN|HARDCORE|BABE|ANAL|ORGY|BIKINITHONGGIRLS|PETGIRL|ROOKIES|PUSSY|LICKING|LESBIAN|EROTIC|DILDOS|VIBRATORS|GAMBLING|CHICKS|TRANSVESTITES|FETISH|WATERSPORTS|SMOTHER|TRAMPLE|PANTY|WEBCAMS|UPSKIRTS|CELEBS|NUDITY|ETHNIC|LATINA|GAY|COCK|CUM|ADULT|BLONDE|TITS|MASTURBATION|ASS|SHEMALE|HAPPYSKY|XCHINA|MOROK|FUCK|JACK|HAPPYSEA|AV|VOA|PENIS|DICK|PISS|PERSIAN|LINGERIE|HUSTLER|INCEST|PLAYBOY|FALUN|DAFA|HGAME|NUSKIN|主席|江泽|锦涛|家宝|www.|.com|.cn|.net|.org";
//var arr=new Array(); 
//arr= words.split(',');
//var reg;
//for(var i=0;i<arr.length;i++)
//{
//reg=new RegExp(arr[i],"g");
//text=text.replace(reg,""); 
//}
var reg=new RegExp(words,"g");
while(text.match(reg)!==null) { 
 text=text.replace(reg,"");
} 

return text;
}
function qhbj(id,str)
{
var obj= document.getElementById(id).getElementsByTagName("dd");
for(var i=0;i<obj.length;i++)
{
if(obj[i].innerText==str)
{
obj[i].style.className='current';
}
}
}
//退出
function poplout()
{
var v = {
          action: "user.out",cc:"0"
        } 
        $.post('/do/loginHandler.ashx', v, function(response){
        //alert(response);
           var json = eval("(" + response + ")");
           if(json.error==0)
           {
          // setTimeout("asyncbox.tips('退出成功！','success',2000)",3000);
           document.location=document.location;
           
           return false;
           }
           });
}

//封装的公用选项卡
function tabs(tabTit,on,tabCon){
     $(tabCon).each(function(){
     $(this).children().eq(0).show();
     });
	 $(tabTit).each(function(){
     $(this).children().eq(0).addClass(on);
     });
     $(tabTit).children().hover(function(){
       $(this).addClass(on).siblings().removeClass(on);
       var index = $(tabTit).children().index(this);
     $(tabCon).children().eq(index).show().siblings().hide();
     });
     }

function clickTabs(tabTit,on,tabCon){
     $(tabCon).each(function(){
     $(this).children().eq(0).show();
     });
	 $(tabTit).each(function(){
     $(this).children().eq(0).addClass(on);
     });
     $(tabTit).children().click(function(){
       $(this).addClass(on).siblings().removeClass(on);
       var index = $(tabTit).children().index(this);
     $(tabCon).children().eq(index).show().siblings().hide();
     });
     }
/*文字展开*/
function introduction(a,num){
var introductionAll = $(a).find(".introduction-all").text();
var introductionInt = introductionAll.slice(0,num);
$(a).find(".introduction-all").each(function () {
if (introductionAll.length >= num) {
$(a).find(".introduction-all").append(introductionInt+"……"+"<a href='javascript:void(0);' class='txtbtn_up'>收起↑</a>")
$(a).find(".introduction-all").hide();
$(a).find(".introduction-less").append(introductionInt+"……"+"<a href='javascript:void(0);' class='txtbtn_down'>更多↓</a>")
$(a).find(".txtbtn_down").click(function(){
$(a).find(".introduction-less").hide(); 
$(a).find(".introduction-all").show();
})
$(a).find(".txtbtn_up").click(function(){
$(a).find(".introduction-less").show(); 
$(a).find(".introduction-all").hide();
})
}
})
}
//---------------------
$(function () {

    inputValue()
    tabs(".tab-hd", "current", ".tab-bd");
    clickTabs(".clickTab-hd", "current", ".clickTab-bd");

    //导航下拉菜单 鼠标单击
   /* $('.nav .downMenu-hd').click(function () {
        if (!($(this).parent().next().css('display') == 'block')) {
            $('.nav .downMenu-bd:visible').hide(); //隐藏同辈元素显示的下拉菜单
            $('.nav .nav-item').removeClass('selected'); //去掉同辈元素的selected状态
            $(this).parent().next().slideDown('fast');
            if ($(this).hasClass('downMenu-hd')) {
                $(this).parent().parent().addClass('selected');
            } else {
                $(this).parent().parent().addClass('active');
            }
            return false;
        } else {
            $('.nav .downMenu-bd:visible').hide();
            $('.nav .nav-item').removeClass('selected');
            return false;
        }
    });
    $('body').click(function (e) {
        $('.nav .downMenu-bd:visible').hide();
        $('.nav .nav-item').removeClass('selected');
    });*/
				
				//导航下拉菜单鼠标经过
				 $('.nav .nav-drop').hover(function (){
      $(this).addClass('selected');
      $(this).find(".downMenu-bd").show();
    },function(){
					$(this).removeClass('selected');
					$(this).find(".downMenu-bd").hide();
					});
   
    //top-Bar下拉菜单
    $(".user-bar li").hover(function () {
        $(this).find(".downMenu-bd").show();
    }, function () {
        $(this).find(".downMenu-bd").hide();
    })

    //****空间个人签名更改****
    //如果个人签名框内容为空或数据库中数据为空，默认在文本框中生成“编辑我的个人签名”
    if ($(".user-say-con").text().length == 0 && $(".user-ality").text().length == 0) {
        $(".user-say-con").text("编辑我的个人签名")
    }
    else {
        //如果数据库中有数据，则提取数据库中的数据进行显示
        $(".user-say-con").text($(".user-ality").text());
    }
    //用户登陆后才能修改个人签名

    var userself = $(".user-self").text();

    if (userself == "True") {
        $(".user-say-con").click(function () {
            //获取用户id
            var userid = $(".user-id").text();
            var userSay = $(".user-say-con").text();

            $(this).hide().after("<textarea class='user-say-edit'>" + userSay + "</textarea>")
            $(".user-say-edit").bind('blur', function () {
                userSay = $(".user-say-edit").val();
                $(this).hide();
                //如果原签名和修改后的签名不一样调用签名更新
                if (userSay != $(".user-say-con").text()) {
                    //过滤关键字
                    userSay = delWords(userSay);

                    $(".user-say-con").text(userSay).css("display", "block");

                    //当签名文本框失去焦点的时候调用ajax进行签名数据更新
                    $.ajax({
                        type: "POST",
                        url: "../space/Ajax/AjaxHandler.ashx",
                        data: "userid=" + userid + "&personality=" + userSay,
                        success: function (msg) {

                            if (msg < 1) {
                                setTimeout("asyncbox.tips('抱歉，由于您的网络不顺畅，请等一会在更新签名！','error',2000)", 500);
                            }
                            else {
                                setTimeout("asyncbox.tips('恭喜您，签名更新成功！','success',2000)", 500);
                            }
                        }
                    });
                }
                else {
                    $(".user-say-con").text($(this).val()).css("display", "block");
                }
                return false;
            })
        });
    }
    //level-link
    $(".level-link").hover(function () {
        $(this).find(".process-tip").show();
    }, function () {
        $(this).find(".process-tip").hide();
    })
    //个人中心推荐
    //$(".user-info-recmd").click(function(){
    //    var id = $(this).attr('data-id');
    //    var type=$(this).attr('data-t');
    //    asyncbox.open({
    //        id:"popRecmd", 
    //        title:"请填写50个字以内的推荐语吧…",
    //        width:315,
    //        height:195,
    //        html:"<div class='popRecmd-form form-box'><ul><li class='form-item clearfix'><textarea autocomplete='off' class='textarea input-value'></textarea><span class='tips textarea-words'>最多输入<strong>50</strong>字</span></li></ul><span class='btn-group clearfix'><a href='javascript:void(0);' id='popRecmd_ok' class='btn btnSmall mr10'><span class='btn-wrap'><span class='btn-inner'><span class='btn-txt'>确 定</span></span></span></a><a href='javascript:void(0);' id='popRecmd_cancel' class='btn btnSmall'><span class='btn-wrap'><span class='btn-inner'><span class='btn-txt'>取 消</span></span></span></a></span></div>",
    //        callback : function(action){/*这里是回调函数*/}
    //    });
    //    textareaWords(".popRecmd-form .textarea",50);
    //    $("#popRecmd_ok").click(function(){
    //        var popRecmdText=$(".popRecmd-form").find(".textarea").val();
    //        $.close('popRecmd');	
    //        
    //	    ting.addRecmd(this,id,popRecmdText,type);
    //    })
    //    $("#popRecmd_cancel").click(function(){
    //        $.close('popRecmd');
    //    })
    //	return false;
    //})

    //song-list
    $(".control-btn-more").hover(function () {
        $(this).find(".downMenu-bd").fadeIn(200);
    }, function () {
        $(this).find(".downMenu-bd").hide();
    });
    $(".song-list .song-item").hover(function () {
        $(this).css("zIndex", "99");
    }, function () {
        $(this).css("zIndex", "1")
    });
    $(".song-list .song-icon .more-icon").hover(function () {
        $(this).find(".downMenu-bd").fadeIn(200);
    }, function () {
        $(this).find(".downMenu-bd").hide();
    });
    //album-box
    $(".album-box li").find(".love-album-del").hide();
    $(".album-box li").hover(function () {
        $(this).find(".love-album-del").show()
    }, function () {
        $(this).find(".love-album-del").hide()
    })


    //singer-box
    $(".singer-box li").find(".love-singer-del").hide();
    $(".singer-box li").hover(function () {
        $(this).find(".love-singer-del").show()
    }, function () {
        $(this).find(".love-singer-del").hide()
    })

    //album-box
    $(".fm-box li").find(".love-fm-del").hide();
    $(".fm-box li").hover(function () {
        $(this).find(".love-fm-del").show()
    }, function () {
        $(this).find(".love-fm-del").hide()
    })
    $(".fm-box li .love-fm-del").click(function () {
        $(this).parent().fadeTo(800, 0.1, function () {
            $(this).remove()
        })
        return false;
    })
    //sms-reply
    textareaWords(".sms-replay-from .textarea", 300);
    textareaWords(".sms-new-form .textarea", 300);
    //sms-new
    $(".selectUser-downMenu .downMenu-hd").click(function () {
        $(this).next(".downMenu-bd").slideToggle();
    })
    $(".selectedUser-list-item .selectedUser-del").click(function () {
        $(this).parent().fadeTo(800, 0.1, function () {
            $(this).remove()
        })
        return false;
    })
    $(".selectUser-downMenu .i-ft .btn").click(function () {
        $(".selectUser-downMenu .downMenu-bd").slideUp();
    })
    $(".selectUser-downMenu .i-bd li input[type='checkbox']").click(function () {
        if ($(".selectedUser-list li").length < 11) {
            //if($(this).attr("checked")){
            var selectedUserName = $(this).parent().parent().text();
            var selectedUserValue = $(this).attr("value")
            $("#selectedUser-input-item").before("<li class='selectedUser-list-item'>" + selectedUserName + "<a href='javascript:void(0);' class='selectedUser-del'></a><input type='hidden' value=" + selectedUserValue + " name='selectedUser'></li>")
            $(".selectedUser-list-item .selectedUser-del").click(function () {
                $(this).parent().fadeTo(800, 0.1, function () {
                    $(this).remove()
                })
                return false;
            })
        } else {
            alert("最多只能选择10位好友哦！")
            return false;
        }

    })
    //set-profile
    textareaWords(".set-profile-form .textarea", 300);
    //fm-edit
    textareaWords(".fm-edit-form .textarea", 300);

    //专辑介绍详细展开
    introduction(".album-info-introduction", 140)
    //song-lrc
    $(".copy-lyric").click(function () {

        var copytext = $(".lyric-content").html();
        var reg = new RegExp("<BR>", "g");
        copytext = copytext.replace(reg, "\r\n");

        if (document.all) { //判断Ie
            window.clipboardData.setData('text', copytext);
            alert("恭喜你，复制成功!");
            return false;
        } else {
            alert("对不起，您的浏览器不支持剪贴板操作，请选中歌词复制。");
        }
        return false;
    });
    //下载歌词
    $(".down-lrc-btn").click(function () {
        var id = $(this).attr('data-id');
        if (id != "") {
            document.location = "/geshou/geci.aspx?id=" + id + "&down=1";
        }
        return false;
    });

    //全选
    $(".select-all").click(function () {
        var t = $(this).attr('checked');
        if (t == true) {
            $(this).parents(".control").next().find(".checkbox-item-hook").attr("checked", "true");
            $(this).parents(".control").prev().find(".checkbox-item-hook").attr("checked", "true");
            $(this).parents(".control").siblings().find(".select-all").attr('checked', 'true')

        }
        else {
            $(this).parents(".control").next().find(".checkbox-item-hook").removeAttr("checked");
            $(this).parents(".control").prev().find(".checkbox-item-hook").removeAttr("checked");
            $(this).parents(".control").siblings().find(".select-all").removeAttr("checked");
        }
    })

$(".toolBtn .select-all").click(function () {
        var t = $(this).attr('checked');
        if (t == true) {
            $(this).parents(".toolBtn-wrap").next().find(".checkbox-item-hook").attr("checked", "true");
            $(this).parents(".toolBtn-wrap").prev().find(".checkbox-item-hook").attr("checked", "true");
            $(this).parents(".toolBtn-wrap").siblings().find(".select-all").attr('checked', 'true')

        }
        else {
            $(this).parents(".toolBtn-wrap").next().find(".checkbox-item-hook").removeAttr("checked");
            $(this).parents(".toolBtn-wrap").prev().find(".checkbox-item-hook").removeAttr("checked");
            $(this).parents(".toolBtn-wrap").siblings().find(".select-all").removeAttr("checked");
        }
    })
    //搜索
    $("#search-9ku-submit").click(function () {
        var req = $.trim($("#search-9ku-input").val());
        if (req.length > 0 && req !== "歌曲\\歌手\\专辑") {
            document.location = "/search/?key=" + encodeURIComponent(req);
            return false;
        }
        else {
            asyncbox.tips('请输入查询内容！', 'error', 1000);
            return false;
        }

    })

    //链接
    function addLink() {
        $("#turn a").click(function () {
            var t = $(this).attr("href");
            if (t.indexOf("comment") > -1) {
                var page = 1;
                if (t.indexOf("page") > -1) {
                    page = t.substring(t.lastIndexOf("/") + 1);
                }
                yc.fenye($(this), page);
                $(this).attr("href", "#pinglun");
                return false;
            }
        })
    }
    addLink();

    //喜欢
    function addLoveico() {
        $(".icon-love").click(function () {
            var sn = 1000;
            var sid = $(this).attr('data-id');
            var t = $(this).attr('data-t');
            if (t == 1 || t == 2 || t == 3) {
                ting.loveadd(t, sn, sid);
            }
            return false;
        })
    }
    addLoveico();

    function addLovefm() {
        $(".jp-love").click(function () {
            var sid = $(this).attr('data-id');
            var t = 2;
            //alert(sid);
            if (t == 1 || t == 2 || t == 3) {
                ting.loveadd(t, 1001, sid);
            }
            return false;
        })
    }
    addLovefm();

    function cancelLovefm() {
        $(".jp-loveed").click(function () {
            var sid = $(this).attr('data-id');
            var t = 2;
            //alert(sid);
            if (t == 1 || t == 2 || t == 3) {
                ting.lovedel(t, 1001, sid);
            }
            return false;
        })
    }
    cancelLovefm();

    //不喜欢
    function addUnLovefm() {
        $(".jp-unlove").click(function () {
            var sid = $(this).attr('data-id');
            var t = 2;
            if (t == 1 || t == 2 || t == 3) {
                ting.blacklistadd(t, sid);
            }
            return false;
        })
    }
    addUnLovefm();

}); //---------------------
/*//回到顶部
$(function(){
      $(window).scroll(function(){
        var top=$(window).scrollTop();
        if(top>500){
          $("#scrolltop").fadeIn();
        }else{
          $("#scrolltop").fadeOut();
        }
      });
      //点击返回头部效果
      $("#scrolltop").click(function(){
      $("html,body").animate({scrollTop:0});
      });
if($(window).width()<1070){
$("#scrolltop").css("marginLeft","430px")
}
});*/

//jQuery.cookie 插件
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


//头部bar
/*$(function(){
	var COOKIE_NAME = "bar";
		   if( $.cookie(COOKIE_NAME)){$(".bar").hide();}else{
						$(".bar").show();
						}

		$(".bar-close,.bar-Off").click(function(){
		  $(".bar").slideUp().remove();
		 	$.cookie(COOKIE_NAME, 'bar', { path: '/', expires: 365 });
			})
});*/

//个人中心举报
$(function(){
$(".user-info-introduction").hover(function(){
	$(this).find(".user-report").toggle();
	})
});

//
$(function(){
$(".subTag-list li,.loveTag-list dd span").hover(function(){
	$(this).toggleClass("hover");
	})		
});



