var columns=[];function selectSource(){var g=document.prefs;var d="";while(g.unselected_columns.length>1){g.unselected_columns.options[g.unselected_columns.length-1]=null}while(g.selected_columns.length>1){g.selected_columns.options[g.selected_columns.length-1]=null}if(g.source.selectedIndex<1){return}var e=g.source.selectedIndex-1;var c=[];var b=[];for(var a=1;a<columns[e].length;a++){if(columns[e][a][2]){c[columns[e][a][3]]=[columns[e][a][1],columns[e][a][0]]}else{b[b.length]=[columns[e][a][1],columns[e][a][0]]}}for(a=0;a<c.length;a++){g.selected_columns.options[a+1]=new Option(c[a][0],c[a][1])}for(a=0;a<b.length;a++){g.unselected_columns.options[a+1]=new Option(b[a][0],b[a][1])}}function deselectHeaders(){document.prefs.unselected_columns[0].selected=false;document.prefs.selected_columns[0].selected=false}function resetHidden(){var c="";for(var b=0;b<columns.length;b++){if(b>0){c+="\n"}c+=columns[b][0];for(var a=1;a<columns[b].length;a++){if(columns[b][a][2]){c+="\t"+columns[b][a][0]}}}document.prefs.columns.value=c}function addColumn(){var c=document.prefs;var b=c.source.selectedIndex-1;for(i=1;i<c.unselected_columns.length;i++){if(c.unselected_columns[i].selected){for(var a=1;a<columns[b].length;a++){if(columns[b][a][0]==c.unselected_columns[i].value){columns[b][a][2]=true}}c.selected_columns[c.selected_columns.length]=new Option(c.unselected_columns[i].text,c.unselected_columns[i].value);c.unselected_columns[i]=null;i--}}resetHidden()}function removeColumn(){var c=document.prefs;var b=c.source.selectedIndex-1;for(i=1;i<c.selected_columns.length;i++){if(c.selected_columns[i].selected){for(var a=1;a<columns[b].length;a++){if(columns[b][a][0]==c.selected_columns[i].value){columns[b][a][2]=false}}c.unselected_columns[c.unselected_columns.length]=new Option(c.selected_columns[i].text,c.selected_columns[i].value);c.selected_columns[i]=null;i--}}resetHidden()}function moveColumnUp(){var d=document.prefs;var c=d.selected_columns.selectedIndex;var b=d.source.selectedIndex-1;if(c<=1||d.selected_columns.length<=2){return}d.selected_columns.selectedIndex=c;var a=d.selected_columns[c].value;tmp=[];for(i=1;i<d.selected_columns.length;i++){tmp[i-1]=new Option(d.selected_columns[i].text,d.selected_columns[i].value)}for(i=0;i<tmp.length;i++){if(i+1==c-1){d.selected_columns[i+1]=tmp[i+1]}else{if(i+1==c){d.selected_columns[i+1]=tmp[i-1]}else{d.selected_columns[i+1]=tmp[i]}}}d.selected_columns.selectedIndex=c-1;for(i=2;i<columns[b].length-1;i++){if(columns[b][i][0]==a){column=columns[b][i];columns[b][i]=columns[b][i-1];columns[b][i-1]=column}}resetHidden()}function moveColumnDown(){var c=document.prefs;var b=c.selected_columns.selectedIndex;var a=c.source.selectedIndex-1;if(b==-1||c.selected_columns.length<=2||b==c.selected_columns.length-1){return}c.selected_columns.selectedIndex=b;var d=c.selected_columns[b].value;tmp=[];for(i=1;i<c.selected_columns.length;i++){tmp[i-1]=new Option(c.selected_columns[i].text,c.selected_columns[i].value)}for(i=0;i<tmp.length;i++){if(i+1==b){c.selected_columns[i+1]=tmp[i+1]}else{if(i+1==b+1){c.selected_columns[i+1]=tmp[i-1]}else{c.selected_columns[i+1]=tmp[i]}}}c.selected_columns.selectedIndex=b+1;for(i=columns[a].length-2;i>0;i--){if(columns[a][i][0]==d||columns[a][i+1][0]==d){column=columns[a][i];columns[a][i]=columns[a][i+1];columns[a][i+1]=column}}resetHidden()};