$(document).ready(function(){init_Index_Precise();});
function init_Index_Precise(){
    var ShowPosition = {
        left: 9,
        top: -20
    };
    var Template = {
        precise: "<div class='popcon'><div class='title'>此类推荐信息</div><div class='content'>{T:Content}</div><div class='more'><a href='{T:Url}' target='_blank'>更多&gt;&gt;</a></div><div class='poparrow'></div></div>",
        item: "<a href='{T:TagId}' target='_blank' title='{T:TagFullName}'>{T:TagName}</a><BR>"
    };
    var PreObj = $('#PrecisionNav');
	var Prewh = PreObj.width();
	var tmparw;
    $('.index_cate a').hover(function(){
        var Pos_Precise = $(this).offset();
		var Pos_wh = $(this).width();
        PreObj.css({
            position: 'absolute'
        });
		if((Pos_Precise.left-Prewh) > 0){
			PreObj.css({
				left: (Pos_Precise.left-(Prewh+ShowPosition.left)) + 'px',
				top: (Pos_Precise.top+ShowPosition.top) + 'px'
			});
			tmparw = 'right';
		}else{
			PreObj.css({
				left: (Pos_Precise.left+Pos_wh+ShowPosition.left-3) + 'px',
				top: (Pos_Precise.top+ShowPosition.top) + 'px'
			});
			tmparw = 'left';
		}
        var Url_Precise = $(this).attr('href');
        var ClassId = null ? 0 : Url_Precise.match(/(\d+)\.html$/)[1];
		var BigClass = Url_Precise.match(/([A-Za-z])(\d+)\.html$/)[1];
        if (ClassId) {                                     
            $.ajax({
                url: "../GetProposeInfo.aspx",
                data: "Classid=" + ClassId+"&BigClass="+BigClass,
                dataType: 'json',
                async: true,
                cache: false,
                beforeSend: function(){
                    var template_this = Template.precise;   
                    template_this = template_this.replace('{T:Content}', '数据加载中<img src="/images/loading.gif"/>');
                    template_this = template_this.replace('{T:Url}', '');
                    PreObj.html(template_this);
                    PreObj.show();
					var prearw = $('.poparrow');
					if(tmparw=='right'){
						prearw.addClass('poparwr');
					}else{
						prearw.addClass('poparwl');
					}
                },
                success: function(msg){
                    var Items = '';
                    if (msg.IsExist == 1) {
                        $.each(msg.Items, function bindItem(i, item){//迷惑
                            var template_tag = Template.item;
                            template_tag = template_tag.replace('{T:TagId}', item.TagId);
                            template_tag = template_tag.replace('{T:TagFullName}', item.TagFullName);
							template_tag = template_tag.replace('{T:TagName}', item.TagName);
                            Items += template_tag;
                        });
                    }
                    else {
                        Items = '本类数据正在整理.';
                    }
                    var template_this = Template.precise;
                    template_this = template_this.replace('{T:Content}', Items);
                    template_this = template_this.replace('{T:Url}', Url_Precise);
                    PreObj.html(template_this);
					var prearw = $('.poparrow');
					if(tmparw=='right'){
						prearw.addClass('poparwr');
					}else{
						prearw.addClass('poparwl');
					}
                },
                error: function(){
                    PreObj.html('数据加载失败.');
                }
            });
        };
            }, function(){
        PreObj.hide();
    });
    PreObj.hover(function(){
        $(this).show();
    }, function(){
        $(this).hide();
    });
}
