
// ********************************************** //
// * Majestic - Content management for everyone * //
// * Copyright (c) 2008 Injader                 * //
// * More information at http://www.injader.com * //
// ********************************************** //

  url = document.location.href;
  xend = url.lastIndexOf("/") + 1;
  var base_url = url.substring(0, xend);
  var ajax_get_error = false;
  var js;

  function ajax_do(url, strAction, el_id) {
  	if (url.substring(0, 4) != 'http') {
  		url = base_url + url;
  	}
  	var js = document.createElement('SCRIPT');
  	js.type = 'text/javascript';
  	js.src = url;
  	document.body.appendChild (js);
    
    // IE event handler
    js.onreadystatechange = function () {
      if (js.readyState == 'complete') {
        strData = document.getElementById(el_id).innerHTML;
        PostAjaxEvent(strAction);
      }
    }

    // Firefox event handler
    js.onload = function () {
      strData = document.getElementById(el_id).innerHTML;
      PostAjaxEvent(strAction);
    }
    return false;
  }

  function ajax_get(url, strAction, el, path) {
  	if (typeof(el) == 'string') {
  		el = document.getElementById(el);
  	}
  	if (el == null) {
      window.alert("Null element");
      return false;
    }
  	if (url.substring(0, 4) != 'http') {
  		url = base_url + url;
  	}
  	strAjaxURL = path + 'getfile.php?url=' + escape(url) + '&el=' + escape(el.id);
  	//strAjaxURL = path + escape('getfile.php?url=') + escape(url) + escape('&el=') + escape(el.id);
  	ajax_do(strAjaxURL, strAction, el.id);
  	return true;
  }

