var columns=[];function selectSource(){var F=document.prefs;var D="";while(F.unselected_columns.length>1){F.unselected_columns.options[F.unselected_columns.length-1]=null}while(F.selected_columns.length>1){F.selected_columns.options[F.selected_columns.length-1]=null}if(F.source.selectedIndex<1){return}var E=F.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++){F.selected_columns.options[A+1]=new Option(C[A][0],C[A][1])}for(A=0;A<B.length;A++){F.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()};