
   object = function () {}
   object.getById = function(id) {
          if (id && document.getElementById(id)) {
             return document.getElementById(id);
          } else if (id && parent.document.getElementById(id)) {
             return parent.document.getElementById(id);
          }
   }

   object.info = function () {}
   object.info.hv = function (id) {
          obj = object.getById(id);
          if (obj.className == 'infoA') {
             obj.className = 'infoH';
          }
          else {
             obj.className = 'infoA';
          }

   }

   object.editor = function (step, objectId, id, parentObjectId, parentRecordId, guid) {
          if (id) id="&id="+id; else id="";
          if (parentObjectId) parentObjectId="&parentObjectId="+parentObjectId; else parentObjectId="";
          if (parentRecordId) parentRecordId="&parentRecordId="+parentRecordId; else parentRecordId="";
          if (guid) guid="&guid="+guid; else guid="";
          object.editor.load("/cms/program/object/?cmsTemplate=a&step="+step+"&objectId="+objectId+""+parentObjectId+""+parentRecordId+""+id+""+guid);
   }

   object.right = function (step, objectId, id, parentObjectId, parentRecordId, guid) {
          if (id) id="&id="+id; else id="";
          if (parentObjectId) parentObjectId="&parentObjectId="+parentObjectId; else parentObjectId="";
          if (parentRecordId) parentRecordId="&parentRecordId="+parentRecordId; else parentRecordId="";
          if (guid) guid="&guid="+guid; else guid="";
          object.editor.load("/cms/program/access/right.php?cmsTemplate=a&step="+step+"&objectId="+objectId+""+parentObjectId+""+parentRecordId+""+id+""+guid);
   }

   object.action = function (step, objectId, objectActionId) {
          object.editor.load("/cms/program/object/?cmsTemplate=a&step="+step+"&objectId="+objectId+"&id="+objectActionId);
   }









   object.editor.mouse = function () {}
   object.body = function () {}
   object.body.parent = function () {}
   xmlHttp = function() {}


   var SelectedItem;
   var SelectedX, SelectedY;
   var MouseX, MouseY;





   object.editor.mouse.move = function(ClickedItem) {
          if (object.getById('editorWindow').className == 'editorWindowLit') {
             SelectedItem = object.getById('editorWindow');
             SelectedX = SelectedItem.style.pixelLeft;
             SelectedY = SelectedItem.style.pixelTop;
             MouseX = event.clientX;
             MouseY = event.clientY;
             SelectedItem.style.width = SelectedItem.offsetWidth;
             document.onmousemove = object.editor.mouse.drag;
             document.onmouseup = object.editor.mouse.drop;
          }
   }


   object.editor.mouse.drag = function() {
          object.getById('show').style.visibility = 'hidden';

//          object.getById('show').style.filter ="alpha(opacity=90);";


          SelectedItem.style.left = SelectedX + (event.clientX - MouseX);
          SelectedItem.style.top = SelectedY + (event.clientY - MouseY);
          return false;
   }

   object.editor.mouse.drop = function() {
          object.getById('show').style.visibility = 'visible';
          document.onmousemove = null;
          document.onmouseup = null;
   }




   object.editor.format = function(){
          if (object.getById('editorWindow').className == 'editorWindowLit') {
             object.editor.format.full();
          } else {
             object.editor.format.lit();
          }

   }


   object.editor.format.lit = function() {
          if (object.editor.top || object.editor.left) {
             object.getById('editorWindow').style.top = object.editor.top;
             object.getById('editorWindow').style.left = object.editor.left;
          } 

          object.getById('editorWindow').className='editorWindowLit';
   }


   object.editor.format.full = function() {
          object.editor.left = object.getById('editorWindow').style.left;
          object.editor.top = object.getById('editorWindow').style.top;


          object.getById('editorWindow').style.width = "100%";
          object.getById('editorWindow').style.top = parseInt(document.body.scrollTop);
          object.getById('editorWindow').style.left = 0;
          object.getById('editorWindow').className='editorWindowFull';



   }




   object.editor.load = function (url) {
          object.getById('show').src=url+'&r'+Math.random();
          document.body.scroll = "no";
          object.editor.format.lit();
          object.location = window.location;
          object.getById('editorWindow').style.top = parseInt(document.body.scrollTop)+100;
          object.getById('editorWindow').style.left = 0;



   }


   object.body.reload = function (url) {
          if (!url) url = object.location;
          if (url.indexOf('?')>=0) {
             char = '&';
          } else {
             char = '?';
          }
          location.replace(url+''+char+'r'+Math.random());

          /*
          object.req = new xmlHttp.create();
          object.req.onreadystatechange = object.body.reload.callback; 
          object.req.open("GET", url+''+char+'r'+Math.random(), true);
          object.req.send(null);
          document.body.scroll = "no";
          */


   }


   object.body.reload.callback = function() {
          if (object.req.readyState == 4) {
             if (object.req.status == 200) {
                document.body.scroll = "yes";
                document.body.innerHTML = object.req.responseText;
             }
          }
   }



   object.body.parent.reload = function (url) {
          if (!url) {
             url = parent.object.location;
             parent.location.replace(url);
          } else {
             location.replace(url);
          }


          /*
          parent.object.req = new xmlHttp.create();
          parent.object.req.onreadystatechange = parent.object.body.parent.reload.callback; 
          parent.object.req.open("GET", url, true);
          parent.object.req.send(null);
          parent.document.body.scroll = "no";
          */

   }

   object.body.parent.reload.callback = function() {
          if (parent.object.req.readyState == 4) {
             if (parent.object.req.status == 200) {



                parent.document.body.scroll = "yes";
                document.body.innerHTML = object.req.responseText;
             }
          }
   }



   object.editor.close = function (reload) {
          if (reload) {
             object.body.parent.reload();
          }
          
          document.body.scroll = "yes";
          parent.document.body.scroll = "yes";
          object.getById('show').src="";
          object.getById('editorWindow').style.top = -1000;
          object.getById('editorWindow').style.left = -1000;

   }



   object.editor.esc = function () {
          var code;
          var e = window.event;
          if (e.keyCode) code = e.keyCode;
          else if (e.which) code = e.which;
          if (code == '27') object.editor.close(); 
   }






   xmlHttp.create = function(){
     if (window.XMLHttpRequest) { 
        var oXmlHttp = new XMLHttpRequest();
        return oXmlHttp;
     } else {
        var aVersions = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XMLHttp", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
        for (var i = 0; i < aVersions.length; i++) {
            try {
                var oXmlHttp = new ActiveXObject(aVersions[i]);
                return oXmlHttp;
            } catch (oError) {
                //Do nothing
            }
        }
        throw new Error("MSXML is not installed.");
     }
   }





   




   function lea(cmd, name, randId) {
            if (cmd == "over") {
               name.className = 'editH';
               //randId.style.display = "";
            }
            else {
               name.className = 'edit';
              // randId.style.display = "none";
            }
   }


