/*-------------------------------------------------------
* 说明：基于jQuery编写
* 作者：Gavin
* 创建时间：2008-10-27
* 最后一次修改时间：2009-03-04 
-------------------------------------------------------*/

$(document).ready(function(){
						   
	//消除链接虚线框
	$("a").bind("focus",function(){
    	if(this.blur){ //如果支持 this.blur
        	this.blur();
        }
    });
	
	//表单label自适应宽度
	var max = 0;  
	$("label").each(function(){  
		if ($(this).width() > max) max = $(this).width();  
	});  
	$("label").width(max);
	
	//文本框高亮
	$('input[type="text"], input[type="password"], textarea').each(function(){
		$(this).addClass("idleField");
		$(this).focus(function() {
			$(this).removeClass("idleField").addClass("focusField");
			if (this.value == this.defaultValue){ 
				this.value = '';
			}
			if(this.value != this.defaultValue){
				this.select();
			}
		});
		$(this).blur(function() {
			$(this).removeClass("focusField").addClass("idleField");
			if ($.trim(this.value) == ''){
				this.value = (this.defaultValue ? this.defaultValue : '');
			}
		});	  
	});
	
	//斑马线表格
	//$(".thinLineTable tr:even").addClass("even");
	$("#toolbarHandler, .toolbar").bind("mouseover",function(){
			$("#toolsList").show();
		}).bind("mouseout",function(){
			$("#toolsList").hide();
		});

    //高亮首页
	var str=window.location.href;
	var r=/[^\/]+$/.exec(str);
	if(r==null || window.location.pathname.indexOf('index')!=-1){
	    $("#mainNav li:first a").addClass("current");
	};

    //category
	$("#subNav ul li").bind("mouseenter", function(){
		$(this).addClass("current")
		.children("ul").show().end()
		.siblings().removeClass("current");
	}).bind("mouseleave", function(){
		$(this).removeClass("current")
		.children("ul").hide();
	});

    var numOfLv2=$("#subNav .content > ul > li").size();
    var j=0;
    var col=0;
    var maxSize=10;
    var liWidth=$("#subNav .content ul ul:first").width();
    for(i=0;i<numOfLv2;i++){
        var $ul=$("#subNav .content > ul > li:eq("+i+") > ul");
        var $li=$ul.find("li");
        j=$li.size();
        if(j>maxSize){
            col=Math.floor(j/maxSize) +1;
            $ul.width(col*liWidth);
        };
    }
	
});
