$(document).ready(function () {



    /* 设置菜单 */
	//$(".item-link-5").click(function(e){
	//	e.stopPropagation();
	//	var o = $(this);
	//	o.addClass('il5-bg');
	//	$(".view_setting").slideToggle(300,function(){ 
	//		if( $(".view_setting").is(":hidden") ){ o.removeClass('il5-bg'); } 
	//	});
	//});
		
	$(document).click(function(){
		$(".view_setting").slideUp(300,function(){$('.item-link-5').removeClass('il5-bg');});
	});
	
	$(".view_setting").click(function(e){e.stopPropagation();});
	
	/* 首页新闻标题 */
    var HOMENL = $('.rt .nlst .new-list ul li');
    HOMENL.hover(
    	function(){$(this).addClass('mnow');$(this).find('.date').hide();},
    	function(){$(this).removeClass('mnow');$(this).find('.date').show();}
    );

    /* 新闻分类切换 */
    var CTULA = $('.ct ul li a');
    CTULA.click(function () {
        CTULA.removeClass('current');
        $(this).addClass('current');
        var NUMB = $(this).parent().index() + 1;
        //alert(String(NUMB));
        if ($(this).attr('class') == 'current') {
            $('.lst').css({ 'display': 'none' });
            $('.lst-' + String(NUMB)).css({ 'display': 'block' });
        } else {
            $('.lst').css({ 'display': 'none' });
        }
    });

    /* 页码切换 */
    var NLNUM = $('.page_num a');
    NLNUM.click(function () {
        NLNUM.removeClass('current');
        $(this).addClass('current');
        var NUMB = $(this).index() + 1;
        //alert(String(NUMB));
        if ($(this).attr('class') == 'current') {
            $('.new-list .block').css({ 'display': 'none' });
            $('.new-list-' + String(NUMB)).css({ 'display': 'block' });
        } else {
            $('.new-list .block').css({ 'display': 'none' });
        }
    });

    /* 浮动内容 */
    $(window).scroll(function () {
        var bodyTop = 0,
        //bodyHeight = $(window).height(),
			 sideTop = $('.sidebar ul').eq(0).height() + 142;
        if (typeof window.pageYOffset != 'undefined') {
            bodyTop = window.pageYOffset;
        } else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
            bodyTop = document.documentElement.scrollTop;
        } else if (typeof document.body != 'undefined') {
            bodyTop = document.body.scrollTop;
        }
        if (bodyTop > sideTop) {
            $('#crf1').css({ 'position': 'fixed', 'top': '53px' });
        } else {
            $('#crf1').css({ 'position': 'relative', 'top': '0px' });
        }
    });
	
	/* 侧边分享按钮 */
    $('#goshare').mouseleave(function(){
		clearTimeout(hideTimer);
		$('#bdshare_s').removeAttr('te');
		hideTimer = setTimeout(function(){
			if ($('#bdshare_s').attr('te') != 'displayed') {
				$('#bdshare_l').fadeOut(200,function(){$('#bdshare_s').prependTo('body');}); 
			}
		}, 100); //鼠标移除元素区域子元素消失
	}).mouseenter(function(){
		$('#bdshare_s').attr('te', 'displayed');
        hideTimer = setTimeout(function(){
			$('#bdshare_s').appendTo('#side_func');
            $('#bdshare_l').addClass('show_bds').fadeIn(200);
        }, 500); //鼠标滑过元素1秒钟显示子元素
        $('#bdshare_l').mouseenter(function(){
				$('#bdshare_s').attr('te', 'displayed');
			}).mouseleave(function(){
			hideTimer = setTimeout(function(){
				$('#bdshare_l').fadeOut(200,function(){$('#bdshare_s').prependTo('body');$('#bdshare_s').removeAttr('te');});
			}, 100); //鼠标移除元素区域子元素消失
		});
	});

    $('.related_post a').hover(
    	function(){$(this).parent().find('span').addClass('rp_span');},
    	function(){$(this).parent().find('span').removeClass('rp_span');}
    );

});/* jQuery Document End */





hd_float="<div id=\"hd_float\" style=\"position:fixed;left:50%;bottom:190px;margin-left:-680px;width:166px;\"><a class=\"close\" href=\"http://www.50it.cn\" target=\"_blank\" style=\"display:block;width:121px;height:138px;background:url(/50it/img/121x138_xzs2.gif) no-repeat;\"></a></div>"
//hd_float="<div id=\"hd_float\" style=\"position:fixed;left:50%;bottom:190px;margin-left:-680px;width:166px;\"><a class=\"close\" href=\"http://s.click.taobao.com/CEOuFex\" target=\"_blank\" style=\"display:block;width:121px;height:138px;background:url(http://img.ithome.com/images/v2.3/ali.png) no-repeat;\"></a></div>"


document.write(hd_float);
$('#hd_float').prependTo('body');



/* 修复Flash遮挡 */
$('embed').attr('wmode','transparent');

if ((navigator.userAgent.match(/(iPhone|iPod|Android|Windows Phone)/i))) {
	app_recom = $('<a href="http://wap.ithome.com" class="go_wap">进入WAP版</a>');
	app_recom .prependTo('#hd');
	$('body').css({'padding-top':'86px'});
}



function connectLogin(type) {
    var url = "",
        name = "",
        width = "",
        height = "";
    var clienttime = parseInt((new Date).getTime()/1000)
    
    switch (type) {
        case "Sina":
            url = "http://www.ithome.com/ithome/openplat/sina/login.aspx";
            name = "SinaLogin";
            width = 562;
            height = 380;
            break;
        case "QQ":
            url = "http://www.ithome.com/ithome/openplat/qq/login.aspx";
            name = "qq";
            width = 600;
            height = 380;
            break;
        case "WX":
            url = "http://www.ithome.com/ithome/openplat/wx/login.aspx";
            name = "wx";
            width = 580;
            height = 660;
            break;

    }
    if(url){
        url +="?clienttime="+clienttime
        var l = (window.screen.width - width) / 2,
            t = (window.screen.height - height) / 2;
        window.open(url, name, "width="+ width +",height="+ height +",left="+ l +",top="+ t +",menubar=0,scrollbars=0,resizable=0,status=0,titlebar=0,toolbar=0,location=1"); 
    }
    
}

$(".login").on({
    click: function () {
			popWin.showWin("450", "370", "软媒通行证登录", "/ithome/divlogin.aspx");
    }
})

$("#btnLogout").on({
    click: function () {
        $.ajax({
            type: "POST",
            url: "/ithome/login.aspx/btnLogout_Click",
            data: "",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            async: true,
            success: function (msg) {
            	  var url = "http://www.lapin365.com/Login/logout";
                $.getScript(url);   
                $.ajax({
								    url: "http://jimeng.com/account/logoutsync",
								    type: "post",
								    dataType: "script",
								    success: function (msg) {
								    }
								});     
                location.reload();
            }
        });
    }
})
$(".refresh a").on({
    click: function () {
			location.reload();
    }
})

$("body").append("<div style='display:none;'>" + $(".con-recom").css("display") + "</div>");

/* 如果广告被屏蔽，则加入统计 */
if ($(".con-recom").css("display") == "none") {
    var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");
    $("body").append(unescape("%3Cspan id='cnzz_stat_icon_1258998645'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "w.cnzz.com/c.php%3Fid%3D1258998645' type='text/javascript'%3E%3C/script%3E"));

    $("#paragraph").before("<a style='margin-bottom:5px;margin-top: 10px;display:block;' href='http://m.ithome.com/ithome/' target='_blank'><img src='http://ww3.sinaimg.cn/large/53bcd254jw1f3lia1f4eaj20k803cwf8.jpg'/></a>");
    //$("#paragraph").parent()
    
}

var nav_html = $(".current_nav").html();
if (nav_html.indexOf("辣品") > 0) {
    var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");

    if (location.href.indexOf("f=left") > 0) {
        $("body").append(unescape("%3Cspan id='cnzz_stat_icon_1259111507'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "w.cnzz.com/c.php%3Fid%3D1259111507' type='text/javascript'%3E%3C/script%3E"));
    } else if (location.href.indexOf("f=right") > 0) {
        $("body").append(unescape("%3Cspan id='cnzz_stat_icon_1259111330'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "w.cnzz.com/c.php%3Fid%3D1259111330' type='text/javascript'%3E%3C/script%3E"));
    } else { // 非导流的辣品
        $("body").append(unescape("%3Cspan id='cnzz_stat_icon_1259109885'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "w.cnzz.com/c.php%3Fid%3D1259109885' type='text/javascript'%3E%3C/script%3E"));
    }
}