
function saveSort( section ) {

    objSorted = $("input[name=sorted_id]");

    var objJSON = new Object;
    objJSON.position = new Array;

    for (i = 0; i < objSorted.length; i++) {
      objJSON.position[i] = objSorted[i].value;
    }

    objSortedJSON = JSON.stringify(objJSON);


    if (section == "dialogue") {

      // Save Repositioning
      $.get("/updates/editDisplayOrder",{
        section: "dialogue",
        content_id: content_id,
        data: objSortedJSON
      },function(txt) {
        //alert(txt);
      });

     }



    if (section == "vocabulary") {

       // Save Repositioning
       try {
         var head = document.getElementsByTagName("head")[0];
         script = document.createElement('script');
         script.id =  'editDisplayOrder';
         script.type = 'text/javascript';
         script.src = "/updates/editDisplayOrder?section=vocabulary&content_id="+content_id+"&data="+objSortedJSON;
         head.appendChild(script);
       } catch(err) { alert("Error: " + err.message); }

     }



    if (section == "test") {

       // Save Repositioning
       try {
         var head = document.getElementsByTagName("head")[0];
         script = document.createElement('script');
         script.id =  'editDisplayOrder';
         script.type = 'text/javascript';
         script.src = "/updates/editDisplayOrder?section=test&content_id="+content_id+"&data="+objSortedJSON;
         head.appendChild(script);
       } catch(err) { alert("Error: " + err.message); }

     }




    if (section == "course") {

       // Save Repositioning
       try {
         var head = document.getElementsByTagName("head")[0];
         script = document.createElement('script');
         script.id =  'editDisplayOrder';
         script.type = 'text/javascript';
         script.src = "/updates/editDisplayOrder?section=course&content_id="+content_id+"&data="+objSortedJSON;
         head.appendChild(script);
       } catch(err) { alert("Error: " + err.message); }

     }




    if (section == "dictionary") {

      // Save Repositioning
      $.post("/updates/editDisplayOrder",{
        section: "dictionary",
        content_id: content_id,
        data: objSortedJSON
      },function(txt) {
       // alert(txt);
      });

     }


}


