function main_tr0_tuo_down(win)
{
if(user_purview-0!=3)return;
var o=win.event.srcElement;
if(o.tagName=='INPUT')return;
var pTD=_gPar("obj.parentElement.id=='tr0'",o)
if(pTD.tagName=="TD" && o!=pTD)
{
var div=_gId('layer_tuo',win);
var l=_gId('layer_tuo_line',win);
l.style.display='none';
div.style.display='none';
win.oldColumnIndex=pTD.cellIndex
var h=win.event.offsetY
var td_y=pTD.offsetTop
l.style.top=td_y-2;
div.style.width=pTD.offsetWidth;
div.innerHTML=pTD.innerHTML;
win.main_tr0_tuo_td=true;
}
}
function main_tr0_tuo_move(win)
{
if(user_purview-0!=3)return;
var div=_gId('layer_tuo',win);
var l=_gId('layer_tuo_line',win);
if(win.event.button!=1)
{
l.style.display='none';
div.style.display='none';
win.main_tr0_tuo_td=false;
}
else
{
if(  win.main_tr0_tuo_td==true && win.cur_reWidth!=true)
{
var o=win.event.srcElement;
if(o.tagName=='INPUT')return;
o=_gPar("obj.parentElement.id.indexOf('tr')>-1",o)
div.style.display=''
div.style.top=win.event.y+20
div.style.left=win.event.x+10
if(o.tagName=="TD")
{
var td=o
l.style.display=''
l.style.height=1888;
var x=get_left(o)
l.style.left=x+o.offsetWidth-2-_gId('tr0_div_div',win).scrollLeft;
l.style.top=28;
}
}
}
}
function main_tr0_tuo_up(win)
{
if(user_purview-0!=3)return;
var oTable=_gId('head_tb',win);
var div=_gId('layer_tuo',win);
var l=_gId('layer_tuo_line',win);
div.style.display='none';
l.style.display='none';
if (win.main_tr0_tuo_td!=true) return false;
if(win.cur_reWidth==true)return false;
var o=win.event.srcElement;
var o=_gPar("obj.parentElement.id=='tr0'",o)
if(o.tagName=="TD")
{
var moveCount=o.cellIndex-win.oldColumnIndex;
if(moveCount>0)
{
win.newColumnIndex=o.cellIndex+1
}
if(moveCount<-1) 
{
win.newColumnIndex=o.cellIndex+1
}
if (win.oldColumnIndex>-1 && win.newColumnIndex>-1)
{
var id=oTable.rows[0].cells[win.oldColumnIndex].id
if(moveCount<0){win.oldColumnIndex+=1}
col_add(win,oTable)
col_copy(win,oTable)
col_del(win,oTable)
var tb=win.workFrame.document.body.getElementsByTagName("TABLE")
for(var i=0;i<tb.length;i++)
{
if(tb[i].id.indexOf("tb")>-1)
{
col_add(win,tb[i])
col_copy(win,tb[i])
col_del(win,tb[i])
}
}
var url='../'+asp_php+'/show_more_list_col.'+asp_php+'?fileName='+request("fileName",win)+'&exe=save_selected_col&list_or_win=show_list&showed_ids='+get_showed_ids(oTable)
_gId('frame_blank',win).src=url;
}
}
win.oldColumnIndex=-1
win.newColumnIndex=-1
win.main_tr0_tuo_td=false
}
function get_showed_ids(tb)
{
var tds=tb.rows[0].cells;
var ids='';
for(var i=0;i<tds.length;i++)
{
ids+=tds[i].id+","
}
if(ids!=''){ids=ids.substr(0,ids.length-1)}
return ids;
}
function col_add(win,oTable) 
{ 
var rowCount = oTable.rows.length; 
var cellCount = oTable.rows[0].cells.length; 
var new_td,old_td;
for( i=0; i<rowCount; i++ ) 
{ 
var tRow = oTable.rows[i];
var new_td = tRow.insertCell(win.newColumnIndex); 
if (i==0)
{
old_td=oTable.rows[i].cells[win.oldColumnIndex];
new_td.className='tr0_td';
new_td.width=_gId('layer_tuo',win).style.width.replace("px","");
new_td.id=old_td.id;
}
} 
}
function get_td_shuXin(obj)
{
var s=obj.outerHTML;
s=s.replace(/(<td )([^>]*)(>)[\w\W]*/i,"$2");
s=s.replace(/"([^"]*?)"/g,"");
s=s+" ";
s=s.replace(/=([^ ]*?)[ ]+/g,",");
return s;
}
function col_copy(win,oTable)   
{
for(i=0;i<oTable.rows.length;i++)
{
var new_td=oTable.rows[i].cells[win.newColumnIndex];
var old_td=oTable.rows[i].cells[win.oldColumnIndex];
new_td.innerHTML=old_td.innerHTML;
copy_attribute(new_td,old_td)
}
}
function col_del(win,oTable)
{
for(var i=0;i<oTable.rows.length;i++)
{
oTable.rows[i].deleteCell(win.oldColumnIndex);
}
}
function copy_attribute(new_td,old_td)
{
var arr=get_td_shuXin(old_td).split(',');
for(var i=0;i<arr.length-1;i++)
{
var t=arr[i]+'';
if(t!='' && t!=' ' && t!='class')
{
new_td.setAttribute(arr[i],old_td.getAttribute(arr[i]))
}
}
}