﻿function startFloatTitle(){var b=0,a=[];allTables=document.getElementsByTagName("table");for(i=0;i<allTables.length;i++)if(allTables[i].className=="FloatTitle"){tableID=allTables[i].id;if(tableID==""){tableID="tmpFloatTitleTableId"+b;allTables[i].id=tableID}a[b]=tableID;b++}for(i=0;i<a.length;i++)floatTitle(a[i],i)}var floatTitleTimer=[];function floatTitle(b,a){if(typeof floatTitleTimer[a]=="undefined")floatTitleTimer[a]=0;clearTimeout(floatTitleTimer[a]);titleID=createTitleObj(b);floatTitleLoop(b,titleID,a)}function createTitleObj(c){var b=c+"Title",d=c+"TitleTable";if(document.getElementById(b)==null){tableObj=document.getElementById(c);clonedtHead=tableObj.tHead.cloneNode(true);titleWrapperObj=document.createElement("div");titleWrapperObj.setAttribute("id",b);TitleTable=document.createElement("table");TitleTable.setAttribute("id",d);TitleTable.appendChild(clonedtHead);titleWrapperObj.appendChild(TitleTable);parentDiv=tableObj.parentNode;parentDiv.insertBefore(titleWrapperObj,tableObj);titleWrapperObj.style.position="absolute";titleWrapperObj.style.top="0px";titleWrapperObj.style.zIndex="1"}tableObj=document.getElementById(c);titleTableObj=document.getElementById(d);titleWrapperObj=document.getElementById(b);titleWrapperObj.style.width=tableObj.offsetWidth+"px";tableCells=tableObj.tHead.rows[0].cells;titleTableCells=titleTableObj.tHead.rows[0].cells;for(var a=0;a!=tableCells.length;a++){titleTableCells[a].style.width=tableCells[a].clientWidth+"px";titleTableCells[a].style.cursor="normal"}return b}function floatTitleLoop(g,h,j){if(document.getElementById(g)!=null&&document.getElementById(h)!=null){var d=document.getElementById(g),f=d.offsetTop,e=d;if(e.offsetParent)while(e=e.offsetParent)f+=e.offsetTop;var a=document.documentElement.scrollTop>0?document.documentElement.scrollTop:document.body.scrollTop;a=0;var k=FindPosition(d),c=k[1]-f,i=c+d.clientHeight;if(a<c)a=c;if(a>i)a=i;var b=document.getElementById(h);if(a>c&&a<i){if(b.style.display!="block")b.style.display="block";a=a+f;easeInWanted=true;if(easeInWanted){oldTop=parseInt(b.style.top);topDiff=a-oldTop;moveTop=0;if(topDiff<-1||topDiff>1)moveTop=Math.round(topDiff/3);a=oldTop+moveTop}if(a<0)a=0;b.style.top=a+"px"}else if(b.style.display!="none"){b.style.display="none";b.style.top="0px";b.style.zIndex="1"}}cmd="floatTitleLoop('"+g+"','"+h+"','"+j+"')";floatTitleTimer[j]=window.setTimeout(cmd,40)}function FindPosition(c){if(c==null)return [0,0];tmpObj=c;var a=tmpObj.offsetLeft,b=tmpObj.offsetTop;if(tmpObj.offsetParent)while(tmpObj=tmpObj.offsetParent){a+=tmpObj.offsetLeft;b+=tmpObj.offsetTop}tmpObj=c;while(tmpObj=tmpObj.parentNode)if(tmpObj.style&&(tmpObj.style.overflow=="auto"||tmpObj.style.overflow=="scroll")){a-=tmpObj.scrollLeft;b-=tmpObj.scrollTop}return [a,b]}window.onload=startFloatTitle;window.onresize=startFloatTitle