  var cxLoginBox = xGetElementById("cxLoginBox");
  var cxLoginBoxFader = new cx_Fader(cxLoginBox, 15, 0, 0, 100);
  var cxLoginBoxVisible = false;
  var cxLoginReq = null;
  
  xAddEventListener(window, "resize", cxLoginBox_Window_OnResize, false);
  xAddEventListener(window, "scroll", cxLoginBox_Window_OnScroll, false);  

  function cxLogin_CheckLogin() {
    var u = escape(xGetElementById("cxUsername").value);
    var p = escape(xGetElementById("cxPassword").value);  
    cxLoginReq = null;
    cxLoginReq = new DataRequestor();
    cxLoginReq.addArg(_GET, "u", u);
    cxLoginReq.addArg(_GET, "p", p);
    cxLoginReq.addArg(_GET, "check", "1");
    var url = cxCMSGlobal.LoginURL;
    cxLoginReq.onLoad = function (data, obj) {
      (data=="1")?cxDoLogin():alert("Invalid Login. Please try again.");
    }
    cxLoginReq.onFail = function (status) {
      alert("Login failed due to error: " + status);
    }    
    cxLoginReq.getURL(url);
  }

  function cxDoLogin() {
    var u = xGetElementById("cxUsername");
    var p = xGetElementById("cxPassword");
    window.location = cxCMSGlobal.LoginURL+"?u="+u.value+"&p="+p.value+"&f="+escape(window.location);
  }
  function cxLoginBox_Toggle() {
    if(cxLoginBoxVisible) {
      cxLoginBoxFader.fadeOut();
    } else {
      cxLoginBoxFader.fadeIn();
    }
    cxLoginBoxVisible = !cxLoginBoxVisible;
    cxLoginBox_Window_OnResize();
  }
  function cxLoginBox_Window_OnResize(evt) {
    if(cxLoginBoxVisible) cx_CenterElement(cxLoginBox);
  }
  function cxLoginBox_Window_OnScroll(evt) {
    if(cxLoginBoxVisible) cx_CenterElement(cxLoginBox);  
  }
  function cx_CenterElement(ele) {
    var width = xWidth(ele);
    var height = xHeight(ele);
    var x = xClientWidth()/2-width/2+xScrollLeft();
    var y = xClientHeight()/2-height/2+xScrollTop();
    xMoveTo(ele,x,y);
  }