$.fn.mergeattributes = function(src){
if($.browser.msie) {
$(this).get(0).mergeattributes(src.get(0));
}else{
attrs = src.get(0).attributes;
i = attrs.length - 1;
for(;i>=0;i--){
var name = attrs[i].name;
if(name.tolowercase() === 'id' || attrs[i].value=="" || attrs[i].value==null ||attrs[i].value=="null"){
continue;
}
try{
$(this).attr(name,attrs[i].value);
}catch(e){
}
}
}
}
$.fn.frozentable = function(irowhead,irowfoot,icolleft){//3,0,1
var otable = $(this);
var otableid = otable.attr("id");
var odiv = $(this).parent();
if(odiv.get(0).tagname != "div") return;
otable.find("td").attr("nowrap","nowrap");
//otable.css("table-layout","fixed");
if (otable.width() > odiv.width() && otable.height() > odiv.height()) {
if(irowhead>0 && icolleft>0){
var oclonetable = $("
");//������������к��н����ı�ͷ
odiv.parent().append(oclonetable);
oclonetable.clonetable(otable,0,irowhead,icolleft);
oclonetable.css("position","absolute");
oclonetable.css("z-index","1004");
oclonetable.css("left",odiv.offset().left);
oclonetable.css("border-bottom-style",'none');
oclonetable.css("border-top-style", 'none');
oclonetable.css("top",odiv.offset().top);
}
if(irowfoot>0 && icolleft>0){
var oclonetable = $("");
odiv.parent().append(oclonetable);
oclonetable.clonetable(otable,otable.find("tr").length-irowfoot,otable.find("tr").length,icolleft);
oclonetable.css("position","absolute");
oclonetable.css("z-index","1003");
oclonetable.css("left",odiv.offset().left);
oclonetable.css("top",(odiv.offset().top+odiv.outerheight(true)-oclonetable.outerheight(true)-17));
}
}
if (irowhead > 0 && otable.height() > odiv.height()) {
var oclonediv = $("");
odiv.parent().append(oclonediv);
oclonediv.find("table").clonetable(otable,0,irowhead,-1);
oclonediv.css("overflow","hidden");
oclonediv.css("width",odiv.outerwidth(true)-17);
oclonediv.css("position","absolute");
oclonediv.css("z-index","1002");
oclonediv.css("left",odiv.offset().left);
oclonediv.css("top",odiv.offset().top);
}
if (irowfoot > 0 && otable.height() > odiv.height()) {
var oclonediv = $("");
odiv.parent().append(oclonediv);
oclonediv.find("table").clonetable(otable,otable.find("tr").length-irowfoot,otable.find("tr").length,-1);
oclonediv.css("overflow","hidden");
oclonediv.css("width",odiv.outerwidth(true)-17);
oclonediv.css("position","absolute");
oclonediv.css("z-index","1001");
oclonediv.css("left",odiv.offset().left);
oclonediv.css("top",odiv.offset().top+odiv.outerheight(true)-oclonetable.outerheight(true)-17);
}
if (icolleft > 0 && otable.width() > odiv.width()) {
var oclonediv = $("");
odiv.parent().append(oclonediv);
oclonediv.find("table").clonetable(otable,0,otable.find("tr").length,icolleft);
oclonediv.css("overflow","hidden");
oclonediv.css("height",odiv.outerheight(true)-17);
oclonediv.css("position","absolute");
oclonediv.css("z-index","1000");
//oclonediv.css("left", odiv.offset().left);//ע�͵�ɽ����������
oclonediv.css("top",odiv.offset().top);
}
odiv.scroll(function(){
if(typeof($("#odivh_"+otableid).get(0))!='undefined'){
$("#odivh_"+otableid).scrollleft($(this).scrollleft());
}
if(typeof($("#odivf_"+otableid).get(0))!='undefined'){
$("#odivf_"+otableid).scrollleft($(this).scrollleft());
}
if(typeof($("#odivl_"+otableid).get(0))!='undefined'){
$("#odivl_"+otableid).scrolltop($(this).scrolltop());
}
});
};
$.fn.clonetable = function(osrctable,irowstart,irowend,icolumnend){
var iwidth = 0,iheight = 0;
$(this).mergeattributes(osrctable);
var log="";
var rowspanvalue = 0;
var rownumber = 0;
var rowindex;
for(var i=irowstart;i=icolumnend && icolumnend!=-1){
break;
}
}
log +=i+"=="+rowindex+"="+rowspancount+"="+rownumber+"="+rowspanvalue+"
";
if(i>rowindex && i<=(rowindex+rowspanvalue-1) && icolumnend!=-1){
if(rownumber!=0 && icolumnend==rownumber){
issinglerowspan = true;
}else{
colnumber -= 1;
if(rowspancount==0){
colnumber -= (rownumber-1);
}
}
}
if(colnumber!=0){
var newtr = $("
");
newtr.mergeattributes(oldtr);
var jwidth = 0;
iheight += oldtr.outerheight(true);
for(var j=0; j