// JavaScript Document
//插件编写
	;(function($) {
		$.fn.extend({
			"tableColor":function(options){
				//设置默认值
				options=$.extend({
					odd:"Rowsodd",	/* 偶数行样式*/
					even:"Rowseven", /* 奇数行样式*/
					selected:"Rowsselected", /* 选中行样式*/
					rowSelect:false,  /*点击行选择check框*/
                    color:true   /*隔行变色*/
				},options);
                if (options.color) {
                    $("tbody>tr:odd", this).addClass(options.odd);
                    $("tbody>tr:even", this).addClass(options.even);
                }
                if (options.rowSelect) {
                    $('tbody>tr', this).click(function() {
                        //判断当前是否选中

                        var hasSelected = $(this).hasClass(options.selected);
                        //如果选中，则移出selected类，否则就加上selected类
                        $(this)[hasSelected ? "removeClass" : "addClass"](options.selected)
                            //查找内部的checkbox,设置对应的属性。
                                .find(':checkbox').attr('checked', !hasSelected);
                        $(this).parents('table');
                    });
                }else{
                    $('tbody :checkbox:enabled',this).click(function() {
                        $(this).parents('tr:first')[this.checked ? "addClass" : "removeClass"]("Rowsselected");
                        $(this).parents('table:first');
                    });
                }
				$('tbody>tr',this).mouseover(function(){
			$(this).addClass("Rows_overBg")
			}).mouseout(function(){
				//如果鼠标放上去加上over_bg类，移开则移出over_bg类
				$(this).removeClass("Rows_overBg");
				});
	$(".checkAll").click(function(){

		//$("[name=choice]:checkbox").attr("checked",this.checked)
		if(this.checked){
			      $(this).parents('table:first').find(':checkbox:enabled').attr("checked",true).each(function(){
			      		$(this).parents("tr:first").addClass(options.selected)
			      	});

				//$("[name=choice]:checkbox").attr("checked",true)
//					.parents("tr").addClass("selected");
					}else{
						$(this).parents('table:first').find(':checkbox:enabled').attr("checked",false).each(function(){
								$(this).parents("tr:first").removeClass(options.selected)
							})

//				$("[name = choice]:checkbox").attr("checked",false)
//					.parents("tr").removeClass("selected")
					}

			});


				// 如果单选框默认情况下是选择的，则高色.
				$('tbody>tr:has(:checked)',this).addClass(options.selected);
				return this;  //返回this，使方法可链。
			}
		});
	})(jQuery);

	
