//MAIN ajax xmlthttprequest functiom
function run_ajaxresponse(url, obj) {
  dojo.io.bind({
    url: url,
    mimetype: "text/xml",
    load: function(type, xml, e) {
      // add the HTML to obj
      var html = xml.getElementsByTagName("html").item(0);
      if (document.getElementById(obj) != null) document.getElementById(obj).innerHTML = html.firstChild.nodeValue;

      // run the script
      var script = xml.getElementsByTagName("script").item(0);
      if (script.firstChild.nodeValue != null) dj_eval(script.firstChild.nodeValue);
    }
  });
}

// MAIN lists functions
function reload_list_content(class_name) {
  //reload the content list
  var paginator_position = document.getElementById('paginator_position').value; if (paginator_position == null) paginator_position='0';
  var cID = document.getElementById('cID').value; if (cID == null) cID='null';
  run_ajaxresponse('ajaxresponse.php?action='+class_name+'_list&class_name='+class_name+'&paginator_position='+paginator_position+'&cID='+cID, 'list_content');
}
function set_active_element() { //set the active element
  if (document.getElementById('s_replaced_className') != null)
    document.getElementById('replaced_className').value=document.getElementById('s_replaced_className').value;
  if (document.getElementById('list_el_'.concat(document.getElementById('cID').value)) != null)
    document.getElementById('list_el_'.concat(document.getElementById('cID').value)).className='list_1s';
}

//popup
function win_popup_wh(page, params, width, height) {
  popupWindow_wh=window.open(page + params,'popupWindow_wh','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+width+', height='+height+', screenX=150, screenY=150, top=150, left=150', false);
}

//countdown function
function reload_page_countdown(actions, timer) {
	if (timer == 0) {
      eval(actions);
	} else {
	  timer = timer-1000;
	  if (document.getElementById('reload_page_countdown_timer') != null)
		  document.getElementById('reload_page_countdown_timer').innerHTML = (timer/1000);
	  setTimeout("reload_page_countdown(\""+actions+"\", "+timer+")", timer);
	}
}

