//===================== set variables for Move up and down choices ================
   var sel = getelm("ctl00_cphMaster_FormatChoices");
   var up = getelm("UpButton");
   var down = getelm("DownButton");
   var result = getelm("ctl00_cphMaster_hdnFormatChoices");
   //--------------------------------------------------
   function getPropText() {
       try {

           var divText = getelm('divPropText');
           var hdnText = getelm('ctl00_cphMaster_hdnPropText');

           if (divText && hdnText) {
               hdnText.value = escapeVal(divText.innerHTML, "<br />");
           }
       }
       catch (e) { alert(e) }
   }
   //===================================
   function escapeVal(_text, replaceWith) {
       //_text is reference to that object, replaceWith is string that will replace the encoded return
       _text = escape(_text) //encode _text string's carriage returns

       for (i = 0; i < _text.length; i++) {
           //loop through string, replacing carriage return encoding with HTML break tag
           if (_text.indexOf("%0D%0A") > -1) {
               //Windows encodes returns as \r\n hex
               _text = _text.replace("%0D%0A", replaceWith)
           }
           else if (_text.indexOf("%0A") > -1) {
               //Unix encodes returns as \n hex
               _text = _text.replace("%0A", replaceWith)
           }
           else if (_text.indexOf("%0D") > -1) {
               //Macintosh encodes returns as \r hex
               _text = _text.replace("%0D", replaceWith)
           }
       }
       return _text; //unescape all other encoded characters
   }

   //----------------------------------------------------------------
function MoveDown(){
   try{ 
    if ( sel.selectedIndex == -1 ) return;
        up.disabled = down.disabled = true;

    if ( sel.selectedIndex< sel.options.length-1){
        var selIndex = sel.selectedIndex;
        var text = sel.options[ selIndex ].text;
        var value = sel.options[ selIndex ].value;
        sel.options[ selIndex ].text = sel.options[ selIndex +1].text;
        sel.options[selIndex ].value =  sel.options[ selIndex +1].value;
        sel.options[ selIndex +1].text = text;
        sel.options[ selIndex +1].value = value;
        sel.selectedIndex++;
    }
     up.disabled = down.disabled = false;
     setFormatChoices()  // set the choices after this function completes  
  } 

  catch(ex){alert(ex)}
}
//------------------------------------------------------------
function MoveUp() {
try{
        if ( sel.selectedIndex == -1 ) return;
                up.disabled = up.disabled = true;

        if ( sel.selectedIndex>0) {
                var selIndex = sel.selectedIndex;
                var text = sel.options[ selIndex ].text;
                var value = sel.options[ selIndex ].value;
                sel.options[ selIndex ].text = sel.options[ selIndex -1].text; // move up the item below this one
                sel.options[selIndex ].value = sel.options[ selIndex -1].value; // move up the item below this one
                sel.options[ selIndex -1].text = text; //set the present at one level below
                sel.options[ selIndex -1].value = value; // set the present at one level below
                sel.selectedIndex--;
            }
                up.disabled =  down.disabled = false;
                
        setFormatChoices()  // set the choices after this function completes
    }
   catch(ex){alert(ex)} 
}

function setFormatChoices() {
    var s= new String();
    for( var i=0; i< sel.options.length; i++){
            s=s + "," + sel.options[i].value;                         
    }
   result.value = s.slice(1, s.length); 
}
// ----- this function is called on page load to restore the order of format choices (saved in a hidden field)
//function restoreFormatChoices(){
//try{
//    var resultVal = result.value;
//    var aresult = resultVal.split(','); 

//    for (var r=0;r<aresult.length;r++){
//     // for ex: this may have 2,1,0,3,4 sequence
//   
//               // by default format choices are loaded in order as 0,1,2,3,4          
//               for( var i=0; i< sel.options.length; i++){ 
//                    if(sel.options[i].value != r){ 
//                        // if present option value is not equal to the current result option ..
//                        // then move this option down the line
//                        sel.options[i]
//                    }
//                } 
//                        
//        }
//}

//catch(ex){}

//}