
function sendRequest(url, form, target, onCompletionFunction) {
  ajaxObj = new sack();
  if (form) {
    for (var i = 0; i < form.length; i++) {    // add form element in ajax var
      if (form[i].name != "") {
        if (form[i].type == "radio") {   // for radio buttons
            if (form[i].checked == true) {
              ajaxObj.setVar(form[i].name, form[i].value);
            }
        } else {
          ajaxObj.setVar(form[i].name, form[i].value);
        }
      }
    } 
  }
  ajaxObj.requestFile = url;
  ajaxObj.onCompletion = function () {
    if (onCompletionFunction != "") {
      this.onComletion = onCompletionFunction;
      this.onComletion();
    } 
    if (target != "") {
      document.getElementById(target).value = ajaxObj.response;
    }
    
  }
  ajaxObj.runAJAX();
}


function sendRequestFromAdmin(url, form, target, onCompletionFunction) {
  ajaxObj = new sack();
  if (form) {
    for (var i = 0; i < form.length; i++) {    // add form element in ajax var
      if (form[i].name != "") {
        if (form[i].type == "radio") {   // for radio buttons
            if (form[i].checked == true) {
//              alert(form[i].name);
              ajaxObj.setVar(form[i].name, form[i].value);
            }
        } else if (form[i].type == "checkbox") {
          if (form[i].checked == true) {
              ajaxObj.setVar(form[i].name, form[i].value);
            }
        } else {
          if (form[i].name == "txt_content") {
                ajaxObj.setVar(form[i].name, FCKeditorAPI.GetInstance('txt_content').GetXHTML());  
              } else {
                ajaxObj.setVar(form[i].name, form[i].value);  
              }
          
        }
      }
    } 
  }
  ajaxObj.requestFile = url;
  ajaxObj.onCompletion = function () {
    if (onCompletionFunction != "") {
      this.onCompletion = onCompletionFunction;
      this.onCompletion();
    } 
    if (target != "") {
      document.getElementById(target).innerHTML = ajaxObj.response;
    }
    
  }
  ajaxObj.runAJAX();
}
