/*------------------------------------------------------------
* Description：Special effects of the website, based on JQuery
* Author：Gavin
* E-mail: shengzhizhang@gmail.com
* Created On：2008-10-27
* Last modification On：2010-01-27 
------------------------------------------------------------*/
function initMenu(treeDiv) {
	$(treeDiv + ' ul:hidden:empty').remove();
	$(treeDiv + ' li a').click(function() {
		var clickElement=$(this);
		var checkElement = $(this).next();
		if(checkElement.is('ul') && (checkElement.is(':has("li")'))){
			if(checkElement.is(':visible')) {
				return false;
			}
			if(!checkElement.is(':visible')) {
				checkElement.parent().parent().find("ul:visible").slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		}
    });
}

$(document).ready(function(){
						   
	// eliminate the dashed box of the links 
	$("a").bind("focus",function(){
    	if(this.blur){
        	this.blur();
        }
    });
	
	// initialize sub navigation
	initMenu("#subNav");
	
	// Hilight sub navigation
	$("#subNav .current").parents("ul").show();

    // Default buttons
    $('.defaultBtn').hover(
		// mouseover
		function(){ $(this).addClass('defaultBtnHover'); },
		
		// mouseout
		function(){ $(this).removeClass('defaultBtnHover'); }
	);
	
	// Adaptive width of the form labels
	var max = 0;  
	$("label").each(function(){  
		if ($(this).width() > max) max = $(this).width();  
	});  
	$("label").width(max);
		
	// Zebra table
	//$(".zebra tr:even").addClass("even");

    // Member toolbar
	$("#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");
	};
	
});
