﻿$(document).ready(function() {

			/* 	1st example	*/

			/// wrap inner content of each anchor with first layer and append background layer
			$("#menu li a").wrapInner( '<span class="out"></span>' ).append( '<span class="bg"></span>' );

			// loop each anchor and add copy of text content
			$("#menu li a").each(function() {
				$( '<span class="over">' +  $(this).text() + '</span>' ).appendTo( this );
			});

			$("#menu li a").hover(function() {
				// this function is fired when the mouse is moved over
				$(".out",	this).stop().animate({'top':	'40px'},	250); // move down - hide
				$(".over",	this).stop().animate({'top':	'0px'},		250); // move down - show
				$(".bg",	this).stop().animate({'top':	'0px'},		120); // move down - show

			}, function() {
				// this function is fired when the mouse is moved off
				$(".out",	this).stop().animate({'top':	'0px'},		250); // move up - show
				$(".over",	this).stop().animate({'top':	'-40px'},	250); // move up - hide
				$(".bg",	this).stop().animate({'top':	'-40px'},	120); // move up - hide
			});
					

			/*	2nd example	*/
			
			$("#menu2 li a").wrapInner( '<span class="out"></span>' );
			
			$("#menu2 li a").each(function() {
				$( '<span class="over">' +  $(this).text() + '</span>' ).appendTo( this );
			});

			$("#menu2 li a").hover(function() {
				$(".out",	this).stop().animate({'top':	'40px'},	200); // move down - hide
				$(".over",	this).stop().animate({'top':	'0px'},		200); // move down - show

			}, function() {
				$(".out",	this).stop().animate({'top':	'0px'},		200); // move up - show
				$(".over",	this).stop().animate({'top':	'-40px'},	200); // move up - hide
			});

		});
		
		

//UL分类菜单
$(document).ready(function(){
    /*初始化分类列表样式*/
	$("ul[dis='0']").hide();
	$("#class_dir>ul").attr("dis","1").show();
	$("li[dis='1'],li[dis='2']").parents("ul").attr("dis","1").show();
	$("li[dis='2']>ul").attr("dis","1").show();
	$("#class_dir ul:visible>li[dis!='2']").attr("dis","1");
	$("#class_dir li").each(function(i){
        var cb=$(this).attr("code")
		var ca=cb.length/4;
		var cc=$(this).attr("dis");
		var objtmp=$("ul[code='"+cb+"']");
        if(cc=="2")$(this).addClass("classdir" + ca + "2");
        if(objtmp.attr("code")==undefined){
            $(this).addClass("classdir" + ca + "0");
        }else{
            if(objtmp.attr("dis")=="0"){
                $(this).addClass("classdir" + ca + "1");
            }else{
                $(this).addClass("classdir" + ca + "0");
            }
        }
	});

    /*绑定列表上的单击事件，阻止事件冒泡*/
	$("#class_dir li").bind("click",function(event){
		//if($(this).attr("notc")=="1")return;
		var icode=$(this).attr("code");
		var lcode=icode.length/4;
		//alert(icode);
		var objtmp=$("ul[code='"+icode+"']");		
        	if(objtmp.attr("code")!=undefined){
            		if(objtmp.attr("dis")=="0"){
                		$(this).removeClass("classdir" + lcode + "1").addClass("classdir" + lcode + "0");
                		objtmp.attr("dis","1").show()
            		}else{
                		$(this).removeClass("classdir" + lcode + "0").addClass("classdir" + lcode + "1");
                		objtmp.attr("dis","0").hide()
            		}
        	}
		event.stopPropagation();
	});
	$("#class_dir").show();
});

//只显示指定长度的字符，<a href="aa.htm" cut="6">这是一个很长的标题我只想让它显示6个字符</a>
$(document).ready(function(){
    $("*[cut]").each(function(i){
        var a_title=$(this).html();
        if (a_title.length>0){
            var a_len=$(this).attr("cut")*2;
            $(this).attr("title",a_title);
            var j=0;
            var k=0;
            var jstr1="";
            for (var i=0;i<a_title.length;i++) {
                if (a_title.charCodeAt(i)>255)j++;
                j++;k=i;
                if(j>a_len){jstr1="...";break;}
            }
            $(this).html(a_title.substr(0,k+2) + jstr1);
        }
    });
});


//按钮样式
$(document).ready(function(){
	$(".button").each(function(i){
		$(this).before("<span class=\"btnout"+(this.disabled?"2":"")+"\" >" + $(this).attr("value") + "</span>"); 
	}); 
	$(".button").prev().bind("click", function(){
  		if(!$(this).next()[0].disabled)$(this).next().click();
	});
 	$(".button").prev().bind("mouseover",function(){
		if(!$(this).next()[0].disabled)$(this).removeClass("btnout").addClass("btnover");
	});
 	$(".button").prev().bind("mouseout",function(){
		if(!$(this).next()[0].disabled)$(this).removeClass("btnover").addClass("btnout");
	});
}); 


/*
更新时间: 2009-12-17 11:51 (QQ:8511175)
配套文件: getdata.asp

功能：
1、获取文件大小  aid_by_col1
2、获取文章点击率  article_viewnum
2、获取文章点击率并+1   article_viewnum_add
3、获取产品点击率		product_viewnum
3、获取产品点击率并+1	product_viewnum_add
4、获取会员价	product_rmb
*/

$(document).ready(function(){
	getdata("aid_by_col1","获取文件大小失败，如您非常需要该信息请联系本站管理员！");
	getdata("article_viewnum","获取文件击率失败1，如您非常需要该信息请联系本站管理员！");
	getdata("article_viewnum_add","获取文件击率失败2，如您非常需要该信息请联系本站管理员！");
	getdata("product_viewnum","获取产品击率失败，如您非常需要该信息请联系本站管理员！");
	getdata("product_viewnum_add","获取产品击率失败，如您非常需要该信息请联系本站管理员！");
	getdata("product_rmb","获取产品会员价失败，如您非常需要该信息请联系本站管理员！");
});

function getdata(type,errinfo2){
	var pids="",joinstr="";
	$("span["+type+"]").each(function(i){
		$(this).html("<img src=../images/ajax/load1.gif>");
		pids=pids + joinstr + $(this).attr(type);joinstr=",";
	});
	if(pids!=""){
		$.ajax({
			url: "../js/getdata.asp?type="+type+"&id=" + pids,
			cache: false,
			async: false,
			success: function(html){
				var pa=html.split(",");
				for(var i=0;i<pa.length-1;i=i+2){
					$("span["+type+"="+pa[i]+"]").html(pa[i+1])
				}
			},
			error: function(oajax,errinfo){
				alert(errinfo + "," + errinfo2)
			}
		})
	}
}
