$import = function(path,className)
{
  try {
    if(className){
      var script = document.createElement("script");
      script.id = "ScriptOf" + className;
      script.type = "text/javascript";
      script.src = path+className+".js";
      document.getElementsByTagName("head")[0].appendChild(script);
    }
  } catch(e) {
    alert("function error [$import]:"+e);
  }
}

$plugin = function(path,className)
{
  try {
    if(className){
      document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + path+className+".js" + '" id="ScriptOf'+className+'"></script>');
    }
  } catch(e) {
    alert("function error [$import]:"+e);
  }
}

/*
 * Editorを読み込んで実行する関数
 */
$include = function(path,name)
{
  $import(path,name);
  $executeOnLoad(name);
};
$executeOnLoad = function(name)
{
  if(JS.isFunction("cmsOnLoad"+name)){
    JS.setTimer("cmsOnLoad"+name+"()",1);
  }else{
    JS.setTimer("$executeOnLoad('"+name+"')",100);
  }
};


var JS = new Object();
JS._timer = new Array();
JS.clearTimer = function(target)
{
  if(JS._timer[target]){
     clearTimeout(JS._timer[target]);
  }
};

JS.setTimer = function(target,time)
{
  JS._timer[target] = setTimeout(target,time);
};

JS.isFunction = function(functionName)
{
  try{
    return (typeof(eval(functionName)) == 'function');
  }catch(e){
    return false;
  }
};

JS.isObject = function(object)
{
  try{
    if(typeof(object) == 'object'){
      return true;
    }else{
      return false;
    }
  }catch(e){
    return false;
  }
};

JS.isDefined = function(param)
{
  try{
    if(typeof(eval(param)) != 'undefined'){
      return true;
    }else{
      return false;
    }
  }catch(e){
    return false;
  }
};

JS.baseURL = "";
var elements = document.getElementsByTagName('script');
for (var i=0; i<elements.length; i++) {
  if (elements[i].src && (elements[i].src.indexOf("cms.js") != -1)){
     var src = elements[i].src;
     JS.baseURL = src.substring(0, src.lastIndexOf('/'));
  }
}
if(JS.baseURL == "") JS.baseURL = ".";
JS.imageURL = JS.baseURL + "/cms/img/";
JS.appURL = JS.baseURL + "/cms/app/";
JS.scriptURL = JS.baseURL + "/cms/js/";
JS.scriptLibURL = JS.scriptURL + "lib/";
JS.scriptEtcURL = JS.scriptURL + "etc/";

var request = null;
function cmsImport() {
  try {
    //Lib
    $import(JS.scriptLibURL,'prototype-1.4.0');
    $import(JS.scriptLibURL,'rico');
    $import(JS.scriptLibURL,'des');
    $import(JS.scriptLibURL,'request');

    $import(JS.scriptEtcURL,'draglayer');
    $import(JS.scriptEtcURL,'effect');
    $import(JS.scriptEtcURL,'mouse');
    $import(JS.scriptEtcURL,'dreamweaver');

    $include(JS.scriptURL,'Login');
    $include(JS.scriptURL,'EditorLoader');

  } catch(e) {
    alert("function error [window.onload]:"+e);
  }
};

/* Ajax Sample
  new Ajax.Request('calendar_stop.php', 
        {
          method:'get',
          parameters: 'reserve_flag=' + flag,
          onSuccess:  function(transport) {
              alert(transport.responseText);
          }
        });


  new Ajax.Request('calendar_staff_schedule.php', 
        {
          method:'post',
          asynchronous: true,
          parameters: Form.serialize(form),
          onSuccess:  function(transport) {
            staff_schedule_update = true;
            Element.update('staff_schedule_form',transport.responseText);
          }
        });
*/