// Start JSIncludeFile:Action_JS
var fGlobalPointer, fBaseTarget, fTabs, fTree, fDynList, fIsPopUp, fPopUpWindow;
function QueryValue(aName, aValue) {
  this.Name  = unescape(aName.toUpperCase());
  this.Value = unescape(aValue);
}
function GetQueryVars() {
  var zQueryString = document.location.search.substring(1, document.location.search.length);
  var zParamPairs = zQueryString.split('&');
  var zSplitPair = [];
  for (var zI=0; zI<zParamPairs.length; zI++) {
    zSplitPair = zParamPairs[zI].split('=');
    if (zSplitPair.length == 2) {
      fQueryValues[fQueryValues.length] = new QueryValue(zSplitPair[0], zSplitPair[1]);
    }
  };
  fQueriesLoaded = true;
}
function GetQueryValue(aParameterName) {
  if (!fQueriesLoaded) {
    GetQueryVars();
  };
  for (var zI=0; zI<fQueryValues.length; zI++) {
    if (fQueryValues[zI].Name == aParameterName) {
      return fQueryValues[zI].Value
    };
  }
  return '';
}
var fQueryValues = [];
var fQueriesLoaded = false;
function CookieValue(aName, aValue) {
  this.Name  = unescape(aName.toUpperCase());
  this.Value = unescape(aValue);
}
function GetCookieVars() {
  var zCookieString = document.cookie;
  var zParamPairs = zCookieString.split('; ');
  var zSplitPair = [];
  for (var zI=0; zI<zParamPairs.length; zI++) {
    zSplitPair = zParamPairs[zI].split('=');
    if (zSplitPair.length == 2) {
      fCookieValues[fCookieValues.length] = new CookieValue(zSplitPair[0], zSplitPair[1])
    }
  };
  fCookiesLoaded = true;
}
function GetCookieValue(aParameterName) {
  if (!fCookiesLoaded) {
    GetCookieVars();
  };
  for (var zI=0; zI<fCookieValues.length; zI++) {
    if (fCookieValues[zI].Name == aParameterName) {
      return fCookieValues[zI].Value
    };
  }
  return '';
}
var fCookieValues = [];
var fCookiesLoaded = false;
function SetHiddenInput(aSource, aVariableName, aInputName) {
  var zValue = '';
  aSource = aSource.toLowerCase();
  if (aSource == 'cookie'){
    zValue = GetCookieValue(aVariableName)
  } else if (aSource == 'url'){
    zValue = GetQueryValue(aVariableName)
  };
  if (zValue != '') {
    document.write('<input type="hidden" name="'+aInputName+'" id="'+aInputName+'" value="'+zValue+'" />');
  }
}
function setURLVariable(aVarName,aValue,aURL,aBeforeNoLiveCache) {
  var zNewString = aVarName + '=' + aValue;
  var zVarsBeforeNoLiveCache = new Array();
  var zVarsAfterNoLiveCache = new Array();
  var zNoLiveCacheFound = false;
  var x,zSplitPair,zNewURL;
  aBeforeNoLiveCache = (aBeforeNoLiveCache===true||aBeforeNoLiveCache=='Y' ? true:(aBeforeNoLiveCache=='N'||aBeforeNoLiveCache===false) ? false:true);
  aURL = ((!aURL||aURL=='') ? document.location.href:aURL);
  var zURLParts = aURL.split('?');
  if(zURLParts.length>1){
    var zParamPairs = zURLParts[1].split('&');
    for (x=0; x<zParamPairs.length; x++) {
      zSplitPair = zParamPairs[x].split('=');
      if(zSplitPair[0].toLowerCase()=='_nolivecache'){
        zNoLiveCacheFound = true;
      }
      if(zSplitPair[0].toLowerCase()!=aVarName.toLowerCase()&&zSplitPair[0].toLowerCase()!='_nolivecache'){
        if(!zNoLiveCacheFound){
          zVarsBeforeNoLiveCache[zVarsBeforeNoLiveCache.length] = zSplitPair[0] + '=' + (zSplitPair[1] ? zSplitPair[1]:'');
        }else{
          zVarsAfterNoLiveCache[zVarsAfterNoLiveCache.length] = zSplitPair[0] + '=' + (zSplitPair[1] ? zSplitPair[1]:'');
        }
      }
    }
  }
  if(aBeforeNoLiveCache){
    zVarsBeforeNoLiveCache[zVarsBeforeNoLiveCache.length] = zNewString;
  }else{
    zVarsAfterNoLiveCache[zVarsAfterNoLiveCache.length] = zNewString;
  }
  zNewURL = zURLParts[0] + '?' + zVarsBeforeNoLiveCache.join('&') + (zVarsAfterNoLiveCache.length>0 ? (zVarsBeforeNoLiveCache.length>0 ? '&':'') + '_nolivecache=Y&' + zVarsAfterNoLiveCache.join('&'):'')
  return zNewURL;
}
function lsSetUserGroup() {
}
var Track = {
  BaseURL: "",
  LastPage: "",
  ClientId: "Live-voig",
  ScreenRes: window.screen.width+'x'+window.screen.height,
  send: function(aPage,aCount,aValue,aCost,aRevenue,aValue) {
    var zI = new Image();
    zI.src = Track.BaseURL
           + '\/l.a\/cnt\/'+Math.random()+Math.random()
           + '?cid='+Track.ClientId
           + '&u='+aPage
           + '&ru='+Track.LastPage
           + '&bt='
           + '&bv='
           + '&sr='+Track.ScreenRes
           + '&cnt='+(aCount?aCount:'')
           + '&val='+(aValue?aValue:'')
           + '&cst='+(aCost?aCost:'')
           + '&rev='+(aRevenue?aRevenue:'')
           + '&val='+(aValue?aValue:'')
           + '0=0';
    Track.LastPage = aPage;
    return true;
  }
}
var _trackArray = [];
function _track(aPath,aAction,aExtraParams) {_trackArray.push(AppendToUrl(((aPath) ? aPath : '/') + '.' + ((aAction) ? aAction : 'track') + '?u=' + UniqueVar(),aExtraParams));}
var _ls='*';
function _la(aParamObject) {
  if (typeof(aParamObject)!='undefined') {
    appendEventHandler(window, "onload", _laLoad, aParamObject);
  }
}
function _laRun() {
  return true;
}
function lsTAdd(s) {_ls+='*t*'+s}
function lsPAdd(s) {_ls+='*p*'+s}
function lsBAdd(s) {_ls+='*b*'+s}
function _laLoad(e,aParamObject) {
    _track(aParamObject.Track[0],aParamObject.Track[1],aParamObject.Track[2]);
    var zImage;
    _trackArray.forEach(function (aURL){zImage = new Image().src = aURL});
  return true;
}
// End JSIncludeFile:Action_JS
// Start JSIncludeFile:Action_JSIncludeArrayMethods
Array.prototype.append = function () {
  var i;
  for (i=0; i < arguments.length; i++) {
    this[this.length] = arguments[i];
  }
}
Array.prototype.copy = function ()  {
  return this.concat();
}
Array.prototype.contains = function (vItem )  {
  return this.indexOf(vItem)>-1;
}
if(!Array.every){
  Array.prototype.every = function (fnTest , oThis ) {
    if (this.length > 0) {
      var i,l,bResult = true;
      var zProperty = '__everyFunc__'+ UniqueVar();
      oThis = oThis || window;
      oThis[zProperty] = fnTest;
      for (i=0, l=this.length; i < l && bResult; i++) {
        bResult = bResult && oThis[zProperty](this[i], i, this);
      }
      oThis[zProperty] = null;
      return bResult;
    } else {
      return true; 
    }
  }
}
if(!Array.filter){
  Array.prototype.filter= function (fnTest , oThis ) {
    var i,l,aResult  = new Array();
    var zProperty = '__filterFunc__'+ UniqueVar();
    oThis = oThis || window;
    oThis[zProperty] = fnTest;
    for (i=0, l=this.length; i < l; i++) {
      if (oThis[zProperty](this[i], i, this)) {
        aResult.push(this[i]);
      }
    }
    oThis[zProperty] = null;
    return aResult;
  }
}
if(!Array.forEach){
  Array.prototype.forEach = function (fnExec , oThis ) {
    var i,l;
    var zProperty = '__forEachFunc__'+ UniqueVar();
    oThis = oThis || window;
    oThis[zProperty] = fnExec;
    for (i=0, l=this.length; i < l; i++) {
      oThis[zProperty](this[i], i, this);
    }
    oThis[zProperty] = null;
  }
}
if(!Array.indexOf){
  Array.prototype.indexOf = function (vItem , iStart ) {
    var i,l;
    if (iStart == null) {
      iStart = 0;
    }
    for (i=iStart, l=this.length; i < l; i++) {
      if (this[i] == vItem) {
        return i;
      }
    }
    return -1;
  }
}
if(!Array.insertAt){
  Array.prototype.insertAt = function (vItem , iIndex )  {
    this.splice(iIndex, 0, vItem);
  }
}
if(!Array.insertBefore){
  Array.prototype.insertBefore = function (vItem , vBeforeItem )  {
    this.insertAt(vItem, this.indexOf(vBeforeItem));
  }
}
if(!Array.lastIndexOf){
  Array.prototype.lastIndexOf = function (vItem , iStart ) {
    var i;
    if (iStart == null || iStart >= this.length) {
      iStart = this.length-1;
    }
    for (i=iStart; i >= 0; i--) {
      if (this[i] == vItem) {
        return i;
      }
    }
    return -1;
  }
}
if(!Array.map){
  Array.prototype.map = function (fnExec , oThis ) {
    var i,l,aResult  = new Array();
    var zProperty = '__mapFunc__'+ UniqueVar();
    oThis = oThis || window;
    oThis[zProperty] = fnExec;
    for (i=0, l=this.length; i < l; i++) {
      aResult.push(oThis[zProperty](this[i], i, this));
    }
    oThis[zProperty] = null;
    return aResult;
  }
}
if(!Array.pop){
  Array.prototype.pop = function () {
    var oItem  = null;
    if (this.length > 0) {
      oItem = this[this.length-1];
      this.length--;
    }
    return oItem;
  }
}
if(!Array.push){
  Array.prototype.push = Array.prototype.append;
}
if(!Array.remove){
  Array.prototype.remove = function (vItem )  {
    this.removeAt(this.indexOf(vItem));
    return vItem;
  }
}
if(!Array.removeAt){
  Array.prototype.removeAt = function (iIndex )  {
    var vItem = this[iIndex];
    if (vItem) {
      this.splice(iIndex, 1);
    }
    return vItem;
  }
}
if(!Array.slice){
  Array.prototype.slice = function (iStart , iStop ) {
    var i,aResult  = new Array();
    iStop = iStop || this.length;
    for (i=iStart; i < iStop; i++) {
      aResult.push(this[i]);
    }
    return aResult;
  }
}
if(!Array.shift){
  Array.prototype.shift = function () {
    var vItem = this[0];
    if (vItem) {
      this.splice(0,1);
    }
    return vItem;
  }
}
if(!Array.some){
  Array.prototype.some= function (fnTest , oThis ) {
    var i,l;
    var zProperty = '__someFunc__'+ UniqueVar();
    oThis = oThis || window;
    oThis[zProperty] = fnTest;
    for (i=0, l=this.length; i < l; i++) {
      if (oThis[zProperty](this[i], i, this)) {
       return true;
      }
    }
    oThis[zProperty] = null;
    return false;
  }
}
if(!Array.splice){
  Array.prototype.splice = function (iIndex , iLength ) {
    var i,aResult  = new Array();
    var aRemoved  = new Array();
    for (i=0; i < iIndex; i++){
      aResult.push(this[i]);
    }
    for (i=iIndex; i < iIndex+iLength; i++) {
     aRemoved.push(this[i]);
    }
    if (arguments.length > 2) {
      for (i=2; i < arguments.length; i++) {
        aResult.push(arguments[i]);
      }
    }
    for (i=iIndex+iLength; i < this.length; i++) {
      aResult.push(this[i]);
    }
    for (i=0; i < aResult.length; i++) {
      this[i] = aResult[i];
    }
    this.length = aResult.length;
    return aRemoved;
  }
}
if(!Array.sum){
  Array.prototype.sum = function (fnConvert , oThis ) {
    if (this.length > 0) {
      var i,l,vResult = null;
      var zProperty = '__sumFunc__'+ UniqueVar();
      oThis = oThis || window;
      oThis[zProperty] = fnConvert || function (vVal) { return vVal; }
      vResult = oThis[zProperty](this[0], 0, this);
      for (i=1, l=this.length; i < l; i++) {
        vResult += oThis[zProperty](this[i], i, this);
      }
      oThis[zProperty] = null;
      return vResult;
    } else {
      return null;
    }
  }
}
if(!Array.unshift){
  Array.prototype.unshift = function () {
    var i,l,sExec = "this.splice(";
    var aArgs = new Array();
    for (i=0,l=arguments.length; i < l; i++) {
      aArgs.push("arguments["+i+"]");
    }
    eval("this.splice(0,0," + aArgs.join(",") + ")");
  }
}
if(!Array.moveBefore){
  Array.prototype.moveBefore = function(aItem,aBeforeItem){
    this.remove(aItem);
    this.insertBefore(aItem,aBeforeItem);
  }
}
if(!Array.insertAfter){
  Array.prototype.insertAfter = function (aItem , aAfterItem )  {
    this.insertAt(aItem, this.indexOf(aAfterItem)+1);
  }
}
if(!Array.moveAfter){
  Array.prototype.moveAfter = function(aItem,aAfterItem){
    this.remove(aItem);
    this.insertAfter(aItem,aAfterItem);
  }
}
Array.prototype.fastFindFirst = function(fnTest, oThis) {
  var zProperty = '__FastFindFirstFunc__'+ UniqueVar();
  oThis = oThis || window;
  oThis[zProperty] = fnTest;
  var zIdx, zMatch;
  var zFirstIndex = 0;
  var zLastIndex     = this.length - 1;
  var zFound = false;
  while (zFirstIndex <= zLastIndex) {
    zIdx = (zFirstIndex + zLastIndex) >> 1;
    zMatch = oThis[zProperty](this[zIdx],zIdx,this);
    if (zMatch < 0) {
      zFirstIndex = zIdx + 1;
    }  else {
      zLastIndex = zIdx - 1;
      if (zMatch == 0) {
        zFound = true;
      }
    }
  }
  oThis[zProperty] = null;
  if (zFound) {
    return zFirstIndex;
  }else{
    return -1;
  }
}
Array.prototype.fastFilter = function(fnTest, oThis) {
  var zProperty = '__FastFilterFunc__'+ UniqueVar();
  oThis = oThis || window;
  oThis[zProperty] = fnTest;
  var zIdx;
  var zLastIndex;
  var zMaxIdx     = this.length - 1;
  var zResultArray = new Array();
  var zFirstIndex = this.fastFindFirst(fnTest, oThis);
  if (zFirstIndex>-1) {
    zLastIndex = zFirstIndex;
    while ((zLastIndex < zMaxIdx) && (oThis[zProperty](this[zLastIndex+1], zLastIndex+1,this) == 0)) {
      zLastIndex++;
    }
    for (zIdx = zFirstIndex; zIdx <= zLastIndex; zIdx++) {
      zResultArray.push(this[zIdx]);
    }
  }
  oThis[zProperty] = null;
  return zResultArray;
}
Array.prototype.set = function(aItem,aKey){
  if(typeof aKey == 'undefined'){
    this.push(aItem);
  }else{
    aKey = aKey.toString();
    if(!this._List){
      this._List = {};
      this._Indexes = {};
    }
    if(this._List[aKey]){
      var zOldItem = this._List[aKey];
      this._List[aKey] = aItem;
      if(this[this._Indexes[aKey]] == zOldItem){
        this[this._Indexes[aKey]] = aItem;
      }else{
        var zIndex = this.indexOf(zOldItem);
        this[zIndex] = aItem;
        this._Indexes[aKey] = zIndex;
      }
    }else{
      this._Indexes[aKey] = this.length;
      this.push(aItem);
      this._List[aKey] = aItem;
    }
  }
}
Array.prototype.get = function(aValue,aField){
  if(typeof aField == 'undefined'){
    return (this._List ? this._List[aValue]:null);
  }else{
    return this.filter(function(aItem){
      return (aItem[aField] == aValue);
    });
  }
}
Array.prototype.makeUnique = function(aField){
  var zResult = [];
  this.forEach(function(aItem){
    zResult.set(aItem,aItem[aField]);
  });
  return zResult;
}
Array.prototype.first = function(){
  return this[0];
}
Array.prototype.last = function(){
  return this[this.length-1];
}
Array.Copy = function(aArray){
  var i,zResult = [];
  for(i=0;i<aArray.length;i++){
    zResult.push(aArray[i]);
  }
  return zResult;
}
// End JSIncludeFile:Action_JSIncludeArrayMethods
// Start JSIncludeFile:Action_JSIncludeGlobalPointer
function GlobalPointerHolder(aFrame) {
  this.Frame = aFrame;
  this.Document = aFrame.document;
  this.LSAccessID           = '';
  this.LSAccountID          = '';
  this.MainKBObject         = '';
  this.CurrentKBObject      = '';
  this.DynamicTree          = null;
  this.TabFrameHolder       = null;
  this.ContentFrame         = '';
  this.PopUpWindow          = '';
  this.PopUpDisplayElement  = '';
  this.PopUpInputElement    = '';
  this.DisplayElement       = '';
  this.InputElement         = '';
  this.KBItemPath           = '';
  this.KBStartPath          = '';
  this.OpenToPath           = '';
  this.CreationLocation     = Math.random()+'_'+location.href;
  this.LogoutDelay          = null;
  this.Browser = new BrowserDetect();
  this.Setup();
  var self = this;
  GlobalPointerHolder.InitFunctions.forEach(function(aInitFunction){
    if(typeof(aInitFunction) == "function") {
      aInitFunction(self);
    }
    else {
      self[aInitFunction]();
    }
  });
}
GlobalPointerHolder.InitFunctions = [];
GlobalPointerHolder.prototype.SelectItem = function(aURL,aIsPopUp,aKBItemPath,aKBItemName) {
  if(aIsPopUp) {
    this.PopUpInputElement.value = aKBItemPath;
    this.PopUpDisplayElement.value = aKBItemName;
  } else {
    this.ContentFrame.document.location.href = aURL;
  }
}
GlobalPointerHolder.prototype.SelectPopUpItem = function(aKBItemPath,aKBItemName) {
  this.PopUpInputElement.value = aKBItemPath;
  this.PopUpDisplayElement.value = aKBItemName;
}
GlobalPointerHolder.prototype.SetForm = function() {
  this.InputElement.value = this.PopUpInputElement.value;
  this.DisplayElement.value = this.PopUpDisplayElement.value;
  if(this.DisplayElement_2) {
    this.DisplayElement_2.value = this.PopUpDisplayElement.value;
  }
  if(this.DisplayElement.getAttribute('onchangefunction')!='' && this.PopUpWindow.opener[this.DisplayElement.getAttribute('onchangefunction')]) {
    this.PopUpWindow.opener[this.DisplayElement.getAttribute('onchangefunction')]();
  }
  this.PopUpWindow.close();
}
GlobalPointerHolder.prototype.CancelPopUp = function() {
  this.PopUpWindow.close();
}
GlobalPointerHolder.prototype.Setup = function() {
  this.LSAccessID = GetQueryValue('LSACCESSID');
  if(this.LSAccessID == '') {
    this.LSAccessID  = GetQueryValue('ALSACCESSID');
  }
  this.LSAccountID = GetQueryValue('LSACCOUNTID');
  if(this.LSAccountID == '') {
    this.LSAccountID = GetQueryValue('ALSACCOUNTID');
  }
}
GlobalPointerHolder.prototype.AutoLogout = function(aLogoutDelay, aMessage) {
  if(this.LogoutDelay) {
    window.clearTimeout(this.LogoutDelay);
  }
  this.LogoutDelay = window.setTimeout("Logout('"+aMessage+"')", aLogoutDelay);
}
function HistoryItem(aURL, aTitle) {
 this.URL = aURL;
 this.Title = aTitle;
}
GlobalPointerHolder.prototype.AddToHistoryTrail = function(aURL,aName) {
 if(!this.HistoryArray){
   this.HistoryArray = new Array();
 }
 for (var y=0;y<this.HistoryArray.length;y++){
   if (this.HistoryArray[y].URL == aURL) {
     this.HistoryArray.length = y;
   }
 }
 this.HistoryArray[this.HistoryArray.length] = new HistoryItem(aURL,aName);
}
GlobalPointerHolder.prototype.DisplayHistoryTrail = function() {
 if(this.HistoryArray){
   var zArray = this.HistoryArray;
   var zDisplayElement = this.HistoryDisplayElement;
   if (zDisplayElement == null) {return}
   var zOutputArray = new Array();
      for (var x=0;x<zArray.length;x++){
     zOutputArray[zOutputArray.length] = '<a h'+'ref="'+zArray[x].URL+'" class="HistoryItem">'+unescape(zArray[x].Title)+'<\/a>';
   }
   zDisplayElement.innerHTML = zOutputArray.join(' > ');
 }
}
GlobalPointerHolder.prototype.ClearHistoryTrail = function() {
 if (this.HistoryArray)
   this.HistoryArray.length = 0;
}
GlobalPointerHolder.prototype.TrimHistoryTrail = function() {
 this.HistoryArray.length = (this.HistoryArray.length-1);
}
function Logout(aMessage) {
  if(GetCookieValue('TLOSID') != '') {
   var zFrame = fGlobalPointer.Frame;
   VarDef(zFrame, top);
   ClearOnBeforeUnload(zFrame);
   if (fGlobalPointer.AutoSave) {
     fGlobalPointer.AutoSave();
   }
   zFrame.location='/home.logoutcomplete?aLoginMessage=' + aMessage;
  }
}
function ClearOnBeforeUnload(aFrame) {
  try {
    aFrame.onbeforeunload = null;
    if (aFrame.frames) {
      for (var zI = 0; zI < aFrame.frames.length; zI++) {
        ClearOnBeforeUnload(aFrame.frames[zI]);
      }
    }
  } catch(e) {}
  return true;
}
function SetGlobalPointer() {
  var fFrame = self;
  function LoopUpFrames() {
    var zTempFrame, zTempLocation;
    while (fFrame != fFrame.top) {
      try {
        if(fFrame.parent.fGlobalPointer){
          fFrame = fFrame.parent;
          return false;
        }
        zTempLocation = fFrame.parent.location.href;
        fFrame = fFrame.parent;
      } catch(e) {
        return false;
      }
    }
    return true;
  }
  var zKeepSearching = LoopUpFrames();
  if (zKeepSearching && fFrame.opener) {
    try {
      if(fFrame.opener.fGlobalPointer){
        fFrame = fFrame.opener;
      }
      zTempLocation = fFrame.opener.location.href;
      fFrame = fFrame.opener;
      LoopUpFrames();
    } catch(e) {}
  }
  if (!fFrame.fGlobalPointer) {
    fFrame.fGlobalPointer = new GlobalPointerHolder(fFrame);
  }
  fGlobalPointer = fFrame.fGlobalPointer;
}
// Browser Detect  v2.1.6
// documentation: http://www.dithered.com/javascript/browser_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)
function BrowserDetect() {
  var ua = navigator.userAgent.toLowerCase();
  this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
  this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);
  this.isKonqueror   = (ua.indexOf('konqueror') != -1);
  this.isSafari      = (ua.indexOf('safari') != - 1);
  this.isOldSafari      = (this.isSafari && !window.XMLHttpRequest);
  this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
  this.isOpera       = (ua.indexOf('opera') != -1);
  this.isIcab        = (ua.indexOf('icab') != -1);
  this.isAol         = (ua.indexOf('aol') != -1);
  this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) );
  this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
  this.isFirebird    = (ua.indexOf('firebird/') != -1);
  this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
  this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
  this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
  this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
  this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
  this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
  this.versionMinor = parseFloat(navigator.appVersion);
  if (this.isGecko && !this.isMozilla) {
    this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
  } else if (this.isMozilla) {
    this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
  } else if (this.isIE && this.versionMinor >= 4) {
    this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
  } else if (this.isKonqueror) {
    this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
  } else if (this.isSafari) {
    this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
  } else if (this.isOmniweb) {
    this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
  } else if (this.isOpera) {
    this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
  } else if (this.isIcab) {
    this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
  }
  this.versionMajor = parseInt(this.versionMinor);
  this.isDOM1 = (document.getElementById);
  this.isDOM2Event = (document.addEventListener && document.removeEventListener);
  this.mode = document.compatMode ? document.compatMode : 'BackCompat';
  this.isWin    = (ua.indexOf('win') != -1);
  this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
  this.isMac    = (ua.indexOf('mac') != -1);
  this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
  this.isLinux  = (ua.indexOf('linux') != -1);
  this.isNS4x = (this.isNS && this.versionMajor == 4);
  this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
  this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
  this.isNS4up = (this.isNS && this.versionMinor >= 4);
  this.isNS6x = (this.isNS && this.versionMajor == 6);
  this.isNS6up = (this.isNS && this.versionMajor >= 6);
  this.isNS7x = (this.isNS && this.versionMajor == 7);
  this.isNS7up = (this.isNS && this.versionMajor >= 7);
  this.isIE4x = (this.isIE && this.versionMajor == 4);
  this.isIE4up = (this.isIE && this.versionMajor >= 4);
  this.isIE5x = (this.isIE && this.versionMajor == 5);
  this.isIE55 = (this.isIE && this.versionMinor == 5.5);
  this.isIE5up = (this.isIE && this.versionMajor >= 5);
  this.isIE6x = (this.isIE && this.versionMajor == 6);
  this.isIE6up = (this.isIE && this.versionMajor >= 6);
  this.isIE7x = (this.isIE && this.versionMajor == 7);
  this.isIE7up = (this.isIE && this.versionMajor >= 7);
  this.isIE4xMac = (this.isIE4x && this.isMac);
  function GetFlashVersion() {
    var x,y,i;
    if (navigator.plugins && navigator.plugins.length) {
      x = navigator.plugins["Shockwave Flash"];
      if (x) {
        if (x.description) {
          y = x.description;
          return  y.charAt(y.indexOf('.')-1);
        }
      } else {
        return -1;
      }
      if (navigator.plugins["Shockwave Flash 2.0"]) {
        return 2;
      }
    } else if (navigator.mimeTypes && navigator.mimeTypes.length) {
      x = navigator.mimeTypes["application/x-shockwave-flash"];
      if (x && x.enabledPlugin){
        return 1;
      } else {
        return -1;
      }
    } else {
      for (i=9; i>0; i--){
       try{
          new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
          return i;
        } catch(e){
        }
      }
    }
    return -1;
  }
  this.flashVersion = GetFlashVersion();
  this.hasFlash = (this.flashVersion>0);
}
SetGlobalPointer();
// End JSIncludeFile:Action_JSIncludeGlobalPointer
// Start JSIncludeFile:Action_JSIncludeAttachmentContainer
function Attachment(aDisplayName, aType, aURL, aIdentifier, aStatus) {
  this.IndexIdentifier  = aIdentifier;
  this.Identifier       = aIdentifier;
  this.DisplayName      = unescape(aDisplayName);
  this.Type             = aType;
  this.UpperType        = aType.toUpperCase();
  this.URL              = unescape(aURL);
  this.Status           = aStatus.toUpperCase();
}
function AttachmentContainer(aName) {
  this.Name = aName;
  this.AttachmentList = [];
}
AttachmentContainer.prototype.Add = function(aDisplayName, aType, aURL, aIdentifier, aStatus, aNoReDraw) {
  var zAttach = this.Find(aIdentifier);
  if(zAttach != null) {
    zAttach.DisplayName = unescape(aDisplayName);
    zAttach.Type        = aType;
    zAttach.UpperType   = aType.toUpperCase();
    zAttach.URL         = unescape(aURL);
    zAttach.Status      = aStatus.toUpperCase();
    return;
  } else {
    this.AttachmentList[this.AttachmentList.length] = new Attachment(aDisplayName, aType, aURL, aIdentifier, aStatus);
  }
  if(!aNoReDraw || aNoReDraw != 'Y') {
    this.Redraw(aType);
  }
}
AttachmentContainer.prototype.Remove = function(aIdentifier) {
  var zAttach = this.Find(aIdentifier);
  if(zAttach == null) { return; }
  if(zAttach.Status == 'NEW') {
    zAttach.IndexIdentifier = '';
    zAttach.Status = 'VOID';
  } else if(zAttach.Status == 'EXISTING') {
    if(confirm('Are you sure you want to delete the '+zAttach.Type+' '+zAttach.DisplayName+'?')) {
      zAttach.Status = 'DELETE';
    } else {
      return;
    }
  }
  this.Redraw(zAttach.Type);
}
AttachmentContainer.prototype.Find = function(aIdentifier) {
  if(aIdentifier == '') { return null; }
  for(var zI=0; zI<this.AttachmentList.length; zI++) {
    if(this.AttachmentList[zI].IndexIdentifier == aIdentifier) {
      return this.AttachmentList[zI];
    }
  }
  return null;
}
AttachmentContainer.prototype.Draw = function() {
  this.Redraw('File');
  this.Redraw('Image');
  this.Redraw('Link');
}
AttachmentContainer.prototype.Redraw = function(aType) {
  var zUpperType         = aType.toUpperCase();
  var zInputStr          = '';
  var zInputRemoveStr    = '';
  var zInputURLStr       = '';
  var zInputRemoveURLStr = '';
  var zInnerHtmlStr      = '';
  var zElement;
  for(var zI=0; zI<this.AttachmentList.length; zI++) {
    if(this.AttachmentList[zI].UpperType == zUpperType) {
      var zAttach =  this.AttachmentList[zI];
      if(zAttach.Status == 'NEW') {
        zInputStr     += ','+zAttach.Identifier;
        zInputURLStr  += ','+zAttach.URL;
        zInnerHtmlStr += '<span class="Remove RemoveFileLink" onClick="'+this.Name+'.Remove(\''+zAttach.Identifier+'\')">x</span>&nbsp;<span class="NewFileHighlight"><a h'+'ref="'+zAttach.URL+'" target="_blank">'+zAttach.DisplayName+'<\/a> (not yet saved)<\/span><br />';
      } else if(zAttach.Status == 'DELETE') {
        zInputRemoveStr     += ','+zAttach.Identifier;
        zInputRemoveURLStr  += ','+zAttach.URL;
      } else if(zAttach.Status == 'EXISTING') {
        zInnerHtmlStr += '<span class="Remove RemoveFileLink" onClick="'+this.Name+'.Remove(\''+zAttach.Identifier+'\')">x</span>&nbsp;<a h'+'ref="'+zAttach.URL+'" target="_blank">'+zAttach.DisplayName+'<\/a><br />';
      }
    }
  }
  zElement = document.getElementById('dv'+aType+'List');
  if(zElement) { zElement.innerHTML = zInnerHtmlStr; }
  zElement = document.getElementById('inp'+aType+'List');
  if(zElement) { zElement.value = zInputStr; }
  zElement = document.getElementById('inp'+aType+'URLList');
  if(zElement) { zElement.value = zInputURLStr; }
  zElement = document.getElementById('inp'+aType+'RemoveList');
  if(zElement) { zElement.value = zInputRemoveStr; }
}
AttachmentContainer.prototype.Debug = function() {
  var zOutputString = '';
  for(var zI=0; zI<this.AttachmentList.length; zI++) {
    var zAttach =  this.AttachmentList[zI];
    zOutputString += '\n ID: '+zAttach.Identifier
                   + ' URL: '+zAttach.URL
                   + ' Type: '+zAttach.UpperType
                   + ' DisplayName: '+zAttach.DisplayName
                   + ' Status: '+zAttach.Status;
  }
  alert(zOutputString);
}
// End JSIncludeFile:Action_JSIncludeAttachmentContainer
// Start JSIncludeFile:Action_JSIncludeUtilities
function setInnerHTML(aElement,aHtml){
  aElement = $(aElement);
  aElement.innerHTML = aHtml;
  Widgets.Update(aElement);
  return aElement;d
}
var Widgets = {
  WidgetArray: new Array(),
  WidgetList: new Object(),
  Add: function(aWidget) {
    aWidget.Id = aWidget.Id || "Widget_"+UniqueVar();
    Widgets.WidgetArray.push(aWidget);
    Widgets.WidgetList[aWidget.Id] = aWidget;
    return true;
  },
  Init: function(aElement,aIsUpdate) {
    Widgets.WidgetArray.forEach(function(aWidget) {
      var zElements;
      if(aWidget.GetElementsFunction) {
        zElements = aWidget.GetElementsFunction(aElement);
      }
      else {
        zElements = getElementsWithAttribute(aWidget.Attribute,aWidget.Value,aWidget.TagName,aElement);
      }
      if(zElements.length) {
        if(aWidget.WidgetInitFunction && !aIsUpdate) {
          aWidget.WidgetInitFunction(zElements);
        }
        if(aWidget.ElementInitFunction) {
          zElements.forEach(aWidget.ElementInitFunction,aWidget);
        }
      }
    });
    return true;
  },
  Update: function(aElement) {
    return Widgets.Init(aElement,true);
  },
  Load: function(e) {
    Widgets.Init();
    return true;
  }
};
onDOMLoad(Widgets.Load);
function MakeHoverable(aElement) {
  var zHoverClass = aElement.getAttribute('hoverclass') || "Hover";
  appendEventHandler(aElement, "onmouseover", function(e,aElement) {AddClass(aElement,zHoverClass); return true;}, aElement);
  appendEventHandler(aElement, "onmouseout", function(e,aElement) {RemoveClass(aElement,zHoverClass); return true;}, aElement);
}
Widgets.Add({
  Id: "Hover",
  Attribute: "hoverable",
  Value: "Y",
  ElementInitFunction: MakeHoverable
});
function MakeSelectable(aElement) {
  if(hasAttribute(aElement,"IsSelected","Y")) {
    SelectElement(aElement);
  }
  else {
    aElement.setAttribute("IsSelected","N");
  }
  appendEventHandler(aElement, "onclick", ToggleSelectElement, aElement);
  return true;
}
Widgets.Add({
  Id: "Selectable",
  Attribute: "selectable",
  Value: "Y",
  ElementInitFunction: MakeSelectable
});
Widgets.Add({
  Id: "SelectGroup",
  Attribute: "selectgroup",
  ElementInitFunction: MakeSelectable
});
function ToggleSelectElement(e,aElement) {
  if(hasAttribute(aElement,"IsSelected","Y")) {
    DeSelectElement(aElement);
  }
  else {
    SelectElement(aElement);
  }
  return true;
}
function SelectElement(aElement) {
  if(hasAttribute(aElement,"SelectGroup")) {
    getElementsWithAttribute("SelectGroup",aElement.getAttribute("SelectGroup")).forEach(function(aGroupElement){
      if(aGroupElement != aElement) {
        DeSelectElement(aGroupElement);
      }
    });
  }
  if(hasAttribute(aElement,"SelectInput")) {
    document.getElementById(aElement.getAttribute("SelectInput")).checked = true;
  }
  aElement.setAttribute("IsSelected","Y");
  AddClass(aElement,"Selected");
}
function DeSelectElement(aElement) {
  aElement.setAttribute("IsSelected","N");
  RemoveClass(aElement,"Selected");
  if(hasAttribute(aElement,"SelectInput")) {
    document.getElementById(aElement.getAttribute("SelectInput")).checked = false;
  }
}
function SetCookie(aName, aValue, aExpires, aPath, aDomain, aSecure) {
  var zCookieValue = new Array();
  zCookieValue[zCookieValue.length] = aName + '=' + escape(aValue);
  if(aExpires!=void(0)){
    if(typeof(aExpires)=='string'&&aExpires.toUpperCase()=='NEVER'){
      aExpires = new Date();
      aExpires.setFullYear(aExpires.getFullYear()+10);
    }
    zCookieValue[zCookieValue.length] = 'expires=' + aExpires.toGMTString();
  }
  if(aPath==void(0)){
    aPath = '/';
  }
  zCookieValue[zCookieValue.length] = 'path='+ aPath;
  if(aDomain!=void(0)){
    zCookieValue[zCookieValue.length] = 'domain=' + aDomain;
  }
  if(aSecure){
    zCookieValue[zCookieValue.length] = 'secure';
  }
  document.cookie = zCookieValue.join('; ');
  fCookiesLoaded = false;
}
function DeleteCookie(aName,aDomain){
  var zExpires = new Date();
  zExpires.setFullYear(zExpires.getFullYear()-1);
  SetCookie(aName,'',zExpires,void(0),aDomain);
}
function popUpWindow(aURL, aWidth, aHeight, aScroll) {
  var zLeft = (screen.width - aWidth) / 2;
  var zTop = (screen.height - aHeight) / 2;
  var zWinProp = 'width='+aWidth+',height='+aHeight
               + ',left='+zLeft+',top='+zTop+',scrollbars='+aScroll+',resizable';
  zWin = window.open(aURL, '', zWinProp);
  zWin.window.focus();
}
function CloseWin() {
  window.close();
  if(opener) {
    window.opener.window.focus();
  }
}
String.prototype.addClass = function(aClass) {
  if (this != "") {
    if (!this.classExists(aClass)) {
      return this + " " + aClass;
    }
  }
  else {
    return aClass;
  }
  return this;
}
String.prototype.classExists = function(aClass) {
  var zRegExp = new RegExp('(^|\\s)' + aClass + '\\b');
  return zRegExp.test(this);
}
String.prototype.removeClass = function(aClass) {
  var zRegExp = new RegExp('(^|\\s)' + aClass + '\\b');
  return this.replace(zRegExp, '').Trim();
}
String.prototype.replaceClass = function(aOldClass,aNewClass) {
  if(this.classExists(aOldClass)){
    var zRegExp = new RegExp('(^|\\s)' + aOldClass + '\\b');
    return this.replace(zRegExp,'$1'+aNewClass);
  }else{
    return this.addClass(aNewClass);
  }
}
function AddClass(aElement,aClass) {
  aElement.className = aElement.className.addClass(aClass);
  return true;
}
function RemoveClass(aElement,aClass) {
  aElement.className = aElement.className.removeClass(aClass);
  return true;
}
function ReplaceClass(aElement,aOldClass,aNewClass) {
  aElement.className = aElement.className.replaceClass(aOldClass,aNewClass);
  return true;
}
function isClass(object, className) {
  return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1);
}
function GetElementsWithClassName(elementName,className) {
  var allElements = document.getElementsByTagName(elementName);
  var elemColl = new Array();
  for(var i = 0; i< allElements.length; i++) {
    if(isClass(allElements[i], className)) {
      elemColl[elemColl.length] = allElements[i];
    }
  }
  return elemColl;
}
function getElementsWithAttribute(aAttribute,aValue,aTagName,aElement) {
  var i, zElements = new Array(), zAllElements = (aElement || document).getElementsByTagName(aTagName || "*");
  for(i = 0; i < zAllElements.length; i++) {
    if(!aAttribute||hasAttribute(zAllElements[i],aAttribute,aValue)) {
      zElements.push(zAllElements[i]);
    }
  }
  return zElements;
}
function hasAttribute(aElement,aAttribute,aValue) {
  if(!aAttribute) {
    return false;
  }
  if(aAttribute == "class" || aAttribute == "className") {
    if(!aValue) {
      return !!(aElement.className);
    }
    return isClass(aElement, aValue);
  }
  else if(aAttribute == "for" || aAttribute == "htmlFor") {
    return ((aElement["htmlFor"] && aElement["htmlFor"] == aValue) || (aElement.getAttribute("for") && aElement.getAttribute("for") == aValue));
  }
  else {
    if(!aValue) {
      return !!(aElement.getAttribute(aAttribute));
    }
    return (aElement.getAttribute(aAttribute) == aValue);
  }
  return false;
}
function VarDef(aVar,aValue) {
  return !aVar ? aValue : aVar;
}
function OpenPopUpTreeNavigation(aDisplayElementId, aInputElementId, aItemPath, aOpenToPath, aPopUpUrl, aStartPath) {
  fGlobalPointer.DisplayElement = document.getElementById(aDisplayElementId);
  fGlobalPointer.InputElement = document.getElementById(aInputElementId);
  var zDefaultPopUpUrl = '/LiveKnowledgeBasev4_PopUpFramework?aItemPath='+aItemPath+'&aStartPath='+ VarDef(aStartPath,fGlobalPointer.StartPath) +'&aOpenToPath='+aOpenToPath+'&LSAccessID='+fGlobalPointer.LSAccessID;
  if(!fPopUpWindow||fPopUpWindow.closed) {
    fPopUpWindow = window.open(VarDef(aPopUpUrl,zDefaultPopUpUrl), '', 'toolbar,menubar,status,width=280,height=550,resizable');
  } else {
    fPopUpWindow.location.href = VarDef(aPopUpUrl,zDefaultPopUpUrl);
  }
  fPopUpWindow.focus();
}
function isTrue(aValue,aDefaultValue) {
  aDefaultValue = (typeof(aDefaultValue)=='undefined' ? false:aDefaultValue);
  if(typeof(aValue)=='undefined'||aValue==null) { return aDefaultValue; }
  var zVal = aValue.toString().toLowerCase();
  return ((zVal=='y'||zVal=='true'||zVal=='1') ? true:((zVal=='n'||zVal=='false'||zVal=='0') ? false:aDefaultValue));
}
function SystemNotification(aRecipients,aFrom,aMessage,aSubject,aType,aPriority,aIncludeDeveloperEmailAddress,aIncludeDefaultRecipients) {
  var zURL = '/JavaScript.SystemNotificationJS';
  if(aRecipients!='') {
    zURL = setURLVariable('aRecipients',escape(aRecipients),zURL,true);
  }
  if(aFrom!='') {
    zURL = setURLVariable('aFrom',escape(aFrom),zURL,true);
  }
  if(aMessage!='') {
    zURL = setURLVariable('aMessage',escape(aMessage),zURL,true);
  }
  if(aSubject!='') {
    zURL = setURLVariable('aSubject',escape(aSubject),zURL,true);
  }
  if(aType!='') {
    zURL = setURLVariable('aType',escape(aType),zURL,true);
  }
  if(aPriority!='') {
    zURL = setURLVariable('aPriority',escape(aPriority),zURL,true);
  }
  if(isTrue(aIncludeDeveloperEmailAddress)){
    zURL = setURLVariable('aIncludeDeveloperEmailAddress','Y',zURL,true);
  }
  if(isTrue(aIncludeDefaultRecipients)){
    zURL = setURLVariable('aIncludeDefaultRecipients','Y',zURL,true);
  }
  if(!window.fSystemNotificationLoadingFrame) {
    window.fSystemNotificationLoadingFrame = new LoadingFrame('fSystemNotificationLoadingFrame',true);
  }
  window.fSystemNotificationLoadingFrame.LoadURL(zURL);
  return;
}
function appendEventHandler(aElement, aEvent, aFunction,aParamObject){
  var zElementFunctions = aEvent +'Functions';
  if(fGlobalPointer.Browser.isSafari&&aElement==window){
    if(window.name==''){
      window.name = 'win_'+ UniqueVar();
    }
    zElementFunctions = window.name+'_'+aEvent+'_Functions';
  }
  if (aElement[zElementFunctions]){
    aElement[zElementFunctions][aElement[zElementFunctions].length] = {Function:aFunction,Params:aParamObject};
  } else {
    aElement[zElementFunctions] = [];
    if (aElement[aEvent]){
      aElement[aEvent + 'OriginalFunction'] = aElement[aEvent];
    }
    aElement[zElementFunctions][aElement[zElementFunctions].length] = {Function:aFunction,Params:aParamObject};
    aElement[aEvent] = (
      function() {
        return function(e){
          e = (e ? e:window.event);
          var x;
          for (x=0;x<this[zElementFunctions].length;x++){
            aElement.TempFunc = this[zElementFunctions][x].Function;
            if(!aElement.TempFunc(e,this[zElementFunctions][x].Params)){
              return false;
            }
          }
          if(aElement[aEvent +'OriginalFunction']){
            aElement.TempFunc = aElement[aEvent + 'OriginalFunction'];
            if(!aElement.TempFunc(e)){
              return false;
            }
          }
          return true;
        }
      }
    )();
  }
}
function removeEventHandler(aElement, aEvent, aFunction,aParamObject){
  if(aElement[aEvent+'Functions']){
    for(var i=aElement[aEvent+'Functions'].length-1;i>=0;i--){
      if(!aFunction||aElement[aEvent+'Functions'][i].Function==aFunction){
        if(!aParamObject||aParamObject==aElement[aEvent+'Functions'][i].Params){
          aElement[aEvent+'Functions'].splice(i,1);
        }
      }
    }
  }
}
function onDOMLoad(aFunction,aParamObject) {
  if (!window.__load_events) {
    var init = function () {
      if (arguments.callee.done) return true;
      arguments.callee.done = true;
      if (window.__load_timer) {
        clearInterval(window.__load_timer);
        window.__load_timer = null;
      }
      for (var i=0;i < window.__load_events.length;i++) {
        window.__load_events[i].Function(window.__load_events[i].Params);
      }
      window.__load_events = null;
      return true;
    };
    if (document.addEventListener) {
      document.addEventListener("DOMContentLoaded", init, false);
    }
    if(/KHTML|WebKit/i.test(navigator.userAgent)) {
      window.__load_timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
          init();
        }
      }, 10);
    }
    /*@cc_on @*/
    /*@if (@_win32)
      document.write('<scr'+'ipt id="__ie_onload" defer s'+'rc="/home.blankjs"><\/scr'+'ipt>');
      var script = document.getElementById('__ie_onload');
      script.onreadystatechange = function() {
        if (this.readyState == 'complete') {
          init();
        }
      };
    /*@end @*/
    appendEventHandler(window, "onload", init, aParamObject);
    window.__load_events = [];
  }
  window.__load_events.push({Function:aFunction,Params:aParamObject});
}
function PlaceElementInView(aElement, aContainerElement, aLeft, aTop) {
  if(!aContainerElement) {
    aContainerElement = document.body
  }
  var zViewableAreaHeight,zViewableAreaWidth,zElementHeight,zElementWidth,zAdjustHeight,zUseLeft,zUseTop,zScrollTop;
  zScrollTop = getScrollTop(aContainerElement);
  zUseLeft = aLeft + aContainerElement.scrollLeft;
  zUseTop = aTop + zScrollTop;
  zElementHeight = (aElement.style.pixelHeight) ? aElement.style.pixelHeight : aElement.scrollHeight;
  zElementWidth = (aElement.style.pixelWidth) ? aElement.style.pixelWidth : aElement.scrollWidth;
  if(aContainerElement == document.body) {
    var zTrueBodyHeight;
    if(aContainerElement.style.pixelHeight) {
      zTrueBodyHeight = aContainerElement.style.pixelHeight;
    }
    else {
      zTrueBodyHeight = aContainerElement.scrollHeight;
    }
    var zTempContainer = document.createElement('div');
    zTempContainer.setAttribute("width", "100%");
    zTempContainer.setAttribute("height", "100%");
    zTempContainer.style.position = "absolute";
    zTempContainer.style.top = "0px";
    zTempContainer.style.left = "0px";
    zTempContainer.style.width = "100%";
    if(fGlobalPointer && fGlobalPointer.Browser) {
      if(!(fGlobalPointer.Browser.isIE && fGlobalPointer.Browser.isMac)) {
        zTempContainer.style.height = "100%";
      }
    }
    else {
        zTempContainer.style.height = "100%";
    }
    var zActiveTempContainer = document.body.appendChild(zTempContainer);
    var zTempContainerHeight;
    if(zActiveTempContainer.style.pixelHeight && typeof(zActiveTempContainer.style.pixelHeight) == 'number') {
      zTempContainerHeight = zActiveTempContainer.style.pixelHeight;
    }
    else {
      zTempContainerHeight = zActiveTempContainer.scrollHeight;
    }
    zViewableAreaHeight = Math.max(zTempContainerHeight,zTrueBodyHeight);
    document.body.removeChild(zActiveTempContainer);
  }
  else {
    if(aContainerElement.style.pixelHeight) {
      zViewableAreaHeight = aContainerElement.style.pixelHeight;
    }
    else {
      zViewableAreaHeight = aContainerElement.scrollHeight;
    }
  }
  zViewableAreaHeight -= zScrollTop;
  zViewableAreaWidth = aContainerElement.scrollWidth - aContainerElement.scrollLeft;
  aElement.style.top = Math.max(0,Math.min((zUseTop),(zViewableAreaHeight-zElementHeight+zScrollTop-20))) + 'px';
  aElement.style.left = Math.max(0,Math.min((zUseLeft),(zViewableAreaWidth-zElementWidth+aContainerElement.scrollLeft-20)))  + 'px';
}
function AppendToUrl(aUrl,aExtraParams) {
  if(!aExtraParams) {
    return aUrl;
  }
  if(aUrl.split('?').length>1){
    return aUrl+"&"+aExtraParams;
  }
  else {
    return aUrl+"?"+aExtraParams;
  }
}
function DisableInputRecurse(aStartElement,aDisable){
  aDisable = isTrue(aDisable);
  var x;
  switch (aStartElement.type) {
    case "text":
    case "hidden":
    case "button":
    case "submit":
    case "textarea":
    case "radio":
    case "select-one":
    case "select-multiple":
    case "checkbox":
      aStartElement.disabled = aDisable;
      break;
    default: 
      for(x=0;x<aStartElement.childNodes.length;x++){
        DisableInputRecurse(aStartElement.childNodes[x],aDisable)
      }
      break;
  }
}
Math.RandomNumber = function(aMin,aMax) {
  return ( Math.floor( Math.random() * ( aMax+1 - aMin ) ) + aMin );
}
function isFunction(a) {
    return typeof a == 'function';
}
function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}
function Function_Apply(o, a) {
  var r, x = '____apply';
  if (!isObject(o)) {
    o = {};
  }
  o[x] = this;
  switch ((a && a.length) || 0) {
    case 0:
        r = o[x]();
        break;
    case 1:
        r = o[x](a[0]);
        break;
    case 2:
        r = o[x](a[0], a[1]);
        break;
    case 3:
        r = o[x](a[0], a[1], a[2]);
        break;
    case 4:
        r = o[x](a[0], a[1], a[2], a[3]);
        break;
    case 5:
        r = o[x](a[0], a[1], a[2], a[3], a[4]);
        break;
    case 6:
        r = o[x](a[0], a[1], a[2], a[3], a[4], a[5]);
        break;
    default:
        r = o[x]();
  }
  delete o[x];
  return r;
}
Function.prototype.SetMethod = function (name, func) {
  this.prototype[name] = func;
  return this;
};
if (!isFunction(Function.apply)) {
  Function.SetMethod("apply", Function_Apply);
}
function SugarMethod_Inherits(parent) {
    var d = 0, p = (this.prototype = new parent());
    var zUberFunction = function(name) {
        var f, r, t = d, v = parent.prototype;
        if (t) {
            while (t) {
                v = v.constructor.prototype;
                t -= 1;
            }
            f = v[name];
        } else {
            f = p[name];
            if (f == this[name]) {
                f = v[name];
            }
        }
        d += 1;
        r = f.apply(this, Array.prototype.slice.apply(arguments, [1]));
        d -= 1;
        return r;
    }
    this.SetMethod("CallInheritedMethod", zUberFunction);
    return this;
}
Function.SetMethod("InheritsFrom", SugarMethod_Inherits);
function SugarMethod_Swiss(parent) {
    for (var i = 1; i < arguments.length; i += 1) {
        var name = arguments[i];
        this.prototype[name] = parent.prototype[name];
    }
    return this;
}
Function.SetMethod("SetPartialInheritance", SugarMethod_Swiss);
String.prototype.HTMLEncode = function(){
  var x,zOutput = new Array(this.length);
  for(x=0;x<this.length;x++){
    zOutput[x] = '&#'+ this.charCodeAt(x) +';';
  }
  return zOutput.join('');
}
String.prototype.HTMLDecode = function() {
  var zMatches = this.match(/&#\d+;/g), zOutput = this.toString();
  if(zMatches) {
    for(var i = 0; i < zMatches.length; i++){
      zOutput = zOutput.replace(/&#\d+;/,String.fromCharCode((zMatches[i]).replace(/\D/g,'')));
    }
  }
  return zOutput;
}
String.prototype.Trim = function(){
  return this.replace(/^\s*|\s*$/g,'');
}
function getAbsolutePosition(aElement){
  var zReturn = { x:aElement.offsetLeft, y:aElement.offsetTop };
  if(aElement.offsetParent) {
    var tmp = getAbsolutePosition(aElement.offsetParent);
    zReturn.x += tmp.x;
    zReturn.y += tmp.y;
  }
  return zReturn;
}
function getEventCoordinates(e,aElement) {
  var zResults, zCoords;
  if(aElement) {
    zCoords = getAbsolutePosition(aElement);
    if(fGlobalPointer&&fGlobalPointer.Browser&&fGlobalPointer.Browser.isIE) {
      zResults = {x: e.offsetX, y: e.offsetY};
    }
    else {
      zResults = {x: (e.clientX-zCoords.x), y: (e.clientY-zCoords.y)};
    }
  }
  else {
    zResults = {x: (e.clientX), y: (e.clientY)};
  }
  return zResults;
}
function CreateBasicElement(aTagName,aId,aClassName,aStyle) {
  var zElement = document.createElement(aTagName);
  if(aId) {
    zElement.setAttribute("name",aId);
    zElement.setAttribute("id",aId);
  }
  if(aClassName) {
    zElement.setAttribute("class", aClassName);
    zElement.setAttribute("className", aClassName);
  }
  if(aStyle) {
    zElement.setAttribute("style",aStyle);
  }
  return zElement;
}
String.prototype.toPagePath = function(){
  return '/'+ this.replace(/\\/g,'/');
}
String.prototype.toAliasString = function(){
  return this.replace(/[^a-z0-9_]/gi,'');
}
function UniqueVar() {
  return ((new Date().valueOf()) + Math.round(Math.random()*1000000));
}
var fDebugAlertContainer = null;
DebugAlert.Enabled = false;
DebugAlert.ThrowError = false;
function DebugAlert(aText) {
  if(DebugAlert.Enabled){
    if(!fDebugAlertContainer&&!DebugAlert.ThrowError) {
      fDebugAlertContainer = CreateBasicElement("textarea","DebugAlertArea","","font-size: 11px; line-height: 12px; display: block; border: 1px solid red; width: 90%; height: 100px;");
      fDebugAlertContainer.style.height = "100px";
      fDebugAlertContainer.style.width = "90%";
      document.body.insertBefore(fDebugAlertContainer,document.body.childNodes[0]);
    }
    if(fDebugAlertContainer||DebugAlert.ThrowError) {
      if(DebugAlert.ThrowError){
        setTimeout(function() {
          throw new Error("[debug] " + aText);
        },0);
      }else{
        fDebugAlertContainer.value += aText + "\n";
        fDebugAlertContainer.scrollTop = fDebugAlertContainer.scrollHeight;
      }
    }
  }
  return false;
}
function ValidateEmail(aEmail){
  var x = aEmail;
  var zTest  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  return zTest.test(x);
}
function CopyObject(aObject){
  return CopyProperties(aObject,new Object());
}
function CopyProperties(aFromObject,aToObject,aOverwrite){
  aOverwrite = isTrue(aOverwrite);
  for(var zProp in aFromObject){
    if(!aToObject[zProp]||aOverwrite){
      aToObject[zProp] = aFromObject[zProp];
    }
  }
  return aToObject;
}
function getIframeDocument(aIframe) {
  return aIframe.contentDocument || aIframe.contentWindow || aIframe.document;
}
if (window.Node && Node.prototype && !Node.prototype.contains) {
  Node.prototype.contains = function (arg) {
    return !!(this.compareDocumentPosition(arg) & 16)
  }
}
function fixEvent(aEvent){
  aEvent = (aEvent ? aEvent:window.event);
  if(typeof(aEvent.layerX)=='undefined'){
    aEvent.layerX = aEvent.offsetX;
  }
  if(typeof(aEvent.layerY)=='undefined'){
    aEvent.layerY = aEvent.offsetY;
  }
  if(typeof(aEvent.target)=='undefined'){
    aEvent.target = aEvent.srcElement;
  }
  return aEvent;
}
function show(aElement,aDisplayType){
  aElement.style.display = aDisplayType||'block';
}
function hide(aElement){
  aElement.style.display = 'none';
}
function showhide(aElement,aDisplayType){
  if(aElement.style.display=='none'){
    show(aElement,aDisplayType);
  }else{
    hide(aElement);
  }
}
function $(){
  if (arguments.length == 1){ return get$(arguments[0]); }
  var i,zElements = [];
  for(i=0;i<arguments.length;i++){
    zElements.push(get$(arguments[i]));
  }
  function get$(el){
    return (typeof el == 'string' ? document.getElementById(el):el);
  }
  return zElements;
}
function setMaxHeight (aElements) {
  var zHeight = 0;
  aElements.forEach(function(aElement) {
    zHeight = Math.max(zHeight,aElement.offsetHeight);
  });
  aElements.forEach(function(aElement) {
    aElement.style.height = zHeight + "px";
  });
}
function setMaxWidth(aElements) {
  var zWidth = 0;
  aElements.forEach(function(aElement) {
    zWidth = Math.max(zWidth,aElement.offsetWidth);
  });
  aElements.forEach(function(aElement) {
    aElement.style.width = zWidth + "px";
  });
}
function setMaxDimensions(aElements) {
  setMaxHeight(aElements);
  setMaxWidth(aElements);
}
function getScrollTop(aElement) {
  var zTop = 0;
  if(aElement && aElement != document.body) {
    zTop = aElement.scrollTop;
  }
  else if (window.innerHeight) {
    zTop = window.pageYOffset;
  }
  else if (document.documentElement && document.documentElement.scrollTop) {
    zTop = document.documentElement.scrollTop;
  }
  else if (document.body) {
    zTop = document.body.scrollTop;
  }
  return zTop;
}
var ScrollingInterface = {
  ScrollerList: {},
  ScrollerArray: [],
  ElementInit: function(aElement) {
    zScrollerContentElement = document.createElement('div');
    var zTotalWidth = 0;
    zChildNodeArray = new Array();
    for (i = 0; i < aElement.childNodes.length; i++) {
      node = aElement.childNodes[i];
      if (node.nodeName=="DIV") {
        zChildNodeArray[zChildNodeArray.length] = node;
      }
    }
    for (j = 0; j < zChildNodeArray.length; j++) {
      node = zChildNodeArray[j];
      zTotalWidth = (node.offsetWidth + zTotalWidth);
      zScrollerContentElement.appendChild(node);
    }
    zScrollerContentElement.style.position   = 'relative';
    zScrollerContentElement.style.width      = zTotalWidth + 'px';
    zScrollerContentElement.style.whiteSpace = 'nowrap';
    aElement.style.overflow = 'hidden';
    aElement.appendChild(zScrollerContentElement);
    var zLeftTrigger    = null;
    var zRightTrigger   = null;
    var zScrollDistance = aElement.clientWidth;
    var zTriggerType    = 'onmouseover';
    if(hasAttribute(aElement,'TriggerType')) {
      zTriggerType = aElement.getAttribute('TriggerType');
    }
    if(hasAttribute(aElement,'ScrollDistance')) {
      zScrollDistance = aElement.getAttribute('ScrollDistance');
    }
    if(hasAttribute(aElement,'LeftTrigger')) {
      zLeftTrigger = $(aElement.getAttribute('LeftTrigger'));
    }
    if(hasAttribute(aElement,'RightTrigger')) {
      zRightTrigger = $(aElement.getAttribute('RightTrigger'));
    }
    var zScroller = {
      ScrollerContainerElement: aElement,
      ScrollerContentElement:   zScrollerContentElement,
      ScrollDistance:           parseInt(zScrollDistance),
      LeftTrigger:              zLeftTrigger,
      RightTrigger:             zRightTrigger,
      TriggerType:              zTriggerType
    }
    ScrollingInterface.ScrollerList[aElement.id] = zScroller;
    ScrollingInterface.ScrollerArray.push(zScroller);
    if (zScroller.LeftTrigger!=null) {
      appendEventHandler(zScroller.LeftTrigger, zScroller.TriggerType, ScrollingInterface.ScrollLeft, zScroller);
    }
    if (zScroller.RightTrigger!=null) {
      appendEventHandler(zScroller.RightTrigger, zScroller.TriggerType, ScrollingInterface.ScrollRight, zScroller);
    }
    return true;
  },
  ScrollLeft: function(e,aScroller){
    ScrollingInterface.Scroll(aScroller,'LEFT');
    return true;
  },
  ScrollRight: function(e,aScroller){
    ScrollingInterface.Scroll(aScroller,'RIGHT');
    return true;
  },
  Scroll:function(aScroller,aDirection) {
    if (aDirection == 'LEFT') {
      zEndValue = (aScroller.ScrollerContentElement.offsetLeft - aScroller.ScrollDistance);
      if ((aScroller.ScrollerContentElement.offsetWidth + zEndValue) < aScroller.ScrollerContainerElement.clientWidth) {
        zEndValue = (-(aScroller.ScrollerContentElement.offsetWidth) + aScroller.ScrollerContainerElement.clientWidth);
      }
    } else {
      zEndValue = (aScroller.ScrollerContentElement.offsetLeft + aScroller.ScrollDistance);
      if ((aScroller.ScrollerContentElement.offsetLeft + zEndValue) > 0) {
        zEndValue = 0;
      }
    }
    Tween.Run({
      Element: aScroller.ScrollerContentElement,
      Function: function(aParams){
        aParams.Element.style.left = aParams.CurrentValue +'px';
      },
      StartValue: aScroller.ScrollerContentElement.offsetLeft,
      EndValue: zEndValue,
      Duration: 300
    });
  }
}  
Widgets.Add({
  Id: "Scroller",
  Attribute: "Scroller",
  TagName: "div",
  ElementInitFunction: ScrollingInterface.ElementInit
});
function DisableCalendar(aCalendarFunctionName,aDisable){
  aDisable = isTrue(aDisable,true);
  var zContainer = $('Calender-Container-'+ aCalendarFunctionName);
  var zInputs = getElementsWithAttribute(null,null,'INPUT',zContainer);
  var zAnchors = getElementsWithAttribute(null,null,'A',zContainer);
  (aDisable ? AddClass:RemoveClass)(zContainer,'CalendarReadOnly');
  zInputs.forEach(function(aInput){
    (aDisable ? AddClass:RemoveClass)(aInput,'ReadOnly');
    aInput.readOnly = aDisable;
  });
  zAnchors.forEach(function(aAnchor){
    if(aDisable){
      if(aAnchor.onclick){
        aAnchor._onclick = aAnchor.onclick;
        aAnchor.onclick = null;
      }
    }else{
      if(aAnchor._onclick){
        aAnchor.onclick = aAnchor._onclick;
        aAnchor._onclick = null;
      }
    }
  });
}
Function.prototype.bind = function() {
  var zMethod = this;
  var zArgs = Array.Copy(arguments);
  var zObject = zArgs.shift();
  return function() {
    return zMethod.apply(zObject, zArgs);
  };
}
String.prototype.CrToBr = function(){
  return this.replace(/\r{0,1}\n/gi,'<br />');
}
function getInnerText(aWhatToParse,aInsertBreaks){
  var zNode,zOutput = [];
  if(typeof aWhatToParse == 'string'){
    zNode = document.createElement('div');
    zNode.innerHTML = aWhatToParse;
  }else{
    zNode = aWhatToParse;
  }
  GetText(zNode);
  function GetText(aElement){
    var zInsertBreak = false;
    if(aElement.nodeType==3){
      zOutput.push(aElement.nodeValue);
      return;
    }else if(aInsertBreaks && aElement.nodeType==1){
      switch(aElement.tagName.toLowerCase()){
        case 'br':
          zOutput.push('<br />');
          break;
        case 'p':
        case 'div':
          zInsertBreak = true;
          break;
      }
    }
    if(aElement.childNodes){
      for(var i=0;i<aElement.childNodes.length;i++){
        GetText(aElement.childNodes[i]);
      }
    }
    if(zInsertBreak){
      zOutput.push('<br />');
    }
    return;
  }
  return zOutput.join(' ');
}
// End JSIncludeFile:Action_JSIncludeUtilities
// Start JSIncludeFile:Action_JSIncludeDOMUtilities
function getLeft(aElement) {
  return aElement.offsetLeft;
}
function getTop(aElement) {
  return aElement.offsetTop;
}
function moveTo(aElement,aCoords){
  if(aCoords.x||aCoords.x===0){
    aElement.style.left = aCoords.x + 'px';
  }
  if(aCoords.y||aCoords.y===0){
    aElement.style.top = aCoords.y + 'px';
  }
}
function moveBy(aElement,aCoords){
  if(aCoords.x){
    aElement.style.left = (getLeft(aElement)+aCoords.x) + 'px';
  }
  if(aCoords.y){
    aElement.style.top = (getTop(aElement)+aCoords.y) + 'px';
  }
}
function resizeTo(aElement,aCoords){
  if(aCoords.width||aCoords.width===0){
    aElement.style.width = aCoords.width + 'px';
  }
  if(aCoords.height||aCoords.height===0){
    aElement.style.height = aCoords.height + 'px';
  }
}
function EnableDrag(aParamObject){
  if(typeof(aParamObject)=='string'){
    aParamObject = {Element:document.getElementById(aParamObject)};
  }else if(!aParamObject.Element){
    aParamObject = {Element:aParamObject};
  }
  Drag.init(
    (aParamObject.TriggerElement ? aParamObject.TriggerElement:aParamObject.Element),
    (aParamObject.TriggerElement ? aParamObject.Element:aParamObject.TriggerElement),
    aParamObject.MinX,
    aParamObject.MaxX,
    aParamObject.MinY,
    aParamObject.MaxY,
    aParamObject.StartFunction,
    aParamObject.DragFunction,
    aParamObject.EndFunction
  );
}
function DisableDrag(aElement){
  if(typeof(aElement)=='string'){
    aElement = document.getElementById(aElement);
  }
  if(aElement.TriggerArray){
    for(var i=0;i<aElement.TriggerArray.length;i++){
      Drag.disable(aElement.TriggerArray[i]);
    }
  }else{
    Drag.disable(aElement);
  }
}
var Drag = {
  obj : null,
  DoNothing : function(){},
  init : function(o, oRoot, minX, maxX, minY, maxY, aStartFunc,aDragFunc,aEndFunc){
    appendEventHandler(o, "onmousedown", Drag.start);
    o.root = oRoot && oRoot != null ? oRoot : o ;
    if(!o.root.TriggerArray){
      o.root.TriggerArray = new Array();
    }
    o.root.TriggerArray.push(o);
    if (isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
    if (isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
    o.minX  = typeof minX != 'undefined' ? minX : null;
    o.minY  = typeof minY != 'undefined' ? minY : null;
    o.maxX  = typeof maxX != 'undefined' ? maxX : null;
    o.maxY  = typeof maxY != 'undefined' ? maxY : null;
    o.root.onDragStart  = aStartFunc || Drag.DoNothing;
    o.root.onDragEnd    = aEndFunc   || Drag.DoNothing;
    o.root.onDrag       = aDragFunc  || Drag.DoNothing;
  },
  start : function(e){
    var o = Drag.obj = this;
    e = fixEvent(e);
    var y = parseInt(o.root.style.top);
    var x = parseInt(o.root.style.left);
    o.root.onDragStart(x, y);
    o.lastMouseX  = e.clientX;
    o.lastMouseY  = e.clientY;
    if (o.minX != null)  o.minMouseX  = e.clientX - x + o.minX;
    if (o.maxX != null)  o.maxMouseX  = o.minMouseX + o.maxX - o.minX;
    if (o.minY != null)  o.minMouseY  = e.clientY - y + o.minY;
    if (o.maxY != null)  o.maxMouseY  = o.minMouseY + o.maxY - o.minY;
    appendEventHandler(document, "onmousemove", Drag.drag, Drag.obj);
    appendEventHandler(document, "onmouseup", Drag.end, Drag.obj);
    return false;
  },
  drag : function(e){
    e = fixEvent(e);
    var o = Drag.obj;
    var ey  = e.clientY;
    var ex  = e.clientX;
    var y = parseInt(o.root.style.top);
    var x = parseInt(o.root.style.left);
    var nx, ny;
    if (o.minX != null) ex = Math.max(ex, o.minMouseX);
    if (o.maxX != null) ex = Math.min(ex, o.maxMouseX);
    if (o.minY != null) ey = Math.max(ey, o.minMouseY);
    if (o.maxY != null) ey = Math.min(ey, o.maxMouseY);
    nx = x + (ex - o.lastMouseX);
    ny = y + (ey - o.lastMouseY);
    Drag.obj.root.style.left = nx + "px";
    Drag.obj.root.style.top = ny + "px";
    Drag.obj.lastMouseX  = ex;
    Drag.obj.lastMouseY  = ey;
    Drag.obj.root.onDrag(nx, ny);
    return false;
  },
  end : function(){
    removeEventHandler(document, "onmousemove", Drag.drag, Drag.obj);
    removeEventHandler(document, "onmouseup", Drag.end, Drag.obj);
    Drag.obj.root.onDragEnd(  parseInt(Drag.obj.root.style.left),parseInt(Drag.obj.root.style.top));
    Drag.obj = null;
  },
  disable : function(o){
    removeEventHandler(o, "onmousedown", Drag.start);
  }
};
var Tween = {
  Run:function(aParams){
    aParams.Duration           = (typeof aParams.Duration != 'undefined' ? aParams.Duration:400);
    aParams.StartValue         = (typeof aParams.StartValue != 'undefined' ? aParams.StartValue:0);
    aParams.Increment          = (typeof aParams.Increment != 'undefined' ? aParams.Increment:16);
    aParams.EndValue           = (typeof aParams.EndValue != 'undefined' ? aParams.EndValue:1);
    aParams.Method             = aParams.Method || "linear";
    aParams.OnCompleteFunction = aParams.OnCompleteFunction || null;
    aParams.CurrentValue       = aParams.StartValue;
    aParams.StartTime          = new Date().getTime();
    aParams.EndTime            = aParams.StartTime + aParams.Duration;
    aParams.Transition         = Tween.Transition[aParams.Method];
    aParams.PercentComplete    = 0;
    aParams.Timer = setInterval(function(){
      Tween.Step(aParams);
    },aParams.Increment);
    return aParams;
  },
  Step:function(aParams){
    var zNow  = new Date().getTime();
    if (zNow >= aParams.StartTime+aParams.Duration) {
      clearInterval (aParams.Timer);
      aParams.Timer = null;
      aParams.CurrentValue = aParams.EndValue;
      aParams.PercentComplete = 1;
      if (aParams.OnCompleteFunction) {
        aParams.OnCompleteFunction(aParams);
      }
    } else {
      aParams.PercentComplete = (zNow - aParams.StartTime) / (aParams.Duration);
      aParams.CurrentValue = aParams.Transition(aParams.PercentComplete) * (aParams.EndValue - aParams.StartValue) + aParams.StartValue;
    }
    aParams.Function(aParams);
  },
  To:function(aElement,aCoords){
  },
  FadeIn:function(aElement,aParams){
    aParams = aParams || {};
    aParams.StartValue = (typeof(aParams.StartValue)=='undefined' ? 0:aParams.StartValue);
    aParams.EndValue = (typeof(aParams.EndValue)=='undefined' ? 1:aParams.EndValue);
    Tween.Common.SetTween(aElement,aParams);
  },
  FadeOut:function(aElement,aParams){
    aParams = aParams || {};
    aParams.StartValue = (typeof(aParams.StartValue)=='undefined' ? 1:aParams.StartValue);
    aParams.EndValue = (typeof(aParams.EndValue)=='undefined' ? 0:aParams.EndValue);
    Tween.Common.SetTween(aElement,aParams);
  },
  Common:{
    SetOpacity:function(aElement,aValue){
    	aElement.style.opacity = aValue;
    	aElement.style.filter = 'alpha(opacity=' + aValue*100 + ')';
    },
    SetTween:function(aElement,aParams){
      aParams.Element  = $(aElement);
      aParams.Function = function(aParams){
        Tween.Common.SetOpacity(aParams.Element,aParams.CurrentValue);
      }
      Tween.Common.SetOpacity(aParams.Element,aParams.StartValue);
      Tween.Run(aParams);
    }
  },
  Transition:{
    sinoidal:function(pos){
      return ((-Math.cos(pos*Math.PI)/2) + 0.5);
    },
    linear:function(pos){
      return pos;
    },
    cubic:function(pos){
      return Math.pow(pos, 3);
    },
    circ:function(pos){
      return Math.sqrt(pos);
    },
    expoIn:function(pos){
      return Math.pow(2, 10 * (pos - 1));
    },
    expoOut:function(pos){
      return (-Math.pow(2, -10 * pos) + 1);
    },
    quadIn:function(pos){
      return Math.pow(pos, 2);
    },
    quadOut:function(pos){
      return -(pos)*(pos-2);
    },
    circOut:function(pos){
      return Math.sqrt(1 - Math.pow(pos-1,2));
    },
    circIn:function(pos){
      return -(Math.sqrt(1 - Math.pow(pos, 2)) - 1);
    },
    backIn:function(pos){
      return (pos)*pos*((2.7)*pos - 1.7);
    },
    backOut:function(pos){
      return ((pos-1)*(pos-1)*((2.7)*(pos-1) + 1.7) + 1);
    },
    sineOut:function(pos){
      return Math.sin(pos * (Math.PI/2));
    },
    sineIn:function(pos){
      return -Math.cos(pos * (Math.PI/2)) + 1;
    },
    sineInOut:function(pos){
      return -(Math.cos(Math.PI*pos) - 1)/2;
    }
  }
};
function getPageSize(){
  var xScroll,yScroll,windowWidth,windowHeight,pageWidth,pageHeight;
  var zSize;
  if (window.innerHeight && window.scrollMaxY) {
    xScroll = document.body.scrollWidth;
    yScroll = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    xScroll = document.body.scrollWidth;
    yScroll = document.body.scrollHeight;
  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    xScroll = document.body.offsetWidth;
    yScroll = document.body.offsetHeight;
  }
  if (self.innerHeight) {  // all except Explorer
    windowWidth = self.innerWidth;
    windowHeight = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    windowWidth = document.documentElement.clientWidth;
    windowHeight = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
  }
  if(yScroll < windowHeight){
    pageHeight = windowHeight;
  } else {
    pageHeight = yScroll;
  }
  if(xScroll < windowWidth){
    pageWidth = windowWidth;
  } else {
    pageWidth = xScroll;
  }
  zSize = {
    pageWidth:pageWidth,
    pageHeight:pageHeight,
    windowWidth:windowWidth,
    windowHeight:windowHeight,
    xScroll:xScroll,
    yScroll:yScroll
  };
  return zSize;
}
var Modal = {
  Current:{
    Element:null,
    Parent:null
  },
  Overlay:null,
  Show:function(aElement, aXPos, aYPos){
    var zPageSize = getPageSize();
    if(!Modal.Overlay){
      Modal.Body = document.getElementsByTagName('BODY')[0];
      Modal.Overlay = CreateBasicElement('DIV','ModalOverlay');
      Modal.Body.appendChild(Modal.Overlay);
    }
    if(aElement){
      Modal.Current.Element = $(aElement);
      Modal.Current.Parent = Modal.Current.Element.parentNode;
      AddClass(Modal.Current.Element,'Modal');
      var zCoords = {
        x: aXPos || (zPageSize.pageWidth-(Modal.Current.Element.clientWidth ? Modal.Current.Element.clientWidth:0))/2,
        y: aYPos || (zPageSize.pageHeight-(Modal.Current.Element.clientHeight ? Modal.Current.Element.clientHeight:0))/2
      };
      Modal.Current.Element.style.left = zCoords.x + 'px';
      Modal.Current.Element.style.top = zCoords.y + 'px';
      Modal.Body.appendChild(Modal.Current.Element);
    }
    Modal.Overlay.style.height = zPageSize.pageHeight +'px';
    AddClass(Modal.Overlay,'Show');
  },
  Hide:function(){
    if(Modal.Current.Element){
      RemoveClass(Modal.Current.Element,'Modal');
      Modal.Current.Parent.appendChild(Modal.Current.Element);
      Modal.Current.Element = null;
      Modal.Current.ElementParent = null;
    }
    if(Modal.Overlay){
      RemoveClass(Modal.Overlay,'Show');
    }
  }
};
(function(){
  var zImage = new Image();
  zImage.src = '/l.c.bin/I/4214453/ModalBackground.png';
})();
var TrackMouse = {
  Coords: {x: 0, y: 0},
  GetMouseX: function(e){if (!e) e = window.event; if (e.pageX) return e.pageX; else if (e.clientX)return e.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return 0;},
  GetMouseY: function(e) {if (!e) e = window.event; if (e.pageY) return e.pageY; else if (e.clientY)return e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return 0;},
  UpdateCoords: function(e){
    if(!e) e = window.event;
    TrackMouse.Coords.x = TrackMouse.GetMouseX(e);
    TrackMouse.Coords.y = TrackMouse.GetMouseY(e);
    if(TrackMouse.Settings) {
      if(TrackMouse.Settings.Element) {
        TrackMouse.Settings.Element.style.left = TrackMouse.Coords.x + (TrackMouse.Settings.OffsetLeft || 0) + "px";
        TrackMouse.Settings.Element.style.top = TrackMouse.Coords.y + (TrackMouse.Settings.OffsetTop || 0) + "px";
      }
      if(TrackMouse.Settings.OnMoveFunction) {
        TrackMouse.Settings.OnMoveFunction(e,TrackMouse.Coords);
      }
    }
  },
  Start: function(aSettings){
    if(aSettings) {
      TrackMouse.Settings = aSettings;
      if(TrackMouse.Settings.Element) {
      }
    }
    appendEventHandler(document, "onmousemove", TrackMouse.UpdateCoords);
  },
  Stop: function(){
    removeEventHandler(document, "onmousemove", TrackMouse.UpdateCoords);
  }
}
// End JSIncludeFile:Action_JSIncludeDOMUtilities
// Start JSIncludeFile:Action_JSIncludeBaseTarget
function SetBaseTarget(aBaseTarget) {
  var zGetBaseTarget;
  if(aBaseTarget && aBaseTarget != '') {
  } else {
    zGetBaseTarget = GetBaseTarget();
    if(zGetBaseTarget) {
      aBaseTarget = zGetBaseTarget.name;
    }
  }
  if(aBaseTarget && aBaseTarget != '') {
    document.write('<base target="'+aBaseTarget+'" />');
  }
  return aBaseTarget;
}
function GetBaseTarget() {
  if (self.name != '' && (self.name == 'KBContentFrame' || self.name == 'CONTENTFRAME')) {
    return self;
  }
  try {
    if (parent && parent.name != '' && (parent.name == 'KBContentFrame' || parent.name == 'CONTENTFRAME')) {
      return parent;
    }
  } catch(e) {
    return null
  }
  try {
    if (parent.parent && parent.parent.name != '' && (parent.parent.name == 'KBContentFrame' || parent.parent.name == 'CONTENTFRAME')) {
      return parent.parent;
    }
  } catch(e) {
    return null
  }
  return null;
}
function LoadUrlUsingBaseTarget(aUrl) {
  var zBaseTarget = GetBaseTarget();
  var zTarget = document;
  if(zBaseTarget) {
    zTarget = zBaseTarget.document;
  }
  zTarget.location.href = aUrl;
  return true;
}
// End JSIncludeFile:Action_JSIncludeBaseTarget
// Start JSIncludeFile:Action_JSIncludeLoadingFrame
function LoadingFrame(aName,aUseMultipleFrames,aURL) {
  this.Name              = aName;
  this.UseMultipleFrames = isTrue(aUseMultipleFrames);
  this.LoadingFrames     = new Array();
  if(typeof(aURL)!='undefined'&&aURL!='') {
    this.LoadURL(aURL);
  }
  return;
}
LoadingFrame.prototype.LoadURL = function(aURL) {
  if(this.UseMultipleFrames) {
    return this.Load_Asynchronous(aURL);
  } else {
    return this.Load_Serial(aURL,0);
  }
}
LoadingFrame.prototype.CreateIframe = function(aFrameIndex) {
  var zOwner = null;
  if(document.getElementById('GlobalHiddenDiv')){
    zOwner = document.getElementById('GlobalHiddenDiv');
  }else if(document.getElementsByTagName('BODY')[0]){
    zOwner = document.getElementsByTagName('BODY')[0];
  }
  if(!zOwner){ return false; }
  var zNewFrame              = document.createElement('IFRAME');
  zNewFrame.name             = this.Name +'_Iframe_'+ aFrameIndex;
  zNewFrame.id               = this.Name +'_Iframe_'+ aFrameIndex;
  zNewFrame.style.visibility = 'hidden';
  zNewFrame.style.position   = 'absolute';
  zNewFrame.style.top        = '0px';
  zNewFrame.style.left       = '0px';
  zNewFrame.style.width      = '1px';
  zNewFrame.style.hieght     = '1px';
  zNewFrame.src              = '/lsglobal/blank.htm';
  zOwner.appendChild(zNewFrame);
  return zNewFrame;
}
LoadingFrame.prototype.Load_Serial = function(aURL,aFrameIndex) {
  if(!this.LoadingFrames[aFrameIndex]) {
    var zNewFrame = this.CreateIframe(aFrameIndex);
    if(zNewFrame){
      this.LoadingFrames[aFrameIndex] = zNewFrame;
    }else{
      return false;
    }
  }
  if(this.LoadingFrames[aFrameIndex].src == aURL) {
    aURL = setURLVariable('aLocalCacheBuster', new Date().valueOf(), aURL,false)
  }
  this.LoadingFrames[aFrameIndex].src = aURL;
  return this.LoadingFrames[aFrameIndex];
}
LoadingFrame.prototype.Load_Asynchronous = function(aURL) {
  var x,zFrame=null;
  var zLoaded = false;
  for(x=0;x<this.LoadingFrames.length;x++) {
    if(window[this.Name +'_Iframe_'+ x]&&window[this.Name +'_Iframe_'+ x].fFrameLoaded) {
      window[this.Name +'_Iframe_'+ x].fFrameLoaded = false;
      return this.Load_Serial(aURL,x);
    }
  }
  if(!zLoaded) {
    zFrame = this.Load_Serial(aURL,this.LoadingFrames.length);
  }
  return zFrame;
}
// End JSIncludeFile:Action_JSIncludeLoadingFrame
// Start JSIncludeFile:Action_JSIncludeLiveRequest
function LiveRequestObject(aCompleteFunction,aCompleteParamObject) {
  this.URLArray = new Array();
  this.LoadedURLArray = new Array();
  this.LoadFunctionArray = new Array();
  this.CompleteFunction = aCompleteFunction;
  this.CompleteParamObject = aCompleteParamObject;
  this.Method = 'GET';
  this.PostValues = null;
  this.Asynchronous = true;
  this.TextOnly = false;
  this.Id = "RequestObject_"+UniqueVar();
  LiveRequestObject.RequestObjectList[this.Id] = this;
  this.RequestList = new Object();
}
LiveRequestObject.RequestObjectList = new Object();
LiveRequestObject.prototype.AddRequest = function(aURL,aOnLoadFunction,aOnLoadParamObject) {
  this.URLArray[this.URLArray.length] = aURL;
  this.LoadFunctionArray[this.LoadFunctionArray.length] = {Function: aOnLoadFunction, Params: aOnLoadParamObject, Loaded: false};
}
LiveRequestObject.prototype.LoadRequests = function() {
  for(var x = 0; x < this.URLArray.length; x++) {
    if(!this.LoadFunctionArray[x].Loaded) {
      this.MakeRequest(this.URLArray[x],this.LoadFunctionArray[x].Function,this.LoadFunctionArray[x].Params,this.LoadFunctionArray[x]);
    }
  }
}
LiveRequestObject.prototype.UpdateStatus = function(aLoadObject) {
  if(aLoadObject) {
    aLoadObject.Loaded = true;
    var zDone = true;
    if(this.CompleteFunction) {
      for(var x = 0; x < this.URLArray.length; x++) {
        if(!this.LoadFunctionArray[x].Loaded) {
          zDone = false;
        }
      }
      if(zDone) {
        this.CompleteFunction(this.CompleteParamObject);
      }
    }
  }
  return true;
}
LiveRequestObject.prototype.MakeRequest = function(aURL,aOnLoadFunction,aOnLoadParamObject, aLoadObject) {
  var zRequestId = "Request_"+UniqueVar();
  var zReq = false;
  if(window.XMLHttpRequest) {
    try {
      zReq = new XMLHttpRequest();
    }
    catch(e) {
      zReq = false;
    }
  } else if(window.ActiveXObject) {
    try {
      zReq = new ActiveXObject('Msxml2.XMLHTTP');
    }
    catch(e) {
      try {
        zReq = new ActiveXObject('Microsoft.XMLHTTP');
      }
      catch(e) {
        zReq = false;
      }
    }
  }
  if(zReq) {
    this.HttpRequest = zReq;
    if(fGlobalPointer&&fGlobalPointer.Browser&&fGlobalPointer.Browser.isSafari){
      aURL = setURLVariable('aCacheBust',UniqueVar(),aURL,false);
    }
    var zSendContent = null;
    zReq.open(this.Method, aURL, true);
    if(this.Method=='POST'){
      zReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    }
    if(this.PostValues){
      var zPostVars = [];
      for(var zKey in this.PostValues){
        zPostVars.push(zKey +'='+ escape(this.PostValues[zKey]));
      }
      zSendContent = zPostVars.join('&').replace(/\+/g,'%2B');
    }
    var zLiveRequestObject = this;
    var zLoadObject = aLoadObject;
    zReq.onreadystatechange = function () {
      var zRequestObject = zLiveRequestObject;
      var zRequest = zReq;
      var zFunc = aOnLoadFunction;
      var zParamObject = aOnLoadParamObject;
      var zUseLoadObject = zLoadObject;
      if(zRequest.readyState==4) {
        try {
          if(zRequestObject.TextOnly) {
            var zObject = zRequest.responseText.Trim();
          } else {
            eval("var zObject = "+zRequest.responseText);
          }
        }
        catch(e) {
        }
        zFunc(zObject,zParamObject);
        zRequestObject.UpdateStatus(zUseLoadObject);
      }
    }
    zReq.send(zSendContent);
  } else {
    if(!LiveRequestObject.LoadingFrame) {
      LiveRequestObject.LoadingFrame = new LoadingFrame(this.Id+'_Loader', true,'',true);
    }
    var zFrame = LiveRequestObject.LoadingFrame.LoadURL(aURL);
    this.RequestList[zRequestId] = {
      LoadingFrame: zFrame,
      LoadFunction: aOnLoadFunction,
      LoadParamObject: aOnLoadParamObject,
      LoadObject: aLoadObject
    };
    setTimeout('LiveRequestCheckIframe(\''+ this.Id +'\',\''+ zRequestId +'\')',50);
  }
}
function LiveRequestCheckIframe(aRequestObjectId,aRequestId) {
  var zRequest = LiveRequestObject.RequestObjectList[aRequestObjectId].RequestList[aRequestId];
  var zFrameId = zRequest.LoadingFrame.id;
  var zFrame;
  var zTryAgain = false;
  if(fGlobalPointer.Browser.isSafari) {
    zFrame = document.getElementById(zFrameId);
  }
  else {
    zFrame = document.frames[zFrameId];
  }
  if(zFrame) {
    if(typeof(zFrame.document) != 'undefined') {
      if(typeof(zFrame.document.documentElement) != 'undefined' && typeof(zFrame.document.documentElement.innerText) != 'undefined' && zFrame.document.documentElement.innerText != '') {
        try {
          if(LiveRequestObject.RequestObjectList[aRequestObjectId].TextOnly) {
            var zObject = zFrame.document.documentElement.innerText.Trim();
          }
          else {
            eval("var zObject = "+zFrame.document.documentElement.innerText);
          }
        }
        catch(e) {
          zTryAgain = true;
        }
        if(!zTryAgain) {
          zRequest.LoadFunction(zObject,zRequest.LoadParamObject);
          LiveRequestObject.RequestObjectList[aRequestObjectId].UpdateStatus(zRequest.LoadObject);
        }
      }
      else{
        zTryAgain = true;
      }
    }
    else {
      zTryAgain = true;
    }
    if(zTryAgain) {
      setTimeout('LiveRequestCheckIframe(\''+ aRequestObjectId +'\',\''+ aRequestId +'\')',100);
    }
  }
}
function LiveRequest_MakeRequest(aURL,aOnLoadFunction,aOnLoadParamObject) {
  var zRequestObject =  new LiveRequestObject();
  zRequestObject.MakeRequest(aURL,aOnLoadFunction,aOnLoadParamObject);
  return zRequestObject;
}
function LiveRequest_MakeTextRequest(aURL,aOnLoadFunction,aOnLoadParamObject) {
  var zRequestObject =  new LiveRequestObject();
  zRequestObject.TextOnly = true;
  zRequestObject.MakeRequest(aURL,aOnLoadFunction,aOnLoadParamObject);
  return zRequestObject;
}
function LiveRequest_PostRequest(aURL,aPostValues,aOnLoadFunction,aOnLoadParamObject) {
  var zRequestObject =  new LiveRequestObject();
  zRequestObject.Method = 'POST';
  zRequestObject.PostValues = aPostValues;
  zRequestObject.MakeRequest(aURL,aOnLoadFunction,aOnLoadParamObject);
  return zRequestObject;
}
function LiveRequest_PostTextRequest(aURL,aPostValues,aOnLoadFunction,aOnLoadParamObject) {
  var zRequestObject =  new LiveRequestObject();
  zRequestObject.TextOnly = true;
  zRequestObject.Method = 'POST';
  zRequestObject.PostValues = aPostValues;
  zRequestObject.MakeRequest(aURL,aOnLoadFunction,aOnLoadParamObject);
  return zRequestObject;
}
function makeRequest(aParams) {
  var zParams = aParams.Params || aParams;
  var zCompleteParams = aParams.CompleteParams || zParams;
  var zCompleteFunction = aParams.CompleteFunction || null;
  var zRequestObject =  new LiveRequestObject(zCompleteFunction, zCompleteParams);
  if(aParams.TextOnly) {
    zRequestObject.TextOnly = isTrue(aParams.TextOnly);
  }
  if(aParams.PostValues) {
    zRequestObject.PostValues = aParams.PostValues;
  }
  if(aParams.Method) {
    zRequestObject.Method = aParams.Method;
  }
  zRequestObject.MakeRequest(aParams.URL,aParams.Function,zParams,aParams);
  return zRequestObject;
}
function LiveRequest_ThreadHandler (aQueuedItems, aMaxThreads, aThreadInterval, aFinishFunction, aFinishParams) {
  this.Id = UniqueVar();
  this.MaxThreads = 3;
  this.ThreadInterval = 0;
  this.Total = 0;
  this.Completed = 0;
  this.Active = 0;
  this.Waiting = 0;
  this.QueuedItems = (aQueuedItems) ? aQueuedItems : new Array();
  this.ActiveList = new Array();
  this.CompletedList = new Array();
  this.Paused = false;
  this.Canceled = false;
  this.Finished = false;
  this.Total = this.QueuedItems.length;
  this.ThreadInterval = (!isNaN(aThreadInterval)&&aThreadInterval>=0) ? aThreadInterval : 500;
  this.MaxThreads = (aMaxThreads) ? aMaxThreads : this.MaxThreads;
  this.FinishFunction = (aFinishFunction) ? aFinishFunction : null;
  this.FinishParams = (aFinishParams) ? aFinishParams : null;
}
LiveRequest_ThreadHandler.prototype.UpdateTotal = function () {
  this.Total++;
}
LiveRequest_ThreadHandler.prototype.Requeue = function(aQueuedItem) {
  this.QueuedItems.push(aQueuedItem);
}
LiveRequest_ThreadHandler.prototype.Queue = function (aQueuedItem) {
  if(!this.Canceled) {
    this.QueuedItems.push(aQueuedItem);
    this.UpdateTotal();
    if(this.Finished) {
      this.Finished = false;
      this.Start();
    }
    return true;
  }
  return false;
}
LiveRequest_ThreadHandler.prototype.Start = function() {
  if(!this.Canceled&&!this.Paused) {
    if(this.QueuedItems.length>0) {
      if(this.ActiveList.length<this.MaxThreads) {
        var zQueuedItem = this.QueuedItems.shift();
        if(zQueuedItem&&!zQueuedItem.RequestSetTimeout) {
          if(this.ActiveList.length<this.MaxThreads) {
            this.Run(zQueuedItem);
          }
        }
        this.Start();
      }
      else {
        var zThisLiveRequest_ThreadHandler = this;
        setTimeout(function(){zThisLiveRequest_ThreadHandler.Start();},zThisLiveRequest_ThreadHandler.ThreadInterval);
      }
    }
    else if(this.ActiveList.length<=0&&!this.Finished) {
      this.Finish();
      return true;
    }
    return true;
  }
}
LiveRequest_ThreadHandler.prototype.Run = function (aQueuedItem) {
  this.ActiveList.push(aQueuedItem);
  this.Active = this.ActiveList.length;
  var zThisLiveRequest_ThreadHandler = this;
  aQueuedItem.RequestTimeout = setTimeout(function(){zThisLiveRequest_ThreadHandler.Execute(aQueuedItem);},zThisLiveRequest_ThreadHandler.ThreadInterval);
}
LiveRequest_ThreadHandler.prototype.Execute = function (aQueuedItem) {
  var zThisLiveRequest_ThreadHandler = this;
  if(!this.Canceled&&!this.Paused) {
    var zRequestParams = {
      URL: aQueuedItem.URL,
      Function: aQueuedItem.Function,
      Params: aQueuedItem.Params,
      CompleteFunction: function(){zThisLiveRequest_ThreadHandler.Complete({QueuedItem: aQueuedItem, QueuedItemCompleteFunction: aQueuedItem.CompleteFunction, QueuedItemCompleteParams: aQueuedItem.CompleteParams});},
      CompleteParams: {QueuedItem: aQueuedItem, QueuedItemCompleteFunction: aQueuedItem.CompleteFunction, QueuedItemCompleteParams: aQueuedItem.CompleteParams},
      TextOnly: aQueuedItem.TextOnly,
      PostValues: aQueuedItem.PostValues,
      Method: aQueuedItem.Method
    };
    makeRequest(zRequestParams);
  }
}
LiveRequest_ThreadHandler.prototype.Cancel = function () {
  this.Canceled = true;
}
LiveRequest_ThreadHandler.prototype.Pause = function () {
  this.Paused = true;
}
LiveRequest_ThreadHandler.prototype.Resume = function () {
  this.Paused = false;
  this.Start();
}
LiveRequest_ThreadHandler.prototype.Complete = function (aCompletedParams) {
  this.CompletedList.push(aCompletedParams.QueuedItem);
  this.Completed++;
  var zQueuedItemActiveIndex = this.ActiveList.indexOf(aCompletedParams.QueuedItem);
  this.ActiveList.splice(zQueuedItemActiveIndex,1);
  this.Active = this.ActiveList.length;
  this.Start();
  if(aCompletedParams.QueuedItemCompleteFunction) {
    aCompletedParams.QueuedItemCompleteFunction(aCompletedParams.QueuedItemCompleteParams);
  }
}
LiveRequest_ThreadHandler.prototype.Finish = function () {
  this.Finished = true;
  if(this.FinishFunction) {
   this.FinishFunction(this.FinishParams);
  }
}
LiveRequest_ThreadHandler.prototype.GetStats = function () {
  return {Total: this.Total, Active: this.Active, Completed: this.Completed, PercentComplete: ((this.Completed/this.Total)*100), Paused: this.Paused, Canceled: this.Canceled, Finished: this.Finished};
}
// End JSIncludeFile:Action_JSIncludeLiveRequest
// Start JSIncludeFile:Action_JSIncludeActivityOptions
function ActivityOptionsContainerObject(aId) {
  this.Id = aId
  this.ActiveLink = null;
  this.ActiveOptionType = null;
  this.ActivePagePath = null;
  this.OptionTypeList = {};
  var zContainer = document.createElement('div');
  zContainer.setAttribute('name',this.Id+'_Container');
  zContainer.setAttribute('id',this.Id+'_Container');
  zContainer.setAttribute("class", "ActivityOptionContainer");
  zContainer.setAttribute("className", "ActivityOptionContainer");
  this.Container = zContainer;
  return this;
}
ActivityOptionsContainerObject.prototype.DisplayOptionArray = function(e,aLink,aOptionArray, aExtraParams, aWindowOptions, aLoadOptionLinkInPopup) {
  this.TemporaryOptions = this.AddActivityOptionType(this.Id+".TemporaryOptions", "", aExtraParams, aWindowOptions, aLoadOptionLinkInPopup);
  for(var i = 0; i < aOptionArray.length; i++) {
    this.TemporaryOptions.AddOption(aOptionArray[i][0],'','',aOptionArray[i][1]);
  }
  this.TemporaryOptions.DisplayOptions(e,aLink);
}
ActivityOptionsContainerObject.prototype.CloseOptions = function() {
  if(this.ActiveLink) {
    document.body.removeChild(this.Container);
  }
  this.ActiveOptionType = null;
  this.ActivePagePath = null;
  this.ActiveLink = null;
  return true;
}
ActivityOptionsContainerObject.prototype.AddActivityOptionType = function(aId,aName, aExtraParams, aWindowOptions, aLoadOptionLinkInPopup) {
  var zNewOptionType = new ActivityOptionTypeObject(aId,aName, aExtraParams, aWindowOptions, aLoadOptionLinkInPopup)
  this.OptionTypeList[aId] = zNewOptionType;
  zNewOptionType.Owner = this;
  return zNewOptionType;
}
function ActivityOptionTypeObject(aId, aName, aExtraParams, aWindowOptions, aLoadOptionLinkInPopup) {
  this.Id = aId;
  this.Name = aName || '';
  this.ExtraParams = aExtraParams || '';
  this.WindowOptions = aWindowOptions || '';
  this.LoadOptionLinkInPopup = isTrue(aLoadOptionLinkInPopup,true);
  this.OptionList = new Array();
}
ActivityOptionTypeObject.prototype.DisplayOptions = function(e,aLink,aPagePath) {
  try {
    aLink.blur();
  } catch(e) {
  }
  if(this.Owner.ActiveLink && this.Owner.ActiveLink == aLink) {
    this.Owner.CloseOptions();
    return true;
  }
  this.Owner.ActiveOptionType = this;
  this.Owner.ActivePagePath = aPagePath;
  if(this.OptionList.length == 1) {
    this.LoadOption(0);
    return true;
  }
  this.Owner.ActiveLink = aLink;
  var zOptionHtmlArray = new Array();
  zOptionHtmlArray[zOptionHtmlArray.length] = '<span><span class="ActivityOptionClose" onclick="'+this.Id+'.Owner.CloseOptions()" target="_self">X</span><div class="ActivityOptionTitle">'+this.Name+'&nbsp;</div>';
  for(var i = 0; i < this.OptionList.length; i++) {
    zOptionHtmlArray[zOptionHtmlArray.length] = '<a href="javascript: void(0);" class="ActivityOptionLink" onclick="'+this.Id+'.LoadOption('+i+'); return false" target="_self">'+this.OptionList[i].DisplayHtml+'</a>'
  }
  zOptionHtmlArray[zOptionHtmlArray.length] = '</span>';
  var zHtmlContainer = this.Owner.Container;
  var zActiveContainer = document.body.appendChild(this.Owner.Container);
  zActiveContainer.innerHTML = zOptionHtmlArray.join('');
  PlaceElementInView(zActiveContainer,'',e.clientX+5,e.clientY+22);
  return true;
}
ActivityOptionTypeObject.prototype.LoadOption = function(aOptionIndex) {
  var zOption, zUrl, zURLParts;
  zOption = this.OptionList[aOptionIndex];
  if(zOption.FullUrl) {
    zUrl = AppendToUrl(AppendToUrl(zOption.FullUrl,this.ExtraParams),zOption.ExtraParams);
  }
  else {
    zUrl = AppendToUrl(AppendToUrl(this.Owner.ActivePagePath+zOption.PathSuffix+'.'+zOption.Action,this.ExtraParams),zOption.ExtraParams);
  }
  if(this.LoadOptionLinkInPopup || zOption.LoadOptionLinkInPopup) {
    zUrl = AppendToUrl(zUrl,'aIsPopup=Y');
    var zNewWindow = window.open(zUrl, '', this.WindowOptions)
  }
  else {
    LoadUrlUsingBaseTarget(zUrl);
  }
  this.Owner.CloseOptions();
  return true;
}
ActivityOptionTypeObject.prototype.AddOption = function(aDisplayHtml, aAction, aExtraParams, aFullUrl, aPathSuffix, aLoadOptionLinkInPopup) {
  var zNewOption = new ActivityOptionObject(aDisplayHtml, aAction, aExtraParams, aFullUrl, aPathSuffix, isTrue(aLoadOptionLinkInPopup,this.LoadOptionLinkInPopup));
  this.OptionList[this.OptionList.length] = zNewOption;
  return zNewOption;
}
function ActivityOptionObject(aDisplayHtml, aAction, aExtraParams, aFullUrl, aPathSuffix, aLoadOptionLinkInPopup) {
  this.DisplayHtml = aDisplayHtml;
  this.Action = aAction;
  this.ExtraParams = aExtraParams;
  this.FullUrl = aFullUrl;
  this.PathSuffix = (typeof(aPathSuffix) == 'undefined') ? '' : aPathSuffix;
  this.LoadOptionLinkInPopup = aLoadOptionLinkInPopup;
}
var fActivityOptions = new ActivityOptionsContainerObject("fActivityOptions");
var ActivityOptions = {
  Show: function(e,aParams) {
    fixEvent(e);
    try {
      e.target.blur();
    } catch(e) {
    }
    if(fActivityOptions.ActiveLink && fActivityOptions.ActiveLink == e.target) {
      ActivityOptions.Hide(e);
      return true;
    }
    if(typeof aParams.length == 'number') {
      aOptionsArray = aParams;
      zTitle = "";
    }
    else {
      zTitle = aParams.Title || "";
      aOptionsArray = aParams.Options;
    }
    fActivityOptions.ActiveOptionType = aOptionsArray;
    fActivityOptions.ActiveLink = e.target;
    document.body.appendChild(fActivityOptions.Container);
    fActivityOptions.Container.innerHTML = '<span><span class="ActivityOptionClose" onclick="fActivityOptions.CloseOptions()" target="_self">X</span><div class="ActivityOptionTitle">'+zTitle+'&nbsp;</div></span>';
    aOptionsArray.forEach(function(aOption) {
      var zSpan = CreateBasicElement("span",null,"ActivityOptionLink");
      fActivityOptions.Container.childNodes[0].appendChild(zSpan);
      zSpan.innerHTML = aOption.DisplayName;
      if(aOption.Class) {
        AddClass(zSpan,aOption.Class);
      }
      appendEventHandler(zSpan, "onclick", ActivityOptions.Hide);
      appendEventHandler(zSpan, "onclick", aOption.Function, aOption.Params);
      MakeHoverable(zSpan);
    });
    PlaceElementInView(fActivityOptions.Container,'',e.clientX+5,e.clientY+22);
    return true;
  },
  Hide: function(e) {
    fActivityOptions.CloseOptions();
    return true;
  },
  AddParams: function(aOptionsArray,aParamObject) {
    var zOptions = [];
    aOptionsArray.forEach(function(aOption) {
      var zOption = CopyObject(aOption);
      zOptions.push(zOption);
      if(!zOption.Params) {
        zOption.Params = CopyObject(aParamObject);
      }
      else {
        CopyProperties(aParamObject,zOption.Params,true);
      }
    });
    return zOptions;
  },
  Append: function(aElement,aOptionsArray,aParamObject) {
    appendEventHandler(aElement, "onclick", ActivityOptions.Show, ActivityOptions.AddParams(aOptionsArray,aParamObject));
    return true;
  }
};
  var fLiveJournal_ActivityOptions = fActivityOptions.AddActivityOptionType("fLiveJournal_ActivityOptions","Create Journal Entry","","width=320,height=370,status=1,resizable=1,scrollbars=1");
  var zLiveJournal_ImageArray = new Array();
// End JSIncludeFile:Action_JSIncludeActivityOptions
// Start JSIncludeFile:Action_JSIncludeSpellCheck
var popupUrl = "/Home.SpellCheckPopup?aLanguage=en-us&LSAccessID=";
var hidePreviewPanel=false;
var directMode=false;
var ww;
var spellCheckField=null;
var previewPanelWidth=450;
var previewPanelHeight=200;
var defaultWidth=240;
var defaultHeight=200;
function spellcheck(formField) {
  spellCheckField = formField;
 	var width = previewPanelWidth;
  var height = previewPanelHeight;
 	if (navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.toLowerCase().indexOf("opera")==-1 && hidePreviewPanel==false) {
 		 directmode = true;
    width = defaultWidth;
 	}
 	if(hidePreviewPanel==true) {
 		 width = defaultWidth;
	 }
 	var w = 1024, h = 768;
 	if (document.all || document.layers) {
 		 w = screen.availWidth;
    h = screen.availHeight;
 	}
 	var leftPos = (w/2-width/2);
  var topPos = (h/2-height/2);
 	ww = window.open(popupUrl, "", "width="+width+",height="+height+",top="+topPos+",left="+leftPos+",toolbar=no,status=no,menubar=yes,directories=no,resizable=yes");
 	ww.focus();
 	return true;
}
function getSpellCheckItem(jspell_n) {
 	var fieldsToCheck=getSpellCheckArray();
 	return fieldsToCheck[jspell_n];
}
function getSpellCheckArray() {
 	var fieldsToCheck=new Array();
 	fieldsToCheck[fieldsToCheck.length] = document.getElementById(spellCheckField);
 	return fieldsToCheck;
}
function updateForm(jspell_m,newvalue) {
  getSpellCheckItem(jspell_m).value = newvalue;
  if(getSpellCheckItem(jspell_m).getAttribute("onspellcheckupdate")) {
    eval(getSpellCheckItem(jspell_m).getAttribute("onspellcheckupdate"));
  }
}
function getSpellCheckItemValueValue(jspell_k) {
  return getSpellCheckItem(jspell_k).value;
}
var SpellChecker = {
  InitializeInput: function(aElement) {
    var zSpellCheckDiv = CreateBasicElement('DIV','SpellChecker_'+aElement.id,'SpellChecker')
    var zSpellCheckImg = CreateBasicElement('IMG','SpellCheckerImage_'+aElement.id,'SpellCheckerImage');
    zSpellCheckImage = new Image();
    zSpellCheckImage.src = '/l.c.bin/I/2798071/spellcheck2.gif';
    zSpellCheckImg.src = zSpellCheckImage.src;
    zSpellCheckDiv.appendChild(zSpellCheckImg);
    appendEventHandler(zSpellCheckDiv,'onclick',SpellChecker.SpellCheck,aElement);
    aElement.parentNode.insertBefore(zSpellCheckDiv,aElement.nextSibling);
    return true;
  },
  InitializeMultiple: function(aElementsIdArray) {
    aElementsIdArray.forEach(function(aElement) {
      SpellChecker.InitializeInput($(aElement.Id));
    });
  },
  SpellCheck: function(e,aElement) {
    spellcheck(aElement.id);
    return true;
  }
};
Widgets.Add({
  Id: "SpellChecker",
  Attribute: "spellcheck",
  Value: "Y",
  ElementInitFunction: SpellChecker.InitializeInput
});
// End JSIncludeFile:Action_JSIncludeSpellCheck
// Start JSIncludeFile:Action_JSIncludeFormControls
var fStylizedSelectIcon = new Image();
fStylizedSelectIcon.src = '/l.c.bin/I/2663439/DownArrow_16x16.gif';
var fLoadSelectIcon = new Image();
fLoadSelectIcon.src = '/l.c.bin/I/2838461/loading_15x15_anim.gif';
var fStylizedSelects = new StylizedSelectController("fStylizedSelects");
var fPageUsesStyledSelects = false;
var fDisableStylizedSelects = false;
var fLoadSelectController;
var fAlertDiv = null;
var fLabelElements = null;
appendEventHandler(window,'onload',InitializeFormControls);
function InitializeFormControls(){
  InitializeSelects();
  InitializeTextareaMaxLength();
  return true;
}
function MyAlert(aText) {
  return false;
}
function InitializeSelects() {
  fLoadSelectController = new LoadSelectControllerObject("fLoadSelectController");
  var zSelects = document.getElementsByTagName("SELECT");
  var zForms = document.getElementsByTagName("FORM");
  for(var h = 0; h < zForms.length; h++) {
    if(zForms[h].getAttribute("StylizedSelects") == "Y") {
      fPageUsesStyledSelects = true;
    }
  }
  for(var i = 0; i < zSelects.length; i++) {
    if(zSelects[i].getAttribute("src")) {
      fLoadSelectController.AddSelect(zSelects[i]);
    }
    if(IsStylizedSelect(zSelects[i])) {
      fPageUsesStyledSelects = true;
    }
  }
  if(fGlobalPointer.Browser.isMac && fGlobalPointer.Browser.isIE4up) {
    fDisableStylizedSelects = false;
  }
  if(fPageUsesStyledSelects && !fDisableStylizedSelects) {
    fLabelElements = document.getElementsByTagName("LABEL");
    for(var j = 0; j < zSelects.length; j++) {
      if(!zSelects[j].getAttribute("src") && zSelects[j].getAttribute("StylizedSelect") != "N") {
        fStylizedSelects.AddStylizedSelect(zSelects[j]);
      }
    }
    appendEventHandler(window,'onresize',UpdateStylizedSelectDropDownPositions);
  }
  else {
  }
  return true;
}
function LoadSelectControllerObject(aId) {
  this.Id = aId;
  this.LoadSelectList = new Object();
  this.LoadSelectArray = new Array();
  return this;
}
LoadSelectControllerObject.prototype.AddSelect = function(aSelect) {
  var zNewSelect = new LoadSelectObject(aSelect);
  zNewSelect.Index = this.LoadSelectArray.length;
  this.LoadSelectArray[this.LoadSelectArray.length] = zNewSelect;
  this.LoadSelectList[zNewSelect.Id] = zNewSelect;
  AddClass(zNewSelect.Select,"AbsolutelyHidden");
  zNewSelect.Select.parentNode.insertBefore(zNewSelect.LoadingImage,zNewSelect.Select);
  zNewSelect.Request = LiveRequest_MakeRequest(zNewSelect.Src,LoadSelectObject_ReceiveData,zNewSelect);
  return zNewSelect;
}
LoadSelectControllerObject.prototype.GetSelect = function(aId) {
  return this.LoadSelectList[aId];
}
function LoadSelectObject(aSelect) {
  this.Select = aSelect;
  this.Id = aSelect.id;
  this.Src = aSelect.getAttribute("src");
  this.SelectedValue = aSelect.getAttribute("SelectedValue");
  this.SelectedValueDelimiter = aSelect.getAttribute("SelectedValueDelimiter");
  this.Done = false;
  this.LoadingImage = CreateBasicElement("span",this.Id+"_LoadingImage","SelectLoadingImage");
  this.LoadingImage.innerHTML = '<im'+'g s'+'rc="'+fLoadSelectIcon.src+'" width="15" height="15" border="0" />';
  return this;
}
LoadSelectObject.prototype.AddOption = function(aText,aValue,aClass) {
  var zIndex = this.Select.length;
  this.Select[zIndex] = new Option(unescape(aText).HTMLDecode(),unescape(aValue));
  if (aClass){
    this.Select[zIndex].className = aClass;
  }
  return true;
}
LoadSelectObject.prototype.Loaded = function() {
  this.Done = true;
  this.Select.parentNode.removeChild(this.LoadingImage);
  RemoveClass(this.Select,"AbsolutelyHidden");
  if(!this.SelectedValueDelimiter) {
    this.Select.value = this.SelectedValue;
  }
  else if(this.SelectedValue != '') {
    var zSelectedValuesArray = this.SelectedValue.split(this.SelectedValueDelimiter);
    for (var zSelectedValueCount = 0; zSelectedValueCount < zSelectedValuesArray.length; zSelectedValueCount++) {
      for(var zSelectOptionCount = 0; zSelectOptionCount < this.Select.options.length; zSelectOptionCount++) {
        if(this.Select.options[zSelectOptionCount].value == zSelectedValuesArray[zSelectedValueCount]) {
          this.Select.options[zSelectOptionCount].selected = true;
          break;
        }
      }
    }
  }
  if(fPageUsesStyledSelects && !fDisableStylizedSelects && this.Select.getAttribute("StylizedSelect") != "N") {
    if(fStylizedSelects && fStylizedSelects.AddStylizedSelect && UpdateStylizedSelectDropDownPositions) {
      setTimeout("fStylizedSelects.AddStylizedSelect(document.getElementById('"+this.Select.id+"'));UpdateStylizedSelectDropDownPositions();",0);
    }
  }
  return true;
}
function LoadSelectObject_ReceiveData(aDataObject,aLoadSelect) {
  if(aDataObject) {
    for(var i = 0; i < aDataObject.length; i++) {
      aLoadSelect.AddOption(aDataObject[i].DisplayName,aDataObject[i].ItemPath,aDataObject[i].Class);
    }
  }
  aLoadSelect.Loaded();
  return true;
}
function IsStylizedSelect(aSelect) {
  if(aSelect.getAttribute("SmartSelect") == "Y") {
    aSelect.setAttribute("StylizedSelect","Y");
  }
  if(aSelect.getAttribute("StylizedSelect") == "Y") {
    return true;
  }
  else {
    return false;
  }
}
function StylizedSelectController(aId) {
  this.Id = aId;
  this.StylizedSelectList = new Object();
  this.StylizedSelectArray = new Array();
  this.ActiveStylizedSelect = null;
  return this;
}
StylizedSelectController.prototype.AddStylizedSelect = function (aSelect){
  var zNewSelect = CreateStylizedSelect(aSelect);
  zNewSelect.Index = this.StylizedSelectArray.length;
  zNewSelect.StylizedSelectController = this;
  this.StylizedSelectArray[this.StylizedSelectArray.length] = zNewSelect;
  this.StylizedSelectList[zNewSelect.Id] = zNewSelect;
  zNewSelect.Draw();
  return zNewSelect;
}
StylizedSelectController.prototype.GetSelect = function (aId){
  return this.StylizedSelectList[aId];
}
function CreateStylizedSelect(aSelect) {
  var zSize = aSelect.getAttribute("size") || 0;
  if(zSize == "1") {
    zSize = 0;
  }
  var zSmartSelect = isTrue(aSelect.getAttribute("SmartSelect"));
  var zStylizedSelectClass = StylizedSelectObject;
  if(zSize) {
    if(zSmartSelect) {
      zStylizedSelectClass = SmartMultiLineSelect;
    }
    else {
      zStylizedSelectClass = MultiLineSelect;
    }
  }
  else {
    if(zSmartSelect) {
      zStylizedSelectClass = SmartDropDownSelect;
    }
    else {
      zStylizedSelectClass = DropDownSelect;
    }
  }
  return new zStylizedSelectClass(aSelect);
}
function StylizedSelectOption(aText,aValue,aClass,aOptGroupLabel) {
  this.Value = aValue;
  this.Text = aText;
  this.Class = aClass;
  this.OptGroupLabel = aOptGroupLabel;
  return this;
}
function StylizedSelectObject(aSelect) {
  if(arguments.length == 0) {return false};
  this.Select = aSelect;
  this.Id = this.Select.id;
  this.Multiple = this.Select.multiple;
  this.Size = this.Select.getAttribute("size") || 0;
  if(this.Size == "1") {
    this.Size = 0;
  }
  this.OnChange = (this.Select.onchange != null && this.Select.onchange != 'undefined') ? this.Select.onchange : null ;
  this.SelectWidth = this.Select.offsetWidth || this.Select.getAttribute("SelectWidth") || 200;
  this.OptionElementArray = new Array();
  if(!this.Size) {
    this.SelectHeight = this.Select.getAttribute("SelectHeight") || document.body.offsetHeight;
  }
  else {
    this.SelectHeight = this.Select.offsetHeight;
  }
  this.InputWidth = this.Select.getAttribute("InputWidth") || this.SelectWidth;
  this.OriginalSelectedIndex = this.Select.selectedIndex;
  this.OriginalSelectedOptionArray = new Array();
  this.SelectedOptionIndex = this.OriginalSelectedIndex;
  this.SelectedOptionArray = new Array();
  this.FocusedElement = null;
  this.OriginalOptionArray = new Array();
  this.ActiveOptionArray = new Array();
  for(var i = 0; i < this.Select.options.length; i++) {
    this.OriginalOptionArray[i] = new StylizedSelectOption(this.Select.options[i].text,this.Select.options[i].value,this.Select.options[i].className,(this.Select.options[i].parentNode.tagName=='OPTGROUP' ? this.Select.options[i].parentNode.label:null));
    this.OriginalOptionArray[i].OriginalArrayIndex = i;
  }
  this.OptGroups = new Object();
  return this;
}
function DropDownSelect(aSelect) {
  this.HasTextInput = true;
  this.IsDropDown = true;
  this.inherited = StylizedSelectObject;
  this.inherited(aSelect);
}
DropDownSelect.prototype = new StylizedSelectObject;
function SmartDropDownSelect(aSelect) {
  this.HasTextInput = true;
  this.IsDropDown = true;
  this.IsSmartSelect = true;
  this.inherited = StylizedSelectObject;
  this.inherited(aSelect);
}
SmartDropDownSelect.prototype = new StylizedSelectObject;
function MultiLineSelect(aSelect) {
  this.HasTextInput = false;
  this.IsDropDown = false;
  this.inherited = StylizedSelectObject;
  this.inherited(aSelect);
}
MultiLineSelect.prototype = new StylizedSelectObject;
function SmartMultiLineSelect(aSelect) {
  this.HasTextInput = true;
  this.IsDropDown = false;
  this.inherited = StylizedSelectObject;
  this.inherited(aSelect);
}
SmartMultiLineSelect.prototype = new StylizedSelectObject;
StylizedSelectObject.prototype.Draw = function() {
  this.IsDrawing = true;
  var zInlineHtml = new Array();
  var zStylizedSelectHtml;
  var zContainerPositionObject;
  var zSelectContainer;
  var zStyledSelectPosition = "absolute";
  var zInputReadOnly = "";
  var zInputCursor = "";
  if(!this.IsDropDown) {
    zStyledSelectPosition = "relative";
  }
  this.Container = CreateBasicElement("span",this.Id+"_Container","StylizedSelectContainer","width: "+this.InputWidth+"px; position: relative; top: 0px; left: 0px;");
  this.Container.style.width = this.InputWidth + "px";
  this.Container.style.position = "relative";
  this.Container.style.top = "0px";
  this.Container.style.left = "0px";
  this.Select.parentNode.insertBefore(this.Container,this.Select);
  zStylizedSelectHtml = '<span class="StylizedSelect" name="'+this.Id+'_StylizedSelect" id="'+this.Id+'_StylizedSelect" '
                      +   'style="width: '+this.SelectWidth+'px; height: '+this.SelectHeight+'px; z-index: 500; visibility: hidden;" '
+   'onmousedown="fStylizedSelects.GetSelect(\''+this.Id+'\').ResetFocusFromSelect();"'
                      +   'onscroll="fStylizedSelects.GetSelect(\''+this.Id+'\').ResetFocusFromSelect();"'
                      + '>'
                      +   this.GetOptionsHtml(this.OriginalOptionArray)
                      + '</span>';
  if(this.HasTextInput) {
    if(!this.IsSmartSelect) {
      zInputReadOnly = "readonly";
      zInputCursor = " cursor: default;"
    }
    zInlineHtml[zInlineHtml.length] = '<span name="'+this.Id+'_InputContainer" id="'+this.Id+'_InputContainer" class="StylizedSelectInputContainer" style="width: '+this.InputWidth+'px; white-space: nowrap;">'
                                    +   '<input type="text" name="'+this.Id+'_Text" id="'+this.Id+'_Text" value="" class="StylizedSelectTextInput" style="height: 18px; width: '+Math.max((this.InputWidth-20),6)+'px;'+zInputCursor+'" autocomplete="off" '
                                    +     'onkeydown="fStylizedSelects.GetSelect(\''+this.Id+'\').ClearMatchOptionsTimeout();" '
                                    +     'onkeyup="fStylizedSelects.GetSelect(\''+this.Id+'\').SetKeyValue(event);" '
                                    +     'onkeypress="return fStylizedSelects.GetSelect(\''+this.Id+'\').HandleEnterKey(event);" '
                                    +     'onclick="fStylizedSelects.GetSelect(\''+this.Id+'\').OpenSelectFromInput();" '
                                    +     'onblur="fStylizedSelects.GetSelect(\''+this.Id+'\').SetBlur();" '
                                    +     zInputReadOnly
                                    +   ' />'
                                    +   '<im'+'g name="'+this.Id+'_Icon" id="'+this.Id+'_Icon" s'+'rc="'+fStylizedSelectIcon.src+'" width="16" height="16" border="0" class="StylizedSelectIcon" style="cursor: pointer; cursor: hand;" onclick="fStylizedSelects.GetSelect(\''+this.Id+'\').FocusInput();" />'
                                    + '</span>';
  }
  else {
    zInlineHtml[zInlineHtml.length] = '<a h'+'ref="javascript: void(0);" id="'+this.Id+'_StylizedSelect_Focus" style="position: absolute; top 0px; left: 0px;" '
                                    +   'onkeyup="fStylizedSelects.GetSelect(\''+this.Id+'\').SetKeyValue(event);" '
                                    +   'onkeypress="return fStylizedSelects.GetSelect(\''+this.Id+'\').HandleEnterKey(event);" '
                                    +   'onblur="fStylizedSelects.GetSelect(\''+this.Id+'\').SetBlur();" '
                                    + '></a>';
  }
  if(this.IsDropDown) {
    zSelectContainer = CreateBasicElement("span",this.Id+"_SelectContainer","","width: "+this.SelectWidth+"px; position: absolute; top: 0px; left: 0px;");
    zSelectContainer.style.position = "absolute";
    zSelectContainer.style.top = "0px";
    zSelectContainer.style.left = "0px";
    document.body.appendChild(zSelectContainer);
    zSelectContainer.innerHTML = zStylizedSelectHtml;
  }
  else {
    zInlineHtml[zInlineHtml.length] = '<span name="'+this.Id+'_SelectContainer" id="'+this.Id+'_SelectContainer" style="position: relative; top: 0px; left: 0px; width: '+this.SelectWidth+'px;">'
                                    +   zStylizedSelectHtml
                                    + '</span>';
  }
  this.Container.innerHTML = zInlineHtml.join('');
  this.SelectContainer = document.getElementById(this.Id+'_SelectContainer');
  this.StylizedSelect = document.getElementById(this.Id+'_StylizedSelect');
  this.NoMatch = document.getElementById(this.Id+'_StylizedSelectNoMatch');
  this.Select.className = "AbsolutelyHidden";
  for(var j = 0; j < this.Select.options.length; j++) {
    this.OptionElementArray[j] = document.getElementById(this.Id+'_StylizedSelect_Option'+j);
    this.ActiveOptionArray[j] = this.OriginalOptionArray[j];
  }
  if(this.HasTextInput) {
    this.InputContainer = document.getElementById(this.Id+'_InputContainer');
    this.TextInput = document.getElementById(this.Id+'_Text');
    this.Icon = document.getElementById(this.Id+'_Icon');
    if(this.IsDropDown) {
      this.UpdateDropDownPosition();
    }
    this.FocusElement = this.TextInput;
  }
  else {
    this.FocusHandler = document.getElementById(this.Id+'_StylizedSelect_Focus');
    this.FocusElement = this.FocusHandler;
  }
  if(fLabelElements) {
    for(var l = 0; l < fLabelElements.length; l++) {
      if(fLabelElements[l] && fLabelElements[l]["htmlFor"] && fLabelElements[l]["htmlFor"] == this.Id) {
        if(this.HasTextInput) {
          try {
            fLabelElements[l].setAttribute("for",this.FocusElement.id);
            fLabelElements[l].setAttribute("htmlFor",this.FocusElement.id);
          }
          catch(e) {
          }
        }
      }
    }
  }
  this.InitializeSelectedOption();
  this.ResizeSelect();
  this.HideSelect();
  this.StylizedSelect.style.visibility = "visible";
  this.IsDrawing = false;
  return this;
}
StylizedSelectObject.prototype.GetOptionsHtml = function(aOptionArray) {
  var zOptions = new Array();
  var zCurrentGroupLabel = null,zLastGroupLabel = null,zSubItemClass='';
  var zLastGroupIndex = null;
  for(var i = 0; i < aOptionArray.length; i++) {
    zCurrentGroupLabel = aOptionArray[i].OptGroupLabel;
    if(zCurrentGroupLabel){
      zSubItemClass = ' SubOption';
      if(zCurrentGroupLabel!=zLastGroupLabel){
        zLastGroupIndex = i;
        this.OptGroups['Group'+ zLastGroupIndex] = {Options:{}};
        zOptions[zOptions.length] = '<span class="StylizedSelectOption OptGroup" id="'+this.Id+'_StylizedSelect_Option'+i+'Group" value="" '
                              +   'onmouseover="AddClass(this,\'Hover\');" '
                              +   'onmouseout="RemoveClass(this,\'Hover\');" '
     +   'onmousedown="fStylizedSelects.GetSelect(\''+this.Id+'\').ToggleOptGroup('+i+');"'
                              +   '>'+(aOptionArray[i].OptGroupLabel || '&nbsp;')+'</span>';
      }
      this.OptGroups['Group'+ zLastGroupIndex].Options['Option'+ i] = i;
    }
    zOptions[zOptions.length] = '<span class="StylizedSelectOption'+ zSubItemClass +'" id="'+this.Id+'_StylizedSelect_Option'+i+'" value="'+aOptionArray[i].Value+'" '
                              +   'onmouseover="fStylizedSelects.GetSelect(\''+this.Id+'\').HoverOption('+i+',true);" '
                              +   'onmouseout="fStylizedSelects.GetSelect(\''+this.Id+'\').HoverOption('+i+',false);" '
         +   'onmousedown="fStylizedSelects.GetSelect(\''+this.Id+'\').ToggleOption('+i+');"'
                              +   '>'+(aOptionArray[i].Text || '&nbsp;')+'</span>';
    zLastGroupLabel = zCurrentGroupLabel;
    zSubItemClass = '';
  }
  zOptions[zOptions.length] = '<span class="StylizedSelectNoMatch" id="'+this.Id+'_StylizedSelectNoMatch" style="display: none;">No Matches Found.</span>';
  return zOptions.join('\n');
}
StylizedSelectObject.prototype.UpdateOptionElementArray = function() {
  this.OptionElementArray = new Array();
  for(var j = 0; j < this.Select.options.length; j++) {
    this.OptionElementArray[j] = document.getElementById(this.Id+'_StylizedSelect_Option'+j);
  }
}
function UpdateStylizedSelectDropDownPositions() {
  for(var i = 0; i < fStylizedSelects.StylizedSelectArray.length; i++) {
    if(fStylizedSelects.StylizedSelectArray[i].IsDropDown) {
      fStylizedSelects.StylizedSelectArray[i].UpdateDropDownPosition();
    }
  }
  return true;
}
StylizedSelectObject.prototype.UpdateDropDownPosition = function() {
  var zAddTop = 0;
  var zContainerPositionObject = getAbsolutePosition(this.Container);
  if(fGlobalPointer.Browser.isSafari) {
    zAddTop = 6;
  }
  this.SelectContainer.style.left = zContainerPositionObject.x+"px";
  this.SelectContainer.style.top = (zContainerPositionObject.y+Math.min(this.InputContainer.offsetHeight,this.TextInput.offsetHeight)+zAddTop)+"px";
}
StylizedSelectObject.prototype.HoverOption = function(aIndex,aToggle) {
  var zOption = this.OptionElementArray[aIndex];
  if (aToggle) {
    AddClass(zOption,"Hover");
  }
  else {
    RemoveClass(zOption,"Hover");
  }
  return zOption;
}
StylizedSelectObject.prototype.ToggleOptGroup = function(aIndex) {
  if(this.Multiple){
    var x,zGroup = this.OptGroups['Group'+ aIndex];
    var zAllSelected = true;
    for(x in zGroup.Options){
      if(this.SelectedOptionArray[zGroup.Options[x]]!='selected'){
        zAllSelected = false;
      }
    }
  }
  for(x in zGroup.Options){
    if(zAllSelected){
      this.DeSelectOption(zGroup.Options[x]);
    }else{
      this.SelectOption(zGroup.Options[x]);
    }
  }
}
StylizedSelectObject.prototype.ToggleOption = function(aIndex) {
  if(this.SelectedOptionArray[aIndex] == "selected" && this.Multiple) {
    this.DeSelectOption(aIndex);
  }
  else {
    if(!this.Multiple && this.SelectedOptionIndex != null) {
      this.DeSelectOption(this.SelectedOptionIndex);
    }
    this.SelectOption(aIndex);
  }
  if(this.IsDropDown) {
    this.HideSelect();
  }
  this.CallOnChange();
}
StylizedSelectObject.prototype.SelectOption = function(aIndex) {
  if(aIndex<0 || aIndex == null) {
    return false;
  }
  if(this.OptionElementArray[aIndex]) {
    AddClass(this.OptionElementArray[aIndex],"Selected");
  }
  this.SelectedOptionIndex = aIndex;
  this.SelectedOptionText = this.OriginalOptionArray[aIndex].Text;
  this.SelectedOptionValue = this.OriginalOptionArray[aIndex].Value;
  this.SelectedOptionArray[aIndex] = "selected";
  this.Select.options[aIndex].selected = true;
  if(this.TextInput) {
    this.TextInput.value = this.SelectedOptionText.HTMLDecode();
  }
  this.TurnOffHovers();
  if(!this.IsDrawing) {
    this.ScrollOptionIntoView(aIndex);
  }
  return true;
}
StylizedSelectObject.prototype.DeSelectOption = function(aIndex) {
  if(aIndex<0 || aIndex == null) {
    return false;
  }
  if(this.OptionElementArray[aIndex]) {
    RemoveClass(this.OptionElementArray[aIndex],"Selected");
  }
  this.SelectedOptionArray[aIndex] = "";
  this.Select.options[aIndex].selected = false;
  if(this.SelectedOptionIndex == aIndex) {
    if(this.TextInput && this.TextInput.value == this.SelectedOptionValue) {
     this.TextInput.value = "";
    }
    this.SelectedOptionIndex = null;
    this.SelectedOptionText = "";
    this.SelectedOptionValue = "";
  }
  return true;
}
StylizedSelectObject.prototype.CallOnChange = function() {
  if(this.OnChange) {
    this.OnChange();
  }
  this.SelectedOptionUponOpen = this.SelectedOptionIndex;
  return true;
}
StylizedSelectObject.prototype.ScrollOptionIntoView = function(aIndex) {
  if(aIndex < 0 || aIndex == null) {
    return false;
  }
  var zSelectTop = this.StylizedSelect.scrollTop;
  var zSelectHeight = this.StylizedSelect.offsetHeight;
  var zSelectBottom = zSelectTop + zSelectHeight;
  var zOptionTop = this.OptionElementArray[aIndex].offsetTop;
  var zOptionHeight = this.OptionElementArray[aIndex].offsetHeight;
  var zOptionBottom = zOptionTop + zOptionHeight;
  if(zOptionTop < zSelectTop) {
    this.StylizedSelect.scrollTop = zOptionTop;
  }
  else if(zOptionBottom > zSelectBottom) {
    this.StylizedSelect.scrollTop = (zOptionTop + zOptionHeight) - zSelectHeight;
  }
  return true;
}
StylizedSelectObject.prototype.InitializeSelectedOption = function() {
  var zIndex = this.OriginalSelectedIndex;
  if(zIndex >= 0) {
    this.SelectedOptionArray[zIndex] = "selected";
    this.SelectOption(zIndex);
  }
  else {
    this.SelectedOptionIndex = null;
    this.SelectedOptionText = "";
    this.SelectedOptionValue = "";
  }
}
MultiLineSelect.prototype.InitializeSelectedOption = function() {
  var zScrolled = false;
  for(var i = 0; i < this.Select.options.length; i++) {
    if(this.Select.options[i].selected) {
      this.OriginalSelectedOptionArray[i] = "selected";
      this.SelectedOptionArray[i] = "selected";
      this.SelectOption(i);
    }
    else {
      this.OriginalSelectedOptionArray[i] = "";
      this.SelectedOptionArray[i] = "";
    }
  }
}
StylizedSelectObject.prototype.SetFocusElement = function() {
  if(this.HasTextInput) {
    if(!this.TextInput) {
      this.TextInput = document.getElementById(this.Id+'_Text');
    }
    this.FocusElement = this.TextInput;
  }
  else {
    if(!this.FocusHandler) {
      this.FocusHandler = document.getElementById(this.Id+'_StylizedSelect_Focus');
    }
    this.FocusElement = this.FocusHandler;
  }
}
StylizedSelectObject.prototype.ResetFocusFromSelect = function() {
  return true;
}
StylizedSelectObject.prototype.Focus = function() {
  if(!this.FocusElement) {
    this.SetFocusElement();
  }
  if(this.FocusElement) {
    this.FocusElement.focus();
    this.FocusedElement = this.FocusElement;
  }
  else {
    this.FocusedElement = null;
  }
}
StylizedSelectObject.prototype.Blur = function() {
  this.FocusElement.blur();
}
StylizedSelectObject.prototype.SetKeyValue = function(e) {
  var zKey = e.keyCode;
  if(zKey == 9) {
    return false;
  }
  else {
    this.ShowSelect();
    if(zKey == 40 || zKey == 39) {
      this.SelectNextOption();
      this.Focus();
    }
    else if(zKey == 38 || zKey == 37) {
      this.SelectPreviousOption();
      this.Focus();
    }
    else if(zKey == 27 || zKey == 13) {
      this.HideSelect();
      this.CallOnChange();
    }
    else {
      if(this.TextInput && this.TextInput.value == '' && this.IsSmartSelect) {
        this.Reset(this.Select);
      }
      else {
        this.SetMatchingOptions(zKey);
      }
    }
  }
  this.Focus();
  return true;
}
StylizedSelectObject.prototype.HandleEnterKey = function(e) {
  if(e.keyCode == 13) {
    return false;
  }
  return true;
}
StylizedSelectObject.prototype.SetMatchingOptions = function() {
  this.MatchOptionsTimeout = setTimeout('fStylizedSelects.GetSelect(\''+this.Id+'\').MatchOptions()',300);
}
StylizedSelectObject.prototype.ClearMatchOptionsTimeout = function() {
  if(this.MatchOptionsTimeout) {
    clearTimeout(this.MatchOptionsTimeout);
    this.MatchOptionsTimeout = false;
  }
}
StylizedSelectObject.prototype.MatchOptions = function() {
  var zMatches = new Array();
  zMatches = this.FindExact(zMatches,this.TextInput.value.toUpperCase(),true);
  zMatches = this.FindExact(zMatches,this.TextInput.value.toUpperCase(),true,true);
  zMatches = this.FindExact(zMatches,this.TextInput.value.toUpperCase());
  this.SetActiveOptions(zMatches);
}
StylizedSelectObject.prototype.SortDisplayOptions = function(aArray) {
  var x,y,zNode;
  var zBeforeNode = document.getElementById(this.Id+'_StylizedSelectNoMatch');
  var zParentNode = zBeforeNode.parentNode;
  for(x=0;x<aArray.length;x++){
    for(y=0;y<this.OriginalOptionArray.length;y++){
      if(aArray[x].Value==this.OriginalOptionArray[y].Value){
        zNode = document.getElementById(this.Id+'_StylizedSelect_Option'+y);
        zParentNode.insertBefore(zNode,zBeforeNode);
        break;
      }
    }
  }
}
function PlainSelect_SetMatchingOptions(aKey) {
  var zMatches = new Array();
  this.SelectNextOption(this.FindExact(zMatches,String.fromCharCode(aKey).toUpperCase(),true))
}
DropDownSelect.prototype.SetMatchingOptions = PlainSelect_SetMatchingOptions;
MultiLineSelect.prototype.SetMatchingOptions = PlainSelect_SetMatchingOptions;
StylizedSelectObject.prototype.SelectNextOption = function(aArray) {
  var zArray = (aArray) ? aArray : this.ActiveOptionArray;
  var zIndex = 0;
  for(var i = 0; i < zArray.length; i++) {
    if(zArray[i].OriginalArrayIndex == this.SelectedOptionIndex) {
      zIndex = i+1;
    }
  }
  this.DeSelectOption(this.SelectedOptionIndex);
  if(!zArray.length) {
    return false;
  }
  if(zIndex == zArray.length) {
    zIndex = 0;
  }
  this.SelectOption(zArray[zIndex].OriginalArrayIndex);
  if(!this.IsDropDown) {
    this.CallOnChange();
  }
  return true;
}
StylizedSelectObject.prototype.SelectPreviousOption = function(aArray) {
  var zArray = (aArray) ? aArray : this.ActiveOptionArray;
  var zIndex = 0;
  for(var i = 0; i < zArray.length; i++) {
    if(zArray[i].OriginalArrayIndex == this.SelectedOptionIndex) {
      zIndex = i-1;
    }
  }
  this.DeSelectOption(this.SelectedOptionIndex);
  if(!zArray.length) {
    return false;
  }
  if(zIndex < 0) {
    zIndex = zArray.length-1;
  }
  this.SelectOption(zArray[zIndex].OriginalArrayIndex);
  if(!this.IsDropDown) {
    this.CallOnChange();
  }
  return true;
}
StylizedSelectObject.prototype.ShowSelect = function() {
  if(this.IsDropDown) {
    if(!this.DropDownIsOpen) {
      this.SelectedOptionUponOpen = this.SelectedOptionIndex;
    }
    this.DropDownIsOpen = true;
    this.UpdateDropDownPosition()
    this.SelectContainer.style.display = 'block';
    this.ScrollOptionIntoView(this.SelectedOptionIndex);
  }
  fStylizedSelects.ActiveStylizedSelect = this;
  return true;
}
StylizedSelectObject.prototype.HideSelect = function(aIsFromFocus) {
  if(this.IsDropDown) {
    this.SelectContainer.style.display = 'none';
    if(aIsFromFocus && (this.SelectedOptionUponOpen != this.SelectedOptionIndex)) {
      this.CallOnChange();
    }
    this.DropDownIsOpen = false;
  }
  this.TurnOffHovers();
  fStylizedSelects.ActiveStylizedSelect = null;
  return true;
}
StylizedSelectObject.prototype.TurnOffHovers = function() {
  for(var i = 0; i < this.OriginalOptionArray.length; i++) {
    this.HoverOption(i,false);
  }
}
StylizedSelectObject.prototype.ToggleSelect = function() {
  if(this.SelectContainer.style.display == 'block'){
    this.HideSelect();
    this.CallOnChange();
  }
  else {
    this.ShowSelect();
    this.Focus();
  }
  return true;
}
StylizedSelectObject.prototype.PopulateTextInput = function(aIndex) {
  this.TextInput.value = this.Select[aIndex].text;
  return true;
}
StylizedSelectObject.prototype.Reset = function() {
  this.NoMatch.style.display = "none";
  this.SetActiveOptions(this.OriginalOptionArray);
  return true;
}
StylizedSelectObject.prototype.FindExact = function(aArray,aString,aBeginning,aBeginningOfWord) {
  var zIsMatch,zRegExp = new RegExp('(^|\\s)'+ escape(aString),'i');
  var zFound = false;
  for(var x = 0; x < this.OriginalOptionArray.length; x++) {
    if(aBeginningOfWord){
      zIsMatch = (this.OriginalOptionArray[x].Text.search(zRegExp) != -1);
    }else if(aBeginning) {
      zIsMatch = (this.OriginalOptionArray[x].Text.toUpperCase().indexOf(aString) == 0);
    }
    else {
      zIsMatch = (this.OriginalOptionArray[x].Text.toUpperCase().indexOf(aString) > 0);
    }
    if(zIsMatch) {
      zFound = false;
      for(var y = 0; y < aArray.length; y++) {
        if(aArray[y].Value == this.OriginalOptionArray[x].Value) {
          zFound = true;
          break;
        }
      }
      if(!zFound) {
        aArray[aArray.length] = this.OriginalOptionArray[x];
      }
    }
  }
  return aArray;
}
StylizedSelectObject.prototype.OpenSelectFromInput = function() {
  this.ShowSelect();
  return true;
}
StylizedSelectObject.prototype.FocusInput = function() {
  this.Focus();
  this.ToggleSelect();
  return true;
}
StylizedSelectObject.prototype.SetBlur = function() {
  this.FocusedElement = null;
  setTimeout('fStylizedSelects.GetSelect("'+this.Id+'").CheckFocus()',100);
  return true;
}
StylizedSelectObject.prototype.CheckFocus = function() {
  if(!this.FocusedElement) {
    this.HideSelect(true);
  }
  this.FocusedElement = null;
  return true;
}
StylizedSelectObject.prototype.SetActiveOptions = function(aArray) {
  this.SortDisplayOptions(aArray);
  this.ActiveOptionArray = aArray;
  var zDisplayOption;
  for(var i = 0; i < this.OriginalOptionArray.length; i++) {
    this.DeSelectOption(i);
    zDisplayOption = false;
    for(var j = 0; j < this.ActiveOptionArray.length; j++) {
      if(this.OriginalOptionArray[i] == this.ActiveOptionArray[j]) {
        zDisplayOption = true;
      }
    }
    if(zDisplayOption) {
      this.ShowOption(i);
    }
    else {
      this.HideOption(i);
    }
  }
  this.ResizeSelect();
  return true;
}
StylizedSelectObject.prototype.HideOption = function(aIndex) {
  this.OptionElementArray[aIndex].style.display = "none";
}
StylizedSelectObject.prototype.ShowOption = function(aIndex) {
  this.OptionElementArray[aIndex].style.display = "block";
}
StylizedSelectObject.prototype.ResizeSelect = function() {
  var zInnerHeight = 0;
  var zHide = false;
  if(this.SelectContainer.style.display=='none'){
    this.SelectContainer.style.display = 'block';
    zHide = true;
  }
  var zScrollHeight = this.StylizedSelect.scrollHeight;
  if(zScrollHeight == 'undefined') {
    zScrollHeight = this.SelectHeight;
  }
  var zMaxHeight = Math.min(zScrollHeight,this.SelectHeight);
  var zUseHeight;
  if(!this.ActiveOptionArray.length) {
    this.NoMatch.style.display = "block";
  }
  else {
    this.NoMatch.style.display = "none";
  }
  for(var i = 0; i < this.StylizedSelect.childNodes.length; i++) {
    if(typeof(this.StylizedSelect.childNodes[i].offsetHeight) != 'undefined' && this.StylizedSelect.childNodes[i].offsetHeight != 0) {
      zInnerHeight = zInnerHeight + Math.max(this.StylizedSelect.childNodes[i].offsetHeight,12);
    }
  }
  zInnerHeight = Math.min(zInnerHeight,zScrollHeight);
  zUseHeight = Math.min(zMaxHeight,zInnerHeight);
  if(fGlobalPointer && fGlobalPointer.Browser && fGlobalPointer.Browser.isIE) {
    zUseHeight = zUseHeight + 2;
  }
  this.StylizedSelect.style.height = zUseHeight + "px";
  if(zHide){
    this.SelectContainer.style.display = 'none';
  }
}
StylizedSelectObject.prototype.SelectValue = function(aValue) {
  for(var i = 0; i < this.OriginalOptionArray.length; i++) {
    if(this.OriginalOptionArray[i].Value == aValue) {
      this.SelectOption(i);
      this.CallOnChange();
      return true;
    }
  }
  return false;
}
StylizedSelectObject.prototype.SetInputValue = function(aString,aSelectFirst) {
  if(this.IsSmartSelect) {
    this.TextInput.value = aString;
    this.SetMatchingOptions();
    if(this.ActiveOptionArray.length && isTrue(aSelectFirst)) {
      this.SelectOption(this.ActiveOptionArray[0].OriginalArrayIndex);
      this.CallOnChange();
    }
  }
  return false;
}
StylizedSelectObject.prototype.AddOption = function(aText,aValue,aClass) {
  var zIndex = this.OriginalOptionArray.length;
  var zActiveIndex = this.ActiveOptionArray.length;
  this.Select.options[this.Select.options.length] = new Option(aText,aValue);
  this.OriginalOptionArray[zIndex] = new StylizedSelectOption(aText,aValue,aClass);
  this.OriginalOptionArray[zIndex].OriginalArrayIndex = zIndex;
  this.StylizedSelect.innerHTML = this.GetOptionsHtml(this.OriginalOptionArray);
  this.UpdateOptionElementArray();
  this.ActiveOptionArray[zActiveIndex] = this.OriginalOptionArray[zIndex];
  this.ShowOption(zActiveIndex);
  this.ShowSelect();
  this.ResizeSelect();
  this.HideSelect();
  for(var j = 0; j < this.Select.options.length; j++) {
    if(this.Select.options[j].selected) {
      this.SelectOption(j);
    }
  }
  return true;
}
StylizedSelectObject.prototype.SelectOptionByValue = function(aValue) {
  var zSelectedIndex = null;
  for(var i = 0; i < this.OriginalOptionArray.length; i++) {
    if(this.OriginalOptionArray[i].Value == aValue) {
      if(this.SelectedOptionArray[i] == "selected" && !this.Multiple) {
        return false;
      }
      if(zSelectedIndex == null) {
        zSelectedIndex = i;
      }
    }
  }
  if(zSelectedIndex == null) {
    return false;
  }
  for(var j = 0; j < this.OriginalOptionArray.length; j++) {
    if(j != zSelectedIndex && this.SelectedOptionArray[j] == "selected") {
      this.DeSelectOption(j);
    }
  }
  this.SelectOption(zSelectedIndex);
  return false;
}
function SetSelectValue(aSelectObject, aValue) {
  var zStylizedSelect = fStylizedSelects.GetSelect(aSelectObject.id);
  if(zStylizedSelect) {
    zStylizedSelect.SelectOptionByValue(aValue);
  }
  else {
    aSelectObject.value = aValue;
  }
  return;
}
function setMaxLength(aEvent){
  aEvent = (aEvent ? aEvent:window.event);
  var zElement = (aEvent.target ? aEvent.target:aEvent.srcElement)
  var zMaxLength = parseInt(zElement.getAttribute('maxlength'));
  if(zElement.value.length>zMaxLength){
    zElement.value = zElement.value.substr(0,zMaxLength);
  }
  return true;
}
function InitializeTextareaMaxLength(){
  var x,zMaxLength;
  var zTextareas = document.getElementsByTagName('TEXTAREA');
  for(x=0;x<zTextareas.length;x++){
    zMaxLength = zTextareas[x].getAttribute('maxlength');
    if(zMaxLength){
      appendEventHandler(zTextareas[x],'onkeyup',setMaxLength);
    }
  }
  return true;
}
var CsvInput = {
  Set:function(aParams){
    var zCsv = [];
    var zTitleList = {};
    var zItem,zColumn;
    var zDataArray = [];
    var zTitleArray = [];
    var zInput = $(aParams.Input);
    if(!aParams.Data){
      try{
        eval("aParams.Data = "+ zInput.getAttribute('csvdata'));
      }catch(e){
      }
    }
    if(aParams.Data){
      if(aParams.Data.length>=0){
        zDataArray = aParams.Data;
      }else{
        zDataArray = [];
        for(zItem in aParams.Data){
          zDataArray.push(aParams.Data[zItem]);
        }
      }
    }
    if(aParams.TitleArray && aParams.TitleArray.length > 0 ){
      zTitleArray = aParams.TitleArray;
    }else if(zInput.getAttribute('csvtitlearray')){
      zTitleArray = zInput.getAttribute('csvtitlearray').split(',');
    }
    if(!zTitleArray || zTitleArray.length == 0){
      zDataArray.forEach(function(aItem){
        for(zColumn in aItem){
          if(!zTitleList[zColumn] && (typeof aItem[zColumn] == 'number' || typeof aItem[zColumn] == 'string')){
            zTitleArray.push(zColumn);
            zTitleList[zColumn] = zColumn;
          }
        }
      });
    }else{
      zTitleArray.forEach(function(aColumn){
        zTitleList[aColumn] = aColumn;
      });
    }
    zCsv.push(zTitleArray.join(','));
    zDataArray.forEach(function(aItem){
      zCsv.push(EncodeItem(aItem));
    });
    zInput.value = zCsv.join('\n');
    function EncodeItem(aItem){
      var zReturn = [];
      zTitleArray.forEach(function(aColumn){
        if(typeof aItem[aColumn] == 'number' || typeof aItem[aColumn] == 'string'){
          zReturn.push(encodeURIComponent(aItem[aColumn]));
        }else{
          zReturn.push('');
        }
      });
      return zReturn.join(',');
    };
  },
  SetSubmit:function(aParams){
    appendEventHandler($(aParams.Input).form,'onsubmit',function(e,aParams){ CsvInput.Set(aParams); return true; },aParams);
  },
  GetElements:function(aStartElement){
    var zResults = [].concat(
      getElementsWithAttribute('csvdata',null,'input',aStartElement),
      getElementsWithAttribute('csvdata',null,'textarea',aStartElement)
    );
    return zResults;
  },
  InitializeInput:function(aElement){
    CsvInput.SetSubmit({
      Input:aElement
    });
  }
};
Widgets.Add({
  Id: "CsvInput",
  GetElementsFunction:CsvInput.GetElements,
  ElementInitFunction:CsvInput.InitializeInput
});
// End JSIncludeFile:Action_JSIncludeFormControls
// Start JSIncludeFile:Action_JS
var aTrapJSErrors = (GetQueryValue('ATRAPJSERRORS')!='' ? GetQueryValue('ATRAPJSERRORS'):null);
if(isTrue(VarDef(aTrapJSErrors,(isTrue('N')? 'N':'Y')))){
  var fErrorCount = 0;
  function captureErrors(aDescription,aPage,aLine,aChar){
    fErrorCount++;
    if(!aDescription){aDescription = 'UNKNOWN'}
      var zMode = ' (live)';
    if(fErrorCount<=5 && aDescription!='error loading script'){
      var zMessage = new Array();
      zMessage[zMessage.length] = 'A JavaScript error has occurred in '+ window.location.hostname;
      zMessage[zMessage.length] = '';
      zMessage[zMessage.length] = '';
      zMessage[zMessage.length] = 'Error Details:';
      zMessage[zMessage.length] = '  Error Number:'+ fErrorCount;
      if(aDescription){ zMessage[zMessage.length] = '  Description:'+ aDescription; }
      if(aPage){ zMessage[zMessage.length] = '  Page:'+ aPage; }
      if(aLine){ zMessage[zMessage.length] = '  Line:'+ aLine; }
      if(aChar){ zMessage[zMessage.length] = '  Char:'+ aChar; }
      zMessage[zMessage.length] = '';
      zMessage[zMessage.length] = '';
      zMessage[zMessage.length] = 'Additional Information:';
      zMessage[zMessage.length] = '  url:'+ window.location.href;
      zMessage[zMessage.length] = '  userAgent:'+ navigator.userAgent;
      zMessage[zMessage.length] = '  platform:'+ navigator.platform;
      zMessage[zMessage.length] = '  referrer:'+ document.referrer;
      zMessage[zMessage.length] = '';
      zMessage[zMessage.length] = '';
      zMessage[zMessage.length] = '';
      zMessage[zMessage.length] = 'View System Notification:';
      SystemNotification('','',zMessage.join('\n'),'JS Error: '+aDescription.substring(0, 100)+zMode+' ('+ fErrorCount +')','JSError','High','Y','Y');
    }
    return true;
  }
  window.onerror = captureErrors;
}
// End JSIncludeFile:Action_JS
// Start ModuleJS:Action_ModuleJS
  // DomainInterfaceModule.ModuleJS
  // SystemManager.ModuleJS
  // CompanyManager.ModuleJS
  // UserManager.ModuleJS
  // LiveAnalysis.ModuleJS
  // ContactManager.ModuleJS
  // LiveMailer.ModuleJS
  // Search.ModuleJS
  // RichTextEditor.ModuleJS
  // LiveDigitalAsset.ModuleJS
function LiveDigitalAsset_SelectAllTypes (aIds, aAllCheckBox) {
  var zIdArray = aIds.split(',');
  for(i=0; i < zIdArray.length; i++) {
    zTypeInput = document.getElementById(zIdArray[i]);
    if(aAllCheckBox.checked) {
      zTypeInput.disabled = true;
    }
    else {
      zTypeInput.disabled = false;
    }
  }
  return;
}
function LiveDigitalAsset_CheckCategory() {
  return true;
}
function LiveDigitalAsset_ToggleViewControls (e) {
  var zViewControls = document.getElementById('LiveDigitalAsset_ToggleViewControls');
  if(zViewControls.style.display == 'none' || zViewControls.style.display == ''){
    zViewControls.style.display = 'block';
    var zX = e.clientX+5;
    var zY = e.clientY+10;
    PlaceElementInView(zViewControls, document.body, zX, zY);
  }
  else {
    hide(zViewControls);
  }
}
function LiveDigitalAsset_ChangeInputField(aCheckbox,aDiv){
  var inputField = document.getElementById(aDiv);
  var checkbox= document.getElementById(aCheckbox);
  if (checkbox.checked){
    inputField.style.display='block';
  }
  else{
    inputField.style.display='none';
  }
}
function __lad(a,b,c,d,e,f,g) {
  var s = window.screen;
  document.write('<a href="'+c+'">'
          +'\<im'+'g s'+'rc="'
          +a
          +Math.random()
          +'?tu='+b
          +'&iid='+d
          +'&cid='+e
          +'&u='+location.href
          +'&ru='+document.referrer
          +'&bt=browser_type'
          +'&bv=browser_version'
          +'&sr='+s.width+'x'+s.height
          +'" width="'+f+'" height="'+g+'" border="0" alt="" \/>\<\/a>');
}
function __lflv(a,b,c,d,e) {
  var s = window.screen;
  var flvUrl = a
             +Math.random()
             +'%3Ftu%3D'+b
             +'%26iid%3D'+d
             +'%26cid%3D'+e
             +'%26u%3D'+location.href
             +'%26ru%3D'+document.referrer
             +'%26bt%3Dbrowser_type'
             +'%26bv%3Dbrowser_version'
             +'%26sr%3D'+s.width+'x'+s.height;
  return flvUrl;
}
var RateIt = {
  MaxRating:5,
  Init: function(aElement) {
    aElement.CurrentRating = aElement.getAttribute('AvgRating');
    aElement.PagePath      = aElement.getAttribute('ItemPath').toPagePath();
    if (hasAttribute(aElement,"ReadOnly","Y")) {
      aElement.ReadOnly = 'Y';
    }
    RateIt.Create(aElement);
    RateIt.Display('',aElement);
    return true;
  },
  Create: function(aElement) {
    for (i = 1; i <= RateIt.MaxRating; i++) {
      var zNode = document.createElement('div');
      zNode.Id = i;
      if (aElement.ReadOnly!='Y') {
        appendEventHandler(zNode,'onmouseout',RateIt.Display,aElement);
        appendEventHandler(zNode,'onmouseover',RateIt.Hover,zNode);
        appendEventHandler(zNode,'onclick',RateIt.WriteData,zNode);
        zNode.style.cursor = 'pointer';
      }
      aElement.appendChild(zNode);
    }
    return true;
  },
  Hover: function(e,aChildElement) {
    var zClassName = '';
    var zParent_Object = aChildElement.parentNode;
    for (k = 0; k < zParent_Object.childNodes.length; k++) {
      if (aChildElement.Id >= (k+1)) {
        zClassName = 'Rating_Full';
      } else {
        zClassName = 'Rating_Empty';
      }
      zParent_Object.childNodes[k].className = zClassName;
    }
    return true;
  },
  WriteData: function(e,aChildElement) {
    var zParent_Object = aChildElement.parentNode;
    LiveRequest_MakeRequest( zParent_Object.PagePath + '.RatingComplete?aRatingValue='+ aChildElement.Id +'&aItemId=' + zParent_Object.id, RateIt.Confirm, aChildElement);
    return true;
  },
  Display: function(e,aElement) {
    for (j = 0; j < aElement.childNodes.length; j++) {
      var zRatingCount = (j+1)
      if (aElement.CurrentRating>0) {
        if (zRatingCount <= aElement.CurrentRating) {
          aElement.childNodes[j].className = 'Rating_Full';
        } else {
          if ((zRatingCount - 1) < aElement.CurrentRating) {
            aElement.childNodes[j].className = 'Rating_Half';
          } else {
            aElement.childNodes[j].className = 'Rating_Empty';
          }
        }
      } else {
        aElement.childNodes[j].className = 'Rating_Empty';
      }
    }
    return true;
  },
  Confirm: function(e,aChildElement) {
    var zParent_Object = aChildElement.parentNode;
    zParent_Object.innerHTML = 'Thank you for rating this item.';
  }
}
Widgets.Add({
  Id: "Rating",
  Attribute: "RateIt",
  Value: "Y",
  ElementInitFunction: RateIt.Init
});
  // MediaTypeManager.ModuleJS
function keyPressAdd(aEvent,aMulitpleInputObject,aValueInputId) {
  if(aEvent.keyCode==13) {
    aMulitpleInputObject.Add(UniqueVar(), document.getElementById(aValueInputId).value, 'NEW')
    return false;
  }
  return true;
}
function MediaType_MultipleInput (aConfigObject) {
  this.Config = aConfigObject;
  return this;
}
MediaType_MultipleInput.prototype.Init = function (aDebug) {
  DebugAlert.Enabled=true;
  this.GridInput = new InputGridObject(this.Config.Id,false,false);
  this.GridInput.AddColumn('Id');
  this.GridInput.AddColumn('Value');
  this.GridInput.AddColumn('Status');
  this.InputList = new Array();
  this.CurrentEditIndex = null;
  if (this.Config.Values!= null && this.Config.Values.length > 0) {
    for(var x = 0; x < this.Config.Values.length; x++) {
      this.Add(this.Config.Values[x].Id, this.Config.Values[x].Value, 'EXISTING')
    }
  }
}
MediaType_MultipleInput.prototype.Add = function (aId, aValue, aStatus) {
  if (aValue && aValue != '') {
    if(this.CurrentEditIndex != null && this.CurrentEditPreviousStatus != null) {
      this.InputList[this.CurrentEditIndex].Value = aValue;
      this.InputList[this.CurrentEditIndex].Status = this.CurrentEditPreviousStatus;
      this.GridInput.Rows('NameValue_' + (this.CurrentEditIndex)).Column('Value').Set(aValue);
      this.GridInput.Rows('NameValue_' + (this.CurrentEditIndex)).Column('Status').Set(this.CurrentEditPreviousStatus);
      this.CurrentEditIndex = null;
      this.CurrentEditPreviousStatus = null;
    }
    else {
      aId = (aId) ? aId : UniqueVar();
      this.InputList[this.InputList.length] = {Id: aId, Value: aValue, Status: aStatus};
      this.GridInput.AddRow('NameValue_'+(this.InputList.length-1),this.InputList[this.InputList.length-1]);
    }
    document.getElementById(this.Config.ValueInputId).value = '';
    this.Draw();
    return true;
  }
}
MediaType_MultipleInput.prototype.Edit = function (aIndex) {
  if (aIndex != null && aIndex >= 0) {
    if (this.CurrentEditIndex != null && this.CurrentEditPreviousStatus != null) {
      this.InputList[this.CurrentEditIndex].Id = (this.InputList[this.CurrentEditIndex].Id) ? this.InputList[this.CurrentEditIndex].Id : UniqueVar();
      this.InputList[this.CurrentEditIndex].Value = document.getElementById(this.Config.ValueInputId).value;
      this.InputList[this.CurrentEditIndex].Status = this.CurrentEditPreviousStatus;
    }
    this.CurrentEditIndex = aIndex;
    this.CurrentEditPreviousStatus = this.InputList[aIndex].Status;
    this.InputList[aIndex].Status = 'EDITTING';
    this.GridInput.Rows('NameValue_' + (this.CurrentEditIndex)).Column('Status').Set('EDITTING');
    document.getElementById(this.Config.ValueInputId).value = this.InputList[aIndex].Value;
    this.Draw();
  }
}
MediaType_MultipleInput.prototype.Remove = function (aIndex) {
  if (aIndex != null && aIndex >= 0) {
    this.InputList[aIndex].Status = 'DELETED';
    this.GridInput.Rows('NameValue_' + (aIndex)).Column('Status').Set('DELETED');
    this.Draw();
  }
}
MediaType_MultipleInput.prototype.Draw = function () {
  var zNameValueHTML = '';
  for (var i = 0; i < this.InputList.length; i++) {
    if(this.InputList[i].Status == 'NEW' || this.InputList[i].Status == 'EXISTING') {
      zNameValueHTML += '<div class="MediaTypeManager_MultipleInputContainer">'
                      +  '<div class="MediaTypeManager_MultipleInputNameContainer">'
                      +     this.InputList[i].Value
                      +  '</div>'
                      +  '<div class="MediaTypeManager_MultipleInputLinksContainer">'
                      +   '<div class="MediaTypeManager_MultipleInputEditLinkContainer"><a href="javascript: void(0);" onClick="'+this.Config.Id+'.Edit('+i+')">[Edit]</a></div>'
                      +   '<div class="MediaTypeManager_MultipleInputRemoveLinkContainer"><a href="javascript: void(0);" onClick="'+this.Config.Id+'.Remove('+i+')">[Remove]</a></div>'
                      +  '</div>'
                      + '</div>';
    }
  }
  document.getElementById(this.Config.InputContainerId).innerHTML = zNameValueHTML;
}
function MediaType_PriceMatrix (aConfigObject) {
  this.Config = aConfigObject;
  this.Prices = new Array();
  if(this.Config.PriceMatrix != null) {
    for(var zPriceMatrixCount = 0; zPriceMatrixCount < this.Config.PriceMatrix.length; zPriceMatrixCount++) {
      this.Prices[this.Config.PriceMatrix[zPriceMatrixCount].SizeFormat] = this.Config.PriceMatrix[zPriceMatrixCount].Price;
    }
  }
  return this;
}
MediaType_PriceMatrix.prototype.Init = function (aDebug) {
  this.GridInput = new InputGridObject(this.Config.Id,false,aDebug);
  this.ColumnIds  = new Array();
  this.GridInput.AddColumn('Size');
  this.GridInput.AddColumn('Format');
  this.GridInput.AddColumn('Price');
  if(this.Config.Formats != null && this.Config.Sizes != null){
    for(var zFormatCount = 0; zFormatCount < this.Config.Formats.length; zFormatCount++) {
      for(var zSizeCount = 0; zSizeCount < this.Config.Sizes.length; zSizeCount++) {
        this.GridInput.AddRow('PriceMatrix_'+zFormatCount+'_'+zSizeCount,{Size: this.Config.Sizes[zSizeCount].Value, Format: this.Config.Formats[zFormatCount].Value, Price: ''});
        var zIndex = this.Config.Sizes[zSizeCount].Value+'_'+this.Config.Formats[zFormatCount].Value;
        var zPrice = '';
        if (this.Prices[zIndex] != null) {
          zPrice = this.Prices[zIndex];
        }
        this.AddPrice(zFormatCount,zSizeCount,zPrice);
      }
    }
    this.DrawGrid();
  }
  else {
    document.write('Please add formats and sizes');
    fHideSubmitButton = true;
    return false;
  }
  return true;
}
MediaType_PriceMatrix.prototype.AddPrice = function(aFormatId, aSizeId, aPrice) {
  this.GridInput.Rows('PriceMatrix_' + aFormatId+'_'+aSizeId).Column('Price').Set(aPrice);
}
MediaType_PriceMatrix.prototype.DrawGrid = function() {
  var zGridHtmlArray = new Array();
  var zRowHtmlArray = new Array();
  var zGridRows = this.GridInput.GetValues();
  zGridHtmlArray[zGridHtmlArray.length] = '<table>';
  zRowHtmlArray[zRowHtmlArray.length] = '<tr>';
  zRowHtmlArray[zRowHtmlArray.length] = '<th>&nbsp;</th>';
  for(var zColumnCount = 0; zColumnCount < this.Config.Formats.length; zColumnCount++) {
    zRowHtmlArray[zRowHtmlArray.length] = '<th>'+this.Config.Formats[zColumnCount].Value+'</th>';
  }
  zRowHtmlArray[zRowHtmlArray.length] = '</tr>';
  for(var zRowCount = 0; zRowCount < this.Config.Sizes.length; zRowCount++) {
    zRowHtmlArray[zRowHtmlArray.length] = '<tr><td>'+this.Config.Sizes[zRowCount].Value+'</td>';
    for(var zColumnCount = 0; zColumnCount < this.Config.Formats.length; zColumnCount++) {
      zPriceColumn = zGridRows['PriceMatrix_'+zColumnCount+'_'+zRowCount];
      zRowHtmlArray[zRowHtmlArray.length] = '<td><input type="text" onChange="'+this.Config.Id+'.AddPrice(\''+zColumnCount+'\',\''+zRowCount+'\',this.value);" value="'+zPriceColumn['Price']+'" /></td>';
    }
    zRowHtmlArray[zRowHtmlArray.length] = '</tr>';
  }
  zGridHtmlArray[zGridHtmlArray.length] = zRowHtmlArray.join('');
  zGridHtmlArray[zGridHtmlArray.length] = '</table>';
  document.getElementById(this.Config.MatrixContainerId).innerHTML = zGridHtmlArray.join('');
}
  // IndustryManager.ModuleJS
var SystemLanguage = {
  Init:function(){
    if($('inpSystemLanguage') && $('inpSystemLanguageGo')){
      appendEventHandler($('inpSystemLanguageGo'),'onclick',SystemLanguage.SelectLanguage);
    }
    return true;
  },
  SelectLanguage:function(){
    var zLanguage = $('inpSystemLanguage').value;
    LiveRequest_MakeRequest('/Javascript.SetLanguage?aObjectTypeAlias=UserLink&inpLanguage='+zLanguage,SystemLanguage.ReloadFrames,zLanguage);
  },
  ReloadFrames:function(aItem,inpLanguage){
    var zURL = setURLVariable('aLanguage',inpLanguage,self.top.location.href,true);
    top.location.href = zURL;
  }
}
function Industry_ChangeInputField(aInputField){
  aInputField = unescape(aInputField);
  var inputField = document.getElementById('inp_'+ aInputField);
  var checkbox= document.getElementById('inpEnable_'+ aInputField);
  if (checkbox.checked){
    if (inputField.value==""){
      inputField.value=document.getElementById('inpHidden_'+ aInputField).value;
    }
    inputField.readOnly=false;
  }
  else{
    inputField.readOnly=true;
  }
}
function Industry_keyPressAdd(aEvent,aMulitpleInputObject,aValueInputId) {
  if(aEvent.keyCode==13) {
    aMulitpleInputObject.Add(document.getElementById(aValueInputId).value, 'NEW')
    return false;
  }
  return true;
}
function Industry_MultipleInput (aConfigObject) {
  this.Config = aConfigObject;
  return this;
}
Industry_MultipleInput.prototype.Init = function (aDebug) {
  this.GridInput = new InputGridObject(this.Config.Id,false,aDebug);
  this.GridInput.AddColumn('Value');
  this.GridInput.AddColumn('Status');
  this.InputList = new Array();
  this.CurrentEditIndex = null;
  if (this.Config.Values!= null && this.Config.Values.length > 0) {
    for(var x = 0; x < this.Config.Values.length; x++) {
      this.Add(this.Config.Values[x].Value, 'EXISTING')
    }
  }
}
Industry_MultipleInput.prototype.Add = function (aValue, aStatus) {
  if (aValue && aValue != '') {
    if(this.CurrentEditIndex != null && this.CurrentEditPreviousStatus != null) {
      this.InputList[this.CurrentEditIndex].Value = aValue;
      this.InputList[this.CurrentEditIndex].Status = this.CurrentEditPreviousStatus;
      this.GridInput.Rows('NameValue_' + (this.CurrentEditIndex)).Column('Value').Set(aValue);
      this.GridInput.Rows('NameValue_' + (this.CurrentEditIndex)).Column('Status').Set(this.CurrentEditPreviousStatus);
      this.CurrentEditIndex = null;
      this.CurrentEditPreviousStatus = null;
    }
    else {
      this.InputList[this.InputList.length] = {Value: aValue, Status: aStatus};
      this.GridInput.AddRow('NameValue_'+(this.InputList.length-1),this.InputList[this.InputList.length-1]);
    }
    document.getElementById(this.Config.ValueInputId).value = '';
    this.Draw();
    return true;
  }
}
Industry_MultipleInput.prototype.Edit = function (aIndex) {
  if (aIndex != null && aIndex >= 0) {
    if (this.CurrentEditIndex != null && this.CurrentEditPreviousStatus != null) {
      this.InputList[this.CurrentEditIndex].Value = document.getElementById(this.Config.ValueInputId).value;
      this.InputList[this.CurrentEditIndex].Status = this.CurrentEditPreviousStatus;
    }
    this.CurrentEditIndex = aIndex;
    this.CurrentEditPreviousStatus = this.InputList[aIndex].Status;
    this.InputList[aIndex].Status = 'EDITTING';
    this.GridInput.Rows('NameValue_' + (this.CurrentEditIndex)).Column('Status').Set('EDITTING');
    document.getElementById(this.Config.ValueInputId).value = this.InputList[aIndex].Value;
    this.Draw();
  }
}
Industry_MultipleInput.prototype.Remove = function (aIndex) {
  if (aIndex != null && aIndex >= 0) {
    this.InputList[aIndex].Status = 'DELETED';
    this.GridInput.Rows('NameValue_' + (aIndex)).Column('Status').Set('DELETED');
    this.Draw();
  }
}
Industry_MultipleInput.prototype.Draw = function () {
  var zNameValueHTML = '';
  for (var i = 0; i < this.InputList.length; i++) {
    if(this.InputList[i].Status == 'NEW' || this.InputList[i].Status == 'EXISTING') {
      zNameValueHTML += '<div class="IndustryManager_MultipleInputContainer">'
                      +  '<div class="IndustryManager_MultipleInputNameContainer">'
                      +     this.InputList[i].Value
                      +  '</div>'
                      +  '<div class="IndustryManager_MultipleInputLinksContainer">'
                      +   '<div class="IndustryManager_MultipleInputEditLinkContainer"><a href="javascript: void(0);" onClick="'+this.Config.Id+'.Edit('+i+')">[Edit]</a></div>'
                      +   '<div class="IndustryManager_MultipleInputRemoveLinkContainer"><a href="javascript: void(0);" onClick="'+this.Config.Id+'.Remove('+i+')">[Remove]</a></div>'
                      +  '</div>'
                      + '</div>';
    }
  }
  document.getElementById(this.Config.InputContainerId).innerHTML = zNameValueHTML;
}
  // LiveLegal.ModuleJS
function Legal_ChangeInputField(aInputField){
  var inputField = document.getElementById('inp_'+ aInputField);
  var checkbox= document.getElementById('inpEnable_'+ aInputField);
  if (!checkbox.checked){
    inputField.readOnly=true;
  }
  else{
    inputField.readOnly=false;
  }
}
function Legal_MultipleInput (aConfigObject) {
  this.Config = aConfigObject;
  return this;
}
function Legal_keyPressAdd(aEvent,aMulitpleInputObject,aValueInputId) {
  if(aEvent.keyCode==13) {
    aMulitpleInputObject.Add(document.getElementById(aValueInputId).value, 'NEW')
    return false;
  }
  return true;
}
Legal_MultipleInput.prototype.Init = function (aDebug) {
  this.GridInput = new InputGridObject(this.Config.Id,false,aDebug);
  this.GridInput.AddColumn('Value');
  this.GridInput.AddColumn('Status');
  this.InputList = new Array();
  this.CurrentEditIndex = null;
  if (this.Config.Values!= null && this.Config.Values.length > 0) {
    for(var x = 0; x < this.Config.Values.length; x++) {
      this.Add(this.Config.Values[x].Value, 'EXISTING')
    }
  }
}
Legal_MultipleInput.prototype.Add = function (aValue, aStatus) {
  if (aValue && aValue != '') {
    if(this.CurrentEditIndex != null && this.CurrentEditPreviousStatus != null) {
      this.InputList[this.CurrentEditIndex].Value = aValue;
      this.InputList[this.CurrentEditIndex].Status = this.CurrentEditPreviousStatus;
      this.GridInput.Rows('NameValue_' + (this.CurrentEditIndex)).Column('Value').Set(aValue);
      this.GridInput.Rows('NameValue_' + (this.CurrentEditIndex)).Column('Status').Set(this.CurrentEditPreviousStatus);
      this.CurrentEditIndex = null;
      this.CurrentEditPreviousStatus = null;
    }
    else {
      this.InputList[this.InputList.length] = {Value: aValue, Status: aStatus};
      this.GridInput.AddRow('NameValue_'+(this.InputList.length-1),this.InputList[this.InputList.length-1]);
    }
    document.getElementById(this.Config.ValueInputId).value = '';
    this.Draw();
    return true;
  }
}
Legal_MultipleInput.prototype.Edit = function (aIndex) {
  if (aIndex != null && aIndex >= 0) {
    if (this.CurrentEditIndex != null && this.CurrentEditPreviousStatus != null) {
      this.InputList[this.CurrentEditIndex].Value = document.getElementById(this.Config.ValueInputId).value;
      this.InputList[this.CurrentEditIndex].Status = this.CurrentEditPreviousStatus;
    }
    this.CurrentEditIndex = aIndex;
    this.CurrentEditPreviousStatus = this.InputList[aIndex].Status;
    this.InputList[aIndex].Status = 'EDITTING';
    this.GridInput.Rows('NameValue_' + (this.CurrentEditIndex)).Column('Status').Set('EDITTING');
    document.getElementById(this.Config.ValueInputId).value = this.InputList[aIndex].Value;
    this.Draw();
  }
}
Legal_MultipleInput.prototype.Remove = function (aIndex) {
  if (aIndex != null && aIndex >= 0) {
    this.InputList[aIndex].Status = 'DELETED';
    this.GridInput.Rows('NameValue_' + (aIndex)).Column('Status').Set('DELETED');
    this.Draw();
  }
}
Legal_MultipleInput.prototype.Draw = function () {
  var zNameValueHTML = '';
  for (var i = 0; i < this.InputList.length; i++) {
    if(this.InputList[i].Status == 'NEW' || this.InputList[i].Status == 'EXISTING') {
      zNameValueHTML += '<div class="LiveLegal_MultipleInputContainer">'
                      +  '<div class="LiveLegal_MultipleInputNameContainer">'
                      +     this.InputList[i].Value
                      +  '</div>'
                      +  '<div class="LiveLegal_MultipleInputLinksContainer">'
                      +   '<div class="LiveLegal_MultipleInputEditLinkContainer"><a href="javascript: void(0);" onClick="'+this.Config.Id+'.Edit('+i+')">[Edit]</a></div>'
                      +   '<div class="LiveLegal_MultipleInputRemoveLinkContainer"><a href="javascript: void(0);" onClick="'+this.Config.Id+'.Remove('+i+')">[Remove]</a></div>'
                      +  '</div>'
                      + '</div>';
    }
  }
  document.getElementById(this.Config.InputContainerId).innerHTML = zNameValueHTML;
}
  // LiveCreditCardProcessor.ModuleJS
  // LiveAnnouncements.ModuleJS
  // LiveMediaLocationManager.ModuleJS
  // LiveBuilder.ModuleJS
  // LiveChart.ModuleJS
  // LiveSlider.ModuleJS
  // LiveMediaMix.ModuleJS
var MediaMix = {
  Slider:null,
  StartDateName:null,
  EndDateName:null,
  Grid:null,
  MatrixInputArray:[],
  MatrixInputList:{},
  Init: function(aParams) {
    MediaMix.StartDateName = aParams.StartDateName;
    MediaMix.EndDateName = aParams.EndDateName;
    MediaMix.Slider = aParams.Slider;
    MediaMix.Grid = new InputGridObject('MediaMixGrid',true,false);
    aParams.MediaMixValues.forEach(function(aMix){
      MediaMix.SetGridValues(aMix);
    });
    appendEventHandler($('inpBudget'),'onkeyup',MediaMix.SetSliderDisplay);
    appendEventHandler(window,'onload',MediaMix.DrawMatrix);
    appendEventHandler(document.forms[0],'onsubmit',MediaMix.OnSubmit);
    return true;
  },
  InsertCommas: function(a) {
    var p,ad,b='',ep='',di=a.indexOf('.');
    if(di>=0){
      ep=a.substring(di,a.length);
      a=a.substring(0,di);
    }
    ad = Math.ceil(a.length/3);
    if(ad>1){
      for(p=1;p<ad;p++){
        al = a.length;
        b = ','+ a.substring(al-3) + b;
        a = a.substring(0,al-3);
      }
    }
    b = a + b + ep;
    return b;
  },
  FormatValue: function(aVal){
    if(aVal==0){
      return '$0  (0%)';
    }
    return '$'+ MediaMix.InsertCommas(Math.round(((aVal/1000)*$('inpBudget').value),0).toString()) + '  ('+Math.round(((aVal/1000)*100),0)+'%)';
  },
  SetGridValues:function(aParams){
    if(!MediaMix.Grid.Rows(aParams.Id)){
      MediaMix.Grid.AddRow(aParams.Id,aParams);
    }else{
      MediaMix.Grid.Rows(aParams.Id).SetValues(aParams);
    }
  },
  OnSubmit:function(e,aParams){
    MediaMix.Slider.SliderArray.forEach(function(aSlider){
      var zValues ={
        Id:aSlider.Id,
        Value:aSlider.Value,
        RunRate:$(aSlider.InputName + '_RunRate').value,
        PubDiversity:$(aSlider.InputName + '_PubDiversity').value
      };
      MediaMix.SetGridValues(zValues);
    });
    return true;
  },
  SetSliderDisplay: function() {
    var i,zSliderDisplayField;
    for (i = 0; i < MediaMix.Slider.SliderArray.length; i++) {
      zSliderDisplayField = $(MediaMix.Slider.Name +'_' + MediaMix.Slider.SliderArray[i].Id + '_Display');
      zSliderDisplayField.value = MediaMix.FormatValue(MediaMix.Slider.SliderArray[i].Value);
    }
    return true;
  },
  SetDateValues: function(aEndDate_Display,aEndDate_Day,aEndDate_Month,aEndDate_Year,aStartDate_Display,aStartDate_Day,aStartDate_Month,aStartDate_Year) {
    $('inpzStartDateDate_Date').value = aStartDate_Display;
    $('inpStartDate_Month').value = aStartDate_Month;
    $('inpStartDate_Day').value = aStartDate_Day;
    $('inpStartDate_Year').value = aStartDate_Year;
    $('inpzEndDateDate_Date').value = aEndDate_Display;
    $('inpEndDate_Month').value = aEndDate_Month;
    $('inpEndDate_Day').value = aEndDate_Day;
    $('inpEndDate_Year').value = aEndDate_Year;
    return true;
  },
  DrawMatrix: function() {
    var m,z,zSliderElement,zDataRow,zRowValue,zColValue,zTempInput;
    for (m=0; m<MediaMix.Slider.SliderArray.length; m++) {
      zSliderElement = MediaMix.Slider.SliderArray[m];
      if(MediaMix.Grid.Rows(zSliderElement.Id)){
        zRowValue = MediaMix.Grid.Rows(zSliderElement.Id).Column('PubDiversity').Get() || 3;
        zColValue = MediaMix.Grid.Rows(zSliderElement.Id).Column('RunRate').Get() || 3;
      }else{
        zRowValue = 3;
        zColValue = 3;
      }
      zTempInput = {
        Slider:zSliderElement,
        Matrix:new MatrixInput({
          Name:'Input'+m,
          RowInputName: zSliderElement.InputName + '_PubDiversity',
          ColInputName: zSliderElement.InputName + '_RunRate',
          RowValue: zRowValue,
          ColValue: zColValue
        })
      };
      MediaMix.MatrixInputArray.push(zTempInput);
      MediaMix.MatrixInputList[zSliderElement.Id] = zTempInput;
    }
    for (z=0; z<MediaMix.MatrixInputArray.length; z++) {
      $(MediaMix.Slider.Name +'_'+MediaMix.MatrixInputArray[z].Slider.Id+'_DisplayDiv').appendChild(MediaMix.MatrixInputArray[z].Matrix.CreateElement());
      $(MediaMix.Slider.Name +'_'+MediaMix.MatrixInputArray[z].Slider.Id+'_DisplayDiv').style.width = '300px';
    }
    return true;
  },
  PopulateForm: function(aSelect) {
    if(aSelect.value){
      LiveRequest_MakeRequest(aSelect.value.toPagePath() + '.GetItemData', MediaMix.ReceiveData);
    }else{
      MediaMix.ResetForm();
    }
    return true;
  },
  ResetForm:function(){
    MediaMix.Slider.ResetWeightedSliders();
    MediaMix.DisableForm(false);
    MediaMix.SetBasicField($('inpDescription'),'');
    MediaMix.SetBasicField($('inpCopy'),'');
    MediaMix.SetBasicField($('inpCoOpPercentage'),0);
  },
  SetBasicField:function(aField,aVal){
    if(!aField){ return; }
    aField.value = aVal;
  },
  DisableForm:function(aDisable){
    function DisableField(aField){
      (aDisable ? AddClass:RemoveClass)(aField,'ReadOnly');
      aField.readOnly = aDisable;
    }
    DisableField($('inpDescription'));
    DisableField($('inpCopy'));
    MediaMix.Slider.SetDisabled(aDisable);
    MediaMix.MatrixInputArray.forEach(function(aInput){
      aInput.Matrix.SetDisabled(aDisable);
    });
  },
  ReceiveData: function(aDataObject) {
    MediaMix.SetBasicField($('inpName'),aDataObject.DisplayName);
    MediaMix.SetBasicField($('inpDescription'),aDataObject.Description);
    MediaMix.SetBasicField($('inpCopy'),aDataObject.Detail);
    MediaMix.SetBasicField($('inpBudget'),aDataObject.Budget);
    MediaMix.SetBasicField($('inpCoOpPercentage'),aDataObject.CoOpPercentage);
    MediaMix.SetBasicField($('inpDuration'),aDataObject.Duration);
    MediaMix.SetBasicField($('inpDurationUnit'),aDataObject.DurationUnit);
    var zSliderValues = {};
    aDataObject.MediaMixValues.forEach(function(aMix){
      zSliderValues[aMix.Id] = parseInt(aMix.Value);
      var zInput = MediaMix.MatrixInputList[aMix.Id];
      if(zInput&&zInput.Matrix){
        zInput.Matrix.SetSelected(aMix.PubDiversity,aMix.RunRate);
      }
    });
    MediaMix.Slider.ResetWeightedSliders(zSliderValues);
    MediaMix.SetDateValues(
      aDataObject.DateValues['EndDateDisplay'].Value,
      aDataObject.DateValues['EndDateDay'].Value,
      aDataObject.DateValues['EndDateMonth'].Value,
      aDataObject.DateValues['EndDateYear'].Value,
      aDataObject.DateValues['StartDateDisplay'].Value,
      aDataObject.DateValues['StartDateDay'].Value,
      aDataObject.DateValues['StartDateMonth'].Value,
      aDataObject.DateValues['StartDateYear'].Value
    );
    function SetField(aField,aVal){
      if(!aField){ return; }
      aField.value = aVal;
    }
    var zLocalCustomizationField = $('inpLocalCustomizationAllowed');
    if (zLocalCustomizationField) {
      if (aDataObject.LocalCustomization=='Y') {
        zLocalCustomizationField.checked = true;
      } else {
        zLocalCustomizationField.checked = false;
      }
    }
    MediaMix.DisableForm(!isTrue(aDataObject.LocalCustomization));
    return true;
  }
};
var MediaMixChart = {
  XIncrementArray:[],
  XSizeBase:10,
  YIncrementArray:[],
  YSizeBase:10,
  YIncrements:10,
  Height:200,
  Width:400,
  MonthModifier:0,
  YearModifier:0,
  ChartContainer:new Object(),
  DataPoint:new Object(),
  DataList:{},
  DisplayDiv:$('MediaMixDetailsPopup'),
  Init: function(aListName) {
    var i;
    MediaMixChart.DataList = aListName;
    MediaMixChart.CalculateXIncrements();
    MediaMixChart.CalculateYIncrements();
    MediaMixChart.DrawAxis();
    for (i = 0; i < MediaMixChart.DataList.length; i++) {
      MediaMixChart.DrawItem();
    }
    return true;
  },
  CalculateXIncrements: function() {
    MediaMixChart.MonthModifier = (365/12/7)
    MediaMixChart.YearModifier = (365/7)
    MediaMixChart.XIncrementArray.push({Duration:6,DurationUnit:'6Wks'});
    MediaMixChart.XIncrementArray.push({Duration:(3*MediaMixChart.MonthModifier),DurationUnit:'3Mo.'});
    MediaMixChart.XIncrementArray.push({Duration:(6*MediaMixChart.MonthModifier),DurationUnit:'6Mo.'});
    MediaMixChart.XIncrementArray.push({Duration:(9*MediaMixChart.MonthModifier),DurationUnit:'9Mo.'});
    MediaMixChart.XIncrementArray.push({Duration:(1*MediaMixChart.YearModifier),DurationUnit:'1Yr'});
    MediaMixChart.XSizeBase = (MediaMixChart.Width/MediaMixChart.XIncrementArray[MediaMixChart.XIncrementArray.length-1].Duration)
    return;
  },
  CalculateYIncrements: function() {
    var i,zPrimaryValue = (Math.ceil((fBudgetMaxValue/MediaMixChart.YIncrements)/1000)*1000);
    MediaMixChart.YIncrementArray.push(zPrimaryValue);
    for (i = 2; i <= MediaMixChart.YIncrements; i++) {
      MediaMixChart.YIncrementArray.push(zPrimaryValue * i);
    }
    MediaMixChart.YSizeBase = (MediaMixChart.Height/MediaMixChart.YIncrementArray[MediaMixChart.YIncrementArray.length-1]);
    return;
  },
  DrawAxis: function() {
    var zDrawScript = '<div id="MediaMixChartAxis">'
                + '<div id="MediaMixChartBlank"></div>'
                + '<div id="MediaMixChartYAxis"></div>'
                + '<div id="MediaMixChartXAxis"></div>'
                + '<div id="MediaMixChartContainer"></div>'
                + '</div>';
    document.write(zDrawScript);
    MediaMixChart.AxisContainer = $('MediaMixChartAxis');
    MediaMixChart.ChartContainer = $('MediaMixChartContainer');
    MediaMixChart.PositionDiv = $('MediaMixChartBlank');
    MediaMixChart.XAxis = $('MediaMixChartXAxis');
    MediaMixChart.DrawXAxis(MediaMixChart.XAxis);
    MediaMixChart.YAxis = $('MediaMixChartYAxis');
    MediaMixChart.DrawYAxis(MediaMixChart.YAxis);
    MediaMixChart.ChartContainer.style.position = 'absolute';
    MediaMixChart.ChartContainer.style.width    = MediaMixChart.Width + 'px';
    MediaMixChart.ChartContainer.style.height   = MediaMixChart.Height + 'px';
    MediaMixChart.ChartContainer.style.top      = MediaMixChart.PositionDiv.offsetHeight + 'px';
    MediaMixChart.ChartContainer.style.left     = MediaMixChart.PositionDiv.offsetWidth + 'px';
    MediaMixChart.XAxis.style.paddingLeft       = MediaMixChart.PositionDiv.offsetWidth + 'px';
    MediaMixChart.XAxis.style.width             = MediaMixChart.Width + 'px';
    MediaMixChart.XAxis.style.height            = MediaMixChart.PositionDiv.offsetHeight + 'px';
    MediaMixChart.YAxis.style.top               = MediaMixChart.PositionDiv.offsetHeight + 'px';
    MediaMixChart.AxisContainer.style.height    = (MediaMixChart.Height + MediaMixChart.PositionDiv.offsetHeight + MediaMixChart.YIncrementArray.length) + 'px';
    MediaMixChart.AxisContainer.style.width     = (MediaMixChart.Width + MediaMixChart.PositionDiv.offsetWidth) + 'px';
  },
  DrawYAxis: function(aAxisNode) {
    var j,zNewNode,zDivTop = 0
    var zDivHeight = Math.ceil(MediaMixChart.Height/MediaMixChart.YIncrements);
    var zDivWidth  = (MediaMixChart.Width + MediaMixChart.PositionDiv.offsetWidth) + 'px';
    for (j = 0; j < MediaMixChart.YIncrementArray.length; j++) {
      zDivTop    = (zDivTop + zDivHeight)
      zNewNode = document.createElement('div');
      zNewNode.innerHTML    = '$' + MediaMixChart.YIncrementArray[j];
      zNewNode.style.width  =  zDivWidth;
      zNewNode.style.height =  zDivHeight + 'px';
      zNewNode.style.top    =  zDivTop + 'px';
      zNewNode.style.lineHeight = (zDivHeight+5) + 'px';
      aAxisNode.appendChild(zNewNode);
    }
  },
  DrawXAxis: function(aAxisNode) {
    var j,zNewNode,zDivWidth = 0;
    for (j = 0; j < MediaMixChart.XIncrementArray.length; j++) {
      if (zDivWidth == 0) {
        zDivWidth = ((MediaMixChart.XIncrementArray[j].Duration * MediaMixChart.XSizeBase)-MediaMixChart.XIncrementArray.length);
      } else {
        zDivWidth = (((MediaMixChart.XIncrementArray[j].Duration - MediaMixChart.XIncrementArray[j-1].Duration) * MediaMixChart.XSizeBase)-MediaMixChart.XIncrementArray.length);
      }
      zNewNode = document.createElement('div');
      zNewNode.innerHTML    = MediaMixChart.XIncrementArray[j].DurationUnit;
      zNewNode.style.width  = zDivWidth + 'px';
      zNewNode.style.height = MediaMixChart.PositionDiv.offsetHeight + 'px';
      aAxisNode.appendChild(zNewNode);
    }
  },
  DrawItem: function() {
    var zNewNode,zDataItem = MediaMixChart.DataList[i];
    zNewNode = document.createElement("div");
    zNewNode.className = 'MediaMixDataPoint';
    zNewNode.innerHTML = '&nbsp;';
    MediaMixChart.ChartContainer.appendChild(zNewNode);
    MediaMixChart.CalculatePosition(zDataItem,zNewNode);
    appendEventHandler(zNewNode,'onclick',MediaMixChart.DisplayDetails,zDataItem)
  },
  CalculatePosition: function(aDataItem,aDisplayNode) {
    var zDurationMultiplier;
    if (aDataItem.DurationUnit == 'W') {
      zDurationMultiplier = 1;
      aDataItem.DurationText = 'Week(s)';
    }
    if (aDataItem.DurationUnit == 'M') {
      zDurationMultiplier = MediaMixChart.MonthModifier;
      aDataItem.DurationText = 'Month(s)';
    }
    if (aDataItem.DurationUnit == 'Y') {
      zDurationMultiplier = MediaMixChart.YearModifier;
      aDataItem.DurationText = 'Year(s)';
    }
    aDisplayNode.style.left = ((aDataItem.Duration * MediaMixChart.XSizeBase) * zDurationMultiplier) + 'px';
    aDisplayNode.style.top = (aDataItem.Budget * MediaMixChart.YSizeBase) + 'px';
  },
  DisplayDetails: function(e,aDataItem) {
    var zDisplayItem = 'Budget: $' + MediaMix.InsertCommas(aDataItem.Budget.toString()) + '<br />'
                 + 'Duration: ' + aDataItem.Duration + ' ' + aDataItem.DurationText + '<br />'
                 + '<a href="#">View Media Mix</a>';
    var zPageURL = aDataItem.ItemPath.toPagePath() + '.ContentInterface';
    ActivityOptions.Show(e,{Title: aDataItem.DisplayName, Options: [
      {DisplayName: zDisplayItem, Function: function(e,aDataItem){document.location = zPageURL;return true;}, Params: aDataItem},
    ]});
    return true;
  }
};
function MatrixInput(aParams){
  this.Name            = aParams.Name;
  this.Units           = aParams.Units || 1;
  this.Rows            = aParams.Rows  || 5;
  this.Cols            = aParams.Cols  || 5;
  this.RowInputName    = aParams.RowInputName || 'inp'+ this.Name +'_Row';
  this.ColInputName    = aParams.ColInputName || 'inp'+ this.Name +'_Col';
  this.RowValue        = aParams.RowValue || this.Units;
  this.ColValue        = aParams.ColValue || this.Units;
  this.MatrixContainer = null;
  this.Disabled        = false;
}
MatrixInput.prototype.Draw = function(){
  var zOut = [];
  zOut.push('<div class="MatrixInput" id="MatrixInput_'+ this.Name +'">');
  zOut.push(this.GetHTML());
  zOut.push('</div>');
  document.write(zOut.join('\n'));
  this.MatrixContainer = $('MatrixInput_'+ this.Name);
  this.Init();
}
MatrixInput.prototype.CreateElement = function(){
  var zDiv = CreateBasicElement('DIV','MatrixInput_'+ this.Name,'MatrixInput');
  setInnerHTML(zDiv,this.GetHTML());
  this.MatrixContainer = zDiv;
  this.Init();
  return zDiv;
}
MatrixInput.prototype.SetSelected = function(aRowValue,aColValue){
  this.SetValues(aRowValue,aColValue);
  var zTD = $('MatrixInput_'+ this.Name +'_'+ aRowValue +'_'+ aColValue);
  SelectElement(zTD);
}
MatrixInput.prototype.SetDisabled = function(aDisable){
  if(aDisable){
    AddClass(this.MatrixContainer,'MatrixDisabled');
    this.RemoveHandlers();
  }else{
    RemoveClass(this.MatrixContainer,'MatrixDisabled');
    this.AppendHandlers();
    Widgets.Update(this.MatrixContainer);
  }
}
MatrixInput.prototype.Init = function(){
  this.AppendHandlers();
}
MatrixInput.prototype.GetHTML = function(){
  var x,y,zOut = [];
  zOut.push('<input type="hidden" name="'+ this.RowInputName +'" id="'+ this.RowInputName +'" value="'+ this.RowValue +'" />');
  zOut.push('<input type="hidden" name="'+ this.ColInputName +'" id="'+ this.ColInputName +'" value="'+ this.ColValue +'" />');
  zOut.push('<table cellpadding="0" cellspacing="0" border="0">');
  var zColValue,zRowValue = 0;
  var zIsSelected = '';
  for(x=this.Rows;x>0;x--){
    zRowValue = x*this.Units;
    zOut.push('<tr>');
    zColValue = 0;
    for(y=1;y<=this.Cols;y++){
      zColValue = y*this.Units;
      if(this.ColValue == zColValue && this.RowValue == zRowValue){
        zIsSelected = ' IsSelected="Y"';
      }else{
        zIsSelected = '';
      }
      zOut.push('<td hoverable="Y" id="MatrixInput_'+ this.Name +'_'+ zRowValue +'_'+ zColValue +'" selectgroup="'+ this.Name +'"'+ zIsSelected +' matrixrow="'+ zRowValue +'" matrixcol="'+ zColValue +'">&nbsp;</td>');
    }
    zOut.push('</tr>');
  }
  zOut.push('</table>');
  return zOut.join('\n');
}
MatrixInput.prototype.AppendHandlers = function(){
  var zTDs = getElementsWithAttribute('selectgroup',this.Name,'TD',this.MatrixContainer);
  var zSelf = this;
  zTDs.forEach(function(aTD){
    appendEventHandler(aTD,'onclick',MatrixInput.SelectIntersection,{MatrixInput:zSelf,Row:aTD.getAttribute('matrixrow'),Col:aTD.getAttribute('matrixcol')});
  });
}
MatrixInput.prototype.RemoveHandlers = function(){
  var zTDs = getElementsWithAttribute('selectgroup',this.Name,'TD',this.MatrixContainer);
  var zSelf = this;
  zTDs.forEach(function(aTD){
    removeEventHandler(aTD,'onclick');
    removeEventHandler(aTD,'onmouseover');
    removeEventHandler(aTD,'onmouseout');
  });
}
MatrixInput.prototype.SetValues = function(aRowValue,aColValue){
  this.RowValue = aRowValue;
  this.ColValue = aColValue;
  $(this.RowInputName).value = aRowValue;
  $(this.ColInputName).value = aColValue;
}
MatrixInput.SelectIntersection = function(e,aParams){
  aParams.MatrixInput.SetValues(aParams.Row,aParams.Col);
  return true;
}
  // LiveBlog.ModuleJS
  // LiveFind.ModuleJS
  // LiveForum.ModuleJS
  // LiveGroup.ModuleJS
var LiveGroup = {
  UserExists:'',
  EmailExists:'',
  Reference: {
    Months: new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'),
    DaysShort: new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')
  },
  CheckAvailability: function(e,aPlayerAliasInputId, aEmailInputId, aDomainInputId) {
    var zPlayerAlias = $(aPlayerAliasInputId).value;
    var zDomain = $(aDomainInputId).value;
    if (aEmailInputId) {
      var zEmailAddress = $(aEmailInputId).value;
    } else {
      var zEmailAddress = '';
    }
    LiveRequest_MakeRequest('/JavaScript.VerifyDetails?aObjectTypeAlias=LiveGroup_Player&aPlayerAlias=' + zPlayerAlias + '&aEmailAddress=' + zEmailAddress + '&aDomain=' + zDomain, LiveGroup.ConfirmAvailbility, LiveGroup.UserExists);
    return true;
  },
  ConfirmAvailbility:function() {
    if (LiveGroup.UserExists=='Y') {
      LiveGroup.MissingInfo += '<div class="MissingItem">This alias has been taken. Please try a different alias.</div>';
    }
    if (LiveGroup.EmailExists == 'Y') {
      LiveGroup.MissingInfo += '<div class="MissingItem">This email address has already been registered. Please enter a new email address.</div>';
    }
    if(LiveGroup.DomainExists=='Y'){
      LiveGroup.MissingInfo += '<div class="MissingItem">This domain is already in use</div>';
    }
    LiveGroup.DisplayModal(LiveGroup.MissingInfo);
    return true;
  },
  PlayerDetails: function(e,aDomain) {
    var zPlayerAlias = $('inpPlayerAlias').value;
    var zPlayerDetails = 'Site URL: http://' +zPlayerAlias+'.'+aDomain+'<br />'
                       + 'Site Email: ' +zPlayerAlias+'@'+aDomain;
    $('DisplayPlayerDetails').innerHTML = zPlayerDetails;
    return true;
  },
  PopUpDiv: function(aItemArray,aParamObj) {
    LiveGroup.RequestLink = this;
    LiveGroup.RequestURL = aParamObj.URL;
    removeEventHandler(this,"onclick",LiveGroup.PopUpDiv)
    LiveGroup.AllContentDIV = $('AllContent');
    var zTempContainer = document.createElement('div');
    zTempContainer.id = aParamObj.PopUpID;
    LiveGroup.AllContentDIV.appendChild(zTempContainer);
    var zIFrame = document.createElement('iframe');
    zIFrame.id = aParamObj.IFrameID;
    zIFrame.src = LiveGroup.RequestURL;
    zIFrame.scrolling = 'no';
    zIFrame.frameborder = '0';
    zTempContainer.appendChild(zIFrame);
    var zCloseButton = document.createElement('div');
    zCloseButton.id = 'CloseDIV';
    zCloseButton.style.width = '10px';
    zCloseButton.style.height = '225px';
    zCloseButton.style.position = 'absolute';
    zCloseButton.style.top = '5px';
    zCloseButton.style.right = '5px';
    zCloseButton.style.color = '#fff';
    zCloseButton.style.fontWeight = 'bold';
    zCloseButton.style.cursor = 'pointer';
    zCloseButton.innerHTML = 'X';
    zTempContainer.appendChild(zCloseButton);
    appendEventHandler(zCloseButton,'onclick',LiveGroup.HideDIV,zTempContainer);
  },
  HideDIV: function(e,aDiv) {
    LiveGroup.AllContentDIV.removeChild(aDiv);
    var zPopUpAttributes = {
      URL: LiveGroup.RequestLink.getAttribute('ControlPanelURL'),
      PopUpID: LiveGroup.RequestLink.getAttribute('PopUpID'),
      IFrameID: LiveGroup.RequestLink.getAttribute('IFrameID')
    }
    appendEventHandler(LiveGroup.RequestLink,'onclick',LiveGroup.PopUpDiv,zPopUpAttributes);
  },
  ValidateForm: function(aForm) {
    LiveGroup.MissingInfo = "";
    if (aForm.inpName) {
      if (aForm.inpName.value == "") {
        LiveGroup.MissingInfo += '<div class="MissingItem">Name Missing</div>';
      }
    }
    if (aForm.inpFirstName) {
      if (aForm.inpFirstName.value == "") {
        LiveGroup.MissingInfo += '<div class="MissingItem">First Name Missing</div>';
      }
    }
    if (aForm.inpLastName) {
      if (aForm.inpLastName.value == "") {
        LiveGroup.MissingInfo += '<div class="MissingItem">Last Name Missing</div>';
      }
    }
    if (aForm.inpPlayerAlias) {
      if (aForm.inpPlayerAlias.value == "") {
        LiveGroup.MissingInfo += '<div class="MissingItem">Player Alias Missing</div>';
      }
    }
    if (aForm.inpPassword) {
      if (aForm.inpPassword.value == "") {
        LiveGroup.MissingInfo += '<div class="MissingItem">Password Missing</div>';
      }
    }
    if (aForm.inpConfirmPassword) {
      if (aForm.inpConfirmPassword.value == "") {
        LiveGroup.MissingInfo += '<div class="MissingItem">Confirm Password Missing</div>';
      }
    }
    if (aForm.inpURLPrefix) {
      if (aForm.inpURLPrefix.value == "") {
        LiveGroup.MissingInfo += '<div class="MissingItem">URL Prefix Missing</div>';
      }
    }
    if (aForm.inpEmailAddress) {
      if (
        (aForm.inpEmailAddress.value == "") ||
        (aForm.inpEmailAddress.value.indexOf('@') == -1) ||
        (aForm.inpEmailAddress.value.indexOf('.') == -1)) {
         LiveGroup.MissingInfo += '<div class="MissingItem">Email Address Missing</div>';
      }
    }
    if (aForm.inpEmailAddress) {
      LiveGroup.CheckAvailability('',aForm.inpName.id,aForm.inpEmailAddress.id, aForm.inpDomain.id);
    } else {
      LiveGroup.CheckAvailability('',aForm.inpName.id,'',aForm.inpDomain.id);
    }
    if (aForm.inpConfirmPassword && aForm.inpPassword) {
      if (aForm.inpConfirmPassword.value != aForm.inpPassword.value) {
        LiveGroup.MissingInfo += '<div class="MissingItem">Password and Confirm Password do not match</div>';
      }
    }
    if (aForm.inpAgree) {
      if (aForm.inpAgree.checked == "") {
        LiveGroup.MissingInfo += '<div class="MissingItem">You did not agree to the TOS or Privacy Policy.</div>';
      }
    }
    if (LiveGroup.Security.PassedAuth != "Y") {
      LiveGroup.MissingInfo += '<div class="MissingItem">You did not enter the correct security code.</div>';
    }
    return false;
  },
  Process: {
    StepNum: 0,
    Processes: [
      "Initializing",
      "Validating Information",
      "Adding User",
      "Giving Access to Database",
      "Setting Up Communication Settings",
      "Setting Up Content List",
      "Setting Up Inbox",
      "Creating Profile",
      "Searching for Avatar",
      "Assigning Avatar",
      "Searching for Skin",
      "Assigning Skin",
      "Creating Dashboard",
      "Scanning for Updates",
      "Finalizing"
    ],
    Step: function(aProcess) {
      var result = Math.random();
      result = Math.floor(result * 3000);
      LiveGroup.Modal.innerHTML = aProcess + '...';
      LiveGroup.Process.StepNum++
      if (LiveGroup.Process.Processes[LiveGroup.Process.StepNum]) {
        setTimeout('LiveGroup.Process.Step(LiveGroup.Process.Processes[LiveGroup.Process.StepNum])',result);
      }
    }
  },
  DisplayModal: function(aMissingInfo,aForm,aModal) {
    if (aMissingInfo != "") {
    if (aModal) {
      var aModal = aModal;
    } else {
      var aModal = $('ModalMessage');
    }
    aModal.innerHTML = '<div id="ErrorMessageIcon"></div>'
                        + '<div id="ErrorMessageTop"><div id="MessageTitle">Error</div></div>'
                        + '<div id="ErrorMessageMiddle"><div id="ErrorMessage"></div></div>'
                        + '<div id="ErrorMessageBottom"></div>'
                        + '<div id="CloseButton">Close</div>';
    var zMessageDiv = $('ErrorMessage');
    var zCloseButton = $('CloseButton');
    zMessageDiv.innerHTML = '<span class="MessageDescription">The following errors were encountered:</span>' + aMissingInfo;
    appendEventHandler(zCloseButton,'onclick',Modal.Hide);
    Modal.Show(aModal);
    window.scrollTo(0,0);
    LiveGroup.ModalOverlay = $('ModalOverlay');
    LiveGroup.ModalOverlay.style.height = '1200px';
      return false;
    } else {
      zLoadingImage = new Image();
      zLoadingImage.src = "/l.c.bin/I/4803774/Loading-BG.gif";
      if (aModal) {
        var aModal = aModal;
      } else {
        var zNormalModal = document.createElement('div');
        zNormalModal.id = 'LoadingModal';
        document.body.appendChild(zNormalModal);
        var aModal = $('LoadingModal');
      }
      Modal.Show(aModal);
      LiveGroup.Modal = aModal;
      LiveGroup.Process.Step(LiveGroup.Process.Processes[LiveGroup.Process.StepNum]);
      window.scrollTo(0,0);
      LiveGroup.ModalOverlay = $('ModalOverlay');
      LiveGroup.ModalOverlay.style.height = '1200px';
      if (document.frmKBItem) {
        document.frmKBItem.submit();
      } else {
        aForm.submit();
      }
      return true;
    }
  },
  DisplaySearchItems: function(aSearchItemPath,aAdditionalDetailsID,aAdditionalDetailsLink,aType) {
    var aParamObj = {
      AdditionalDetailsID : aAdditionalDetailsID,
      AdditionalDetailsLink : aAdditionalDetailsLink,
      SearchPath : aSearchItemPath
    };
    switch (aType) {
      case "PLAYER":
        LiveRequest_MakeRequest('/JavaScript.GetInfo?aObjectTypeAlias=LiveGroup_Player&aSearchItemPath=' +aSearchItemPath, LiveGroup.DisplaySearchItemInfo, aParamObj);
      break;
      case "TEAM":
        LiveRequest_MakeRequest('/JavaScript.GetInfo?aObjectTypeAlias=LiveGroup_TeamDatabase&aSearchItemPath=' +aSearchItemPath, LiveGroup.DisplaySearchItemInfo, aParamObj);
      break;
    }
    return true;
  },
  DisplaySearchItemInfo: function(aItemArray,aParamObj) {
    var zAdditionalDetails = $(aParamObj.AdditionalDetailsID);
    var zAdditionalDetailsLink = $(aParamObj.AdditionalDetailsLink);
    zAdditionalDetails.style.display = 'block';
    switch (aItemArray[0].TYPE) {
      case "PLAYER":
        var zDescriptionDiv = document.createElement('div');
          zDescriptionDiv.className = 'SearchItemDetail';
          zDescriptionDiv.innerHTML = '<b>About ' + aItemArray[0].PLAYERNAME + ':</b><br>' + aItemArray[0].DESCRIPTION;
          zAdditionalDetails.appendChild(zDescriptionDiv);
        var zGamesPlayingDiv = document.createElement('div');
          zGamesPlayingDiv.className = 'SearchItemDetail';
          zGamesPlayingDiv.innerHTML = '<b>Games Playing:</b><br>' +aItemArray[0].GAMESPLAYED;
          zAdditionalDetails.appendChild(zGamesPlayingDiv);
        var zLinXDiv = document.createElement('div');
          zLinXDiv.className = 'SearchItemDetail';
          zLinXDiv.innerHTML = '<b>LinX:</b><br>' +aItemArray[0].LINX;
          zAdditionalDetails.appendChild(zLinXDiv);
          zAdditionalDetailsLink.innerHTML = 'Hide Info';
          zAdditionalDetailsLink.style.display = 'none';
      break;
      case "TEAM":
        var zDescriptionDiv = document.createElement('div');
          zDescriptionDiv.className = 'SearchItemDetail';
          zDescriptionDiv.innerHTML = '<b>About ' +aItemArray[0].TEAMNAME + ':</b><br>' + aItemArray[0].DESCRIPTION;
          zAdditionalDetails.appendChild(zDescriptionDiv);
        var zTeamMembersDiv = document.createElement('div');
          zTeamMembersDiv.className = 'SearchItemDetail';
          zTeamMembersDiv.innerHTML = '<b>Team Members:</b><br>' +aItemArray[0].TEAMMEMBERS;
          zAdditionalDetails.appendChild(zTeamMembersDiv);
          zAdditionalDetailsLink.innerHTML = 'Hide Info';
          zAdditionalDetailsLink.style.display = 'none';
      break;
    }
    return true;
  },
  Login: {
    PollingCount: 1,
    ChangeButton: function(e,aMessage) {
      aMessage = unescape('Authenticating%20player%20details%2E%20Please%20be%20patient%2E%2E%2E');
      var zSubmitButton     = $('btnLogin');
      var zLoginArea_Object = $('LoginArea');
      var zNode       = document.createElement('div');
      zNode.id        = 'Login_SubmitMessage';
      zNode.innerHTML = aMessage;
      zSubmitButton.style.visibility = 'hidden';
      zLoginArea_Object.appendChild(zNode);
      $('frmLoginForm').submit();
      return true;
    },
    UserInformation: '',
    PlayerDetails: null,
    Init: function() {
      LiveGroup.Login.Auth();
      return true;
    },
    Auth: function(aForce) {
      zCurrentID=GetCookieValue('TLOAID');
      if (zCurrentID != '') {
        if (aForce || LiveGroup.Login.UserInformation == null || LiveGroup.Login.UserInformation == '') {
          LiveRequest_MakeRequest('/voig/ContentList/LiveFindDatabaseList/H/HA/HAI/HairymopDatabase/Hairymop/JavaScript.GetAccountDetails?aLanguage=en-us&aObjectTypeAlias=LiveGroup_PlayerDatabase&CurrentID=' + zCurrentID + '', LiveGroup.Login.ReceiveUserInformation);
        }
      } else {
        LiveGroup.Login.ReceiveUserInformation({LoggedInStatus: 'N'});
      }
    },
    Display: function() {
      var zLoginForm = $('frmLoginForm');
      if (LiveGroup.Login.UserInformation.LoggedInStatus=='Y') {
        LiveGroup.Login.PlayerDetails = $('Login_PlayerDetails');
        LiveGroup.Login.PopulateUserInfo(LiveGroup.Login.UserInformation);
        LiveGroup.Login.PlayerDetails.style.display = 'block';
        zLoginForm.style.display = 'none';
      } else {
        zLoginForm.style.display = 'block';
      }
    },
    GetSites: function() {
      return true;
    },
    DrawSites: function(aSiteArray,e) {
      LiveGroup.Login.SitePopUpDiv = document.createElement('div');
      LiveGroup.Login.SitePopUpDiv.id = 'SiteDetailsContainer';
      document.body.appendChild(LiveGroup.Login.SitePopUpDiv);
      for (i=0; i<aSiteArray.length; i++) {
        var zSiteInfoContainer = document.createElement('div');
        zSiteInfoContainer.className = 'SiteInfoContainer';
        LiveGroup.Login.SitePopUpDiv.appendChild(zSiteInfoContainer);
        zSiteInfoContainer.innerHTML = '<div class="ManageSiteLink"><a href="' + unescape(aSiteArray[i].AdminURL) + '">Manage</a></div>' +
                                       '<div class="SiteName"><a href="'+ unescape(aSiteArray[i].SiteURL) +'">' + unescape(aSiteArray[i].SiteName) + '</a></div>'+
                                       '<div class="NewMessages">' + unescape(aSiteArray[i].Messages) + ' Messages</div>'+
                                       '<div class="NewRequests">' + unescape(aSiteArray[i].Requests) + ' Requests</div>';
      }
      return true;
    },
    DisplayTeams: function() {
      LiveGroup.Login.SitePopUpDiv.style.display = 'block';
      return true;
    },
    HideTeams: function() {
      LiveGroup.Login.SitePopUpDiv.style.display = 'none';
      return true;
    },
    PopulateUserInfo: function(aUserInformationObject) {
      if (aUserInformationObject.MultipleSites == 'Y') {
        var aManageButtonMessage = 'Manage Sites';
        LiveGroup.Login.GetSites();
      } else {
        var aManageButtonMessage = 'Manage Site';
      }
      var zPlayerDetails  = '<div id="Login_Avatar"><i'+'mg s'+'rc="' + aUserInformationObject.PlayerAvatarURL + '" border=0 /></div>'
                          + '<h2>' + aUserInformationObject.PlayerAlias + '</h2>'
                          + '<div id="Login_DatabaseURL"><a hr'+'ef="http://' + aUserInformationObject.URL+ '">View Site</a></div>'
                          + '<div id="Login_SignOutLink"><a href="/Home.LogoutComplete?aLanguage=en%2Dus&aReturnURL=http%3A%2F%2Fhairymop.voig.com%2FHome.html">Sign out</a></div>'
                          + '<div id="Login_MessageCount">'+ aUserInformationObject.MessageCount + ' </div>'
                          + '<div id="Login_RequestCount">'+ aUserInformationObject.RequestCount +' </div>'
                          + '<div id="Login_CommentCount">'+ aUserInformationObject.CommentCount +' </div>'
                          + '<div id="Login_ManageSite">' + aManageButtonMessage + '</div>';
      LiveGroup.Login.PlayerDetails.innerHTML = zPlayerDetails;
      var zAdminURL = LiveGroup.Login.UserInformation.AdminURL.substring(0,(LiveGroup.Login.UserInformation.AdminURL.length - 10));
      var zViewMessageLink = document.createElement("a");
        zViewMessageLink.href = 'http://' + zAdminURL + '/Admin.Mailbox';
        zViewMessageLink.appendChild(document.createTextNode("New Messages"));
        document.getElementById("Login_MessageCount").appendChild(zViewMessageLink);
      var zViewRequestLink = document.createElement("a");
        zViewRequestLink.href = 'http://' + zAdminURL + '/Admin.Friends';
        zViewRequestLink.appendChild(document.createTextNode(" Friend Requests"));
        document.getElementById("Login_RequestCount").appendChild(zViewRequestLink);
     var zViewComments = document.createElement("a");
        zViewComments.href = 'http://' + zAdminURL;
        zViewComments.appendChild(document.createTextNode(" New Comments"));
        document.getElementById("Login_CommentCount").appendChild(zViewComments);
      var zManageButton = $('Login_ManageSite');
      var zButton_ManageSite = $('Login_ManageSite');
      var zAvatar_ManageSite = $('Login_Avatar');
      if(aUserInformationObject.MultipleSites=='Y'){
        new LiveGroup.Database.ManageSites(zManageButton);
      }
      else{
        appendEventHandler(zButton_ManageSite, 'onclick', LiveGroup.Login.Launch, LiveGroup.Login.UserInformation.AdminURL);
        appendEventHandler(zAvatar_ManageSite, 'onclick', LiveGroup.Login.Launch, LiveGroup.Login.UserInformation.AdminURL);
      }
      return true;
    },
    Launch: function(e,aURL) {
      document.location = 'http://' + aURL;
      return true;
    },
    SubmitForm: {
      Init: function() {
        LiveGroup.Login.SubmitForm.UserName = $('inpUserName');
        LiveGroup.Login.SubmitForm.Password = $('inpPassword');
        appendEventHandler(LiveGroup.Login.SubmitForm.Password,'onkeypress',LiveGroup.Login.SubmitForm.KeyPress);
        appendEventHandler(LiveGroup.Login.SubmitForm.UserName,'onkeypress',LiveGroup.Login.SubmitForm.KeyPress);
        appendEventHandler($('inpUserName'),'onfocus',LiveGroup.Login.SubmitForm.HideTitleEvent, 'inpUserName');
        appendEventHandler($('inpUserName'),'onkeypress',LiveGroup.Login.SubmitForm.HideTitleEvent, 'inpUserName');
        appendEventHandler($('inpPassword'),'onfocus',LiveGroup.Login.SubmitForm.HideTitleEvent, 'inpPassword');
        appendEventHandler($('inpPassword'),'onkeypress',LiveGroup.Login.SubmitForm.HideTitleEvent, 'inpPassword');
        appendEventHandler($('btnLogin'),'onclick',LiveGroup.Login.ChangeButton);
        LiveGroup.Login.SubmitForm.HideTitleIfNeeded();
        setTimeout("LiveGroup.Login.SubmitForm.HideTitleIfNeeded();",1000);
        return true;
      },
      KeyPress: function(e) {
        if(e.keyCode==13) {
          document.frmLoginForm.submit();
        }
        return true;
      },
      HideTitleIfNeeded: function(){
        if (LiveGroup.Login.SubmitForm.UserName.value != '')
          LiveGroup.Login.SubmitForm.HideFieldTitle('inpUserName');
        else
          LiveGroup.Login.SubmitForm.UserName.style.backgroundImage = 'url()';
        if (LiveGroup.Login.SubmitForm.Password.value != '')
          LiveGroup.Login.SubmitForm.HideFieldTitle('inpPassword');
        else
          LiveGroup.Login.SubmitForm.Password.style.backgroundImage = 'url()';
        return true;
      },
      HideTitleEvent: function(e,aInputName){
        LiveGroup.Login.SubmitForm.HideAllTitles();
        return true;
      },
      HideAllTitles: function(){
        LiveGroup.Login.SubmitForm.HideFieldTitle('inpPassword');
        LiveGroup.Login.SubmitForm.HideFieldTitle('inpUserName');
        return true;
      },
      HideFieldTitle: function(aInputName){
        $(aInputName).style.background='#ffffff url() repeat-x';
        return true;
      }
    },
    LoginDependentFunctions: new Array(),
    ReceiveUserInformation: function(aUserInformationObject) {
      LiveGroup.Login.UserInformation = aUserInformationObject;
      LiveGroup.Login.PollingCount++;
      if (LiveGroup.Login.PollingCount<6) {
        setTimeout('LiveGroup.Login.Auth(\'Y\')', 300000);
      }
      for (i = 0; i < LiveGroup.Login.LoginDependentFunctions.length; i++) {
        if (isFunction(LiveGroup.Login.LoginDependentFunctions[i])) {
          LiveGroup.Login.LoginDependentFunctions[i]();
        } else if (isObject(LiveGroup.Login.LoginDependentFunctions[i])) {
          LiveGroup.Login.LoginDependentFunctions[i].Func(LiveGroup.Login.LoginDependentFunctions[i].Param);
        }
      }
    },
    DisplayVariableLinks: function() {
      var zVarLinkInSpan = $('VariableLinksIn');
      var zVarLinkOutSpan = $('VariableLinksOut');
      var zVarLinkWelcome = $('VariableLinksWelcome');
      var zVarLinkAdmin = $('MinorSignInLink');
      if (LiveGroup.Login.UserInformation.LoggedInStatus == 'Y') {
        zVarLinkAdmin.href = 'http://' + LiveGroup.Login.UserInformation.AdminURL;
        var zVarUserFlag = '';
        if (LiveGroup.Login.UserInformation.PlayerFlagURL != null && LiveGroup.Login.UserInformation.PlayerFlagURL != '')
          zVarUserFlag = '<img src="' + LiveGroup.Login.UserInformation.PlayerFlagURL + '" alt=""/>';
        zVarLinkWelcome.innerHTML = 'Hi ' + LiveGroup.Login.UserInformation.PlayerAlias + ' ' + zVarUserFlag + ' | ';
        zVarLinkInSpan.style.display = 'block';
        zVarLinkOutSpan.style.display = 'none';
      } else {
        zVarLinkOutSpan.style.display = 'block';
      }
      return true;
    }
  },
  Utils: {
    RemoveSubItems: function(aElement) {
      var zElementCount = aElement.childNodes.length;
      for (var j = 0; j < zElementCount; j++) {
        aElement.removeChild(aElement.childNodes[0]);
      }
      return true;
    },
    SetTabClass: function(aTabElement) {
      var zSelected = hasAttribute(aTabElement,'selected');
      if (zSelected) {
        aTabElement.className = 'AssetTab SelectedTab';
        return true;
      } else {
        aTabElement.className = 'AssetTab';
        return false;
      }
    },
    Pagination: {
      Init: function() {
        LiveGroup.Utils.Pagination.CurrentPage = 0;
        LiveGroup.Utils.Pagination.ArticlePage = getElementsWithAttribute('class','Page');
        LiveGroup.Utils.Pagination.ArticlePage[LiveGroup.Utils.Pagination.CurrentPage].style.display = 'block';
        LiveGroup.Utils.Pagination.NextButton = getElementsWithAttribute('IsNextButton','Y');
        LiveGroup.Utils.Pagination.NextButton.forEach(function(aNextButton){
          LiveGroup.Utils.Pagination.NextButton = aNextButton;
        });
        LiveGroup.Utils.Pagination.BackButton = getElementsWithAttribute('IsBackButton','Y');
        LiveGroup.Utils.Pagination.BackButton.forEach(function(aBackButton){
          LiveGroup.Utils.Pagination.BackButton = aBackButton;
        });
        LiveGroup.Utils.Pagination.FocusDIV = getElementsWithAttribute('IsFocusDIV','Y');
        LiveGroup.Utils.Pagination.FocusDIV.forEach(function(aFocusDIV){
          LiveGroup.Utils.Pagination.FocusDIV = aFocusDIV;
        });
        appendEventHandler(LiveGroup.Utils.Pagination.NextButton,'onclick',LiveGroup.Utils.Pagination.Direction,'F');
        appendEventHandler(LiveGroup.Utils.Pagination.BackButton,'onclick',LiveGroup.Utils.Pagination.Direction,'B');
        LiveGroup.Utils.Pagination.DisplayButtons();
        return true;
      },
      Direction: function(e,aDirection) {
        if (aDirection == 'F') {
          if (LiveGroup.Utils.Pagination.CurrentPage < LiveGroup.Utils.Pagination.ArticlePage.length - 1) {
            LiveGroup.Utils.Pagination.ArticlePage[LiveGroup.Utils.Pagination.CurrentPage].style.display = 'none';
            LiveGroup.Utils.Pagination.CurrentPage++;
            LiveGroup.Utils.Pagination.ArticlePage[LiveGroup.Utils.Pagination.CurrentPage].style.display = 'block';
          }
        } else {
          if (LiveGroup.Utils.Pagination.CurrentPage > 0) {
            LiveGroup.Utils.Pagination.ArticlePage[LiveGroup.Utils.Pagination.CurrentPage].style.display = 'none';
            LiveGroup.Utils.Pagination.CurrentPage--;
            LiveGroup.Utils.Pagination.ArticlePage[LiveGroup.Utils.Pagination.CurrentPage].style.display = 'block';
          }
        }
        LiveGroup.Utils.Pagination.DisplayButtons();
        return true;
      },
      DisplayButtons: function() {
        if (LiveGroup.Utils.Pagination.CurrentPage >= LiveGroup.Utils.Pagination.ArticlePage.length - 1) {
          LiveGroup.Utils.Pagination.NextButton.className = 'UnselectedButton';
        } else {
          LiveGroup.Utils.Pagination.NextButton.className = 'SelectedButton';
        }
        if (0 < LiveGroup.Utils.Pagination.CurrentPage) {
          LiveGroup.Utils.Pagination.BackButton.className = 'SelectedButton';
        } else {
          LiveGroup.Utils.Pagination.BackButton.className = 'UnselectedButton';
        }
        LiveGroup.Utils.Pagination.Focus();
        return true;
      },
      Focus: function() {
        if (LiveGroup.Utils.Pagination.PageLoaded) {
          LiveGroup.Utils.Pagination.FocusTop = LiveGroup.Utils.Pagination.FocusDIV.offsetTop;
          window.scrollTo(0,LiveGroup.Utils.Pagination.FocusTop);
        }
        LiveGroup.Utils.Pagination.PageLoaded = 'Y';
        return true;
      },
      GoTo: function(e,aURL) {
        document.location = aURL;
      }
    },
    ScrollingDiv: function(aElement) {
      this.container = aElement;
      this.startScrollUp = function(e, aScrollElement) {
        aScrollElement.content.ScrollInterval = setInterval(function(){
          aScrollElement.scrollUp();
        }, 50);
        return true;
      }
      this.startScrollDown = function(e, aScrollElement) {
        aScrollElement.content.ScrollInterval = setInterval(function(){
          aScrollElement.scrollDown();
        }, 50);
        return true;
      }
      this.scrollUp = function() {
        var zContentTop = parseInt(this.content.style.top);
        zContentTop += 15;
        if(zContentTop <= 0){
          this.content.style.top = zContentTop + 'px';
          this.updateScrollHandlePosition();
        }
        else{
          this.content.style.top = '0px';
        }
        return true;
      }
      this.scrollDown = function() {
        var zContentTop = parseInt(this.content.style.top);
        if((zContentTop * -1) < this.containerMaxY) {
          zContentTop -= 15;
          this.content.style.top = zContentTop + 'px';
          this.updateScrollHandlePosition();
        }
        return true;
      }
      this.updateScrollHandlePosition = function() {
        var zItemContainer = this.content;
        var zOffsetTop = (parseInt(zItemContainer.style.top)/this.containerMaxY)*-1;
        var zScrollHandleOffsetTop = this.handleMaxY * zOffsetTop;
        this.handle.style.top = Math.round(zScrollHandleOffsetTop) + 'px';
      }
      this.dragScrollHandle = function() {
        var zScrollElements = this.parentScroll.setup;
        var zItemContent = this.parentScroll.content;
        var zScrollHandle = this.parentScroll.handle;
        var zAvailableScroll = (parseInt(zScrollHandle.style.top)/this.parentScroll.handleMaxY);
        var zContainerScroll = this.parentScroll.containerMaxY*zAvailableScroll;
        if(zAvailableScroll > 0) {
          zItemContent.style.top = '-' + zContainerScroll + 'px';
        }
        else {
          this.style.top = '0px';
          zItemContent.style.top = '0px';
        }
        return true;
      }
      this.endScroll = function(e, aScrollElement) {
        clearInterval(aScrollElement.content.ScrollInterval);
        aScrollElement.content.ScrollInterval = null;
        return true;
      }
      this.handleMousewheel = function(e) {
        var delta = 0;
        if (!e) e = window.event;
        if (e.wheelDelta) { 
          delta = e.wheelDelta/120;
          if (DOM.isOpera)
            delta = -delta;
        } else if (e.detail) { 
          delta = -e.detail/3;
        }
        if (delta) {
          if (delta < 0)
            this.scrollDown();
          else
            this.scrollUp();
        }
        if (e.preventDefault)
          e.preventDefault();
        e.returnValue = false;
      }
      this.content = CreateBasicElement('div');
      this.content.style.position = 'relative';
      this.content.innerHTML = this.container.innerHTML;
      LiveGroup.Utils.RemoveSubItems(this.container);
      this.container.appendChild(this.content);
      this.content.style.width = this.container.clientWidth - 30 + 'px';
      this.container.style.overflow = 'hidden';
      this.container.style.position = 'relative';
      this.scrollBar = CreateBasicElement('div', null, 'ScrollerBar');
        var zScrollUpButton = CreateBasicElement('span', null, 'ScrollUp TransparentBG');
        this.scrollBar.appendChild(zScrollUpButton);
        var zScrollHandleContainer = CreateBasicElement('div', null, 'ScrollHandleContainer');
        this.scrollBar.appendChild(zScrollHandleContainer);
          this.handle = CreateBasicElement('div', null, 'ScrollHandle');
          zScrollHandleContainer.appendChild(this.handle);
        var zScrollDownButton = CreateBasicElement('span', null, 'ScrollDown TransparentBG');
        this.scrollBar.appendChild(zScrollDownButton);
      this.container.appendChild(this.scrollBar);
      var zScrollMaxY = this.scrollBar.clientHeight - (zScrollDownButton.clientHeight + zScrollUpButton.clientHeight);
      this.containerMaxY = this.content.clientHeight - this.container.clientHeight;
      this.content.style.top = '0px';
      zScrollHandleContainer.style.height = zScrollMaxY + 'px';
      this.handleMaxY = zScrollMaxY - this.handle.clientHeight;
      this.handle.parentScroll = this;
      Drag.init(this.handle, null, 0, 0, 0, zScrollMaxY - this.handle.clientHeight, null, this.dragScrollHandle);
      appendEventHandler(zScrollUpButton, 'onmousedown', this.startScrollUp, this);
      appendEventHandler(zScrollUpButton, 'onmouseup', this.endScroll, this);
      appendEventHandler(zScrollUpButton, 'onmouseout', this.endScroll, this);
      appendEventHandler(zScrollDownButton, 'onmousedown', this.startScrollDown, this);
      appendEventHandler(zScrollDownButton, 'onmouseup', this.endScroll, this);
      appendEventHandler(zScrollDownButton, 'onmouseout', this.endScroll, this);
      var zElement = this;
      var zFunc = function(e) { zElement.handleMousewheel(e); }
      if (this.container.addEventListener)
        this.container.addEventListener('DOMMouseScroll', zFunc, false);
      this.container.onmousewheel = zFunc;
    }
  },
  Security: {
    PassedAuth: '',
    SecureImageURL: '',
    IMGCode: '',
    Init: function() {
      LiveGroup.Security.GetImageLink = $('GetImage');
      LiveGroup.Security.AuthInput = $('inp_AuthCode');
      LiveGroup.Security.IMGInput = $('inpIMGCode');
      LiveGroup.Security.SecureImage = $('SecureImage');
      if (LiveGroup.Security.GetImageLink) {
        LiveGroup.Security.AppendEvents();
      }
      return true;
    },
    AppendEvents: function() {
      appendEventHandler(LiveGroup.Security.GetImageLink,'onclick',LiveGroup.Security.GetImage);
      return true;
    },
    CheckCode: function() {
      LiveRequest_MakeRequest('/Javascript.CheckCode?aLanguage=en%2Dus&aObjectTypeAlias=LiveGroup_Database&inp_AuthCode='+ LiveGroup.Security.AuthInput.value +'&inpIMGCode='+ LiveGroup.Security.IMGInput.value, LiveGroup.Security.Alert, LiveGroup.Security.PassedAuth);
      return false;
    },
    Alert: function() {
      if (LiveGroup.Security.PassedAuth != 'Y') {
        LiveGroup.Security.AuthInput.value = '';
        LiveGroup.Security.GetImage();
      } else {
        LiveGroup.Security.GetImageLink.innerHTML = 'Correct Code Entered';
        LiveGroup.Security.GetImageLink.className = 'SecurityConfirmationText';
        LiveGroup.Security.AuthInput.style.display = 'none';
        $('label-AuthCode').style.display = 'none';
        removeEventHandler(LiveGroup.Security.GetImageLink,'onclick',LiveGroup.Security.GetImage);
      }
      LiveGroup.ValidateForm($('frmKBItem'));
      return false;
    },
    GetImage: function() {
      LiveRequest_MakeRequest('/Javascript.GetSecureImage?aLanguage=en%2Dus&aObjectTypeAlias=LiveGroup_Database', LiveGroup.Security.DisplayImage,  LiveGroup.Security.PassedAuth);
      return false;
    },
    DisplayImage: function() {
      LiveGroup.Security.AuthInput.value = '';
      LiveGroup.Security.SecureImage.src = LiveGroup.Security.SecureImageURL;
      LiveGroup.Security.IMGInput.value = LiveGroup.Security.IMGCode;
      return false;
    },
    InsertCommas: function(a) {
      var p,ad,b='',ep='',di=a.indexOf('.');
      if(di>=0){
        ep=a.substring(di,a.length);
        a=a.substring(0,di);
      }
      ad = Math.ceil(a.length/3);
      if(ad>1){
        for(p=1;p<ad;p++){
          al = a.length;
          b = ','+ a.substring(al-3) + b;
          a = a.substring(0,al-3);
        }
      }
      b = a + b + ep;
      return b;
    }
  }
}
var ColorPicker = {
  PickerArray: [],
  HexArray: new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'),
  Init: function (aId) {
    ColorPicker.PickerArray = getElementsWithAttribute('ColorPicker','Y','div');
    ColorPicker.PickerArray.forEach(function(aDiv){
      ColorPicker.Draw(aDiv);
    });
    return true;
  },
  Draw: function (aContainerDiv) {
    var zPreviewContainerNode = document.createElement('div');
    zPreviewContainerNode.id   = 'ColorPreviewContainer';
    zPreviewContainerNode.className = 'ColorPreviewContainer';
    var zSelectedColorNode = document.createElement('div');
    zSelectedColorNode.id   = 'ColorSelected';
    aContainerDiv.ColorPreviewContainer = zPreviewContainerNode;
    aContainerDiv.ColorPreviewContainer.Selected = zSelectedColorNode;
    aContainerDiv.ColorPreviewContainer.appendChild(zSelectedColorNode);
    aContainerDiv.appendChild(zPreviewContainerNode);
    var zInputNode  = document.createElement('input');
    zInputNode.type = 'Text';
    zInputNode.id   = aContainerDiv.getAttribute('InputName');
    zInputNode.name   = aContainerDiv.getAttribute('InputName');
    aContainerDiv.ColorInput = zInputNode;
    aContainerDiv.appendChild(zInputNode);
    var zColorSwatchNode  = document.createElement('div');
    zColorSwatchNode.className = 'ColorSwatchContainer';
    aContainerDiv.ColorSwatchContainer = zColorSwatchNode;
    aContainerDiv.appendChild(zColorSwatchNode);
    var c = "0";
    var zColNo = new Array(16);
    for (i=0;i<16;i++) {
      zColNo[c] = ColorPicker.HexArray[i]+""+ColorPicker.HexArray[i];
      c++
    }
    for (j=0;j<16;j++) {
      var zColor = zColNo[j]+''+zColNo[j]+''+zColNo[j];
      ColorPicker.DrawElement(aContainerDiv,zColor);
    }
    var zRGBArray = new Array(256);
    var k=0;
    for (i=0;i<16;i++) {
      for (j=0;j<16;j++) {
        zRGBArray[k] = ColorPicker.HexArray[i] + ColorPicker.HexArray[j];
        k++;
      }
    }
    for (d=0;d<6;d++) {
      for (e=0;e<6;e++) {
        for (f=0;f<6;f++) {
          var zColor = zRGBArray[eval(d*51)]+zRGBArray[eval(e*51)]+zRGBArray[eval(f*51)];
          ColorPicker.DrawElement(aContainerDiv,zColor);
        }
      }
    }
    if(hasAttribute(aContainerDiv,'InputValue')) {
      var zDefaultColor = aContainerDiv.getAttribute('InputValue');
      aContainerDiv.ColorInput.value = zDefaultColor;
      aContainerDiv.ColorPreviewContainer.Selected.style.background =  '#' + zDefaultColor;
    }
    return true;
  },
  DrawElement: function (aContainerDiv,aColor) {
    var zColorNodeId = 'C' + aColor;
    var zColorNode = CreateBasicElement('div',zColorNodeId,'ColorPickerDiv');
    zColorNode.style.background = '#'+aColor;
    zColorNode.HexColor = aColor;
    zColorNode.ContainerDiv = aContainerDiv;
    appendEventHandler(zColorNode,'onclick',ColorPicker.SetColor,zColorNode);
    aContainerDiv.ColorSwatchContainer.appendChild(zColorNode);
    return true;
  },
  SetColor: function (e,aColorNode) {
    aColorNode.ContainerDiv.ColorInput.value = aColorNode.HexColor;
    aColorNode.ContainerDiv.ColorPreviewContainer.Selected.style.background =  '#' + aColorNode.HexColor;
    return true;
  },
  PreviewColor: function (e,aColorNode) {
    return true;
  }
}
appendEventHandler(window,'onload',ColorPicker.Init);
var LiveGroupSkins = {
  Init: function () {
    var zSkinThumbs = getElementsWithAttribute('class','SkinThumbnailContainer');
    zSkinThumbs.forEach(function(zSkinThumbs){
      var zSkinPath = zSkinThumbs.getAttribute('Path');
      appendEventHandler(zSkinThumbs,'onclick',LiveGroupSkins.ChooseSkin,zSkinPath);
    });
    return true;
  },
  ChooseSkin: function (e,aSkinPath) {
    LiveGroup.SkinIdInput = $('inpSkinId');
    LiveGroup.PreviousInput = $('inpPreviousSkin');
    LiveGroup.PreviousInput.value = LiveGroup.SkinIdInput.value;
    LiveGroup.PreviousDIV = $(LiveGroup.PreviousInput.value);
    if (LiveGroup.PreviousDIV) {
      LiveGroup.PreviousDIV.style.border = '0';
    }
    this.style.border = '3px solid #B8FF5D';
    LiveGroup.SkinIdInput.value = this.getAttribute('id');
    LiveGroup.SkinPathInput = $('inpSkinPath');
    LiveGroup.SkinPathInput.value = aSkinPath;
    return true;
  }
}
appendEventHandler(window,'onload',LiveGroupSkins.Init);
var LiveGroupSettings = {
  Init: function() {
    var zEditLink = getElementsWithAttribute('Edit');
    zEditLink.forEach(function(zEditLink){
      var zEditContainer = zEditLink.getAttribute('Edit');
      appendEventHandler(zEditLink,'onclick',LiveGroupSettings.ToggleContainers,zEditContainer);
    });
    return true;
  },
  ToggleContainers: function(e,aDisplayContainer) {
    if (LiveGroupSettings.CurrentContainer) {
      LiveGroupSettings.CurrentContainer.style.display = 'none';
    }
    LiveGroupSettings.DisplayContainer = $(aDisplayContainer);
    LiveGroupSettings.DisplayContainer.style.display = 'block';
    LiveGroupSettings.CurrentContainer = LiveGroupSettings.DisplayContainer;
    return true;
  }
}
appendEventHandler(window,'onload',LiveGroupSettings.Init);
var ErrorCheck = {
  ErrorExists: '',
  Init: function() {
    ErrorCheck.CurrentAvatar = $('inpCurrentAvatar');
    ErrorCheck.AddFileInput = $('inpFile_fFileUploadInput1');
    if (ErrorCheck.ErrorExists == 'Y') {
      ErrorCheck.DisplayError('');
    }
    return true;
  },
  DisplayError: function(aErrorMessage) {
    var zModalDiv = $('ErrorMessageContainer');
    zModalDiv.innerHTML =  '<div id="ErrorMessageTop"><div id="MessageTitle">Error</div></div>'
                         + '<div id="ErrorMessageMiddle"><div id="ErrorMessage"></div></div>'
                         + '<div id="ErrorMessageBottom"></div>'
                         + '<div id="CloseButton">Close</div>';
    var zMessageDIV = $('ErrorMessage');
    zMessageDIV.innerHTML = '<span class="MessageDirections">The following errors were found:</span><br>' + aErrorMessage;
    var zCloseButton = $('CloseButton');
    appendEventHandler(zCloseButton,'onclick',Modal.Hide);
    Modal.Show(zModalDiv);
    return false;
  },
  ValidateForm: function(aForm) {
    var zErrorMessage = '';
    if (ErrorCheck.CurrentAvatar.value == '' && ErrorCheck.AddFileInput.value == '') {
      zErrorMessage = '\n You currently have no avatar selected';
    }
    return false;
  }
}
appendEventHandler(window,'onload',ErrorCheck.Init);
var RemoveLink = {
  Init: function () {
    var zRemoveLinks = getElementsWithAttribute('RemoveURL');
    if (zRemoveLinks) {
      zRemoveLinks.forEach(function(zRemoveLinks) {
        zRemoveURL = zRemoveLinks.getAttribute('RemoveURL');
        appendEventHandler(zRemoveLinks,'onclick',RemoveLink.ConfirmRemoveItem,zRemoveURL);
      });
    }
    return true;
  },
  ConfirmRemoveItem: function (aItemArray,aRemoveURL) {
    var zFileURL = $('inpFileURL');
    var zModalDiv = $('ModalMessage');
    zModalDiv.innerHTML = '<div id="ErrorMessageIcon"></div>'
                        + '<div id="ErrorMessageTop"><div id="MessageTitle">Confirm</div></div>'
                        + '<div id="ErrorMessageMiddle"><div id="ErrorMessage"></div></div>'
                        + '<div id="ErrorMessageBottom"></div>';
    if (zFileURL) {
      var zRemoveConfirmLink = '<a class="ConfirmLink" href="'+ zFileURL.value +'">Yes</a>';
    }
    else {
      var zRemoveConfirmLink = '<a class="ConfirmLink" href="'+ aRemoveURL +'">Yes</a>';
    }
    var zMessageDiv = $('ErrorMessage');
    zMessageDiv.innerHTML = '<span class="MessageDescription">Are you sure you want to remove this item?</span>'
                          +  zRemoveConfirmLink
                          + '<a id="CloseLink" class="ConfirmLink" href="javascript: void(0);">No</a>';
    var zCloseButton= $('CloseLink');
    appendEventHandler(zCloseButton,'onclick',Modal.Hide);
    Modal.Show(zModalDiv);
    window.scrollTo(0,0);
    return true;
  }
}
LiveGroup.Reviews = {
  ItemPath: 'voig\\ModuleList\\LiveGroup\\ReviewList',
  Mode: 'Preview',
  DisplayMode:'',
  ReviewedItems: 'Y',
  GameDataLoaded: 0,
  ArticleDataLoaded: 0,
  boxesPerPages: 10,
  currentPage: new Array(),
  lastDisplayed: 0,
  Init: function(e,aElement) {
    LiveGroup.Reviews.ManagementArea = $(aElement);
    LiveGroup.Reviews.FlashSlider = $('QuickRatingSlider');
    var zContainers = getElementsWithAttribute('tabinterface','Y','');
    LiveGroup.Reviews.currentPage['Y'] = 0;
    LiveGroup.Reviews.currentPage['N'] = 0;
    zContainers.forEach(function(aTabElement) {
      var zIsSelected = LiveGroup.Utils.SetTabClass(aTabElement);
      if (zIsSelected) {
        LiveGroup.Reviews.ReviewedItemsOnly = aTabElement.getAttribute('hasreviewed');
      }
    });
    LiveGroup.Reviews.GetListData(LiveGroup.Reviews.ManagementArea);
  },
  GetListData: function(aElement) {
    var zURL =  LiveGroup.Reviews.ItemPath.toPagePath() + '.GetList?aMode=' + LiveGroup.Reviews.Mode;
    var aDataObject =  new Object();
    LiveRequest_MakeRequest(zURL, LiveGroup.Reviews.ReceiveData, aDataObject);
  },
  ReceiveData: function(aDataObject) {
    LiveGroup.Reviews.Data = aDataObject;
    if (aDataObject != null) {
      if (LiveGroup.Reviews.PreselectAdd == 'Y') {
        LiveGroup.Reviews.Draw(LiveGroup.Reviews.ManagementArea,'N');
        document.getElementById('ReviewTab').style.backgroundPosition = '0px -40px';
        document.getElementById('AddReviewTab').style.backgroundPosition = '0px 0px';
      } else {
        LiveGroup.Reviews.Draw(LiveGroup.Reviews.ManagementArea,LiveGroup.Reviews.ReviewedItemsOnly);
      }
    }
  },
  Draw: function(aElement, aReviewedItemsOnly) {
    var col = 0, row = 0, total = 0;
    if (aElement.childNodes)
      LiveGroup.Utils.RemoveSubItems(aElement);
    for (var i = 0; i < LiveGroup.Reviews.Data.Items.length; i++) {
      var zAddReview = 'N';
      if (LiveGroup.Reviews.Data.Items[i].HasReviewed == 'Y' && LiveGroup.Reviews.Data.Items[i].IsQuickRating == 'N')
        zAddReview = 'Y';
      if (zAddReview == aReviewedItemsOnly) {
        var startAt = LiveGroup.Reviews.boxesPerPages * LiveGroup.Reviews.currentPage[aReviewedItemsOnly];
        if (col > 4) { row++; col = 0; }
        if ((total >= startAt) && total < (startAt + LiveGroup.Reviews.boxesPerPages)) {
          var zBuildItem = LiveGroup.Reviews.Build(LiveGroup.Reviews.Data.Items[i], col, row);
          aElement.appendChild(zBuildItem);
          col++;
          LiveGroup.Reviews.lastDisplayed = total + 1;
        }
        total++;
      }
    }
    if (startAt != 0 && total != 0) {
      zPreviousArrow = CreateBasicElement('div', 'PreviousArrow');
      aElement.appendChild(zPreviousArrow);
      appendEventHandler(zPreviousArrow, 'onclick', LiveGroup.Reviews.PreviousPage, aReviewedItemsOnly);
    }
    if (LiveGroup.Reviews.lastDisplayed < total) {
      zNextArrow = CreateBasicElement('div', 'NextArrow');
      aElement.appendChild(zNextArrow);
      appendEventHandler(zNextArrow, 'onclick', LiveGroup.Reviews.NextPage, aReviewedItemsOnly);
    }
    if (total == 0) {
      var zNoItemsDiv = CreateBasicElement('div','NoItemFound');
      if (aReviewedItemsOnly == "Y") {
        zNoItemsDiv.innerHTML = "You haven't reviewed any game yet! Click on the ADD A REVIEW tab to write a new review.";
      } else {
        zNoItemsDiv.innerHTML = "We didn't find any game you haven't reviewed yet.";
      }
      aElement.appendChild(zNoItemsDiv);
    }
    LiveGroup.Reviews.loadingDiv = $('ArticleEditLoadImage');
    if (LiveGroup.Reviews.loadingDiv != null) {
      LiveGroup.Reviews.loadingDiv.style.display = 'none';
    }
    LiveGroup.Reviews.formDiv = document.getElementById('RevArtEditForm');
    LiveGroup.Reviews.status = 0;
  },
  Build: function(aArrayItem, x, y) {
    aArrayItem.ContainerDiv = CreateBasicElement('div', aArrayItem.Id, 'ReviewInfoContainer');
    aArrayItem.ContainerDiv.style.left = (12 + x * 110) + 'px';
    aArrayItem.ContainerDiv.style.top = (100 + y * 220) + 'px';
    if (aArrayItem.ImageURL!='') {
      var zImage = new Image();
      zImage.src = aArrayItem.ImageURL;
      zImage.width = aArrayItem.ImageWidth;
      zImage.height = aArrayItem.ImageHeight;
      aArrayItem.ContainerDiv.appendChild(zImage);
    }
    if (aArrayItem.DisplayName!='') {
      var zDisplayNameDiv = CreateBasicElement('div','DisplayName','ReviewInfo');
      zDisplayNameDiv.innerHTML = aArrayItem.DisplayName;
      aArrayItem.ContainerDiv.appendChild(zDisplayNameDiv);
    }
    appendEventHandler(aArrayItem.ContainerDiv, 'onclick', LiveGroup.Reviews.Select, aArrayItem);
    return aArrayItem.ContainerDiv;
  },
  ClickTab: function(e, aTabElement) {
    if (LiveGroup.Reviews.status != 0 && LiveGroup.Reviews.status != 3) return;
    LiveGroup.Reviews.status = 1;
    LiveGroup.Reviews.HideForm();
    var zSelected = hasAttribute(aTabElement,'hasreviewed','Y');
    if (zSelected) {
      LiveGroup.Reviews.Draw(LiveGroup.Reviews.ManagementArea,'Y');
      document.getElementById('ReviewTab').style.backgroundPosition = '0px 0px';
      document.getElementById('AddReviewTab').style.backgroundPosition = '0px -40px';
    } else {
      LiveGroup.Reviews.Draw(LiveGroup.Reviews.ManagementArea,'N');
      document.getElementById('ReviewTab').style.backgroundPosition = '0px -40px';
      document.getElementById('AddReviewTab').style.backgroundPosition = '0px 0px';
    }
  },
  Select: function(e, aArrayItem) {
    if (LiveGroup.Reviews.status != 0) return;
    LiveGroup.Reviews.status = 2;
    LiveGroup.Reviews.selectedItem = aArrayItem;
    LiveGroup.Reviews.selectedItem.divLeft = LiveGroup.Reviews.selectedItem.ContainerDiv.offsetLeft - 10;
    LiveGroup.Reviews.selectedItem.divTop = LiveGroup.Reviews.selectedItem.ContainerDiv.offsetTop - 10;
    for (var i = 0; i < LiveGroup.Reviews.Data.Items.length; i++) {
      if (LiveGroup.Reviews.Data.Items[i].Id != LiveGroup.Reviews.selectedItem.ContainerDiv.id) {
	        var zUnselectedDiv = document.getElementById(LiveGroup.Reviews.Data.Items[i].Id);
	        if (zUnselectedDiv != null)
	          zUnselectedDiv.style.display = 'none';
      }
    }
    if (document.getElementById('PreviousArrow') != null)
      document.getElementById('PreviousArrow').style.display = 'none';
    if (document.getElementById('NextArrow') != null)
      document.getElementById('NextArrow').style.display = 'none';
    if (LiveGroup.Reviews.loadingDiv == null) {
      LiveGroup.Reviews.loadingDiv = CreateBasicElement('div', 'ArticleEditLoadImage', 'LoadingImage');
      LiveGroup.Reviews.ManagementArea.parentNode.appendChild(LiveGroup.Reviews.loadingDiv);
    }
    LiveGroup.Reviews.loadingDiv.style.display = 'block';
    document.getElementById('inp_Name').value = '';
    document.getElementById('inp_Copy').value = '';
    document.getElementById('inp_Rating').value = '';
    document.getElementById('inp_Recommend').value = '';
    document.getElementById('inp_ShouldPlay').value = '';
    if (LiveGroup.Reviews.selectedItem.HasReviewed == 'Y') {
      var zURL = LiveGroup.Reviews.getPlayerDataURL + LiveGroup.Reviews.selectedItem.Id + ':KBPointsTo.GetData';
      document.forms[0].action = '/voig/ModuleList/LiveGroup/ReviewList.SaveArticle';
      var aDataObject = new Object();
      LiveRequest_MakeRequest(zURL, LiveGroup.Reviews.ReceiveArticleData, aDataObject);
    } else {
      document.forms[0].action = '/voig/ModuleList/LiveGroup/ReviewList/' + LiveGroup.Reviews.selectedItem.Id + '.AddArticle';
      document.getElementById('inp_ItemPath').value = 'voig\\ContentList\\LiveFindDatabaseList\\H\\HA\\HAI\\HairymopDatabase\\Hairymop\\JavaScript\\' + LiveGroup.Reviews.selectedItem.Id;
      LiveGroup.Reviews.ArticleData = null;
      LiveGroup.Reviews.selectedItem.ArticleDataLoaded = 1;
    }
    var zURL = '/voig/ModuleList/LiveGroup/ReviewList/' + LiveGroup.Reviews.selectedItem.Id + '.GameDetails?aJSData=Y';
    var aGameDataObject =  new Object();
    LiveRequest_MakeRequest(zURL, LiveGroup.Reviews.ReceiveGameData, aGameDataObject);
  },
  ReceiveGameData: function(aGameDataObject) {
    LiveGroup.Reviews.GameData = aGameDataObject;
    LiveGroup.Reviews.selectedItem.GameDataLoaded = 1;
    if (LiveGroup.Reviews.selectedItem.ArticleDataLoaded == 1)
      LiveGroup.Reviews.Finish();
  },
  ReceiveArticleData: function(aDataObject) {
    LiveGroup.Reviews.ArticleData = aDataObject;
    if (LiveGroup.Reviews.ArticleData != null && LiveGroup.Reviews.ArticleData.ItemPath != null) {
      document.getElementById('inp_ItemPath').value = LiveGroup.Reviews.ArticleData.ItemPath;
      document.getElementById('inp_Name').value = LiveGroup.Reviews.ArticleData.DisplayName;
      document.getElementById('inp_Copy').value = LiveGroup.Reviews.ArticleData.Detail;
      document.getElementById('inp_Rating').value = LiveGroup.Reviews.ArticleData.Rating;
      document.getElementById('inp_Recommend').value = LiveGroup.Reviews.ArticleData.Recommend;
      document.getElementById('inp_ShouldPlay').value = LiveGroup.Reviews.ArticleData.ShouldPlay;
    }
    LiveGroup.Reviews.selectedItem.ArticleDataLoaded = 1;
    if (LiveGroup.Reviews.selectedItem.GameDataLoaded == 1)
      LiveGroup.Reviews.Finish();
  },
  Finish: function() {
    LiveGroup.Reviews.loadingDiv.style.display = 'none';
    LiveGroup.Reviews.selectedItem.ContainerDiv.parentNode.appendChild(LiveGroup.Reviews.formDiv);
    if (LiveGroup.Reviews.FlashSlider != null)
      LiveGroup.Reviews.FlashSlider.style.visibility = 'visible';
    LiveGroup.Reviews.formDiv.style.display = 'block';
    LiveGroup.Reviews.formDiv.style.border = 'none';
    document.getElementById('DisplayName').style.display = 'none';
    LiveGroup.Reviews.selectedItem.finalLeft = 5;
    LiveGroup.Reviews.selectedItem.finalTop = 75;
    LiveGroup.Reviews.selectedItem.imgWidth = 90;
    LiveGroup.Reviews.selectedItem.divLeftStep = (LiveGroup.Reviews.selectedItem.divLeft - LiveGroup.Reviews.selectedItem.finalLeft) / 15;
    LiveGroup.Reviews.selectedItem.divTopStep = (LiveGroup.Reviews.selectedItem.divTop - LiveGroup.Reviews.selectedItem.finalTop) / 15;
    LiveGroup.Reviews.selectedItem.imgWidthStep = (180 - 90) / 15;
    LiveGroup.Reviews.SlideStep();
  },
  SlideStep: function() {
    var zKeepMoving = 0;
    if (LiveGroup.Reviews.selectedItem.divLeft > LiveGroup.Reviews.selectedItem.finalLeft) {
      LiveGroup.Reviews.selectedItem.ContainerDiv.style.left = LiveGroup.Reviews.selectedItem.divLeft + 'px';
      LiveGroup.Reviews.selectedItem.divLeft -= LiveGroup.Reviews.selectedItem.divLeftStep;
      zKeepMoving = 1;
    } else {
      LiveGroup.Reviews.selectedItem.ContainerDiv.style.left = LiveGroup.Reviews.selectedItem.finalLeft + 'px';
    }
    if (LiveGroup.Reviews.selectedItem.divTop > LiveGroup.Reviews.selectedItem.finalTop) {
      LiveGroup.Reviews.selectedItem.ContainerDiv.style.top = LiveGroup.Reviews.selectedItem.divTop + 'px';
      LiveGroup.Reviews.selectedItem.divTop -= LiveGroup.Reviews.selectedItem.divTopStep;
      zKeepMoving = 1;
    } else {
      LiveGroup.Reviews.selectedItem.ContainerDiv.style.top = LiveGroup.Reviews.selectedItem.finalTop + 'px';
    }
    if (LiveGroup.Reviews.selectedItem.imgWidth < 180) {
      LiveGroup.Reviews.selectedItem.ContainerDiv.firstChild.style.width = LiveGroup.Reviews.selectedItem.imgWidth + 'px';
      LiveGroup.Reviews.selectedItem.imgWidth += LiveGroup.Reviews.selectedItem.imgWidthStep;
      zKeepMoving = 1;
    } else {
      LiveGroup.Reviews.selectedItem.ContainerDiv.firstChild.style.width = 180 + 'px';
    }
    if (zKeepMoving)
      setTimeout('LiveGroup.Reviews.SlideStep()', 10);
    else {
      LiveGroup.Reviews.selectedItem.ContainerDiv.firstChild.style.width = 180 + 'px';
      LiveGroup.Reviews.selectedItem.ContainerDiv.childNodes[1].style.fontSize = '14pt';
      LiveGroup.Reviews.selectedItem.ContainerDiv.childNodes[1].style.fontFamily = 'Impact, verdana';
      LiveGroup.Reviews.selectedItem.ContainerDiv.style.background = 'url()';
      LiveGroup.Reviews.selectedItem.ContainerDiv.style.backgroundPosition = '0 -80px';
      LiveGroup.Reviews.selectedItem.ContainerDiv.style.borderColor = '#777';
      LiveGroup.Reviews.selectedItem.ContainerDiv.style.width = 190 + 'px';
      LiveGroup.Reviews.selectedItem.ContainerDiv.style.height = 450 + 'px';
      LiveGroup.Reviews.selectedItem.ContainerDiv.lastChild.style.display = 'block';
      if (LiveGroup.Reviews.selectedItem.ContainerDiv.lastChild.id != 'DescriptionDetails') {
        var zDisplayNameDiv2 = CreateBasicElement('div', 'DescriptionDetails');
        zDisplayNameDiv2.innerHTML = LiveGroup.Reviews.GameData.GameDescription;
        LiveGroup.Reviews.selectedItem.ContainerDiv.appendChild(zDisplayNameDiv2);
      }
      document.getElementById('ReviewDescriptionDetail').style.display = 'block';
      if (LiveGroup.Reviews.ArticleData != null) {
        LiveGroup.Reviews.setSlider('ReviewsRatingSliderObject', LiveGroup.Reviews.ArticleData.Rating);
      } else {
        LiveGroup.Reviews.setSlider('ReviewsRatingSliderObject', 0);
        LiveGroup.Reviews.setSlider('ReviewsRatingSliderObject', '');
      }
      LiveGroup.Reviews.status = 3;
    }
  },
  HideForm: function() {
    if (LiveGroup.Reviews.FlashSlider != null)
      LiveGroup.Reviews.FlashSlider.style.visibility = 'hidden';
    LiveGroup.Reviews.formDiv = document.getElementById('RevArtEditForm');
    LiveGroup.Reviews.formDiv.style.display = 'none';
    LiveGroup.Reviews.ManagementArea.parentNode.parentNode.appendChild(LiveGroup.Reviews.formDiv);
  },
		setSlider: function(movieName, newValue) {
		    if (navigator.appName.indexOf("Microsoft") != -1) {
		        zMovie = window[movieName];
          if (zMovie != null) {
            zMovie.setValue(newValue);
          }
		    }
		    else
        document[movieName].setValue(newValue);
		    return true;
		},
  NextPage: function(e, aReviewedItemsOnly) {
    LiveGroup.Reviews.currentPage[aReviewedItemsOnly]++;
    LiveGroup.Reviews.Draw(LiveGroup.Reviews.ManagementArea, aReviewedItemsOnly);
  },
  PreviousPage: function(e, aReviewedItemsOnly) {
    LiveGroup.Reviews.currentPage[aReviewedItemsOnly]--;
    LiveGroup.Reviews.Draw(LiveGroup.Reviews.ManagementArea, aReviewedItemsOnly);
  },
  ArticleCheckFields: function(e) {
    var errorString = '';
    var errorCount = 0;
    var copyMaxWords = 250;
    if ($('inp_Name').value.length < 1) {
      errorString = errorString + '<li>You need to provide an article title, for example "Tribute to the best RPG" or just simply "My Starcraft 3 Review".</li>';
      errorCount++;
    }
    var copyWordCount = $('inp_Copy').value.split(/\s+/g).length;
    if ($('inp_Copy').value.length < 1 || copyWordCount > 250 || copyWordCount < 10) {
      errorString = errorString + '<li>You must provide a review containing between 10 and 250 words.</li>';
      errorCount++;
    }
    if ($('inp_Rating').value.length < 1) {
      errorString = errorString + '<li>You need to provide a rating, any integer between 0 and 100.</li>';
      errorCount++;
    } else {
      var cleanRating = parseInt($('inp_Rating').value);
      if (cleanRating < 0 || cleanRating > 100) {
        errorString = errorString + '<li>Your rating must be an integer between 0 and 100.</li>';
        errorCount++;
      }
    }
    if (errorCount == 0)
      return true;
    var zFlashApp = document.getElementById('QuickRatingSlider');
    if (zFlashApp != null) {
      zFlashApp.style.visibility = 'hidden';
    }
    var zModalDiv = $('ModalMessage');
    zModalDiv.innerHTML =  '<div id="ErrorMessageTop"><div id="MessageTitle">Error</div></div>'
                         + '<div id="ErrorMessageMiddle"><div id="ErrorMessage"></div></div>'
                         + '<div id="ErrorMessageBottom"></div>'
                         + '<div id="CloseButton">Close</div>';
    var zMessageDIV = $('ErrorMessage');
    zMessageDIV.innerHTML = '<span class="MessageDirections">The following errors were found:</span><ul>' + errorString + '</ul>';
    var zCloseButton = $('CloseButton');
    appendEventHandler(zCloseButton,'onclick', LiveGroup.Reviews.HideModal, zFlashApp);
    Modal.Show(zModalDiv);
  },
  HideModal: function(e, aFlashApp) {
    if (aFlashApp != null) {
      aFlashApp.style.visibility = 'visible';
    }
    Modal.Hide(e);
  },
  ArticleWordCount: function(e, inputTag) {
    var numOfWords = $('inp_' + inputTag).value.split(/\s+/g).length;
    var prefix = 'Your review (';
    var comment = '';
    if (numOfWords <= 250) {
      comment = (250 - numOfWords) + ' word' + ((250 - numOfWords)>1?'s':'') + ' left';
    } else {
      comment = 'you are ' + (numOfWords - 250) + ' word' + ((numOfWords - 250)>1?'s':'') + ' over the limit';
    }
    $('label-' + inputTag).innerHTML = prefix + comment + '):';
  },
  TopReviews: {
    Current: 0,
    PathList: [
        'voig/InterfaceList/Live/Reviews.DisplayRanking?aJSString=Y&aOnlyStaff=Y',
        'voig/ContentList/LiveFindDatabaseList/T/TO/TON/TonyDaytonaDatabase.DisplayTopReviews?aJSString=Y',
        'voig/ContentList/LiveFindDatabaseList/E/EU/EUR/EuroTrash.DisplayTopReviews?aJSString=Y',
        'voig/ContentList/LiveFindDatabaseList/T/TZ/TZO/_OC269710205.DisplayTopReviews?aJSString=Y',
        'voig/InterfaceList/Live/Reviews.DisplayRanking?aJSString=Y'
    ],
    offColor: '#05a',
    onColor: '#f91',
    loadColor: '#000',
    Switch: function(e, aButtonNumber) {
      var aData;
      if (aButtonNumber != null)
        LiveGroup.Reviews.TopReviews.Current = aButtonNumber;
      var zTopAuthor = document.getElementById('TopAuthor_' + LiveGroup.Reviews.TopReviews.Current);
      zTopAuthor.style.backgroundColor = LiveGroup.Reviews.TopReviews.loadColor;
      document.getElementById('RankingLoadingImage').style.display = 'block';
      var zRequestURL = '/' + LiveGroup.Reviews.TopReviews.PathList[LiveGroup.Reviews.TopReviews.Current];
      LiveRequest_MakeRequest(zRequestURL, LiveGroup.Reviews.TopReviews.Recv, aData);
    },
    Recv: function(aData) {
      zRankingTableContainer = document.getElementById('RankingTableContainer');
      LiveGroup.Utils.RemoveSubItems(zRankingTableContainer);
      if (aData != null)
        zRankingTableContainer.innerHTML = aData;
      document.getElementById('RankingLoadingImage').style.display = 'none';
      for (i = 0; i < 5; i++) {
        zTopAuthor = document.getElementById('TopAuthor_' + i);
        if (i == LiveGroup.Reviews.TopReviews.Current)
          zTopAuthor.style.backgroundColor = LiveGroup.Reviews.TopReviews.onColor;
        else
          zTopAuthor.style.backgroundColor = LiveGroup.Reviews.TopReviews.offColor;
      }
    }
  },
  Tabs: {
    List: {},
    Array: [],
    Previous: null,
    Init: function() {
      var zTabElements = getElementsWithAttribute('class','ReviewTabs','div');
      var zCount = 0;
      zTabElements.forEach(function(aTabElement) {
        LiveGroup.Reviews.Tabs.List[aTabElement.id];
        LiveGroup.Reviews.Tabs.Array.push(aTabElement);
        aTabElement.DisplayInfo = $('View' + aTabElement.id);
        appendEventHandler(aTabElement, 'onclick', LiveGroup.Reviews.Tabs.Select, aTabElement);
        if (zCount == 0) {
          LiveGroup.Reviews.Tabs.SwitchClass(aTabElement);
          ScrollingInterface.Current = aTabElement;
        }
        zCount++;
      });
      return true;
    },
    Select: function(e, aTabElement) {
      ScrollingInterface.Current = aTabElement;
      LiveGroup.Reviews.Tabs.SwitchClass(aTabElement);
      var zScroller_List = ScrollingInterface.ScrollerList[aTabElement.DisplayInfo.parentNode.parentNode.id];
      var zScroller_Object = aTabElement.DisplayInfo.parentNode.parentNode;
      var zPreviousScrollDistance = zScroller_List.ScrollDistance;
      var zAbsolutePosition = getAbsolutePosition(aTabElement.DisplayInfo);
      var zContainerAbsolutePosition = getAbsolutePosition(zScroller_Object);
      zScroller_List.ScrollDistance = (zContainerAbsolutePosition.x - zAbsolutePosition.x);
      ScrollingInterface.Scroll(zScroller_List,'RIGHT');
      zScroller_List.ScrollDistance = zPreviousScrollDistance;
      return true;
    },
    SwitchClass: function(aTabElement) {
      if (LiveGroup.Reviews.Tabs.Previous!=null) {
        LiveGroup.Reviews.Tabs.Previous.className = 'ReviewTabs';
      }
      aTabElement.className = 'ReviewTabs ReviewTabsSelected';
      LiveGroup.Reviews.Tabs.Previous = aTabElement;
    }
  },
  QuickRate: {
    Receive: function(aCommunityReviewRating) {
      document.getElementById('CommunityQRatingValue').innerHTML = aCommunityReviewRating + '%';
      document.getElementById('HoverSlider').style.display = 'none';
    },
    SliderCallBack: function(aSliderValue) {
      if (LiveGroup.Login.UserInformation.LoggedInStatus == 'Y') {
        document.getElementById('HoverSlider').style.display = 'block';
        zLiveRequestURL = unescape(LiveGroup.Reviews.QuickRate.submitURL) + aSliderValue;
        LiveRequest_MakeRequest(zLiveRequestURL, LiveGroup.Reviews.QuickRate.Receive);
      } else {
        var zReturnURL = encodeURIComponent(window.location);
        window.location = 'http://Hairymop.Voig.com/Home.Welcome?aReturnURL=' + zReturnURL;
      }
    }
  }
}
var AdServe = {
  Receive: function(aAdLink, aAdData) {
    if (aAdData.Div != null) {
      if (aAdLink.IsDynamic == 'Y') {
        AdServe.Iframe = document.createElement('iframe');
        AdServe.Iframe.id = 'AdServeIframe';
        AdServe.Iframe.style.width = aAdLink.Width + 'px';
        AdServe.Iframe.style.height = aAdLink.Height + 'px';
        AdServe.Iframe.style.border = '0';
        AdServe.Iframe.frameborder = '0';
        AdServe.Iframe.scrolling = 'no';
        AdServe.Iframe.src = 'http://Hairymop.Voig.com/.DynamicAdServe?aObjectTypeAlias=LocalSiteLayout&aAdCode=' + aAdLink.AdCode;
        aAdData.Div.appendChild(AdServe.Iframe);
      } else {
        if (LiveGroup.UniqueAdCode) {
          if (LiveGroup.UniqueAdCode == aAdLink.UniqueCode) {
            AdServe.MakeRequest(LiveGroup.UniqueAdCode,aAdData);
          } else {
            aAdData.Div.innerHTML = aAdLink.AdCode;
            LiveGroup.UniqueAdCode = aAdLink.UniqueCode;
          }
        } else {
          aAdData.Div.innerHTML = aAdLink.AdCode;
          LiveGroup.UniqueAdCode = aAdLink.UniqueCode;
        }
      }
    }
  },
  MakeRequest: function(e, aAdData) {
    var randomString = '';
    var curChar;
    for (i = 0; i < 64; i++) {
      curChar = 0;
      while (curChar < 48 || curChar > 57 && curChar < 65 || curChar > 90 && curChar < 97 || curChar > 122) {
        var curChar = Math.floor(255 * Math.random());
      }
      randomString = randomString + String.fromCharCode(curChar);
    }
    aAdData.Div = document.getElementById(aAdData.DivId);
    if (aAdData.Div == null)
      return;
    LiveRequest_MakeRequest('http://hairymop.voig.com/.AdServe?&aObjectTypeAlias=LocalSiteLayout&aBannerAdSizeWidth=' + aAdData.Width + '&aBannerAdSizeHeight='
                             + aAdData.Height + '&x=' + randomString, AdServe.Receive, aAdData);
    return true;
  },
  Request: function(aAdSizeWidth, aAdSizeHeight, aAdDivId) {
    appendEventHandler(window, "onload", AdServe.MakeRequest, {Width: aAdSizeWidth, Height: aAdSizeHeight, DivId: aAdDivId});
  }
};
LiveGroup.InfoBox = function(aTargetDiv, aItemPath) {
  this.targetDiv = aTargetDiv;
  this.active = false;
  if (aItemPath == null)
    return;
  this.itemURL = unescape('/' + aItemPath.replace(/\\/g, '/'));
  this.Receive = function(aData, aParentInfoBox) {
    aParentInfoBox.window.innerHTML = aData;
  }
  this.SetActive = function(e, aParentInfoBox) {
    aParentInfoBox.window.style.display = 'block';
    aParentInfoBox.active = true;
  }
  this.SetInactive = function(e, aParentInfoBox) {
    aParentInfoBox.window.style.display = 'none';
    aParentInfoBox.active = false;
  }
  this.Show = function(e, aParentInfoBox) {
    if (!aParentInfoBox.active)
      return;
    var zCoords = getEventRealCoordinates(e);
    aParentInfoBox.window.style.left = (zCoords.x + 4) + 'px';
    aParentInfoBox.window.style.top  = (zCoords.y + 8) + 'px';
  }
  if (LiveGroup.InfoBoxList == null)
    LiveGroup.InfoBoxList = new Array();
  LiveGroup.InfoBoxList.push(this);
  this.window = CreateBasicElement('div', 'InfoBox', 'InfoBox');
  this.window.style.position = 'absolute';
  this.window.style.display = 'none';
  this.window.innerHTML = 'Loading...';
  document.body.appendChild(this.window);
  LiveRequest_MakeRequest(this.itemURL + '.InfoBox', this.Receive, this);
  appendEventHandler(aTargetDiv, 'onmousemove', this.Show, this);
  appendEventHandler(aTargetDiv, 'onmouseover', this.SetActive, this);
  appendEventHandler(aTargetDiv, 'onmouseout', this.SetInactive, this);
}
LiveGroup.InfoBoxInit = function() {
  if (document.body.getAttribute('UseInfoBox') != 'Y')
    return true;
  var zDocDivs = document.getElementsByTagName('div');
  for (var i = 0; i < zDocDivs.length; i++) {
    aItemPath = zDocDivs[i].getAttribute('InfoBox');
    if (aItemPath != '') {
      zDocDivs = zDocDivs[i];
      if (zDocDivs.id == '') {
        zDocDivs.id = zDocDivs.name;
      }
      zInfoBox = new InfoBox(zDocDivs, aItemPath);
    }
  }
  return true;
}
LiveGroup.PickThumb = {
  Init: function() {
    LiveGroup.PickThumb.Container = $('PickThumb_ListContainer');
    if (LiveGroup.PickThumb.Container == null)
      return true;
    LiveGroup.PickThumb.PreviewContainer = $('PickThumb_PreviewContainer');
    if (LiveGroup.PickThumb.PreviewContainer == null)
      return true;
    LiveGroup.PickThumb.getURL     = LiveGroup.PickThumb.Container.getAttribute('PickThumbURL');
    LiveGroup.PickThumb.maxThumbs  = LiveGroup.PickThumb.Container.getAttribute('PickThumbMax');
    LiveGroup.PickThumb.startCount = LiveGroup.PickThumb.Container.getAttribute('PickThumbStartCount');
    LiveGroup.PickThumb.QuickFindButton = $('searchButton');
    LiveGroup.PickThumb.QuickFindInput = $('inp_QuickFind');
    if (LiveGroup.PickThumb.QuickFindButton != null || LiveGroup.PickThumb.QuickFindInput != null) {
      appendEventHandler(LiveGroup.PickThumb.QuickFindButton, 'onclick', LiveGroup.PickThumb.Search);
      appendEventHandler(LiveGroup.PickThumb.QuickFindInput, 'onkeypress', LiveGroup.PickThumb.SearchKeypress);
    }
    LiveGroup.PickThumb.buttonBack = $('PickThumb_ListBackButton');
    LiveGroup.PickThumb.buttonNext = $('PickThumb_ListNextButton');
    LiveGroup.PickThumb.statusItem = $('StatusCell');
    if (LiveGroup.PickThumb.buttonBack == null || LiveGroup.PickThumb.buttonNext == null || LiveGroup.PickThumb.statusItem == null)
      return true;
    appendEventHandler(LiveGroup.PickThumb.buttonBack, 'onclick', LiveGroup.PickThumb.ChangePage, -1);
    appendEventHandler(LiveGroup.PickThumb.buttonNext, 'onclick', LiveGroup.PickThumb.ChangePage, +1);
    LiveGroup.PickThumb.loading = $('ThumbsLoading');
    LiveGroup.PickThumb.locked = true;
    LiveGroup.PickThumb.currentSkin = null;
    LiveGroup.PickThumb.currentPage = 0;
    LiveGroup.PickThumb.CategoryContainer = $('PickThumb_Category');
    if (LiveGroup.PickThumb.CategoryContainer != null) {
      LiveGroup.PickThumb.ReadCategories();
      LiveGroup.PickThumb.ChangeCategory(null, 0);
    } else {
      LiveGroup.PickThumb.Request();
    }
    LiveGroup.PickThumb.skinInput = $('inpThumbSelection')
    if (LiveGroup.PickThumb.skinInput == null)
      return true;
    LiveGroup.PickThumb.SkinColorContainer = $('SkinColor_Container');
    return true;
  },
  onPreviewClick: function() {},
  Search: function() {
    LiveGroup.PickThumb.searchKeyword = LiveGroup.PickThumb.QuickFindInput.value;
    LiveGroup.PickThumb.searchCategory = null;
    LiveGroup.PickThumb.Request(LiveGroup.PickThumb.QuickFindInput.value);
  },
  Request: function(aSearch, aCategory, aStartRowModifier) {
    if (LiveGroup.PickThumb.getURL == null)
      return;
    var aExtraOpts = '&aAlwaysShowCurrent=Y';
    LiveGroup.PickThumb.loading.style.display = 'block';
    if (aSearch != null && aSearch != '') {
      aExtraOpts += '&aSearch=' + aSearch;
    }
    if (aCategory != null && aCategory != '') {
      aExtraOpts += '&aCategory=' + aCategory;
    }
    if (aStartRowModifier != null && aStartRowModifier != '') {
      aExtraOpts += '&aStartRow=' + aStartRowModifier;
    } else {
      LiveGroup.PickThumb.currentPage = 0;
    }
    LiveRequest_MakeRequest(LiveGroup.PickThumb.getURL + aExtraOpts, LiveGroup.PickThumb.Receive);
  },
  Receive: function(aThumbData) {
    LiveGroup.PickThumb.Data = aThumbData.SearchResults;
    LiveGroup.PickThumb.TotalResults = aThumbData.TotalResults;
    if (aThumbData.SearchResults == null)
      aThumbData.SearchResults = [];
    first = aThumbData.SearchResults.shift();
    if (LiveGroup.PickThumb.currentSkin == null) {
      LiveGroup.PickThumb.currentSkin = first;
      LiveGroup.PickThumb.LoadSkinPreview(first);
    }
    LiveGroup.PickThumb.Update();
  },
  Update: function() {
    LiveGroup.PickThumb.firstSkin = 1;
    LiveGroup.PickThumb.lastSkin = ((LiveGroup.PickThumb.currentPage * 16) + 16);
    if (LiveGroup.PickThumb.currentPage == 0)
      LiveGroup.PickThumb.firstSkin = 0;
    if (LiveGroup.PickThumb.lastSkin > LiveGroup.PickThumb.TotalResults)
      LiveGroup.PickThumb.lastSkin = LiveGroup.PickThumb.TotalResults;
    LiveGroup.PickThumb.UpdateList();
    LiveGroup.PickThumb.UpdateStatus();
    LiveGroup.PickThumb.UpdateButtons();
    LiveGroup.PickThumb.locked = false;
    LiveGroup.PickThumb.loading.style.display = 'none';
  },
  UpdateList: function() {
    LiveGroup.Utils.RemoveSubItems(LiveGroup.PickThumb.Container);
    for (var i = 0; i < LiveGroup.PickThumb.Data.length; i++) {
      if (i >= LiveGroup.PickThumb.firstSkin && i < LiveGroup.PickThumb.lastSkin) {
        var zThumbImage = new Image(60, 60);
        zThumbImage.src = unescape(LiveGroup.PickThumb.Data[i].URL);
        zThumbImage.alt = unescape(LiveGroup.PickThumb.Data[i].ImageName);
        zThumbInfoBox = new LiveGroup.InfoBox(zThumbImage, LiveGroup.PickThumb.Data[i].ItemPath);
        appendEventHandler(zThumbImage, 'onclick', LiveGroup.PickThumb.SelectSkin, i);
        if (LiveGroup.PickThumb.Data[i].PrivateAvatar == "Y" && LiveGroup.PickThumb.currentSkin.AvatarID != LiveGroup.PickThumb.Data[i].AvatarID) {
          LiveGroup.PickThumb.ImageContainer = CreateBasicElement('div', null, 'ThumbImageContainer');
          LiveGroup.PickThumb.Container.appendChild(LiveGroup.PickThumb.ImageContainer);
          LiveGroup.PickThumb.ThumbRemove = CreateBasicElement('div','RemoveThumb');
          LiveGroup.PickThumb.ThumbRemove.innerHTML = "X";
          LiveGroup.PickThumb.ThumbRemove.title = unescape('Delete Private Avatar');
          var aRemoveDetails = {Image: zThumbImage, URL: LiveGroup.PickThumb.Data[i].RemoveURL};
          appendEventHandler(LiveGroup.PickThumb.ThumbRemove, 'onclick', LiveGroup.PickThumb.DeleteConfirm, aRemoveDetails);
          LiveGroup.PickThumb.ImageContainer.appendChild(LiveGroup.PickThumb.ThumbRemove);
          LiveGroup.PickThumb.ImageContainer.appendChild(zThumbImage);
        } else {
          LiveGroup.PickThumb.Container.appendChild(zThumbImage);
        }
      }
    }
  },
  UpdateStatus: function() {
    zText = 'No results.';
    if (LiveGroup.PickThumb.Data.length > 0)
      zText = 'Viewing ' + ((LiveGroup.PickThumb.currentPage * 16) + 1) + ' - '
               + LiveGroup.PickThumb.lastSkin + ' of '
               + LiveGroup.PickThumb.TotalResults;
    LiveGroup.PickThumb.statusItem.innerHTML = zText;
  },
  UpdateButtons: function() {
    if (LiveGroup.PickThumb.firstSkin > 0 || LiveGroup.PickThumb.currentPage > 0) {
      LiveGroup.PickThumb.canGoBack = true;
      LiveGroup.PickThumb.buttonBack.style.backgroundPosition = '0 0';
    } else {
      LiveGroup.PickThumb.canGoBack = false;
      LiveGroup.PickThumb.buttonBack.style.backgroundPosition = '0 -13px';
    }
    if (LiveGroup.PickThumb.lastSkin >= LiveGroup.PickThumb.TotalResults) {
      LiveGroup.PickThumb.canGoNext = false;
      LiveGroup.PickThumb.buttonNext.style.backgroundPosition = '0 -13px';
    } else {
      LiveGroup.PickThumb.canGoNext = true;
      LiveGroup.PickThumb.buttonNext.style.backgroundPosition = '0 0';
    }
  },
  ChangePage: function(e, aPageModifier) {
    if (LiveGroup.PickThumb.locked)
      return;
    if (aPageModifier == 1 && !LiveGroup.PickThumb.canGoNext || aPageModifier == -1 && !LiveGroup.PickThumb.canGoBack)
      return;
    LiveGroup.PickThumb.currentPage += aPageModifier;
    LiveGroup.PickThumb.locked = true;
    var aStartRowModifier = (LiveGroup.PickThumb.currentPage * 16);
    if (aPageModifier == 1)
      aStartRowModifier = (LiveGroup.PickThumb.currentPage * 16) + (aPageModifier * 16) - 16;
    LiveGroup.PickThumb.Request(LiveGroup.PickThumb.searchKeyword, LiveGroup.PickThumb.searchCategory, aStartRowModifier)
  },
  ChangeCategory: function(e, aCategoryNumber) {
    for (var i = 0; i < LiveGroup.PickThumb.categoryList.length; i++) {
      var zChosenOne = '';
      if (i == aCategoryNumber) {
        LiveGroup.PickThumb.categoryList[i].Object.style.backgroundPosition = '0 0';
        zChosenOne = LiveGroup.PickThumb.categoryList[i].Alias;
      } else {
        LiveGroup.PickThumb.categoryList[i].Object.style.backgroundPosition = '0 -40px';
      }
      if (zChosenOne != '') {
        LiveGroup.PickThumb.searchCategory = zChosenOne;
        LiveGroup.PickThumb.searchKeyword = null;
        LiveGroup.PickThumb.Request(null, zChosenOne);
      }
    }
  },
  ReadCategories: function() {
    var realCount = 0;
    LiveGroup.PickThumb.categoryList = new Array();
    for (var i = 0; i < LiveGroup.PickThumb.CategoryContainer.childNodes.length; i++) {
      if (LiveGroup.PickThumb.CategoryContainer.childNodes[i].className == 'CategoryLink') {
        LiveGroup.PickThumb.categoryList[realCount] = new Object();
        LiveGroup.PickThumb.categoryList[realCount].Object = LiveGroup.PickThumb.CategoryContainer.childNodes[i];
        LiveGroup.PickThumb.categoryList[realCount].Alias = LiveGroup.PickThumb.CategoryContainer.childNodes[i].getAttribute('CategoryAlias');
        appendEventHandler(LiveGroup.PickThumb.CategoryContainer.childNodes[i], 'onclick', LiveGroup.PickThumb.ChangeCategory, realCount);
        realCount++;
      }
    }
  },
  SelectSkin: function(e, aNum) {
    if (LiveGroup.InfoBoxList != null) {
      for (var i = 0; i < LiveGroup.InfoBoxList.length; i++) {
        LiveGroup.InfoBoxList[i].SetInactive(null, LiveGroup.InfoBoxList[i]);
      }
    }
    for (var i = 0; i < LiveGroup.PickThumb.Data.length; i++) {
      if (i == aNum) {
        LiveGroup.PickThumb.LoadSkinPreview(LiveGroup.PickThumb.Data[i]);
        LiveGroup.PickThumb.currentSkin = LiveGroup.PickThumb.Data[i];
      }
    }
    LiveGroup.PickThumb.skinInput.value = LiveGroup.PickThumb.Data[aNum].ItemPath;
    LiveGroup.PickThumb.UpdateList();
  },
  LoadSkinPreview: function(aThumbData) {
    zSkinTitle = CreateBasicElement('h3');
    zSkinTitle.innerHTML = unescape(aThumbData.ImageName);
    zSkinImage = CreateBasicElement('img');
    if (aThumbData.FullURL != null)
      zSkinImage.src = unescape(aThumbData.FullURL);
    else
      zSkinImage.src = unescape(aThumbData.URL);
    zSkinImage.width = '270';
    zSkinImage.height = '270';
    zSkinPreview = CreateBasicElement('div', 'PickThumb_Preview', 'PickThumb_Preview');
    zSkinPreview.appendChild(zSkinImage);
    zSkinInfoBox = new LiveGroup.InfoBox(zSkinPreview, aThumbData.ItemPath);
    LiveGroup.Utils.RemoveSubItems(LiveGroup.PickThumb.PreviewContainer);
    LiveGroup.PickThumb.PreviewContainer.appendChild(zSkinTitle);
    LiveGroup.PickThumb.PreviewContainer.appendChild(zSkinPreview);
    appendEventHandler(zSkinImage, "onclick", LiveGroup.PickThumb.onPreviewClick, aThumbData.FullImage);
    if (LiveGroup.PickThumb.SkinColorContainer != null) {
      if (aThumbData.Customizable == 'Y') {
        LiveGroup.PickThumb.SkinColorContainer.style.visibility = 'visible';
      } else {
        LiveGroup.PickThumb.SkinColorContainer.style.visibility = 'hidden';
      }
   }
  },
  SearchKeypress: function(e) {
    if(e.keyCode==13) {
      LiveGroup.PickThumb.Search(e);
    }
    return true;
  },
  OnStylizedSelectChange: function(e, aElement) {
    var debug= 1;
    aElement.Select.StylizedSelect_onChange(aElement.Select);
    return true;
  },
  DeleteConfirm: function(e, aThumbToRemove) {
    LiveGroup.PickThumb.ConfirmWindow = new LiveGroup.WM.Window('Delete confirmation');
    LiveGroup.PickThumb.ConfirmWindow.Show();
    LiveGroup.PickThumb.ConfirmWindow.Center();
    LiveGroup.PickThumb.ConfirmWindow.SetContent('Are you sure you want to delete this avatar?');
    LiveGroup.PickThumb.ConfirmWindow.AddCloseButton('No');
    LiveGroup.PickThumb.ConfirmWindow.AddButton('Yes', LiveGroup.PickThumb.Delete, aThumbToRemove);
  },
  DeleteComplete: function(e,aThumbRef) {
    LiveGroup.PickThumb.ConfirmWindow.Close();
    var zImageContainer = aThumbRef.parentNode;
    zImageContainer.parentNode.removeChild(zImageContainer);
  },
  Delete: function(e, aDetails) {
    LiveGroup.PickThumb.ConfirmWindow.Loading();
    LiveRequest_MakeRequest(aDetails.URL, LiveGroup.PickThumb.DeleteComplete,aDetails.Image);
  }
}
LiveGroup.Skins = {
  Init: function() {
    if (document.body.id != 'ManageSkinPage')
      return true;
    LiveGroup.Skins.submitButton = $('btnSubmit');
    LiveGroup.Skins.mainContainer = $('FormMiddleBox');
    LiveGroup.Skins.Tabs.Init();
    LiveGroup.PickThumb.Init();
    LiveGroup.Skins.AdvancedEditor.Init();
    return true;
  },
  ValidateForm: function() {
    var zErrors = ''
    var zErrorCount = 0;
    if (zErrorCount < 1)
      return true;
    var zModalDiv = $('ModalMessage');
    zModalDiv.innerHTML =  '<div id="ErrorMessageTop"><div id="MessageTitle">Error</div></div>'
                         + '<div id="ErrorMessageMiddle"><div id="ErrorMessage"></div></div>'
                         + '<div id="ErrorMessageBottom"></div>'
                         + '<div id="CloseButton">Close</div>';
    var zMessageDIV = $('ErrorMessage');
    zMessageDIV.innerHTML = '<span class="MessageDirections">The following errors were found:</span><ul>' + zErrors + '</ul>';
    var zCloseButton = $('CloseButton');
    appendEventHandler(zCloseButton, 'onclick', Modal.Hide);
    Modal.Show(zModalDiv);
    return false;
  },
  Tabs: {
    Init: function() {
      LiveGroup.Skins.Tabs.fullList = getElementsWithAttribute('class','AssetTab');
      LiveGroup.Skins.Tabs.fullList.forEach(function(zListTabs){
        appendEventHandler(zListTabs, 'onclick', LiveGroup.Skins.Tabs.Switch, zListTabs);
        zListTabs.contentId = zListTabs.getAttribute('ContentDiv');
        if (zListTabs.contentId != null && zListTabs.contentId != '')
          zListTabs.contentDiv = $(zListTabs.contentId);
        zSelected = zListTabs.getAttribute('selected');
        if (zSelected == 'Y') {
          LiveGroup.Skins.Tabs.Enable(zListTabs);
        }
      });
    },
    Disable: function(aTab) {
      if (aTab.contentDiv != null)
        aTab.contentDiv.style.display = 'none';
      aTab.style.backgroundPosition = '0px -39px';
      aTab.style.height = '28px';
    },
    Enable: function(aTab) {
      if (aTab.contentDiv != null)
        aTab.contentDiv.style.display = 'block';
      aTab.style.backgroundPosition = '0px 0px';
      aTab.style.height = '32px';
      LiveGroup.Skins.mainContainer.className = aTab.contentId;
    },
    Switch: function(e, aSelectedTab) {
      LiveGroup.Skins.Tabs.fullList.forEach(function(zOneTab) {
        if (zOneTab.id == aSelectedTab.id) {
          LiveGroup.Skins.Tabs.Enable(zOneTab);
        } else {
          LiveGroup.Skins.Tabs.Disable(zOneTab);
        }
      });
    }
  },
  AdvancedEditor: {
    Init: function() {
      zAcceptAdvanced = $('inp_AcceptCustomCSS');
      zInputAdvanced = $('inp_CustomCSS');
      if (zAcceptAdvanced != null && zInputAdvanced != null) {
        zInputAdvanced.style.color = '#ccc';
        appendEventHandler(zAcceptAdvanced, "onclick", LiveGroup.Skins.AdvancedEditor.ToggleTextArea, zInputAdvanced);
      } else
        alert('Unable to find checkbox and/or textarea in Advanced Editor');
    },
    ToggleTextArea: function(e, aTextareaElement) {
      if (e.target == null)
        e.target = e.srcElement;
      if (e.target.checked) {
        aTextareaElement.disabled = false;
        aTextareaElement.style.color = '#777';
      } else {
        aTextareaElement.disabled = true;
        aTextareaElement.style.color = '#ccc';
      }
      return true;
    }
  }
}
LiveGroup.Refacer = {
  stylesheetBuffer: [],
  pageOffsetY: 20,
  pageOffsetX: 0,
  lock: false,
  currentHilight: null,
  HilightInput: function(e, aElement) {
    if (LiveGroup.Refacer.lock) return;
    if (LiveGroup.Refacer.currentHilight != null)
      LiveGroup.Refacer.UnhilightInput(e, LiveGroup.Refacer.currentHilight);
    LiveGroup.Refacer.currentHilight = aElement;
    aElement.style.border = '1px dashed red';
    aElement.style.backgroundColor = '#fee';
  },
  UnhilightInput: function(e, aElement) {
    if (LiveGroup.Refacer.lock) return;
    aElement.style.border = '1px solid #fff';
    aElement.style.backgroundColor = '#fff';
  },
  Init: function(e) {
    if (typeof(refaceList) == 'undefined' || refaceList == null)
      return true;
    LiveGroup.Refacer.refaceList = refaceList;
    LiveGroup.Refacer.currentStylesheet = document.styleSheets[document.styleSheets.length-1];
    if (LiveGroup.Refacer.currentStylesheet.cssRules == null)
      LiveGroup.Refacer.currentStylesheet.cssRules = LiveGroup.Refacer.currentStylesheet.rules;
    LiveGroup.Refacer.rulesOffset = LiveGroup.Refacer.currentStylesheet.cssRules.length;
    LiveGroup.Refacer.CreateStyle();
    for (var i = 0; i < refaceList.length; i++) {
      var highlightElement = null;
      zElement = $('inp_' + refaceList[i].Id);
      if (zElement == null)
        continue;
      refaceList[i].Element = zElement;
      appendEventHandler(zElement, 'onmouseover', LiveGroup.Refacer.UpdateHint, refaceList[i]);
      if (refaceList[i].Action == 'colorpicker') {
        appendEventHandler(zElement.parentNode, 'onmouseover', LiveGroup.Refacer.UpdateHint, refaceList[i]);
        if (zElement.LiveGroup_Refacer_Ids == null) {
          zElement.LiveGroup_Refacer_Ids = new Array();
        }
        zElement.LiveGroup_Refacer_Ids.push(i);
        zElement.ColorPicker_onChange = function(aColor) {
          for (var i=0; i<this.LiveGroup_Refacer_Ids.length; i++) {
            LiveGroup.Refacer.UpdateElement(null, this.LiveGroup_Refacer_Ids[i], aColor.Hex);
          }
        }
        zElement.ColorPicker_onShow = function() { LiveGroup.Refacer.lock = true; }
        zElement.ColorPicker_onHide = function() { LiveGroup.Refacer.lock = false; }
        highlightElement = zElement.parentNode;
      } else if (refaceList[i].Action == 'onstylizedchange') {
        appendEventHandler(zElement.previousSibling, 'onmouseover', LiveGroup.Refacer.UpdateHint, refaceList[i]);
        appendEventHandler(zElement.previousSibling, 'onmouseover', LiveGroup.Refacer.HilightInput, refaceList[i].Element.parentNode);
        appendEventHandler(zElement.previousSibling, 'onmouseout', LiveGroup.Refacer.UnhilightInput, refaceList[i].Element.parentNode);
        zElement.LiveGroup_Refacer_Id = i;
        zElement.StylizedSelect_onChange = function(aElement) {
          LiveGroup.Refacer.UpdateElement(null, aElement.LiveGroup_Refacer_Id);
        }
        highlightElement = zElement.previousSibling;
      } else {
        if (refaceList[i].Action == null || refaceList[i].Action == '')
          refaceList[i].Action = 'onchange';
        appendEventHandler(zElement, refaceList[i].Action, LiveGroup.Refacer.UpdateElement, i);
      }
      if (highlightElement != null) {
        appendEventHandler(highlightElement, 'onmouseover', LiveGroup.Refacer.HilightInput, refaceList[i].Element.parentNode);
        appendEventHandler(highlightElement, 'onmouseout', LiveGroup.Refacer.UnhilightInput, refaceList[i].Element.parentNode);
      }
      if (refaceList[i].IdentifierType == 'id') {
        var zPreviewed = $(refaceList[i].IdentifierName);
        if (zPreviewed != null) {
          appendEventHandler(zPreviewed, 'onmouseover', LiveGroup.Refacer.HilightInput, refaceList[i].Element.parentNode);
          appendEventHandler(zPreviewed, 'onmouseout', LiveGroup.Refacer.UnhilightInput, refaceList[i].Element.parentNode);
        }
      }
      LiveGroup.Refacer.UpdateElement(null, i);
    }
    return true;
  },
  SetStyle: function(aRank, aIdentifier, aValue) {
    LiveGroup.Refacer.stylesheetBuffer[aRank] = new Object();
    LiveGroup.Refacer.stylesheetBuffer[aRank].identifier = aIdentifier;
    LiveGroup.Refacer.stylesheetBuffer[aRank].value = aValue;
  },
  CreateStyle: function() {
    for (var j=0; j < refaceList.length; j++) {
      if (fGlobalPointer.Browser.isIE) {
        LiveGroup.Refacer.currentStylesheet.addRule('#null', 'color:#fff', LiveGroup.Refacer.rulesOffset + j);
      } else {
        LiveGroup.Refacer.currentStylesheet.insertRule('#null {}', LiveGroup.Refacer.rulesOffset + j);
      }
    }
  },
  UpdateStyle: function(aRank) {
    var zCount = 0;
    aUnescapedIdentifier = unescape(LiveGroup.Refacer.stylesheetBuffer[aRank].identifier);
    aUnescapedValue = unescape(LiveGroup.Refacer.stylesheetBuffer[aRank].value);
    if (fGlobalPointer.Browser.isIE) {
      LiveGroup.Refacer.currentStylesheet.removeRule(LiveGroup.Refacer.rulesOffset + aRank);
      if (aUnescapedIdentifier.match(/^[a-zA-Z0-9*:# \t.][a-zA-Z0-9*:# \t._-]*$|^$/)) {
        LiveGroup.Refacer.currentStylesheet.addRule(aUnescapedIdentifier, aUnescapedValue, LiveGroup.Refacer.rulesOffset + aRank);
      }
    } else {
      LiveGroup.Refacer.currentStylesheet.deleteRule(LiveGroup.Refacer.rulesOffset + aRank);
      LiveGroup.Refacer.currentStylesheet.insertRule(aUnescapedIdentifier + '{' + aUnescapedValue + '}', LiveGroup.Refacer.rulesOffset + aRank);
    }
  },
  UpdateHint: function(e, refaceItem) {
    if (LiveGroup.Refacer.lock) return;
    var HintElement = $('EditingArrow');
    if (HintElement == null)
      return;
    switch (refaceItem.HintType) {
      case 'box':
        HintElement.style.display = 'none';
        break;
      case 'arrowleft':
        HintElement.className = '';
        HintElement.style.display = 'block';
        HintElement.style.left = (parseInt(refaceItem.HintX) + LiveGroup.Refacer.pageOffsetX) + 'px';
        HintElement.style.top  = (parseInt(refaceItem.HintY) + LiveGroup.Refacer.pageOffsetY) + 'px';
        break;
      case 'arrowright':
        HintElement.className = 'flip';
        HintElement.style.display = 'block';
        HintElement.style.left = (parseInt(refaceItem.HintX) + LiveGroup.Refacer.pageOffsetX) + 'px';
        HintElement.style.top  = (parseInt(refaceItem.HintY) + LiveGroup.Refacer.pageOffsetY) + 'px';
        break;
      default:
        break;
    }
    return true;
  },
  UpdateElementFromId: function(elementId, aValue) {
    for (var i = 0; i < LiveGroup.Refacer.refaceList.length; i++) {
      if (LiveGroup.Refacer.refaceList[i].Id == elementId) {
        LiveGroup.Refacer.UpdateElement(null, i, aValue);
      }
    }
  },
  UpdateElement: function(e, aRank, aValue) {
    var aRefacingItem = LiveGroup.Refacer.refaceList[aRank];
    var aPrefix = '';
    switch (aRefacingItem.IdentifierType) {
      case 'id':
        aPrefix = '#ManageSkinPage #preview #';
        break;
      case 'class':
        aPrefix = '#ManageSkinPage #preview .';
        break;
      case 'element':
        aPrefix = '#ManageSkinPage #preview ';
        break;
      default:
        break;
    }
    if (aRefacingItem.Element != null && aValue == null)
      aValue = aRefacingItem.Element.value;
    var aIdentifier = aPrefix + aRefacingItem.IdentifierName;
    switch (aRefacingItem.ModifierType) {
      case 'BackgroundColor':
        aValue = Color.Utils.addHashToHex(aValue)
        LiveGroup.Refacer.SetStyle(aRank, aIdentifier, 'background-color: ' + aValue);
        break;
      case 'FontColor':
        aValue = Color.Utils.addHashToHex(aValue)
        LiveGroup.Refacer.SetStyle(aRank, aIdentifier, 'color: ' + aValue);
        break;
      case 'BorderColor':
        aValue = Color.Utils.addHashToHex(aValue)
        LiveGroup.Refacer.SetStyle(aRank, aIdentifier, 'border-color: ' + aValue);
        break;
      case 'FontFamily':
        LiveGroup.Refacer.SetStyle(aRank, aIdentifier, 'font-family: ' + aValue);
        break;
      default:
        break;
    }
    LiveGroup.Refacer.UpdateStyle(aRank);
    return true;
  }
}
LiveGroup.WM = {
  hasFlash: false,
  onlyOne: true,
  GetObjType: function() {
    myBrowser = new BrowserDetect();
    if (myBrowser.isIE) {
      return 'object';
    } else {
      return 'embed';
    }
  },
  HideEmbed: function() {
    zObjList = document.getElementsByTagName(this.GetObjType());
    for (var i = 0; i < zObjList.length; i++) {
      zObjList[i].oldVisibility = zObjList[i].style.visibility;
      zObjList[i].style.visibility = 'hidden';
    }
  },
  RestoreEmbed: function() {
    zObjList = document.getElementsByTagName(this.GetObjType());
    for (var i = 0; i < zObjList.length; i++) {
      zObjList[i].style.visibility = zObjList[i].oldVisibility == null ? 'visible' : zObjList[i].oldVisibility;
    }
  },
  Window: function(aTitle) {
    this._MoveEnable = function(e, aWin) {
      EnableDrag(aWin);
    }
    this._MoveDisable = function(e, aWin) {
      DisableDrag(aWin);
    }
    this.MoveOnScreen = function(aPosX, aPosY) {
      var zScrollY = 0;
      if (document.documentElement && document.documentElement.scrollTop) zScrollY = document.documentElement.scrollTop;
      else if (document.body && document.body.scrollTop) zScrollY = document.body.scrollTop;
      else if (window.pageYOffset) zScrollY = window.pageYOffset;
      else if (window.scrollY) zScrollY = window.scrollY;
      this.Move(aPosX, (aPosY + zScrollY));
    }
    this.Move = function(aPosX, aPosY) {
      this.container.style.left = aPosX + 'px';
      this.container.style.top = aPosY + 'px';
    }
    this.Center = function() {
      var zPageSize = getPageSize();
      var zX = (zPageSize.pageWidth - (this.container.clientWidth ? this.container.clientWidth : 0)) / 2;
      var zY = (zPageSize.windowHeight - (this.container.clientHeight ? this.container.clientHeight : 0)) / 2;
      this.MoveOnScreen(zX, zY);
    }
    this.SetContent = function(aContent) {
      this.content.innerHTML = aContent;
      var zIsFocused  = false;
      var zInputArray = this.content.getElementsByTagName('input');
      var zTextareaArray = this.content.getElementsByTagName('textarea');
      if (zInputArray.length > 0||zTextareaArray.length > 0) {
        for (i = 0; i < zInputArray.length; i++) {
          if (zInputArray[i].type!='hidden'&&zIsFocused!=true) {
            zInputArray[i].focus();
            zIsFocused = true;
          }
        }
        if (zIsFocused!=true) {
          for (i = 0; i < zTextareaArray.length; i++) {
            if (zIsFocused!=true) {
              zTextareaArray[i].focus();
              zIsFocused = true;
            }
          }
        }
      }
    }
    this.Loading = function() {
      LiveGroup.Utils.RemoveSubItems(this.content);
      LiveGroup.Utils.RemoveSubItems(this.buttonsContainer);
      this.content.appendChild(this.loadingImage);
    }
    this.Close = function() {
      this._Close(null, this);
    }
    this._Close = function(e, aWin) {
      if (aWin.onClose != null && typeof(aWin.onClose) == 'function') {
        aWin.onClose(aWin.onCloseData);
      }
      Tween.Run({
        Element: aWin,
        Function: function(aParams){ Tween.Common.SetOpacity(aParams.Element.container, aParams.CurrentValue) },
        OnCompleteFunction: function(aParams) {
          document.body.removeChild(aParams.Element.container);
          if (LiveGroup.WM.hasFlash) { LiveGroup.WM.RestoreEmbed(); }
          if (LiveGroup.WM.onlyOne) { LiveGroup.WM.currentWindow = null; }
          aParams.Element.active = false;
        },
        StartValue: 1.0,
        EndValue: 0.0,
        Duration: 300
      });
    }
    this.Show = function() {
      this._Show(null, this);
    }
    this._Show = function(e, aWin) {
      if (LiveGroup.WM.onlyOne) {
        if (LiveGroup.WM.currentWindow != null) {
          LiveGroup.WM.currentWindow.Close();
        }
        LiveGroup.WM.currentWindow = aWin;
      }
      if (LiveGroup.WM.hasFlash) {
        LiveGroup.WM.HideEmbed();
      }
      document.body.appendChild(aWin.container);
      aWin.container.style.display = 'block';
      aWin.active = true;
    }
    this.AddButton = function(aName, aCallback, aData) {
      zButton = CreateBasicElement('div', null, 'LGWM_Window_Button');
      zButton.innerHTML = aName;
      appendEventHandler(zButton, 'onclick', aCallback, aData);
      this.buttonsContainer.appendChild(zButton);
    }
    this.AddCloseButton = function(aName) {
      if (aName == null || aName == '') aName = 'Okay';
      this.AddButton(aName, this._Close, this);
    }
    this.container = CreateBasicElement('div', null, 'LGWM_Window');
    this.container.style.display = 'none';
    if (aTitle != null) {
      this.titlebar = CreateBasicElement('div', null, 'LGWM_Window_TitleBar');
      this.titlebar.innerHTML = aTitle;
      appendEventHandler(this.titlebar, 'onmouseover', this._MoveEnable, this.container);
      appendEventHandler(this.titlebar, 'onmouseout', this._MoveDisable, this.container);
      this.container.appendChild(this.titlebar);
    }
    var zCloseButton = CreateBasicElement('a', null, 'LGWM_Window_TitleBarClose');
    zCloseButton.innerHTML = 'X';
    appendEventHandler(zCloseButton, 'onclick', this._Close, this);
    this.container.appendChild(zCloseButton);
    this.loadingImage = CreateBasicElement('img', null, 'LGWM_Window_LoadingImage');
    this.loadingImage.src = '/l.c.bin/I/4803774/Loading-BG.gif';
    this.content = CreateBasicElement('div', null, 'LGWM_Window_Content');
    this.container.appendChild(this.content);
    this.buttonsContainer = CreateBasicElement('div', null, 'LGWM_Window_ButtonsContainer');
    this.container.appendChild(this.buttonsContainer);
    this.Loading();
  },
  Error: function(aContent) {
    this.window = new LiveGroup.WM.Window('Error!');
    this.window.Show();
    this.window.Center();
    this.window.SetContent(aContent);
    this.window.AddCloseButton('Okay');
  }
}
LiveGroup.ActionBar = {
  Control: function(aControlSetup) {
    this.Show = function(e, aControl) {
      if (e) {
        e.cancelBubble = true;
      }
      var zURLPrefix = '';
      if (aControl.window != null && aControl.window.active) {
        return true;
      }
      aControl.window = new LiveGroup.WM.Window(aControl.setup.Title);
      aControl.window.Show();
      aControl.window.Center();
      if (aControl.parentbar != null && aControl.parentbar.setup != null && aControl.parentbar.setup.ItemBaseURL != null) {
        zURLPrefix = aControl.parentbar.setup.ItemBaseURL;
      } else if (aControl.setup.ItemBaseURL != null) {
        zURLPrefix = aControl.setup.ItemBaseURL;
      }
      if (aControl.setup.OnCancelCallback != null && typeof(aControl.setup.OnCancelCallback) == 'function') {
        aControl.window.onClose = aControl.setup.OnCancelCallback;
        aControl.window.onCloseData = aControl.setup.OnCancelCallbackData;
      }
      LiveRequest_MakeRequest(zURLPrefix + aControl.setup.ContentAction, aControl.ReceiveContent, aControl)
      return true;
    }
    this.LoginAndShow = function(e, aControl) {
      if (e) {
        e.cancelBubble = true;
      }
      var zLoginError = '';
      var zURLPrefix = '';
      if (GetCookieValue('TLOAID') != '') {
        aControl.Show(e, aControl);
        return true;
      }
      if (aControl.LoginError != null)
        zLoginError = '&aLoginError=' + escape(aControl.LoginError);
      if (aControl.setup.ItemBaseURL != null) {
        zURLPrefix = aControl.setup.ItemBaseURL;
      }
      aControl.LoginError = null;
      var zLoginAction = {
        Title: 'Login',
        ContentAction: zURLPrefix + '.LoginForm?aObjectTypeAlias=LiveGroup_ActionBar&aActionBar=Y' + zLoginError,
        Type: 'action',
        ActionName: 'Login',
        OnClickURL: zURLPrefix + '.LoginComplete?aObjectTypeAlias=LiveGroup_ActionBar&aActionBar=Y',
        AddFields: ['inpControlUserName', 'inpControlPassword'],
        bar: aControl.parentbar,
        noLink: true,
        OriginalAction: aControl
      }
      aLoginControl = new LiveGroup.ActionBar.Control(zLoginAction);
      aLoginControl.Show(e, aLoginControl);
    }
    this.UpdateButtons = function() {
      LiveGroup.Utils.RemoveSubItems(this.window.buttonsContainer);
      switch (this.setup.Type) {
        case 'url':
          break;
        case 'action':
          var zButtonName = 'Save';
          this.window.AddCloseButton('Cancel');
          if (this.setup.ActionName != null) zButtonName = this.setup.ActionName;
          this.window.AddButton(zButtonName, this.OnClick, this);
          break;
        case 'info':
        default:
          this.window.AddCloseButton();
          break;
      }
    }
    this.ReceiveContent = function(aData, aControl) {
      if (aData == null) {
        aControl.Close();
        return;
      }
      if (aData.Type == 'callback') {
        if (typeof(aData.Callback) == 'function') {
          aData.Callback(aData.CallbackData, aControl);
          aControl.Close();
          return;
        }
      }
      if (aData.ReturnFromLogin) {
        aControl.Close();
        if (aData.LoginSuccess) {
          SetCookie('TLOAID', aData.LSAccessID, 'NEVER', void(0), '.voig.com');
          aControl.Show(null, aControl.setup.OriginalAction);
          LiveGroup.Login.Auth(true);
        } else {
          if (aControl.setup.OriginalAction == null) {
            aControl.setup.OriginalAction = aControl;
          }
          aControl.setup.OriginalAction.LoginError = aData.LoginError != null ? aData.LoginError : '';
          aControl.LoginAndShow(null, aControl.setup.OriginalAction);
        }
        return;
      }
      aControl.window.SetContent(unescape(aData.Content));
      if (aControl.setup.hasAdvancedElement == true) {
        InitializeFormControls();
      }
      if (typeof(aData.OnLoadCallback) == 'function') {
        aData.OnLoadCallback(aData.OnLoadCallbackData, aControl);
      }
      if (aData.ActionName != null && aData.ActionName != '') {
        aControl.setup.ActionName = aData.ActionName;
      }
      if (aData.OnClickURL != null && aData.OnClickURL != '') {
        aControl.setup.OnClickURL = aData.OnClickURL;
      }
      if (aData.Type != null && aData.Type != '') {
        aControl.setup.Type = aData.Type;
      } else {
        aControl.setup.Type = aControl.defaulttype;
      }
      aControl.UpdateButtons();
      if (aData.PreActionCallback != null && typeof(aData.PreActionCallback) == 'function') {
        aControl.setup.PreActionCallback = aData.PreActionCallback;
      }
    }
    this.OnClick = function(e, aControl) {
      if (e) {
        e.cancelBubble = true;
      }
      if (aControl.setup.PreActionCallback != null) {
        if (aControl.setup.PreActionCallback() == false) {
          return true;
        }
      }
      if (aControl.setup.OnClickURL != null && aControl.setup.OnClickURL != '') {
        var zLReqURL;
        if (aControl.parentbar != null && aControl.parentbar.setup != null && aControl.parentbar.setup.ItemBaseURL != null) {
          zLReqURL = aControl.parentbar.setup.ItemBaseURL + aControl.setup.OnClickURL;
        } else if (aControl.setup.ItemBaseURL != null) {
          zLReqURL = aControl.setup.ItemBaseURL + aControl.setup.OnClickURL;
        } else {
          zLReqURL = aControl.setup.OnClickURL;
        }
        if (aControl.setup.AddFields != null && aControl.setup.AddFields.length > 0) {
          for (var i = 0; i < aControl.setup.AddFields.length; i++) {
            zInputObject = $(aControl.setup.AddFields[i]);
            if (zInputObject == null) continue;
            if (zInputObject.type == 'checkbox' && zInputObject.checked == false) {
              zInputObject.value = '';
            }
            zLReqURL += '&' + aControl.setup.AddFields[i] + '=' + escape(zInputObject.value);
          }
        }
        aControl.window.Loading();
        LiveRequest_MakeRequest(zLReqURL, aControl.ReceiveContent, aControl)
      } else {
        aControl.Close();
      }
    }
    this.GotoURL = function(e, aControl) {
      if (aControl.setup.OnClickURL != null && aControl.setup.OnClickURL != '') {
        window.location = aControl.setup.OnClickURL;
      }
    }
    this.Close = function() {
      this.window.Close();
    }
    this.parentbar = aControlSetup.bar;
    this.setup = aControlSetup;
    this.defaulttype = aControlSetup.Type;
    if (this.setup.noLink) {
      return;
    }
    if (this.setup.TriggerId != null) {
      this.link = $(this.setup.TriggerId);
    } else if (this.setup.Trigger != null) {
      this.link = this.setup.Trigger;
    } else {
      this.link = CreateBasicElement('a', 'ActionBar_Item_' + aControlSetup.Alias, 'ActionBar_Link');
      if (this.setup.IconOnly) {
        this.link.title = aControlSetup.Title;
      } else {
        this.link.innerHTML = aControlSetup.Title;
      }
      this.parentbar.container.appendChild(this.link);
    }
    if (this.setup.Type == 'url') {
      appendEventHandler(this.link, 'onclick', this.GotoURL, this);
    } else {
      if (this.setup.RequireLogin) {
        appendEventHandler(this.link, 'onclick', this.LoginAndShow, this);
      } else {
        appendEventHandler(this.link, 'onclick', this.Show, this);
      }
    }
  },
  Bar: function(aSetup) {
    this.controlsetups = new Array();
    this.setup = aSetup;
    if (aSetup.Toggle && aSetup.Toggle.Inappropriate) {
      this.controlsetups.push({
        Title: 'Flag as inappropriate',
        ContentAction: aSetup.ItemBaseURL + '.Inappropriate?aObjectTypeAlias=LiveGroup_ActionBar&aJSON=Y',
        Type: 'action',
        ActionName: 'Flag!',
        OnClickURL: aSetup.ItemBaseURL + '.InappropriateSave?aObjectTypeAlias=LiveGroup_ActionBar&aJSON=Y',
        RequireLogin: true
      });
    }
    if (aSetup.Toggle && aSetup.Toggle.Share) {
      this.controlsetups.push({
        Title: 'Share with a friend',
        ContentAction: aSetup.ItemBaseURL + '.Share?aObjectTypeAlias=LiveGroup_Asset&aActionBar=Y',
        Type: 'action',
        ActionName: 'Share',
        OnClickURL: aSetup.ItemBaseURL + '.ShareComplete?aObjectTypeAlias=LiveGroup_Asset&aActionBar=Y',
        AddFields: ['inp_Name', 'inp_EmailToAddress', 'inp_Message']
      });
    }
    if (aSetup.Toggle && aSetup.Toggle.AddComment) {
      this.controlsetups.push({
        Title: 'Add Comment',
        ContentAction: aSetup.ItemBaseURL + '.Share?aObjectTypeAlias=LiveGroup_Asset&aActionBar=Y',
        Type: 'info'
      });
    }
    if (aSetup.Actions != null && aSetup.Actions.length > 0) {
      this.controlsetups = this.controlsetups.concat(aSetup.Actions);
    }
    if (this.setup.container == null) {
      document.write('<div class="LiveGroup_ActionBar" id="ActionBar_' + aSetup.ObjectCode + '"></div>');
      this.container = $('ActionBar_' + aSetup.ObjectCode);
    } else {
      this.container = this.setup.container;
    }
    if (this.container == null)
      return null;
    for (var i = 0; i < this.controlsetups.length; i++) {
      if (this.controlsetups[i] == null)
        continue;
      this.controlsetups[i].order = i;
      this.controlsetups[i].bar = this;
      if (this.setup.IconsOnly) {
        this.controlsetups[i].IconOnly = true;
      }
      zControl = new LiveGroup.ActionBar.Control(this.controlsetups[i]);
    }
  }
}
function getEventRealCoordinates(e,aElement) {
  var zResults, zCoords;
  if(aElement) {
    zCoords = getAbsolutePosition(aElement);
    if(fGlobalPointer&&fGlobalPointer.Browser&&fGlobalPointer.Browser.isIE) {
      zResults = {x: e.offsetX, y: e.offsetY};
    }
    else {
      if (e.pageX || e.pageY) {
        zResults = {x: (e.pageX-zCoords.x), y: (e.pageY-zCoords.y)};
      } else {
        zResults = {
          x: ((e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft)-zCoords.x),
          y: ((e.clientY + document.documentElement.scrollTop + document.body.scrollTop)-zCoords.y)
        };
      }
    }
  }
  else {
    if (e.pageX || e.pageY) {
      zResults = {x: (e.pageX), y: (e.pageY)};
    } else {
      zResults = {
        x: (e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft),
        y: (e.clientY + document.documentElement.scrollTop + document.body.scrollTop)
      };
    }
  }
  return zResults;
}
LiveGroup.Database = new Object();
LiveGroup.Database.MaxNameSize = 14;
LiveGroup.Database.Card = function(aCardSetup) {
  this.setup = aCardSetup;
  this.parent = $(aCardSetup.ParentId);
  this.currentSide = 0;
  if (this.setup.NoBackground != true) {
    this.frontImage = 'url(/l.c.bin/I/5472190/Animated_LoadingCard_v2.gif)';
  }
  this.BuildMain = function() {
    if (this.setup.DatabaseType == 'Player') {
      this.frontImage = 'url(/l.c.bin/I/5363896/PlayerPlayingcard_v3.png)';
      this.backImage  = 'url(/l.c.bin/I/5363928/PlayerPlayingcardBack_v3.png)';
    } else {
      this.frontImage = 'url(/l.c.bin/I/5418828/TeamCardv2.png)';
      this.backImage  = 'url(/l.c.bin/I/5192436/Home_TeamCardBG2_Flip.png)';
    }
    this.inside = CreateBasicElement('div');
    this.container.appendChild(this.inside);
    zFlipTrigger = CreateBasicElement('div', null, 'FlipTrigger');
    appendEventHandler(zFlipTrigger, "onclick", this.CurtainClose, this);
    this.container.appendChild(zFlipTrigger);
    this.leftCurtain = CreateBasicElement('div', null, 'FlipCurtainLeft LG_ColorAltBodyBack');
    this.container.appendChild(this.leftCurtain);
    this.rightCurtain = CreateBasicElement('div', null, 'FlipCurtainRight LG_ColorAltBodyBack');
    this.container.appendChild(this.rightCurtain);
    if (this.parent != null) {
      this.parent.appendChild(this.container);
    }
  }
  this.ShowFront = function() {
    LiveGroup.Utils.RemoveSubItems(this.inside);
    if (this.setup.NoBackground != true) {
      this.container.style.backgroundImage = this.frontImage;
    }
    zPic = CreateBasicElement('img');
    zPic.src = this.setup.Avatar;
    appendEventHandler(zPic, 'onclick', this.GotoSite, this);
    this.inside.appendChild(zPic);
    zName = CreateBasicElement('div', null, 'Name');
    if (this.setup.Name.length > LiveGroup.Database.MaxNameSize + 1) {
      this.setup.Name = this.setup.Name.substring(0, LiveGroup.Database.MaxNameSize) + '...';
    }
    zName.innerHTML = unescape(this.setup.Name);
    appendEventHandler(zName, 'onclick', this.GotoSite, this);
    this.inside.appendChild(zName);
    if (this.setup.DatabaseType == 'Player') {
      zRankContainer = CreateBasicElement('div', null, 'Rank LG_ColorH2');
      zRankContainer.title = 'Rank';
      zRankContainer.innerHTML = this.setup.Rank;
      this.inside.appendChild(zRankContainer);
      if (this.setup.Online == 'Y') {
        zOnlineContainer = CreateBasicElement('div', null, 'Online TransparentBG');
        zOnlineContainer.backgroundPosition = '';
        zOnlineContainer.title = 'Online';
        this.inside.appendChild(zOnlineContainer);
      } else {
        zOfflineContainer = CreateBasicElement('div', null, 'Offline TransparentBG');
        zOfflineContainer.backgroundPosition = '0px -12px';
        zOfflineContainer.title = 'Offline';
        this.inside.appendChild(zOfflineContainer);
      }
      if (this.setup.Recruit != 'N') {
        zRecruitContainer = CreateBasicElement('div', null, 'Recruit TransparentBG');
        zRecruitContainer.backgroundPosition = '-12px -12px';
        zRecruitContainer.title = 'Recruit';
        this.inside.appendChild(zRecruitContainer);
      }
    }
    zFriendsContainer = CreateBasicElement('div', null, 'Alliances Friends LG_ColorLabel');
    zFriendsContainer.title = this.setup.DatabaseType == 'Player' ? 'Friends' : 'Members';
    zFriendsContainer.innerHTML = this.setup.Friends;
    this.inside.appendChild(zFriendsContainer);
    zRivalsContainer = CreateBasicElement('div', null, 'Alliances Rivals LG_ColorLabel');
    zRivalsContainer.title = 'Rivals';
    zRivalsContainer.innerHTML = this.setup.Rivals;
    this.inside.appendChild(zRivalsContainer);
  }
  this.ShowBack = function() {
    var zSpaceLeft = 6;
    LiveGroup.Utils.RemoveSubItems(this.inside);
    if (this.setup.NoBackground != true) {
      this.container.style.backgroundImage = this.backImage;
    }
    zPicAndName = CreateBasicElement('div', null, 'BackName LG_ColorH2');
      zPic = CreateBasicElement('img', null, 'SmallerPic');
      zPic.src = this.setup.Avatar;
      zPicAndName.appendChild(zPic);
      zPicAndName.innerHTML += unescape(this.setup.Name);
      appendEventHandler(zPicAndName, 'onclick', this.GotoSite, this);
    this.inside.appendChild(zPicAndName);
    if (this.setup.DatabaseType == 'Player') {
      zRankContainer = CreateBasicElement('div', null, 'RankBack LG_ColorLabel');
      zRankContainer.title = 'Rank';
      zRankContainer.innerHTML = this.setup.Rank;
      this.inside.appendChild(zRankContainer);
      zSoftDollarsContainer = CreateBasicElement('div', null, 'SoftDollarsContainer');
      this.inside.appendChild(zSoftDollarsContainer);
      zRankLabel = CreateBasicElement('div', null, 'RankLabel LG_ColorLabel');
      zRankLabel.title = 'Rank Label';
      zRankLabel.innerHTML = unescape(this.setup.RankLabel);
      zSoftDollarsContainer.appendChild(zRankLabel);
      zSoftDollars = CreateBasicElement('div', null, 'SoftDollars LG_ColorLabel');
      zSoftDollars.title = 'Soft Dollars';
      zSoftDollars.innerHTML = '<span class="LG_ColorLabel">Soft Dollars: </span>' + unescape(this.setup.SoftDollars);
      zSoftDollarsContainer.appendChild(zSoftDollars);
    }
    if (this.setup.Membership != '') {
      zMembershipContainer = CreateBasicElement('div', null, 'Membership');
      zMembershipContainer.innerHTML = '<span>Joined: </span>' + unescape(this.setup.Membership);
      this.inside.appendChild(zMembershipContainer);
      zSpaceLeft -= 1;
    }
    if (this.setup.Game != null && this.setup.Game != '') {
      zGameContainer = CreateBasicElement('div', null, 'Game');
      zGameContainer.innerHTML = '<span>Game: </span>' + unescape(this.setup.Game);
      this.inside.appendChild(zGameContainer);
      zSpaceLeft -= 1;
    }
    if (this.setup.Server != null && this.setup.Server != '') {
      zServerContainer = CreateBasicElement('div', null, 'Server');
      zServerContainer.innerHTML = '<span>Location: </span>' + unescape(this.setup.Server);
      this.inside.appendChild(zServerContainer);
      zSpaceLeft -= 1;
    }
    if (this.setup.SkillLevel != null && this.setup.SkillLevel != '') {
      zSkillLevelContainer = CreateBasicElement('div', null, 'SkillLevel');
      zSkillLevelContainer.innerHTML = '<span>Skill Level: </span>' + unescape(this.setup.SkillLevel);
      this.inside.appendChild(zSkillLevelContainer);
      zSpaceLeft -= 1;
    }
    if (this.setup.Country != null) {
      zCountryContainer = CreateBasicElement('div', null, 'Country');
      if (this.setup.CountryFlag != null) {
        zCountryFlagImage = CreateBasicElement('img');
        zCountryFlagImage.src = this.setup.CountryFlag;
        zCountryFlagImage.title = unescape(this.setup.Country);
        zCountryContainer.appendChild(zCountryFlagImage);
      }
      this.inside.appendChild(zCountryContainer);
      zSpaceLeft -= 1;
    }
    zAcBarContainer = CreateBasicElement('div', null, 'LiveGroup_ActionBar');
    this.inside.appendChild(zAcBarContainer);
    this.setup.container = zAcBarContainer;
    this.setup.IconsOnly = true;
    this.setup.Data = this;
    zMyActionBar = new LiveGroup.ActionBar.Bar(this.setup);
  }
  this.GotoSite = function(e, aCard) {
    document.location = aCard.setup.Website;
  }
  this.Refresh = function() {
    if (this.currentSide == 0) {
      this.ShowFront();
    } else {
      this.ShowBack();
    }
  }
  this.CurtainClose = function(e, aCard) {
    Tween.Run({
      Element: aCard,
      Function: function(aParams){
        aParams.Element.leftCurtain.style.width = aParams.CurrentValue +'px';
        aParams.Element.rightCurtain.style.width = aParams.CurrentValue +'px';
      },
      OnCompleteFunction: function(aParams){
        aParams.Element.Flip(null, aParams.Element);
      },
      StartValue: 0, EndValue: aCard.setup.curtainSize, Duration: 100
    });
  }
  this.CurtainOpen = function() {
    Tween.Run({
      Element: this,
      Function: function(aParams){
        aParams.Element.leftCurtain.style.width = aParams.CurrentValue +'px';
        aParams.Element.rightCurtain.style.width = aParams.CurrentValue +'px';
      },
      StartValue: this.setup.curtainSize, EndValue: 0, Duration: 100
    });
  }
  this.Flip = function(e, aCard) {
    if (aCard.currentSide == 0)
      aCard.currentSide = 1;
    else
      aCard.currentSide = 0;
    aCard.Refresh();
    aCard.setup.curtainSize = Math.round(aCard.container.clientWidth / 2);
    aCard.CurtainOpen();
  }
  this.getData = function() {
    LiveRequest_MakeRequest(this.setup.ItemBaseURL + '.GetCardJSON', this.receiveData, this);
  }
  this.receiveData = function(aData, aParent) {
    zNoBack = aParent.setup.NoBackground;
    if (aParent.setup.Actions) {
      aData.Actions = aParent.setup.Actions;
    }
    aParent.setup = aData;
    aParent.setup.NoBackground = zNoBack;
    aParent.BuildMain();
    aParent.Refresh();
  }
  this.container = CreateBasicElement('a', null, 'Card');
  if (this.setup.Avatar) {
    this.receiveData(this.setup,this);
  } else {
    this.getData();
  }
}
LiveGroup.Database.CardControls = {
  PlayerPublic: [
    {
      Title: 'Request Alliance',
      Alias: 'MkFriend',
      ContentAction: '.FriendRequest?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      Type: 'action',
      ActionName: 'Request Alliance',
      OnClickURL: '.FriendRequestComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      AddFields: ['inpRequestHTML', 'inpSourceDatabasePath'],
      RequireLogin: true
    },
      {
        Title: 'Recruit',
        Alias: 'Recruit',
        ContentAction: '.RecruitRequest?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
        Type: 'action',
        ActionName: 'Recruit',
        OnClickURL: '.RecruitRequestComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
        AddFields: ['inp_Team', 'inpHTML'],
        RequireLogin: true
      },
    {
      Title: 'Send Message',
      Alias: 'Message',
      ContentAction: '.SendMessage?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      Type: 'action',
      ActionName: 'Send Message',
      OnClickURL: '.SendMessageComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      AddFields: ['inpSubject', 'inpHTML', 'inpForceNotification'],
      RequireLogin: true
    },
    {
      Title: 'Event Invite',
      Alias: 'Event',
      ContentAction: '.EventInvite?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      Type: 'action',
      ActionName: 'Invite',
      OnClickURL: '.EventInviteComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      AddFields: ['inpSubject', 'inpHTML', 'inpDate'],
      RequireLogin: true
    },
    {
      Title: 'Make Rival',
      Alias: 'MkRival',
      ContentAction: '.MakeRival?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      Type: 'action',
      ActionName: 'Make Rival',
      OnClickURL: '.MakeRivalComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      AddFields: ['inpSourceDatabasePath', 'inpNothing'],
      RequireLogin: true
    },
    {
      Title: 'Challenge',
      Alias: 'Challenge',
      ContentAction: '.Challenge?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      Type: 'action',
      ActionName: 'Challenge',
      OnClickURL: '.ChallengeComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      AddFields: ['inpSubject', 'inpHTML'],
      RequireLogin: true
    },
  null
]
,
  TeamPublic: [
    {
      Title: 'Request Alliance',
      Alias: 'MkFriend',
      ContentAction: '.FriendRequest?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      Type: 'action',
      ActionName: 'Request Alliance',
      OnClickURL: '.FriendRequestComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      AddFields: ['inpRequestHTML', 'inpSourceDatabasePath'],
      RequireLogin: true
    },
      {
        Title: 'Join Team',
        Alias: 'Recruit',
        ContentAction: '.RequestAccess?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
        Type: 'action',
        ActionName: 'Request membership',
        OnClickURL: '.RequestAccessComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
        AddFields: ['inp_Team', 'inpHTML'],
        RequireLogin: true
      },
    {
      Title: 'Send Message',
      Alias: 'Message',
      ContentAction: '.SendMessage?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      Type: 'action',
      ActionName: 'Send Message',
      OnClickURL: '.SendMessageComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      AddFields: ['inpSubject', 'inpHTML', 'inpForceNotification'],
      RequireLogin: true
    },
    {
      Title: 'Event Invite',
      Alias: 'Event',
      ContentAction: '.EventInvite?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      Type: 'action',
      ActionName: 'Invite',
      OnClickURL: '.EventInviteComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      AddFields: ['inpSubject', 'inpHTML', 'inpDate'],
      RequireLogin: true
    },
    {
      Title: 'Make Rival',
      Alias: 'MkRival',
      ContentAction: '.MakeRival?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      Type: 'action',
      ActionName: 'Make Rival',
      OnClickURL: '.MakeRivalComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      AddFields: ['inpSourceDatabasePath', 'inpNothing'],
      RequireLogin: true
    },
    {
      Title: 'Challenge',
      Alias: 'Challenge',
      ContentAction: '.Challenge?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      Type: 'action',
      ActionName: 'Challenge',
      OnClickURL: '.ChallengeComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      AddFields: ['inpSubject', 'inpHTML'],
      RequireLogin: true
    },
  null
]
}
LiveGroup.DropDown = function() {
  this.midHeight = 84;
  this.teamHeight = 50;
  this.extraHeight = 14;
  this.scrollSpeed = 300;
  this.Receive = function(aData, aCTA) {
    aCTA.Items = aData;
    LiveGroup.Utils.RemoveSubItems(aCTA.container);
    aCTA.Build();
    Tween.Run({
      Element: aCTA,
      Function: function(aParams){
        aParams.Element.container.style.height = aParams.CurrentValue + 'px';
      },
      OnCompleteFunction: function(aParams) {
        aParams.Element.locked = false;
        aParams.Element.container.style.height = 'auto';
      },
      StartValue: aCTA.midHeight,
      EndValue: (aData.length * aCTA.teamHeight) + aCTA.extraHeight,
      Duration: aCTA.scrollSpeed
    });
  }
  this.Init = function(aTrigger) {
    appendEventHandler(aTrigger, 'onclick', this.Trigger, this);
  }
  this.Request = function() {
    zLoading = CreateBasicElement('div', null, 'LoadingImage');
    this.container.appendChild(zLoading);
    LiveRequest_MakeRequest(this.requestURL, this.Receive, this);
  }
  this.BuildMenu = function() {
    this.active = true;
    this.locked = true;
    this.container = CreateBasicElement('div', null, this.containerClass);
    this.parent.appendChild(this.container);
    this.container.style.height = '0px';
    if (this.preLoaded) {
      this.Receive(this.preLoaded, this);
    } else {
      Tween.Run({
        Element: this,
        Function: function(aParams) { aParams.Element.container.style.height = aParams.CurrentValue + 'px'; },
        OnCompleteFunction: function(aParams) {
          if (aParams.Element.PreRequest) {aParams.Element.PreRequest()};
          aParams.Element.Request();
        },
        StartValue: 0,
        EndValue: this.midHeight,
        Duration: this.scrollSpeed
      });
    }
  }
  this.CloseMenu = function() {
    Tween.Run({
      Element: this,
      Function: function(aParams){ Tween.Common.SetOpacity(aParams.Element.container, aParams.CurrentValue) },
      OnCompleteFunction: function(aParams) {
        aParams.Element.parent.removeChild(aParams.Element.container);
        aParams.Element.active = false;
      },
      StartValue: 1.0,
      EndValue: 0.0,
      Duration: 400
    });
  }
  this._CloseMenu = function(e, aCTA) { aCTA.CloseMenu(); }
  this.Trigger = function(e, aCTA) {
    if (aCTA.locked) return;
    if (aCTA.active) {
      aCTA.CloseMenu();
    } else {
      aCTA.BuildMenu();
    }
  }
}
LiveGroup.Database.CallToArms = function(aTrigger) {
  this.active = false;
  this.parent = $('AllContent');
  this.containerClass = 'CallToArms';
  this.Build = function() {
    for (var i = 0; i < this.Items.length; i++) {
      zTeamContainer = CreateBasicElement('div', null, 'Team');
      zTeamButton = CreateBasicElement('div', null, 'HornButton');
      zTeamContainer.appendChild(zTeamButton);
      zTeamName = CreateBasicElement('div', null, 'TeamName');
      zTeamNameH1 = CreateBasicElement('h1');
      this.Items[i].Name = unescape(this.Items[i].Name)
      if (this.Items[i].Name.length > LiveGroup.Database.MaxNameSize) {
        zDisplayName = this.Items[i].Name.substring(0, LiveGroup.Database.MaxNameSize) + '...';
      } else {
        zDisplayName = this.Items[i].Name;
      }
      zTeamNameH1.innerHTML = zDisplayName;
      zTeamNameH1.title = this.Items[i].Name;
      zTeamName.appendChild(zTeamNameH1);
      zTeamNameMembers = CreateBasicElement('div');
      zTeamNameMembers.innerHTML = this.Items[i].Members + (this.Items[i].Members > 1 ? ' members' : ' member');
      zTeamName.appendChild(zTeamNameMembers);
      zTeamContainer.appendChild(zTeamName);
      var zURL = unescape(this.Items[i].ItemPath);
      new LiveGroup.ActionBar.Control({
        ItemBaseURL: '/' + zURL.replace(/\\/g, '/'),
        Title: 'Call to arms!',
        ContentAction: '.CallToArms',
        OnClickURL: '.CallToArmsComplete?',
        Type: 'action',
        ActionName: 'Call to arms!',
        AddFields: ['inpHTML', 'inpForceNotification'],
        Trigger: zTeamContainer
      });
      appendEventHandler(zTeamContainer, 'onclick', this._CloseMenu, this);
      this.container.appendChild(zTeamContainer);
    }
    if (this.Items.length < 1) {
      zNoTeams = CreateBasicElement('div');
      zNoTeams.innerHTML = 'You are not the admin of any team at the moment, Call to Arms is a priviledge of team admins. Click <a href="http://www.voig.com/voig/ContentList/LiveGroup_TeamDatabaseList.Add?aLanguage=en-us&aObjectTypeAlias=LiveGroup_TeamDatabase">here</a> to register your own team.';
      this.container.appendChild(zNoTeams);
      this.Items.length = 1;
    }
    zClose = CreateBasicElement('div', null, 'CloseButton');
    zClose.innerHTML = 'Cancel';
    this.container.appendChild(zClose);
    appendEventHandler(zClose, 'onclick', this._CloseMenu, this);
  }
  this.PreRequest = function() {
    this.requestURL = '/' + LiveGroup.Login.UserInformation.ObjectPath + '.CallToArmTeamListJSON';
  }
  this.Init(aTrigger);
}
LiveGroup.Database.CallToArms.prototype = new LiveGroup.DropDown;
LiveGroup.Database.ManageSites = function(aTrigger) {
  this.active = false;
  this.parent = $('AllContent');
  this.requestURL = '/Javascript.GetSitesJSON?aObjectTypeAlias=LiveGroup_PlayerDatabase';
  this.containerClass = 'ManageSitesContainer';
  this.teamHeight = 44;
  this.extraHeight = 18;
  this.preLoaded = LiveGroup.Login.UserInformation.Sites;
  this.Build = function() {
    zClose = CreateBasicElement('div', null, 'CloseButton');
    zClose.innerHTML = 'Close (X)';
    this.container.appendChild(zClose);
    appendEventHandler(zClose, 'onclick', this._CloseMenu, this);
    for (var i = 0; i < this.Items.length; i++) {
      zTeamContainer = CreateBasicElement('div', null, 'Site');
      this.container.appendChild(zTeamContainer);
      zAvatar = CreateBasicElement('a', null, 'Avatar');
      zAvatar.href = unescape(this.Items[i].SiteURL);
      zAvatarImg = CreateBasicElement('img');
      zAvatarImg.src = unescape(this.Items[i].AvatarURL);
      zAvatar.appendChild(zAvatarImg);
      zTeamContainer.appendChild(zAvatar);
      zName = CreateBasicElement('a', null, 'Name');
      zName.href = unescape(this.Items[i].SiteURL);
      zName.innerHTML = unescape(this.Items[i].SiteName);
      zTeamContainer.appendChild(zName);
      zManage = CreateBasicElement('a', null, 'Manage');
      zManage.innerHTML = "MANAGE";
      zManage.href = unescape(this.Items[i].AdminURL);
      zTeamContainer.appendChild(zManage);
      zMessageCount = CreateBasicElement('div', null, 'MessageCount');
      zMessageCount.innerHTML = unescape(this.Items[i].Messages) + ' Messages';
      zTeamContainer.appendChild(zMessageCount);
      zRequestCount = CreateBasicElement('div', null, 'RequestCount');
      zRequestCount.innerHTML = unescape(this.Items[i].Requests) + ' Requests';
      zTeamContainer.appendChild(zRequestCount);
    }
  }
  this.Init(aTrigger);
}
LiveGroup.Database.ManageSites.prototype = new LiveGroup.DropDown;
LiveGroup.Comment = {
  ForceRefresh: false,
  ObjectArray:[],
  ObjectList:{},
  ToggleForm:'',
  ChatObject: function (aCommentsAlias, aSaveURL, aGetURL, aDisplayCount, aCommentsContainer, aTextAreaContainer, aMaxCommentsPerPage, aNewCommentsDisplay) {
    this.saveURL = aSaveURL;
    this.getURL = aGetURL;
    this.CommentsAlias = aCommentsAlias;
    this.commentCount = 0;
    this.displayCount = aDisplayCount;
    this.CommentsContainer = aCommentsContainer;
    this.CommentContainerDiv = document.getElementById('CommentBlock_' + this.CommentsAlias + '_CommentsContainer');
    this.TextAreaContainer = aTextAreaContainer;
    this.maxCommentsPerPage = aMaxCommentsPerPage;
    this.currentPage = 1;
    this.previousButton = document.getElementById('CommentBlock_' + aCommentsAlias + '_PreviousPage');
    this.nextButton = document.getElementById('CommentBlock_' + aCommentsAlias + '_NextPage');
    this.buttonsContainer = document.getElementById('CommentBlock_' + aCommentsAlias + '_ButtonsContainer');
    this.nextActive = true;
    this.previousActive = true;
    this.newCommentsDisplay = aNewCommentsDisplay;
    if (this.previousButton != null)
      appendEventHandler(this.previousButton, 'onclick', this.PreviousPage, this);
    if (this.previousButton != null)
      appendEventHandler(this.nextButton, 'onclick', this.NextPage, this);
    LiveGroup.Comment.ObjectArray.push(this);
    LiveGroup.Comment.ObjectList[aCommentsAlias] = this;
    return true;
  },
  RefreshAllLists: function () {
    for (i = 0; i < LiveGroup.Comment.ObjectArray.length; i++) {
      LiveGroup.Comment.ForceRefresh = true;
      LiveGroup.Comment.ObjectArray[i].GetComments();
    }
  }
}
LiveGroup.Comment.ChatObject.prototype.NextPage = function (e, aLogObject) {
  if (aLogObject.nextActive) {
    aLogObject.currentPage++;
    aLogObject.RefreshComments();
  }
  return true;
}
LiveGroup.Comment.ChatObject.prototype.PreviousPage = function (e, aLogObject) {
  if (aLogObject.previousActive) {
    aLogObject.currentPage--;
    aLogObject.RefreshComments();
  }
  return true;
}
LiveGroup.Comment.ChatObject.prototype.Save = function () {
  var zDate = new Date();
  var zAmPm = 'am';
  var zMinutes = zDate.getMinutes();
  if (zMinutes < 10) zMinutes = '0' + zMinutes;
  var zHours = zDate.getHours();
  if (zHours > 12) { zHours -= 12; zAmPm = 'pm'; }
  if (zHours == 0) zHours = 12;
  var zYears = zDate.getFullYear();
  var zDateString = (zDate.getMonth()+1) + '/' + zDate.getDate() + '/' + zYears + ' ' + zHours + ':' + zMinutes + ' ' + zAmPm;
  var aPostValues = '&inpNewComment=' + $('inpNewComment_' + this.CommentsAlias).value + '&aCommentsAlias=' + this.CommentsAlias + '&aCommentDate=' + zDateString + '&aCurrentCommentCount=' + this.commentCount;
  $('inpNewComment_' + this.CommentsAlias).disabled = true;
LiveRequest_MakeRequest(this.saveURL + aPostValues, this.OnLoadFunction, this);
  $('inpNewComment_' + this.CommentsAlias).value = '';
}
LiveGroup.Comment.ChatObject.prototype.GetComments = function () {
  var aPostValues = '&aCommentsAlias=' + this.CommentsAlias + '&aCurrentCommentCount=' + this.commentCount;
  LiveRequest_MakeRequest(this.getURL + aPostValues, this.OnLoadFunction, this);
}
LiveGroup.Comment.ChatObject.prototype.OnLoadFunction = function (aArray, aLogObject) {
  var zCommentStats_Object = $('CommentBlock_' + aLogObject.CommentsAlias + '_Stats');
  if (aArray==null) {
    return;
  }
  var zCommentCount = 0;
  for (var j = 0 ; j < aArray.length; j++) {
    if (aArray[j]['CommentDisabled'] != "Y")
      zCommentCount++;
  }
  if (zCommentStats_Object&&aArray.length>-1) {
    if (aLogObject.newCommentsDisplay) {
      zCommentStats_Object.innerHTML = '('+ zCommentCount + ')';
    } else {
      zCommentStats_Object.innerHTML = '('+ zCommentCount +' Comments)';
    }
  }
  if ($('inpNewComment_' + aLogObject.CommentsAlias)) {
    $('inpNewComment_' + aLogObject.CommentsAlias).disabled = false;
  }
  var zComments = '';
  var zFirstCommentIndex = 0;
  if (aLogObject.displayCount >= 0) {
    zFirstCommentIndex = aArray.length - aLogObject.displayCount;
  }
  if (zFirstCommentIndex < 0) {
    zFirstCommentIndex = 0;
  }
  if (aArray.length && aArray.length > aLogObject.commentCount || LiveGroup.Comment.ForceRefresh) {
    LiveGroup.Comment.ForceRefresh = false;
    var zEditCommentsArray = [];
    var zRemoveCommentsArray = [];
    for (var i = zFirstCommentIndex; i < aArray.length; i++) {
      if (aArray[i]['CommentDisabled'] != "Y") {
        var zEvenOdd = i % 2;
        var zAvatarTag = '';
        var zLinkOpenTag = '';
        var zLinkCloseTag = '';
        if (aArray[i]['CommentorAvatar'] != "") {
          zAvatarTag = '<img class="LiveGroup_Comment_MiniAvatar" src="' + unescape(aArray[i]['CommentorAvatar']) + '"alt="Commenter Avatar" width=32 height=32 />';
        }
        if (aArray[i]['Commentor'] != 'Anonymous') {
          zLinkOpenTag = '<a href="' + unescape(aArray[i]['CommentorPage']) + '">';
          zLinkCloseTag = '</a>';
        }
        var zEditLink = '';
        if (aArray[i]['IsUser']) {
          var zEditLinkId = 'Edit_' +aLogObject.CommentsAlias+ '_'+ i ;
          zEditCommentsArray.push({
            Title: 'Edit Comments',
            ContentAction: LiveGroup.Comment.ObjectList[aLogObject.CommentsAlias].ItemBaseURL + '.PostComment?aObjectTypeAlias=LiveGroup_Comment&ActionBar=Y&aCommentId='+aArray[i]['CommentId']+'&aCommentsAlias='+aLogObject.CommentsAlias,
            OnClickURL: LiveGroup.Comment.ObjectList[aLogObject.CommentsAlias].ItemBaseURL + '.SaveComment?aObjectTypeAlias=LiveGroup_Comment&ActionBar=Y'+'&aCommentsAlias='+aLogObject.CommentsAlias,
            Type: 'action',
            ActionName: 'Post',
            AddFields: ['inp_NewComment','inp_CommentId'],
            TriggerId: zEditLinkId,
            RequireLogin: true
          });
          zEditLink = '<span class="Link EditLink" id="' +zEditLinkId+ '">Edit</span>';
        }
        var zRemoveLink = '';
        if (aArray[i]['IsDatabaseOwner']) {
          var zRemoveLinkId = 'Remove_' +aLogObject.CommentsAlias+ '_'+ i ;
          zRemoveCommentsArray.push({
            Title: 'Edit Comments',
            ContentAction: LiveGroup.Comment.ObjectList[aLogObject.CommentsAlias].ItemBaseURL + '.DisableComment?aObjectTypeAlias=LiveGroup_Comment&ActionBar=Y&aCommentId='+aArray[i]['CommentId']+'&aCommentsAlias='+aLogObject.CommentsAlias,
            OnClickURL: LiveGroup.Comment.ObjectList[aLogObject.CommentsAlias].ItemBaseURL + '.DisableCommentComplete?aObjectTypeAlias=LiveGroup_Comment&ActionBar=Y'+'&aCommentsAlias='+aLogObject.CommentsAlias,
            Type: 'action',
            ActionName: 'Remove',
            AddFields: ['inp_CommentID'],
            TriggerId: zRemoveLinkId,
            RequireLogin: true
          });
          var zPipeDelimiter = '';
          if (aArray[i]['IsUser']) {
            zPipeDelimiter = '<span>|</span>';
          }
          zRemoveLink = '<span class="Link RemoveLink" id="' +zRemoveLinkId+ '">Remove</span>' + zPipeDelimiter;
        }
        zComments += '<div style="display:none;" class="LogComment LogComment_' + zEvenOdd + '">' + zLinkOpenTag + zAvatarTag + '<span class="CommentorSpan">' + unescape(aArray[i]['Commentor']) + '</span>:' + zLinkCloseTag
                  +  ' <span class="LogCommentDate">' + unescape(aArray[i]['CommentDate']) + ':</span><span class="CommentControls">'
                  +  zRemoveLink
                  +  zEditLink
                  +  '</span><span class="CommentText">' + unescape(aArray[i]['Comment']) + '</span></div>';
      }
    }
    $('CommentBlock_' + aLogObject.CommentsAlias + '_CommentsContainer').innerHTML = zComments;
    for (j = 0; j < zEditCommentsArray.length; j++) {
      var zCommentBlockControls = new LiveGroup.ActionBar.Control(zEditCommentsArray[j]);
    }
    for (m = 0; m < zRemoveCommentsArray.length; m++) {
      var zCommentBlockControls = new LiveGroup.ActionBar.Control(zRemoveCommentsArray[m]);
    }
    aLogObject.RefreshComments();
    aLogObject.commentCount = aArray.length;
  }
}
LiveGroup.Comment.ChatObject.prototype.RefreshComments = function () {
  if (this.CommentContainerDiv == null)
    return true;
  var pageStart = this.maxCommentsPerPage * (this.currentPage - 1);
  var pageStop = this.maxCommentsPerPage * this.currentPage - 1;
  if (this.CommentContainerDiv.childNodes.length > this.maxCommentsPerPage) {
    this.buttonsContainer.style.display = 'block';
  }
  if (this.currentPage != 1) {
    this.previousButton.style.backgroundPosition = '0 -9px';
    this.previousActive = true;
  } else {
    this.previousButton.style.backgroundPosition = '0 0';
    this.previousActive = false;
  }
  if (pageStop < this.CommentContainerDiv.childNodes.length) {
    this.nextButton.style.backgroundPosition = '0 -9px';
    this.nextActive = true;
  } else {
    this.nextButton.style.backgroundPosition = '0 0';
    this.nextActive = false;
  }
  for (var i = 0; i < this.CommentContainerDiv.childNodes.length; i++) {
    if (i >= pageStart && i <= pageStop) {
      this.CommentContainerDiv.childNodes[i].style.display = 'block';
    } else {
      this.CommentContainerDiv.childNodes[i].style.display = 'none';
    }
  }
}
LiveGroup.Calendar = {
  maxEventPerDays: 2,
  Event: function(aParentDay, aEventData) {
    this.setup = aEventData;
    this.parentDay = aParentDay;
    this.parentMonth = aParentDay.parentMonth;
    this.Remove = function(aData) {
      for (var i = 0; i < this.parentDay.parentMonth.EventsData.length; i++) {
        if (this.parentDay.parentMonth.EventsData[i] == this.setup) {
          this.parentDay.parentMonth.EventsData.splice(i, 1);
        }
      }
      return true;
    }
    this.Update = function(aName, aContent, aSmallContent, aEditUpdate) {
      var length = 15;
      if (LiveGroup.Calendar.ReadOnly) {
        length = 18;
      }
      this.link.title = aName;
      if (aEditUpdate != "Y") {
        if (aEventData.truncate && aName.length > length) {
          aName = aName.substring(0, length - 2) + '...';
        } else if (aEventData.Date != null && aEventData.EndDate != null) {
          aName = unescape(aEventData.Date) + '-' + unescape(aEventData.EndDate) + ': ' + aName;
        } else if (aEventData.Date != null) {
          aName = unescape(aEventData.Date) + ': ' + aName;
        }
      }
      this.link.innerHTML = aName;
      if (this.content != null && aSmallContent != null && aContent.length > aSmallContent.length && aSmallContent != 'undefined') {
        this.content.innerHTML = aSmallContent;
      }else if (this.content != null && aContent != null) {
        this.content.innerHTML = aContent;
      }
    }
    this.Build = function() {
      this.container = CreateBasicElement('div', null, 'Event');
        zEventTitle = CreateBasicElement('div', null, 'EventTitle');
          zEventRemove = CreateBasicElement('div', null, 'RemoveLink');
          if (!(LiveGroup.Calendar.ReadOnly)) {
            zEventRemove.innerHTML = 'x';
          }
          zEventTitle.appendChild(zEventRemove);
          this.link = CreateBasicElement('a');
          zEventTitle.appendChild(this.link);
        this.container.appendChild(zEventTitle);
        if (this.setup.Content != null) {
          this.content = CreateBasicElement('div', 'EventContent', 'EventContent');
          this.container.appendChild(this.content);
        }
        if ((aEventData.SmallContent == null || aEventData.SmallContent == 'undefined') && aEventData.MonthView != "Y") {
          this.content.style.display = 'none';
          zDetailsLink = CreateBasicElement('div', 'DetailsLink', 'DetailsLink');
          if (aEventData.Attendees == "Y")
            zDetailsLink.innerHTML = 'Details/Attendees';
          else
            zDetailsLink.innerHTML = 'Details';
          appendEventHandler(zDetailsLink, 'onclick', LiveGroup.Calendar.Day.GetEventDetails, aEventData);
          zEventTitle.appendChild(zDetailsLink);
        }
      this.Update(unescape(this.setup.Name), unescape(this.setup.Content), unescape(this.setup.SmallContent));
    }
    this.SetControls = function() {
      if (LiveGroup.Calendar.ReadOnly) {
        appendEventHandler(this.link, 'onclick', this.parentDay._ShowFullScreen, this.parentDay);
      } else {
        var zEditControl = new LiveGroup.ActionBar.Control({
          Title: 'Edit Event',
          ContentAction: '/' + unescape(this.setup.ItemPath) + '.Form',
          OnClickURL: '/' + unescape(this.setup.ItemPath) + '.EditComplete?inpEventDate_Day=' + this.parentDay.day + '&inpEventDate_Month=' + this.parentDay.month + '&inpEventDate_Year=' + this.parentDay.year + '&inpEventEndDate_Day=' + this.parentDay.day + '&inpEventEndDate_Month=' + this.parentDay.month + '&inpEventEndDate_Year=' + this.parentDay.year,
          Type: 'action',
          ActionName: 'Save Changes',
          Trigger: this.link,
          Data: this,
          AddFields: ['inp_CalendarEventName','inp_CalendarEventDescription','inp_CalendarEventPrivate','inp_CalendarEventClass','inpMinute','inpHour','inpAMPM','inp_EndMinute','inp_EndHour','inp_EndAMPM'],
          OnCancelCallback: this.parentDay.SetInactive,
          OnCancelCallbackData: this.parentDay
        });
        var zRemoveControl = new LiveGroup.ActionBar.Control({
          Title: 'Remove Event',
          ContentAction: '/' + unescape(this.setup.ItemPath) + '.Remove',
          OnClickURL: '/' + unescape(this.setup.ItemPath) + '.RemoveComplete',
          Type: 'action',
          ActionName: 'Remove',
          Data: this,
          Trigger: zEventRemove,
          OnCancelCallback: this.parentDay.SetInactive,
          OnCancelCallbackData: this.parentDay
        });
      }
    }
    this.Build();
    this.SetControls();
  },
  Day: function(dy, dayofweek, aWeek, aMonth, aYear, aParentMonth, aNoLoad) {
    this.Build = function() {
      var today = new Date();
      this.cell = CreateBasicElement('td', null, 'DayCell LG_xColorAltInactiveBack');
          this.parentWeek.appendChild(this.cell);
    	if ((this.month == today.getMonth()+1) && (dy == today.getDate())) {
        this.cell.className = 'DayCell CurrentDay';
    	}
      var zDayContainer = CreateBasicElement('div', null, 'DayContainer');
          this.cell.appendChild(zDayContainer);
      var zDayEventsContainer = CreateBasicElement('div', null, 'DayEventsContainer');
          zDayContainer.appendChild(zDayEventsContainer);
      var zDayNumber = CreateBasicElement('div', null, 'DayNumber');
          zDayNumber.innerHTML = dy;
          zDayEventsContainer.appendChild(zDayNumber);
      appendEventHandler(zDayNumber, 'onclick', this._ShowFullScreen, this);
      this.eventContainer = CreateBasicElement('div', null, 'EventsContainer');
          zDayContainer.appendChild(this.eventContainer);
      if (LiveGroup.Calendar.ReadOnly) {
        appendEventHandler(zDayEventsContainer, 'onclick', this._ShowFullScreen, this);
      } else {
        var zControlSetup = {
          Title: 'Add Event to ' + this.month + '.' + dy + '.' + this.year,
          ContentAction: LiveGroup.Calendar.currentCalendarPath + '.Form?aObjectTypeAlias=LiveGroup_CalendarEvent&aEventDate=' + this.year +'_'+ LiveGroup.Calendar.Utils.twoDigitFormat(this.month) + '_' + LiveGroup.Calendar.Utils.twoDigitFormat(dy),
          OnClickURL: LiveGroup.Calendar.currentCalendarPath + '.AddComplete?aObjectTypeAlias=LiveGroup_CalendarEvent&aMonthView=Y&aEventDate=' + this.year +'_'+ LiveGroup.Calendar.Utils.twoDigitFormat(this.month) + '_' + LiveGroup.Calendar.Utils.twoDigitFormat(dy) + '&inpEventEndDate_Day=' + LiveGroup.Calendar.Utils.twoDigitFormat(dy) + '&inpEventEndDate_Month=' + LiveGroup.Calendar.Utils.twoDigitFormat(this.month) + '&inpEventEndDate_Year=' + this.year,
          Type: 'action',
          Data: this,
          ActionName: 'Add Event',
          Trigger: zDayEventsContainer,
          AddFields: ['inp_CalendarEventName','inp_EventDate_Date','inp_CalendarEventPrivate','inp_CalendarEventClass','inp_CalendarEventDescription','inpEventDate','inpMinute','inpHour','inpAMPM','inp_EndMinute','inp_EndHour','inp_EndAMPM','inp_NumberOfWeeks'],
          OnCancelCallback: this.SetInactive,
          OnCancelCallbackData: this
        };
        var zControl = new LiveGroup.ActionBar.Control(zControlSetup);
      }
    }
  	this.SetActive = function(e, aDay) {
      aDay.cell.classNameBAK = aDay.cell.className;
      aDay.cell.className = 'DayCell ActiveCell LG_ColorAltActiveBorder';
      return true;
  	}
  	this.SetInactive = function(aDay) {
      if (aDay.cell != null && aDay.cell.classNameBAK != null) {
        aDay.cell.className = aDay.cell.classNameBAK;
        aDay.cell.classNameBAK = null;
      }
      return true;
  	}
  	this.ShowWindow = function(e, aDay) {
      zDayWindow = new LiveGroup.WM.Window('July 34th 2045');
      zDayWindow.Show();
      LiveGroup.Utils.RemoveSubItems(zDayWindow.content);
      for (var i = 0; i < aDay.events.length; i++) {
        zEvent = new LiveGroup.Calendar.Event(aDay, aDay.parentMonth.EventsData[i]);
        zDayWindow.content.appendChild(zEvent.container);
      }
      zDayWindow.AddCloseButton('Close');
      zDayWindow.Center();
  	}
  	this.ShowFullScreen = function() {
      this.parentContainer = $('CalendarContainer');
      LiveGroup.Utils.RemoveSubItems(this.parentContainer);
      this.container = CreateBasicElement('div', null, 'DayView');
        this.loading = CreateBasicElement('div', 'CalendarLoadingImage', 'LoadingImage');
        this.container.appendChild(this.loading);
      	var zTitleContainer = CreateBasicElement('div', 'TitleContainer', 'LG_ColorBorder');
   	    this.container.appendChild(zTitleContainer);
        var zTabContainer = CreateBasicElement('div', null, 'AssetTabContainer');
        zTitleContainer.appendChild(zTabContainer);
        var zTabMonth = CreateBasicElement('div', null, 'AssetTab');
        zTabMonth.innerHTML = 'MONTH';
        zTabContainer.appendChild(zTabMonth);
        appendEventHandler(zTabMonth, 'onclick', this.GotoMonth, this);
        var zTabDay = CreateBasicElement('div', null, 'AssetTab');
        zTabDay.style.height = '32px';
        zTabDay.style.backgroundPosition = '0 0';
        zTabDay.innerHTML = 'DAY';
        zTabContainer.appendChild(zTabDay);
        var zTabSummary = CreateBasicElement('div', null, 'AssetTab');
        zTabSummary.innerHTML = 'SUMMARY';
        zTabContainer.appendChild(zTabSummary);
        appendEventHandler(zTabSummary, 'onclick', this.GoToSummary, this);
        zDayViewContainer = CreateBasicElement('div', null, 'Container');
        this.container.appendChild(zDayViewContainer);
        var zTitleH1 = CreateBasicElement('h1');
        zTitleH1.innerHTML = LiveGroup.Reference.Months[this.month-1] + ' ' + LiveGroup.Calendar.Utils.Num2Rank(this.day) + ', ' + this.year;
        zDayViewContainer.appendChild(zTitleH1);
        zNav = CreateBasicElement('div', null, 'NavigationContainer');
          zPreviousDay = CreateBasicElement('div', null, 'PreviousItem LG_ColorBorder LG_ColorAltInactiveBack');
          zPreviousDay.innerHTML = 'Previous';
          appendEventHandler(zPreviousDay, 'onclick', this.Previous, this);
          zNav.appendChild(zPreviousDay);
          zNextDay = CreateBasicElement('div', null, 'NextItem LG_ColorBorder LG_ColorAltInactiveBack');
          zNextDay.innerHTML = 'Next';
          appendEventHandler(zNextDay, 'onclick', this.Next, this);
          zNav.appendChild(zNextDay);
        zDayViewContainer.appendChild(zNav);
        this.eventContainer = CreateBasicElement('div');
        zDayViewContainer.appendChild(this.eventContainer);
      this.parentContainer.appendChild(this.container);
      var EvenOdd = 'Odd';
      for (var i=0; i<24 ; i++){
        if (EvenOdd == 'Odd')
          EvenOdd = 'Even';
        else
          EvenOdd = 'Odd';
        hourContainer = CreateBasicElement('div', 'hour_'+i, 'Hours ' + EvenOdd);
        if (i == 0)
          hourContainer.innerHTML = '12:00AM';
        else if (i < 12)
          hourContainer.innerHTML = i + ':00AM';
        else if (i == 12)
          hourContainer.innerHTML = '12:00PM';
        else
          hourContainer.innerHTML = i - 12 + ':00PM';
        this.eventContainer.appendChild(hourContainer);
        hourTextContainer = CreateBasicElement('div', 'hourText_'+i, 'HoursText ' + EvenOdd);
        this.eventContainer.appendChild(hourTextContainer);
      }
      this.GetEvents();
   	}
  	this._ShowFullScreen = function(e, aParent) {
      aParent.ShowFullScreen();
    }
    this.GotoMonth = function(e, aDay) {
      zContainer = aDay.container.parentNode.parentNode;
      zContainer.removeChild(aDay.container.parentNode);
      zNewMonth = new LiveGroup.Calendar.Month(zContainer, aDay.year, aDay.month);
    }
    this.GoToSummary = function(e, aDay){
      zContainer = aDay.container.parentNode.parentNode;
      zContainer.removeChild(aDay.container.parentNode);
      zNewSummary = new LiveGroup.Calendar.Summary(zContainer, 0);
    }
    this.Switch = function(aOffset) {
      if (aOffset == -1) {
        if (this.day == 1) {
          aNewDay = LiveGroup.Calendar.Utils.NumDaysIn(this.month - 1, this.year);
          aNewMonth = this.month - 1;
          if (aNewMonth == 0) {
            aNewMonth = 12;
            aNewYear = this.year - 1;
          } else {
            aNewYear = this.year;
          }
        } else {
          aNewDay = this.day - 1;
          aNewMonth = this.month;
          aNewYear = this.year;
        }
      } else {
        if (this.day == LiveGroup.Calendar.Utils.NumDaysIn(this.month, this.year)) {
          aNewDay = 1;
          aNewMonth = this.month + 1;
          if (aNewMonth == 13) {
            aNewMonth = 1;
            aNewYear = this.year + 1;
          } else {
            aNewYear = this.year;
          }
        } else {
          aNewDay = this.day + 1;
          aNewMonth = this.month;
          aNewYear = this.year;
        }
      }
      this.container.parentNode.removeChild(this.container);
      zNewFullDay = new LiveGroup.Calendar.Day(aNewDay, 0, 0, aNewMonth, aNewYear);
    }
    this.Next = function(e, aDay) {
      aDay.Switch(+1);
    }
    this.Previous = function(e, aDay) {
      aDay.Switch(-1);
    }
  	this.GetEvents = function() {
      LiveRequest_MakeRequest(LiveGroup.Calendar.currentCalendarPath + '.EventsJS?aObjectTypeAlias=LiveGroup_Calendar&aIncludeContent=Y&aDayViewAdd=Y&aYear=' + this.year + '&aMonth=' + this.month + '&aDay=' + this.day, this.LoadEvents, this);
  	}
  	LiveGroup.Calendar.Day.GetEventDetails = function(e, aData) {
      zDayViewContainer.parentNode.firstChild.style.display = 'block';
      LiveRequest_MakeRequest(LiveGroup.Calendar.currentCalendarPath + '.GetCommentsJS?aObjectTypeAlias=LiveGroup_Calendar&aEventItemPath=' + aData.ItemPath, LiveGroup.Calendar.Day.ShowEventDetails, aData);
  	}
  	LiveGroup.Calendar.Day.ShowEventDetails = function(aData, aEventData) {
      zChild = (aEventData.Hour * 2) + 1;
      zContainerChild = this.zDayViewContainer.childNodes[2].childNodes[zChild];
      zContainerChild.style.height = 'auto';
      if (zContainerChild.firstChild.childNodes[1].innerHTML == unescape(aEventData.Content)) {
        zContainerChild.firstChild.childNodes[1].style.display = 'block';
        zDetailsLink = zContainerChild.firstChild.childNodes[0].lastChild;
        zLinkInnerHTML = zDetailsLink.innerHTML;
        zContainerChild.firstChild.childNodes[0].removeChild(zDetailsLink);
        var zNode = 0;
      } else {
        for (var i=0; i<zContainerChild.childNodes.length; i++){
          if (zContainerChild.childNodes[i].childNodes[1].innerHTML == unescape(aEventData.Content)) {
            var zNode = i;
            zContainerChild.childNodes[i].childNodes[1].style.display = 'block';
            zDetailsLink = zContainerChild.childNodes[i].childNodes[0].lastChild;
            zLinkInnerHTML = zDetailsLink.innerHTML;
            zContainerChild.childNodes[i].childNodes[0].removeChild(zDetailsLink);
            break;
          }
        }
      }
      if (aData.Attendants.length > 0){
        zContainerChild.childNodes[zNode].childNodes[1].style.height = (70 + (aData.Attendants.length * 10)) + 'px';
        LiveGroup.Utils.RemoveSubItems(zContainerChild.childNodes[zNode].childNodes[1]);
        zContainerChild.childNodes[zNode].childNodes[1].innerHTML = unescape(aEventData.Content);
        zAttendeeInfoContainer = CreateBasicElement('div', null, 'AttendeeInfoContainer');
        zContainerChild.childNodes[zNode].childNodes[1].appendChild(zAttendeeInfoContainer);
        zAttendeeTitle = CreateBasicElement('div', null, 'AttendeeTitle');
        zAttendeeTitle.innerHTML = '<h3>Attendants:</h3>';
        zAttendeeInfoContainer.appendChild(zAttendeeTitle);
        zAttendeeInfo = CreateBasicElement('div', null, 'AttendeeInfoTitle');
        zAttendeeInfoContainer.appendChild(zAttendeeInfo);
        zPlayerName = CreateBasicElement('div', null, 'AttendeeName');
        zPlayerName.innerHTML = 'Players';
        zAttendeeInfo.appendChild(zPlayerName);
        zPlayerClass = CreateBasicElement('div', null, 'PlayerClass');
        zPlayerClass.innerHTML = 'Class';
        zAttendeeInfo.appendChild(zPlayerClass);
        zAttending = CreateBasicElement('div', null, 'Attending');
        zAttending.innerHTML = 'Attending';
        zAttendeeInfo.appendChild(zAttending);
        zPlayerComment = CreateBasicElement('div', null, 'PlayerComment');
        zPlayerComment.innerHTML = 'Comment';
        zAttendeeInfo.appendChild(zPlayerComment);
        for (var i=0; i < aData.Attendants.length; i++) {
          zPlayerEventData = CreateBasicElement('div', null, 'PlayerEventData');
          zPlayerEventData.style.top = (i * 15) + 15 + 'px';
          zAttendeeInfoContainer.appendChild(zPlayerEventData);
          zPlayersName = CreateBasicElement('div', null, 'PlayersName');
          zPlayersName.innerHTML = '<a href=' + unescape(aData.Attendants[i].PlayerURL) +'>'+ aData.Attendants[i].Name + '</a>';
          zPlayerEventData.appendChild(zPlayersName);
          zPlayersClass = CreateBasicElement('div', null, 'PlayersClass');
          zPlayersClass.innerHTML = aData.Attendants[i].Class;
          zPlayerEventData.appendChild(zPlayersClass);
          zIsAttending = CreateBasicElement('div', null, 'IsAttending ' + aData.Attendants[i].Attending);
          zIsAttending.innerHTML = aData.Attendants[i].Attending;
          zPlayerEventData.appendChild(zIsAttending);
          zPlayersComment = CreateBasicElement('div', null, 'PlayersComment');
          zPlayersComment.innerHTML = aData.Attendants[i].Comment;
          zPlayerEventData.appendChild(zPlayersComment);
        }
      }
      this.zDayViewContainer.parentNode.firstChild.style.display = 'none';
      if (LiveGroup.Calendar.TeamSite == true) {
        var zCalendarContainer = document.getElementById('CalendarObjectContainer');
        var zBaseHeight = 240;
      } else {
        var zCalendarContainer = document.getElementById('CalendarContainer');
        var zBaseHeight = 115;
      }
      var zAllContent = document.getElementById('AllContent');
      zAllContent.style.height = zCalendarContainer.offsetHeight + zBaseHeight + 'px';
    }
  	this.LoadEvents = function(aData, aDay) {
      if (aData == null) {
        return true;
      }
      for (var i = 0; i < aData.length; i++) {
        zNewEvent = new LiveGroup.Calendar.Event(aDay, aData[i]);
        var zHour = aData[i].Date.substring(0,2);
        zHour = parseInt(zHour);
        var zAMPM = aData[i].Date.charAt(aData[i].Date.length - 2);
        if (zHour == 0)
          zHour = parseInt(aData[i].Date.charAt(1));
        if (zHour == 12 && zAMPM == 'A')
          zHour = 0;
        else if (zAMPM == 'P' && zHour != 12)
          zHour = zHour + 12;
        else if (zHour < 10)
          zHour = parseInt(aData[i].Date.charAt(1));
        var zEndHour = aData[i].EndDate.substring(0,2);
        zEndHour = parseInt(zEndHour);
        var zEndAMPM = aData[i].EndDate.charAt(aData[i].EndDate.length - 2);
        if (zEndHour == 0)
          zEndHour = parseInt(aData[i].EndDate.charAt(1));
        if (zEndHour == 12 && zEndAMPM == 'A')
          zEndHour = 0;
        else if (zEndAMPM == 'P' && zEndHour != 12)
          zEndHour = zEndHour + 12;
        else if (zEndHour < 10)
          zEndHour = parseInt(aData[i].EndDate.charAt(1));
        aData[i].Hour = zHour;
        var zhourTextID = 'hourText_'+zHour;
        var zDataID = document.getElementById(zhourTextID);
        if (zDataID.innerHTML != ''){
          if (zDataID.style.height != '') {
            zDataID.style.height = parseInt(zDataID.style.height) + 25 + 'px';
          } else {
            zDataID.style.height = '50px';
          }
        }
        zDataID.appendChild(zNewEvent.container);
      }
      aDay.loading.style.display = 'none';
      if (!(LiveGroup.Calendar.ReadOnly)) {
        if (aDay.notfound != null) {
          aDay.notfound.parentNode.removeChild(aDay.notfound);
        }
        aDay.notfound = CreateBasicElement('div', null, 'NotFound');
        aDay.notfound.innerHTML = 'Click here to create a new event for this day';
        aDay.eventContainer.appendChild(aDay.notfound);
        var zControlSetup = {
          Title: 'Add Event to ' + aDay.month + '.' + aDay.day + '.' + aDay.year,
          ContentAction: LiveGroup.Calendar.currentCalendarPath + '.Form?aObjectTypeAlias=LiveGroup_CalendarEvent&aEventDate=' + aDay.year +'_'+ LiveGroup.Calendar.Utils.twoDigitFormat(aDay.month) + '_' + LiveGroup.Calendar.Utils.twoDigitFormat(aDay.day),
          OnClickURL: LiveGroup.Calendar.currentCalendarPath + '.AddComplete?aObjectTypeAlias=LiveGroup_CalendarEvent&aDayViewAdd=Y&aEventDate=' + aDay.year +'_'+ LiveGroup.Calendar.Utils.twoDigitFormat(aDay.month) + '_' + LiveGroup.Calendar.Utils.twoDigitFormat(aDay.day) + '&inpEventEndDate_Day=' + LiveGroup.Calendar.Utils.twoDigitFormat(aDay.day) + '&inpEventEndDate_Month=' + LiveGroup.Calendar.Utils.twoDigitFormat(aDay.month) + '&inpEventEndDate_Year=' + aDay.year,
          Type: 'action',
          Data: aDay,
          ActionName: 'Add Event',
          Trigger: aDay.notfound,
          AddFields: ['inp_CalendarEventName','inp_CalendarEventPrivate','inp_EventDate_Date','inp_CalendarEventDescription','inpEventDate','inpMinute','inpHour','inpAMPM','inp_EndHour','inp_EndMinute','inp_EndAMPM','inp_NumberOfWeeks']
        };
        var zControl = new LiveGroup.ActionBar.Control(zControlSetup);
      }
      if (LiveGroup.Calendar.TeamSite == true) {
        var zCalendarContainer = document.getElementById('CalendarObjectContainer');
        var zBaseHeight = 240;
      } else {
        var zCalendarContainer = document.getElementById('CalendarContainer');
        var zBaseHeight = 115;
      }
      var zAllContent = document.getElementById('AllContent');
      zAllContent.style.height = zCalendarContainer.offsetHeight + zBaseHeight + 'px';
  	}
    this.parentMonth = aParentMonth;
    this.parentWeek = aWeek;
    this.day = dy;
    this.month = aMonth;
    this.year = aYear;
    this.eventCount = 0;
    this.events = new Array();
    this.seeMore = null;
  	if (this.parentMonth == null && aNoLoad != true) {
      this.ShowFullScreen();
    } else if (aNoLoad != true) {
      this.Build();
      appendEventHandler(this.cell, 'onclick', this.SetActive, this);
    }
  },
  Month: function(containerId, year, month) {
    this.Build = function() {
      var day = 1;
      this.container = $('CalendarContainer');
      if (this.container != null) {
        LiveGroup.Utils.RemoveSubItems(this.container);
      } else {
      	this.container = CreateBasicElement('div','CalendarContainer');
            this.parentContainer.appendChild(this.container);
      }
      this.loading = CreateBasicElement('div', 'CalendarLoadingImage', 'LoadingImage');
      this.parentContainer.appendChild(this.loading);
    	var zTitleContainer = CreateBasicElement('div', 'TitleContainer', 'LG_ColorBorder');
 	    this.container.appendChild(zTitleContainer);
      var zTabContainer = CreateBasicElement('div', null, 'AssetTabContainer');
      zTitleContainer.appendChild(zTabContainer);
      var zTabMonth = CreateBasicElement('div', null, 'AssetTab');
      zTabMonth.style.height = '32px';
      zTabMonth.style.backgroundPosition = '0 0';
      zTabMonth.innerHTML = 'MONTH';
      zTabContainer.appendChild(zTabMonth);
      var zTabDay = CreateBasicElement('div', null, 'AssetTab');
      zTabDay.innerHTML = 'DAY';
      appendEventHandler(zTabDay, 'onclick', this.ShowOneDay, null);
      zTabContainer.appendChild(zTabDay);
      var zTabSummary = CreateBasicElement('div', null, 'AssetTab');
      zTabSummary.innerHTML = 'SUMMARY';
      zTabContainer.appendChild(zTabSummary);
      appendEventHandler(zTabSummary, 'onclick', this.GoToSummary, this);
      var zTitleH1 = CreateBasicElement('h1');
      zTitleH1.innerHTML = LiveGroup.Reference.Months[this.month-1] + " " + this.year;
      this.container.appendChild(zTitleH1);
      var zNavigationContainer = CreateBasicElement('div', null, 'NavigationContainer');
      this.container.appendChild(zNavigationContainer);
      var zPreviousLink = CreateBasicElement('a', null, 'PreviousItem LG_ColorBorder LG_ColorAltInactiveBack LG_ColorAltActiveFront');
          zPreviousLink.innerHTML = LiveGroup.Reference.Months[(this.month == 1 ? 11 : this.month - 2)];
          zNavigationContainer.appendChild(zPreviousLink);
          appendEventHandler(zPreviousLink, 'onclick', this.Previous, this);
      var zNextLink = CreateBasicElement('a', null, 'NextItem LG_ColorBorder LG_ColorAltInactiveBack LG_ColorAltActiveFront');
          zNextLink.innerHTML = LiveGroup.Reference.Months[(this.month == 12 ? 0 : this.month)];
          zNavigationContainer.appendChild(zNextLink);
          appendEventHandler(zNextLink, 'onclick', this.Next, this);
    	var zTableElement = CreateBasicElement('table','CalendarTable');
          this.container.appendChild(zTableElement);
      var zTBodyElement = CreateBasicElement('tbody');
          zTableElement.appendChild(zTBodyElement);
      var zWeekHeadersTR = CreateBasicElement('tr', 'WeekHeadersTR');
          zTBodyElement.appendChild(zWeekHeadersTR);
    	for (var i=1; i<=7; i++) {
        var zWeekHeader = CreateBasicElement('th', 'WeekHeader' + LiveGroup.Reference.DaysShort[i-1], 'CalendarHeader LG_ColorAlt2ActiveBack LG_ColorAlt2ActiveFront');
        zWeekHeader.align = 'center';
        zWeekHeader.innerHTML = LiveGroup.Reference.DaysShort[i-1];
        zWeekHeadersTR.appendChild(zWeekHeader);
    	}
      var zWeekRowOne = CreateBasicElement('tr','WeekRowOne');
          zTBodyElement.appendChild(zWeekRowOne);
    	for (var i=1; i<=7; i++) {
    		if (i <= this.first.getDay()){
          var zDay = CreateBasicElement('td');
              zDay.innerHTML = ' ';
              zWeekRowOne.appendChild(zDay);
    		}
    		else {
    			this.days[day] = new LiveGroup.Calendar.Day(day++, i, zWeekRowOne, this.month, this.year, this);
    		}
    	}
      var zWeekRowTwo = CreateBasicElement('tr', 'zWeekRowTwo');
          zTBodyElement.appendChild(zWeekRowTwo);
    	while (day <= this.last) {
        var zWeek = CreateBasicElement('tr');
            zTBodyElement.appendChild(zWeek);
    		for (var i=1; i<=7; i++) {
    			if (day > this.last) {
            var zDay = CreateBasicElement('td');
            zWeek.appendChild(zDay);
    			}
    			else {
            this.days[day] = new LiveGroup.Calendar.Day(day++, i, zWeek, this.month, this.year, this);
    			}
    		}
    	}
      if (LiveGroup.Calendar.TeamSite == true) {
        var zCalendarContainer = document.getElementById('CalendarObjectContainer');
        var zBaseHeight = 240;
      } else {
        var zCalendarContainer = document.getElementById('CalendarContainer');
        var zBaseHeight = 115;
      }
      var zAllContent = document.getElementById('AllContent');
      zAllContent.style.height = zCalendarContainer.offsetHeight + zBaseHeight + 'px';
    	return true;
  	}
  	this.Switch = function(aOffset) {
      if (aOffset > 0) {
        newYear = this.month == 12 ? this.year + 1 : this.year;
        newMonth = this.month == 12 ? 1 : this.month + 1;
      } else if (aOffset < 0) {
        newYear = this.month == 1 ? this.year - 1 : this.year;
        newMonth = this.month == 1 ? 12 : this.month - 1;
      } else {
        return;
      }
      this.parentContainer.removeChild(this.container);
      zNewMonth = new LiveGroup.Calendar.Month(this.parentContainer, newYear, newMonth);
  	}
  	this.Previous = function(e, currentMonth) {
      currentMonth.Switch(-1);
  	}
  	this.Next = function(e, currentMonth) {
      currentMonth.Switch(+1);
  	}
  	this.GetEvents = function(aYear, aMonth) {
      var zEventURL = LiveGroup.Calendar.currentCalendarPath + '.EventsJS?aObjectTypeAlias=LiveGroup_Calendar&aIncludeContent=Y&aMonthView=Y&aYear=' + aYear + '&aMonth=' + aMonth;
      LiveRequest_MakeRequest(zEventURL, this.LoadEvents, this);
      return true;
  	}
  	this.LoadEvents = function(aData, parentMonth) {
      parentMonth.EventsData = aData;
      for (var i = 0; i < parentMonth.EventsData.length; i++) {
        if ((LiveGroup.Calendar.ReadOnly) && parentMonth.EventsData[i].Private == "Y")
          continue;
        parentMonth.EventsData[i].Day = parseInt(parentMonth.EventsData[i].Day, 10);
        zDay = parentMonth.days[parentMonth.EventsData[i].Day];
        parentMonth.EventsData[i].truncate = true;
        zNewEvent = new LiveGroup.Calendar.Event(zDay, parentMonth.EventsData[i]);
        zDay.eventContainer.appendChild(zNewEvent.container);
        zDay.events.push(zNewEvent);
        if (zDay.events.length > LiveGroup.Calendar.maxEventPerDays) {
          zNewEvent.container.style.display = 'none';
          if (zDay.seeMore == null) {
            zDay.seeMore = CreateBasicElement('div', null, 'SeeMoreLink');
            zDay.eventContainer.appendChild(zDay.seeMore);
            appendEventHandler(zDay.seeMore, 'onclick', parentMonth.ShowOneDay, zDay);
          }
          zDay.seeMore.innerHTML = 'See all ' + zDay.events.length + ' events...';
        }
      }
      parentMonth.loading.style.display = 'none';
      return true;
  	}
  	this.ShowOneDay = function(e, zDay) {
      var today = new Date();
      if (zDay == null) {
        zDay = new LiveGroup.Calendar.Day(null, null, null, null, null, null, true);
        zDay.day = today.getDate();
        zDay.month = today.getMonth() + 1;
        zDay.year = today.getFullYear();
      }
      zDay.ShowFullScreen();
      return true;
  	}
    this.GoToSummary = function(e, aMonth){
      zContainer = aMonth.container.parentNode;
      zContainer.removeChild(aMonth.container);
      zNewSummary = new LiveGroup.Calendar.Summary(zContainer, 0);
    }
    var today = new Date();
    this.parentContainer = $(containerId);
    LiveGroup.Utils.RemoveSubItems(this.parentContainer);
  	this.month = month ? month : today.getMonth()+1;
  	this.year = year ? year : today.getFullYear();
  	this.first = new Date(LiveGroup.Reference.Months[this.month - 1] + ' 1,' + this.year);
  	this.last = LiveGroup.Calendar.Utils.NumDaysIn(this.month, this.year);
  	this.days = new Array();
    this.Build();
    this.GetEvents(this.year, this.month);
  },
  Summary: function(containerId, currentPage){
    this.build = function(){
      this.container = CreateBasicElement('div','CalendarContainer');
      this.parentContainer.appendChild(this.container);
      this.loading = CreateBasicElement('div', 'CalendarLoadingImage', 'LoadingImage');
      this.parentContainer.appendChild(this.loading);
      this.loading.style.display = 'block';
      this.loading.style.display = 'block';
      this.loading.style.display = 'block';
      this.loading.style.display = 'block';
    	var zTitleContainer = CreateBasicElement('div', 'TitleContainer', 'LG_ColorBorder');
 	    this.container.appendChild(zTitleContainer);
      var zTabContainer = CreateBasicElement('div', null, 'AssetTabContainer');
      zTitleContainer.appendChild(zTabContainer);
      var zTabMonth = CreateBasicElement('div', null, 'AssetTab');
      zTabMonth.innerHTML = 'MONTH';
      appendEventHandler(zTabMonth, 'onclick', this.GoToMonth, this);
      zTabContainer.appendChild(zTabMonth);
      var zTabDay = CreateBasicElement('div', null, 'AssetTab');
      zTabDay.innerHTML = 'DAY';
      appendEventHandler(zTabDay, 'onclick', this.ShowOneDay, null);
      zTabContainer.appendChild(zTabDay);
      var zTabSummary = CreateBasicElement('div', null, 'AssetTab');
      zTabSummary.innerHTML = 'SUMMARY';
      zTabSummary.style.height = '32px';
      zTabSummary.style.backgroundPosition = '0 0';
      zTabContainer.appendChild(zTabSummary);
      this.SummaryViewContainer = CreateBasicElement('div', null, 'Calendar CalendarSummaryContainer Container');
      this.container.appendChild(this.SummaryViewContainer);
      var zTitleH1 = CreateBasicElement('h1');
      zTitleH1.innerHTML = 'Upcoming Events';
      this.SummaryViewContainer.appendChild(zTitleH1);
      zNavContainer = CreateBasicElement('div', null, 'NavigationContainer');
        this.PreviousDay = CreateBasicElement('div', null, 'PreviousItem LG_ColorBorder LG_ColorAltInactiveBack');
        this.PreviousDay.innerHTML = 'Previous';
        this.PreviousDay.style.display = "none";
        appendEventHandler(this.PreviousDay, 'onclick', this._Previous, this);
        zNavContainer.appendChild(this.PreviousDay);
        this.NextDay = CreateBasicElement('div', null, 'NextItem LG_ColorBorder LG_ColorAltInactiveBack');
        this.NextDay.innerHTML = 'Next';
        this.NextDay.style.display = "none";
        appendEventHandler(this.NextDay, 'onclick', this._Next, this);
        zNavContainer.appendChild(this.NextDay);
      this.SummaryViewContainer.appendChild(zNavContainer);
      this.SummaryView = new LiveGroup.SiteModules.EventViewer.EventList('/voig/ContentList/LiveFindDatabaseList/H/HA/HAI/HairymopDatabase', this.DisplayCount, this.StartRow, true);
      this.SummaryViewContainer.appendChild(this.SummaryView.Container);
      this._UpdateButtons();
    }
    this._UpdateButtons = function(){
      stopLoading = function(){
        zNewSummary.UpdateButtons();
      }
      window.setTimeout(stopLoading, 1000);
    }
    this.UpdateButtons = function(){
      if (this.CurrentPage != 0){
        this.PreviousDay.style.display = "block";
      } else {
        this.PreviousDay.style.display = "none";
      }
      if (((this.StartRow + this.DisplayCount) > LiveGroup.Calendar.EventCount)){
        this.NextDay.style.display = "none";
      } else {
        this.NextDay.style.display = "block";
      }
      this.loading.style.display = 'none';
    }
    this._Next = function(e, aParent){
      aParent.Next();
    }
    this.Next = function(){
      this.loading.style.display = 'block';
      this.CurrentPage++;
      var zStartRow = (this.CurrentPage * this.DisplayCount) + 1;
      this.StartRow = zStartRow;
      this.SummaryViewContainer.removeChild(this.SummaryView.Container);
      this.SummaryView = new LiveGroup.SiteModules.EventViewer.EventList('/voig/ContentList/LiveFindDatabaseList/H/HA/HAI/HairymopDatabase', this.DisplayCount, this.StartRow, true);
      this.SummaryViewContainer.appendChild(this.SummaryView.Container);
      this._UpdateButtons();
    }
    this._Previous = function(e, aParent){
      aParent.Previous();
    }
    this.Previous = function(){
      this.loading.style.display = 'block';
      this.CurrentPage--;
      var zStartRow = (this.CurrentPage * this.DisplayCount) + 1;
      this.StartRow = zStartRow;
      this.SummaryViewContainer.removeChild(this.SummaryView.Container);
      this.SummaryView = new LiveGroup.SiteModules.EventViewer.EventList('/voig/ContentList/LiveFindDatabaseList/H/HA/HAI/HairymopDatabase', this.DisplayCount, this.StartRow, true);
      this.SummaryViewContainer.appendChild(this.SummaryView.Container);
      this._UpdateButtons();
    }
  	this.ShowOneDay = function(e, zDay) {
      var today = new Date();
      if (zDay == null) {
        zDay = new LiveGroup.Calendar.Day(null, null, null, null, null, null, true);
        zDay.day = today.getDate();
        zDay.month = today.getMonth() + 1;
        zDay.year = today.getFullYear();
      }
      zDay.ShowFullScreen();
      return true;
  	}
    this.GoToMonth = function(e, aSummary) {
      zContainer = aSummary.container.parentNode;
      zContainer.removeChild(aSummary.container);
      var today = new Date();
      var month = today.getMonth() + 1;
      var year = today.getFullYear();
      zNewMonth = new LiveGroup.Calendar.Month(zContainer, year, month);
    }
    if (LiveGroup.Calendar.TeamSite == true) {
      var zHeight = 305 + 975;
    } else {
      var zHeight = 150 + 995;
    }
    var zAllContent = document.getElementById('AllContent');
    zAllContent.style.height = zHeight + 'px';
    this.parentContainer = $(containerId);
    this.CurrentPage = currentPage;
    var zStartRow = (currentPage * 9) + 1;
    this.StartRow = zStartRow;
    if (LiveGroup.Calendar.TeamSite){
      this.DisplayCount = 12;
    } else {
      this.DisplayCount = 9;
    }
    this.build();
  },
  Utils: {
    isLeapYear: function(aYear) {
    	if (((aYear % 4 == 0) && aYear % 100 != 0) || aYear % 400 == 0) return true;
    	else return false;
    },
    NumDaysIn: function(aMonth, aYear) {
    	if (aMonth == 4 || aMonth == 6 || aMonth == 9 || aMonth == 11) return 30;
    	else if ((aMonth == 2) && LiveGroup.Calendar.Utils.isLeapYear(aYear)) return 29;
    	else if (aMonth == 2) return 28;
    	else return 31;
    },
    twoDigitFormat: function(aInteger) {
      return aInteger<10?'0'+aInteger:''+aInteger;
    },
    RemoveEvent: function(aData, aControl) {
      zDay = aControl.setup.Data.parentDay;
      if (zDay.parentMonth == null) {
        zDay.ShowFullScreen();
      } else {
        aControl.setup.Data.Remove();
        zDay.parentMonth.Build();
        zDay.parentMonth.LoadEvents(zDay.parentMonth.EventsData, zDay.parentMonth);
      }
      return true;
    },
    UpdateEvent: function(aData, aControl) {
      zEvent = aControl.setup.Data;
      if (zEvent.setup.SmallContent != '' && zEvent.setup.SmallContent != null){
        zEvent.Update(unescape(aData.EventName + ' ' + aData.Name), unescape(aData.Content), null, "Y");
      } else {
        zEvent.parentDay.ShowFullScreen();
      }
      return true;
    },
    DrawEvent: function(aData, aControl) {
      zDay = aControl.setup.Data;
      if (zDay.cell != null) {
        zDay.cell.className = 'DayCell';
      }
      if (zDay.parentMonth == null) {
        zDay.ShowFullScreen();
      } else {
        zDay.parentMonth.EventsData.push(aData);
        zDay.parentMonth.Build();
        zDay.parentMonth.LoadEvents(zDay.parentMonth.EventsData, zDay.parentMonth);
      }
      return true;
    },
    MultipleEvents: function(aData, aControl) {
      if (aData.CallbackData != null) {
        if (aData.CallbackData.NumWeeks == 1) {
          for (var i=1; i < zCalendar.parentContainer.childNodes.length; i++ ) {
            zCalendar.parentContainer.childNodes[i].style.display = 'none';
          }
        }
        if (aData.CallbackData.DayViewAdd != "Y" && aData.CallbackData.Month == zNewDay.setup.Data.month) {
          aData.CallbackData.MonthView = "Y";
          zNewDay.setup.Data.day = parseInt(aData.CallbackData.Day);
          LiveGroup.Calendar.Utils.DrawEvent(aData.CallbackData, zNewDay);
        }
      }
      if (aData.NumWeeks>1) {
        zNewEvent.parentDay.weeks = parseInt(aData.NumWeeks);
        aNumWeeks = (aData.NumWeeks - 1);
        aTotalWeeks = (aData.TotalWeeks + 1);
        zNewEvent.parentDay.day = parseInt(aData.Day);
        zNewEvent.parentDay.month = parseInt(aData.Month);
        zNewEvent.parentDay.year = parseInt(aData.Year);
        zNewDay = aControl;
        if (aData.DayViewAdd != "Y") {
          zCalendar.parentContainer.lastChild.style.display = 'block';
          LiveGroup.Calendar.Utils.DrawEvent(aData, zNewDay);
        } else {
          zNewDay.setup.Data.ShowFullScreen();
        }
        LiveRequest_MakeRequest(LiveGroup.Calendar.currentCalendarPath + '.AddComplete?aObjectTypeAlias=LiveGroup_CalendarEvent&inpEventDate=' + aData.Year +'_'+ aData.Month + '_' + LiveGroup.Calendar.Utils.twoDigitFormat(aData.Day) + '&aDate=' + aData.Date + '&aEndDate=' + aData.EndDate + '&inp_NumberOfWeeks=' + aNumWeeks + '&inp_CalendarEventDescription=' + aData.Content + '&inp_CalendarEventName=' + aData.Name + '&aTotalWeeks=' + aTotalWeeks + '&InpHour=' + aData.InpHour + '&InpMinute=' + aData.InpMinute + '&inp_EndHour=' + aData.InpEndHour + '&inp_EndMinute=' + aData.InpEndMinute + '&inp_CalendarEventClass=' + aData.ClassData + '&inp_CalendarEventPrivate=' + aData.PrivateFlag + '&aDayViewAdd=' + aData.DayViewAdd, LiveGroup.Calendar.Utils.MultipleEvents, this);
      } else if (aData.CallbackData.NumWeeks>1){
        aNumWeeks = (aData.CallbackData.NumWeeks - 1);
        aTotalWeeks = (aData.CallbackData.TotalWeeks);
        LiveRequest_MakeRequest(LiveGroup.Calendar.currentCalendarPath + '.AddComplete?aObjectTypeAlias=LiveGroup_CalendarEvent&inpEventDate=' + aData.CallbackData.Year +'_'+ aData.CallbackData.Month + '_' + LiveGroup.Calendar.Utils.twoDigitFormat(aData.CallbackData.Day) + '&aDate=' + aData.CallbackData.Date + '&aEndDate=' + aData.CallbackData.EndDate + '&inp_NumberOfWeeks=' + aNumWeeks + '&inp_CalendarEventDescription=' + aData.CallbackData.Content + '&inp_CalendarEventName=' + aData.CallbackData.Name + '&aTotalWeeks=' + aTotalWeeks + '&InpHour=' + aData.CallbackData.InpHour + '&InpMinute=' + aData.CallbackData.InpMinute + '&inp_EndHour=' + aData.CallbackData.InpEndHour + '&inp_EndMinute=' + aData.CallbackData.InpEndMinute + '&inp_CalendarEventClass=' + aData.CallbackData.ClassData + '&inp_CalendarEventPrivate=' + aData.CallbackData.PrivateFlag + '&aDayViewAdd=' + aData.CallbackData.DayViewAdd, LiveGroup.Calendar.Utils.MultipleEvents, this);
      }
      zCalendar.parentContainer.lastChild.style.display = 'none';
    },
    DrawEventDay: function(aData, aControl) {
      if (aData.ItemPath != null && aData.ItemPath != 'undefined') {
        aControl.setup.Data.ShowFullScreen();
      } else {
        return true;
      }
    },
    Num2Rank: function(aNumber) {
      if (aNumber%10 == 1 && aNumber != 11) return aNumber + 'st';
      if (aNumber%10 == 2 && aNumber != 12) return aNumber + 'nd';
      if (aNumber%10 == 3 && aNumber != 13) return aNumber + 'rd';
      return aNumber + 'th';
    }
  }
}
LiveGroup.Assets = {
  GetNaturalSize: function(zImg) {
    if (zImg.naturalHeight) {
      return { width: zImg.naturalWidth, height: zImg.naturalHeight };
    } else {
      lgi = new Image();
      lgi.src = zImg.src;
      return { width: lgi.width, height: lgi.height };
    }
  },
  FullScreenshot: function(zImg) {
    zNaturalSize = LiveGroup.Assets.GetNaturalSize(zImg);
    zPageSize = getPageSize();
    zNaturalWidth = zNaturalSize.width;
    zWidth = zPageSize.pageWidth * 0.95;
    if (zWidth > zNaturalWidth) {
      zWidth = zNaturalWidth;
    }
    zHeight = zNaturalSize.height / (zNaturalSize.width / zWidth);
    zImg.style.width = zWidth + 'px';
    zImg.style.height = zHeight + 'px';
    zImg.style.display = 'block';
  }
}
    LiveGroup.Utils.InsertCommas = function(a) {
      var p,ad,b='',ep='',di=a.indexOf('.');
      if(di>=0){
        ep=a.substring(di,a.length);
        a=a.substring(0,di);
      }
      ad = Math.ceil(a.length/3);
      if(ad>1){
        for(p=1;p<ad;p++){
          al = a.length;
          b = ','+ a.substring(al-3) + b;
          a = a.substring(0,al-3);
        }
      }
      b = a + b + ep;
      return b;
    }
LiveGroup.SortTable = {
  TableOutput: [],
  FullItemArray: [],
  OrderBy:'Rank',
  OrderDirection:'Desc',
  RowCount: 0,
  RowStart: 1,
  RowEnd: 500,
  Init: function(e,aSettingsObject) {
    LiveGroup.SortTable.BaseURL    = aSettingsObject.BaseURL;
    LiveGroup.SortTable.BrowseType = aSettingsObject.BrowseType;
    LiveGroup.SortTable.RowEnd     = aSettingsObject.RowEnd;
    LiveGroup.SortTable.GetItems();
    return true;
  },
  GetSortButtons: function() {
    var zSortButton = getElementsWithAttribute('SortBy');
    zSortButton.forEach(function(aElement){
      appendEventHandler(aElement,'onclick',LiveGroup.SortTable.Sort,aElement);
    });
    var zCurrentSortButton = getElementsWithAttribute('SortBy',LiveGroup.SortTable.OrderBy);
    zCurrentSortButton[0].style.backgroundColor = '#7C9CB9';
    return true;
  },
  Loading: function() {
    LiveGroup.SortTable.LayoutContainer.innerHTML = '<div id="LoadingDiv" class="LoadingImage"></div>';
    return true;
  },
  Sort: function(e,aSortButton) {
    LiveGroup.SortTable.PreviousSortBy = LiveGroup.SortTable.OrderBy;
    LiveGroup.SortTable.PreviousSortDirection = LiveGroup.SortTable.OrderDirection;
    LiveGroup.SortTable.OrderBy = aSortButton.getAttribute('SortBy');
    if (LiveGroup.SortTable.PreviousSortBy == LiveGroup.SortTable.OrderBy) {
      if (LiveGroup.SortTable.PreviousSortDirection == 'Asc') {
        LiveGroup.SortTable.OrderDirection = 'Desc';
        aSortButton.setAttribute('OrderDirection','Desc');
      } else {
        LiveGroup.SortTable.OrderDirection = 'Asc';
        aSortButton.setAttribute('OrderDirection','Asc');
      }
    } else {
      LiveGroup.SortTable.OrderDirection = aSortButton.getAttribute('OrderDirection');
    }
    LiveGroup.SortTable.FullItemArray = new Array();
    LiveGroup.SortTable.RowCount = 0;
    LiveGroup.SortTable.RowStart = 1;
    LiveGroup.SortTable.RowEnd = 500;
    LiveGroup.SortTable.Loading();
    LiveGroup.SortTable.GetItems();
    return true;
  },
  Next: function() {
    LiveGroup.SortTable.RowCount = LiveGroup.SortTable.RowCount + 25;
    LiveGroup.SortTable.GetItems();
    return true;
  },
  Previous: function() {
    LiveGroup.SortTable.RowCount = LiveGroup.SortTable.RowCount - 25;
    LiveGroup.SortTable.GetItems();
    return true;
  },
  GetPage: function(aPageNumber) {
    LiveGroup.SortTable.RowCount = [(aPageNumber*25)-25];
    LiveGroup.SortTable.GetItems();
    return true;
  },
  GetItems: function() {
    if (LiveGroup.SortTable.FullItemArray[LiveGroup.SortTable.RowCount]) {
      LiveGroup.SortTable.DisplayNextItems();
    } else {
      if (LiveGroup.SortTable.RowCount){
        LiveGroup.SortTable.RowCount =  Number(LiveGroup.SortTable.RowCount);
        LiveGroup.SortTable.RowStart =  Number(LiveGroup.SortTable.RowCount) + 1;
        LiveGroup.SortTable.RowEnd   =  Number(LiveGroup.SortTable.RowCount) + 500;
      }
      LiveGroup.SortTable.URL = LiveGroup.SortTable.BaseURL + '&aStart=' + LiveGroup.SortTable.RowCount + '&aSortBy=' + LiveGroup.SortTable.OrderBy + '&aOrderDirection=' + LiveGroup.SortTable.OrderDirection + '&aRowStart=' +LiveGroup.SortTable.RowStart+ '&aRowEnd=' +LiveGroup.SortTable.RowEnd;
      LiveGroup.SortTable.Params = {Start: LiveGroup.SortTable.RowCount};
      LiveRequest_MakeRequest(LiveGroup.SortTable.URL,LiveGroup.SortTable.ReceiveItems,LiveGroup.SortTable.Params);
    }
    return true;
  },
  ReceiveItems: function(aItems,aParams) {
    if (aItems){
      aItems.forEach(function(aItem){
        LiveGroup.SortTable.FullItemArray.push(aItem);
      });
      LiveGroup.SortTable.DisplayNextItems();
    } else {
      LiveGroup.SortTable.LayoutContainer = $("LayoutContainer");
      LiveGroup.SortTable.LayoutContainer.innerHTML = '<div id="NoContentMessage">Sorry, boet. There is no info to display.</div>';
    }
    return true;
  },
  DisplayNextItems: function() {
    LiveGroup.SortTable.TableOutput = new Array();
    LiveGroup.SortTable.RowCount = Number(LiveGroup.SortTable.RowCount);
    zCurrentCount = LiveGroup.SortTable.RowCount + 25;
    if (zCurrentCount > LiveGroup.SortTable.FullItemArray.length){
      fDisplayCount = LiveGroup.SortTable.FullItemArray.length - LiveGroup.SortTable.RowCount;
    } else {
      fDisplayCount = 25;
    }
    $("LayoutContainer").innerHTML = '';
    var zTitle = CreateBasicElement('div', 'Page_Title');
    zTitle.innerHTML = LiveGroup.SortTable.BrowseType + 's';
    $("LayoutContainer").appendChild(zTitle);
    $("LayoutContainer").appendChild(LiveGroup.SortTable.Navigation());
    $("LayoutContainer").appendChild(LiveGroup.SortTable.Rankings());
    $("LayoutContainer").appendChild(LiveGroup.SortTable.Navigation());
    LiveGroup.SortTable.LayoutContainer = $('LayoutContainer');
    LiveGroup.SortTable.MoveToTop();
    LiveGroup.SortTable.GetSortButtons();
  },
  Navigation: function() {
    zNav = new Array();
    var zDiv = CreateBasicElement('div', 'ControlsContainer');
    zNav.push('<div id="Controls">');
    zNav.push('<ul id="ULControls">');
    var zStartRowCount = 1;
    var zEndRowCount = 11;
    if (LiveGroup.SortTable.RowCount >= 250){
      var zStartRowCount = zStartRowCount + 10;
      var zEndRowCount = zEndRowCount + 9;
    }
    if (LiveGroup.SortTable.RowCount >= 250 || zCurrentCount > 25) {
      zNav.push('<li id="Controls_Previous"><a href="javascript: void(0);" onclick="javascript:LiveGroup.SortTable.Previous();">&lt;Previous</a></li>');
    }
    if (zCurrentCount >= 500){
      var zStartRowCount = zStartRowCount + 20;
      var zEndRowCount = zEndRowCount + 19;
    }
    for (var i = zStartRowCount; i < zEndRowCount; i++){
      if (LiveGroup.SortTable.RowCount < LiveGroup.SortTable.FullItemArray.length){
        if (LiveGroup.SortTable.RowCount == [i*25-25]){
          if (LiveGroup.SortTable.FullItemArray.length > 25){
            zNav.push('<li class="Controls_Number_Selected">'+ [i] +'</li>');
          }
        } else {
          if ([i*25-25] < LiveGroup.SortTable.FullItemArray.length){
            zNav.push('<li class="Controls_Number"><a href="javascript: void(0);" onclick="javascript:LiveGroup.SortTable.GetPage(\''+ [i] +'\');" id="Controls_NumberLink_">'+ [i] +'</a></li>');
          }
        }
      }
    }
    if (zCurrentCount < LiveGroup.SortTable.FullItemArray.length || [i*25-25] <= LiveGroup.SortTable.FullItemArray.length) {
      zNav.push('<li id="Controls_Next"><a href="javascript: void(0);" onclick="javascript:LiveGroup.SortTable.Next(\''+ [LiveGroup.SortTable.RowCount+25] +'\');">Next &gt;</a></li>');
    }
    zNav.push('</ul></div>');
    zNav.push('</div>');
    zNav.push('<div class="clear">&nbsp;</div>');
    zDiv.innerHTML = zNav.join('\n');
    return zDiv;
  },
  Rankings: function() {
    var zTable = CreateBasicElement('table', 'RankTable');
      var zTBody = CreateBasicElement('tbody');
      var zTrHeaders = CreateBasicElement('tr');
        var zThRank = CreateBasicElement('th', null, 'RankTH');
        zThRank.innerHTML = 'Rank';
        zTrHeaders.appendChild(zThRank);
        var zThImage = CreateBasicElement('th', null, 'ImageColumn');
        zTrHeaders.appendChild(zThImage);
        var zThName = CreateBasicElement('th', 'DisplayNameTH', 'ClickableTH');
        zThName.innerHTML = 'Name';
        zThName.setAttribute('SortBy', 'DisplayName');
        zThName.setAttribute('OrderDirection', 'Asc');
        zThName.setAttribute('AltDirection', 'Desc');
        zTrHeaders.appendChild(zThName);
        var zThScore = CreateBasicElement('th', 'ScoreTH', 'ClickableTH');
        zThScore.innerHTML = 'Score';
        zThScore.setAttribute('SortBy', 'Rank');
        zThScore.setAttribute('OrderDirection', 'Desc');
        zThScore.setAttribute('AltDirection', 'Asc');
        zTrHeaders.appendChild(zThScore);
        var zThDate = CreateBasicElement('th', 'InsertDateTH', 'ClickableTH');
        zThDate.innerHTML = 'Insert Date';
        zThDate.setAttribute('SortBy', 'InsertDate');
        zThDate.setAttribute('OrderDirection', 'Desc');
        zThDate.setAttribute('AltDirection', 'Asc');
        zTrHeaders.appendChild(zThDate);
      zTBody.appendChild(zTrHeaders);
    for (var x = 0; x < fDisplayCount; x++) {
      var zCurrentRowCount   = (LiveGroup.SortTable.RowCount+x);
      var zCurrentRow_Object = LiveGroup.SortTable.FullItemArray[zCurrentRowCount];
      if (zCurrentRow_Object.DisplayName){
        var aPagePath = zCurrentRow_Object.ItemPath.toPagePath();
        var zItemHREF = '';
        if (zCurrentRow_Object.Domain != '') {
          zItemHREF = 'http://' + zCurrentRow_Object.Domain;
        } else {
          zItemHREF = aPagePath +'.html';
        }
        var zTr = CreateBasicElement('tr', null, (x%2 == 0 ? 'even' : 'odd'));
          var zTdRank       = CreateBasicElement('td', null, 'Ranktd');
          zTdRank.innerHTML = [zCurrentRowCount+1];
          zTr.appendChild(zTdRank);
          var zTdAvatar = CreateBasicElement('td');
          var zTdAvatarAnchor = CreateBasicElement('a');
          zTdAvatarAnchor.href = zItemHREF;
          zTdAvatar.appendChild(zTdAvatarAnchor);
          var zTdAvatarImage          = new Image();
          zTdAvatarImage.width        = zCurrentRow_Object.ImageWidth;
          zTdAvatarImage.height       = zCurrentRow_Object.ImageHeight;
          zTdAvatarImage.style.width  = zCurrentRow_Object.ImageWidth;
          zTdAvatarImage.style.height = zCurrentRow_Object.ImageHeight;
          zTdAvatarImage.src          = zCurrentRow_Object.ImageURL;
          zTdAvatarAnchor.appendChild(zTdAvatarImage);
          zTr.appendChild(zTdAvatar);
          var zTdName = CreateBasicElement('td', null, 'DisplayNametd');
            var zTdNameAnchor       = CreateBasicElement('a');
            zTdNameAnchor.href      = zItemHREF;
            var zDisplayName        = zCurrentRow_Object.DisplayName.replace(/_/g, " ");
            zTdNameAnchor.innerHTML = zDisplayName;
            zTdName.appendChild(zTdNameAnchor);
            var zTdNameDescription = CreateBasicElement('div', null, 'ItemDescription');
            zTdNameDescription.innerHTML = zCurrentRow_Object.Description;
            zTdName.appendChild(zTdNameDescription);
            if (zCurrentRow_Object.Domain != '') {
              var zTdNameAddFriend = CreateBasicElement('a');
              zTdNameAddFriend.href = 'javascript: void(0);';
              zTdNameAddFriend.innerHTML = 'Request Frienship';
              zTdName.appendChild(zTdNameAddFriend);
              var zSeparator = CreateBasicElement('span');
              zSeparator.innerHTML = ' &middot; ';
              zTdName.appendChild(zSeparator);
              var zTdNameAddRival = CreateBasicElement('a');
              zTdNameAddRival.href = 'javascript: void(0);';
              zTdNameAddRival.innerHTML = 'Make Rival';
              zTdName.appendChild(zTdNameAddRival);
            }
          zTr.appendChild(zTdName);
          if (zCurrentRow_Object.Domain != '') {
            new LiveGroup.ActionBar.Control({
              ItemBaseURL: '/' + unescape(zCurrentRow_Object.ItemPath).replace(/\\/g, '/'),
              Title: 'Request Frienship',
              ContentAction: '.FriendRequest?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
              OnClickURL: '.FriendRequestComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
              Type: 'action',
              ActionName: 'Request',
              AddFields: ['inpRequestHTML', 'inpSourceDatabasePath'],
              Trigger: zTdNameAddFriend
            });
            new LiveGroup.ActionBar.Control({
              ItemBaseURL: '/' + unescape(zCurrentRow_Object.ItemPath).replace(/\\/g, '/'),
              Title: 'Make Rival',
              ContentAction: '.MakeRival?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
              OnClickURL: '.MakeRivalComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
              Type: 'action',
              ActionName: 'Make Rival',
              AddFields: ['inpSourceDatabasePath', 'inpNothing'],
              Trigger: zTdNameAddRival
            });
          }
          var zTdScore = CreateBasicElement('td', null, 'Scoretd');
          zTdScore.innerHTML = LiveGroup.Utils.InsertCommas(zCurrentRow_Object.Rank);
          zTr.appendChild(zTdScore);
          var zTdDate = CreateBasicElement('td', null, 'InsertDateDisplaytd');
          zTdDate.innerHTML = zCurrentRow_Object.InsertDateDisplay;
          zTr.appendChild(zTdDate);
        zTBody.appendChild(zTr);
      }
    }
    zTable.appendChild(zTBody);
    return zTable;
  },
  MoveToTop: function() {
    if(window){
      window.scrollTo(0,0)
      return true;
    } else {
      return false;
    }
  }
}
LiveGroup.Utils.QuickBrowse = function(aSetup) {
  this.Setup = aSetup;
  this.CurrentPage = 0;
  if (this.Setup) {
    this.buildHeader = this.Setup.BuildHeaderFunc;
    this.buildItem = this.Setup.BuildItemFunc;
    this.onNext = this.Setup.OnNextFunc;
  }
  this.populate = function() {
    this.CurrentPageData = this.Pages[this.CurrentPage];
    this.build();
    if (this.Setup.HasPager) {
      this.updatePager();
    }
    this.Locked = false;
  }
  this.build = function() {
    if (isFunction(this.buildHeader)) {
      zHeader = this.buildHeader();
      if (zHeader) {
        this.Container.appendChild(zHeader);
      }
    }
    if (this.Setup.HasPager) {
      this.PagerContainer = CreateBasicElement('div', null, 'Pager');
      this.Container.appendChild(this.PagerContainer);
    }
    if (this.TotalItems > this.Setup.PerPages) {
      this.FlipContainer = CreateBasicElement('div', null, 'FlipButtonContainer');
      this.Container.appendChild(this.FlipContainer);
      this.PreviousButton = CreateBasicElement('div', null, 'FlipButtons FlipPrevious');
      this.FlipContainer.appendChild(this.PreviousButton);
      appendEventHandler(this.PreviousButton, "onclick", this.previousPage, this);
      this.NextButton = CreateBasicElement('div', null, 'FlipButtons FlipNext');
      this.FlipContainer.appendChild(this.NextButton);
      appendEventHandler(this.NextButton, "onclick", this.nextPage, this);
    }
    if (this.TotalItems < 1) {
      this.NoItemMessage = CreateBasicElement('div', null, 'NoItemsMessage');
      if (this.Setup.NoItemsMsg) {
        this.NoItemMessage.innerHTML = this.Setup.NoItemsMsg;
      } else {
        this.NoItemMessage.innerHTML = 'No item found.';
      }
      this.Container.appendChild(this.NoItemMessage);
    }
    var DisplayLimit = Math.min(this.CurrentPageData.length, this.Setup.PerPages);
    for (var i = 0; i < DisplayLimit; i++) {
      if (this.CurrentPageData[i] != null && isFunction(this.buildItem)) {
        this.Container.appendChild(this.buildItem(this.CurrentPageData[i]));
      }
    }
  }
  this.updatePager = function() {
    LiveGroup.Utils.RemoveSubItems(this.PagerContainer);
    for (var i = this.LastPage; i >= 0; i--) {
      var onePage = CreateBasicElement('div', null, 'PageLink');
      onePage.style.backgroundPosition = (i == this.CurrentPage) ? '0 -15px' : '0 0';
      appendEventHandler(onePage, "onclick", this._choosePage, {Parent: this, PageNumber: i});
      this.PagerContainer.appendChild(onePage);
    }
  }
  this.makeRequest = function() {
    this.Locked = true;
    LiveGroup.Utils.RemoveSubItems(this.Container);
    if (this.Pages[this.CurrentPage] == null) {
      this.Loading = CreateBasicElement('div', null, 'LoadingImage');
      this.Container.appendChild(this.Loading);
      this.StartRow = this.CurrentPage * this.Setup.PerPages + 1;
      var aURL = AppendToUrl(this.Setup.Url, 'aStartRow=' + this.StartRow + '&aRowCount=' + this.Setup.PerPages);
      LiveRequest_MakeRequest(aURL, this.receiveRequest, this);
    } else {
      this.populate();
    }
  }
  this.receiveRequest = function(aData, aParent) {
    aParent.TotalItems = aData.TotalItems;
    aParent.LastPage = (aParent.TotalItems / aParent.Setup.PerPages) - 1;
    aParent.Pages[aParent.CurrentPage] = aData.Items;
    aParent.Container.removeChild(aParent.Loading);
    if (aParent.Setup.onReceiveCallback != null) {
      aParent.Setup.onReceiveCallback(aParent);
    }
    aParent.populate();
  }
  this.changePage = function(aOffset) {
    if (this.Locked != true) {
      this.CurrentPage += aOffset;
      this.makeRequest();
    }
  }
  this.choosePage = function(aPageNumber) {
    if (this.Locked != true) {
      this.CurrentPage = aPageNumber;
      this.makeRequest();
    }
  }
  this._choosePage = function(e, aPageObj) {
    aPageObj.Parent.choosePage(aPageObj.PageNumber);
  }
  this.nextPage = function(e, aParent) {
    if (isFunction(aParent.onNext)) {
      if (aParent.onNext(aParent) != true) {
        return false;
      }
    }
    if (aParent.CurrentPage < aParent.LastPage) {
      aParent.changePage(+1);
    } else if (aParent.Setup.AlwaysLoop) {
      aParent.choosePage(0);
    }
  }
  this.previousPage = function(e, aParent) {
    if (aParent.CurrentPage > 0) {
      aParent.changePage(-1);
    } else if (aParent.Setup.AlwaysLoop) {
      aParent.choosePage(aParent.LastPage);
    }
  }
  this.init = function() {
    if (isObject(this.Setup.Container)) {
      this.Container = this.Setup.Container;
    } else {
      this.Container = $(this.Setup.Container);
    }
    this.Pages = new Array();
    this.makeRequest();
  }
  if (this.Setup) {
    this.init();
  }
}
LiveGroup.Database.CardQuickBrowse = function(aSetup) {
  this.Setup = aSetup;
  if (this.Setup.Title) {
    this.buildHeader = function() {
      var a = CreateBasicElement('a', null, 'title');
      a.href = this.Setup.ViewMoreURL;
      a.name = this.Setup.Title;
      a.innerHTML = this.Setup.Title + '<span>Click here to see more</span>';
      return a;
    }
  }
  this.buildItem = function(aCardSetup) {
    var zCard = new LiveGroup.Database.Card(aCardSetup);
    return zCard.container;
  }
  this.onNext = function(aParent) {
    if (aParent.CurrentPage >= 3) {
      document.location = aParent.Setup.ViewMoreURL;
    }
    return true;
  }
  this.init();
}
LiveGroup.Database.CardQuickBrowse.prototype = new LiveGroup.Utils.QuickBrowse;
LiveGroup.Assets.AssetQuickBrowse = function(aSetup) {
  this.Setup = aSetup;
  if (this.Setup.Title) {
    this.buildHeader = function() {
      var a = CreateBasicElement('a', null, 'title');
      a.href = this.Setup.ViewMoreURL;
      a.name = this.Setup.Title;
      a.innerHTML = this.Setup.Title + '<span>Click here to see more</span>';
      return a;
    }
  }
  this.buildItem = function(aItemData) {
    var zThumbContainer, zThumbLink, zThumbImage, zThumbName, zThumbText;
    zThumbContainer = CreateBasicElement('div', null, 'OneThumb');
      zThumbLink = CreateBasicElement('a');
      zThumbLink.href = aItemData.LinkURL;
        zThumbImage = CreateBasicElement('img');
        zThumbImage.src = aItemData.ImageURL;
        zThumbLink.appendChild(zThumbImage);
        if (aItemData.Name) {
          zThumbName = CreateBasicElement('div', null, 'AssetName');
          zThumbName.innerHTML = unescape(aItemData.Name);
          zThumbLink.appendChild(zThumbName);
        }
        zThumbText = CreateBasicElement('div');
        zThumbText.innerHTML = unescape(aItemData.Text);
        zThumbLink.appendChild(zThumbText);
      zThumbContainer.appendChild(zThumbLink);
    return zThumbContainer;
  }
  this.onNext = function(aParent) {
    return true;
  }
  this.init();
}
LiveGroup.Assets.AssetQuickBrowse.prototype = new LiveGroup.Utils.QuickBrowse;
LiveGroup.Loading = {
  Small: new Image(),
  Play: function (aLoadingElement) {
    aLoadingElement.style.backgroundImage = 'url('+ LiveGroup.Loading.Small.src + ')';
    aLoadingElement.style.backgroundRepeat = 'no-repeat';
  },
  Stop: function (aLoadingElement) {
    aLoadingElement.style.backgroundImage = 'none';
  }
}
LiveGroup.Loading.Small.src = '/l.c.bin/I/5257066/ajax-loader.gif';
LiveGroup.TeamMemberList = {
  RemoveArray:[],
  CurrentElement:'',
  PreviousElement:'',
  RowCount:10,
  Init: function() {
    var zTeamListButtons = getElementsWithAttribute('IsTeamButton','Y','DIV');
    zTeamListButtons.forEach(function(aElement){
      appendEventHandler(aElement,'onclick',LiveGroup.TeamMemberList.StartClick,aElement);
    });
    return true;
  },
  Display: function(e,aElement) {
    var zItemPath = aElement.getAttribute('TeamDatabasePath');
    var zPagePath = zItemPath.toPagePath(zItemPath);
    if (aElement.StartRow) {
      aElement.StartRow = (aElement.StartRow + LiveGroup.TeamMemberList.RowCount);
    } else {
      aElement.StartRow = 1;
    }
    if (LiveGroup.TeamMemberList.CurrentElement!='') {
      LiveGroup.TeamMemberList.PreviousElement = LiveGroup.TeamMemberList.CurrentElement;
    }
    var zPreviousElement = LiveGroup.TeamMemberList.PreviousElement;
    if (zPreviousElement != '') {
      var zPreviousListElement = $(zPreviousElement.id + '_LIST');
      LiveGroup.TeamMemberList.RemoveArray.push(zPreviousListElement)
    }
    LiveGroup.TeamMemberList.CurrentElement  = aElement;
    var zURL = zPagePath + '.GetTeamMembers?aStartRow='+ aElement.StartRow +'&aRowCount=' + LiveGroup.TeamMemberList.RowCount;
    LiveGroup.Loading.Play(aElement);
    LiveRequest_MakeRequest(zURL,LiveGroup.TeamMemberList.Draw);
    return true;
  },
  Draw: function(aTeamMemberList) {
    var zCurrentElement  = LiveGroup.TeamMemberList.CurrentElement;
    LiveGroup.TeamMemberList.aTotalResults = aTeamMemberList.TotalResults;
    zCurrentElement.List = aTeamMemberList.ListResults;
    var zTableNode = LiveGroup.TeamMemberList.DrawTable();
    var zTBodyNode = zTableNode.childNodes[0];
    for (i = 0; i < (aTeamMemberList.ListResults.length) && i < LiveGroup.TeamMemberList.RowCount; i++) {
      var zCurrentRow = aTeamMemberList.ListResults[i];
      var zTableRowNode = LiveGroup.TeamMemberList.DrawRow(zCurrentRow.DatabasePath,zCurrentRow.ItemPath,zCurrentRow.SiteURL,zCurrentRow.PlayerName,zCurrentRow.IsLeader,zCurrentRow.IsAdmin);
      zTBodyNode.appendChild(zTableRowNode);
    }
    var zNavigationRow = LiveGroup.TeamMemberList.DrawNavigationRow(zCurrentElement,zCurrentElement.StartRow,LiveGroup.TeamMemberList.RowCount,aTeamMemberList.ListResults.length);
    zTBodyNode.appendChild(zNavigationRow);
    LiveGroup.TeamMemberList.RemoveTable();
    var zTargetListElement = $(zCurrentElement.id + '_LIST');
    zTargetListElement.appendChild(zTableNode);
    LiveGroup.Loading.Stop(zCurrentElement);
    var zLeftColumn = document.getElementById('LeftColumn');
    var zRightColumn = document.getElementById('RightColumn');
    var zAllContent = document.getElementById('AllContent');
    if (zRightColumn.offsetHeight > zLeftColumn.offsetHeight){
      zAllContent.style.height = zRightColumn.offsetHeight + 110 + 'px';
    } else {
      zAllContent.style.height = zLeftColumn.offsetHeight + 100 + 'px';
    }
    return true;
  },
  DrawTable: function() {
    zTableNode = document.createElement('table');
    zTableNode.className = 'TeamMembers';
    zTBodyNode = document.createElement('tbody');
    zTableNode.appendChild(zTBodyNode);
    return zTableNode;
  },
  DrawRow: function(aDatabasePath,aItemPath,aSiteURL,aDatabaseName,aIsLeader,aIsAdmin) {
    var zRowNode = document.createElement('tr');
    var zAdminNode = document.createElement('td');
    zAdminNode.setAttribute("height","16");
    if (aIsAdmin=='Y') {
      zAdminNode.innerHTML = '<div id="SpannerImage"></div>';
    } else {
      zAdminNode.innerHTML = '<div></div>';
    }
    zAdminNode.className = 'TeamAdmin';
    zRowNode.appendChild(zAdminNode);
    var zLeaderNode = document.createElement('td');
    if (aIsLeader=='Y') {
      zLeaderNode.innerHTML = '<div id="CaptainImage"></div>';
    } else {
      zLeaderNode.innerHTML = '<div></div>';
    }
    zLeaderNode.className = 'TeamLeader';
    zRowNode.appendChild(zLeaderNode);
    var zDatabaseNode = document.createElement('td');
    zDatabaseNode.innerHTML = aDatabaseName;
    zDatabaseNode.className = 'PlayerName';
    zRowNode.appendChild(zDatabaseNode);
    var zMessageNode = document.createElement('td');
    zAnchor = CreateBasicElement('a');
    zAnchor.href = 'javascript: void(0);';
    zAnchor.innerHTML = 'Message';
    var zItemBase = unescape(aDatabasePath);
    var zControl = new LiveGroup.ActionBar.Control({
      ItemBaseURL: '/' + zItemBase.replace(/\\/g, '/'),
      Title: 'Send Message',
      Alias: 'Message',
      ContentAction: '.SendMessage?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      Type: 'action',
      ActionName: 'Send Message',
      OnClickURL: '.SendMessageComplete?aObjectTypeAlias=LiveGroup_Database&aActionBar=Y',
      AddFields: ['inpSubject', 'inpHTML', 'inpForceNotification'],
      Trigger: zAnchor
    });
    zMessageNode.appendChild(zAnchor);
    zMessageNode.className = 'PlayerLinks';
    zRowNode.appendChild(zMessageNode);
    var zURLNode = document.createElement('td');
    zURLNode.innerHTML = '<a href="http://' + aSiteURL + '">View Site</a>';
    zRowNode.appendChild(zURLNode);
    return zRowNode;
  },
  DrawNavigationRow: function(aElement,aStartRow,aRowCount,aListCount) {
    if (aStartRow<=1) {
      aStartRow = 1;
    }
    var zNavigationRow = document.createElement('tr');
    if (LiveGroup.TeamMemberList.aTotalResults > 10) {
      var zNavigationCol = document.createElement('td');
      zNavigationCol.colSpan = 4;
      var zBackNode = document.createElement('div');
      var zNextNode = document.createElement('div');
      zNextNode.className = "UnselectedButtonNext";
      zBackNode.className = "UnselectedButtonBack";
      zBackNode.appendChild(document.createTextNode("Back"));
      if(aStartRow != 1){
        zBackNode.className = "SelectedButtonBack";
        appendEventHandler(zBackNode,'onclick',LiveGroup.TeamMemberList.BackClick,aElement);
      }
      aRowCount = aStartRow + 9;
      if(aRowCount < LiveGroup.TeamMemberList.aTotalResults){
        zNextNode.className = "SelectedButtonNext";
        appendEventHandler(zNextNode,'onclick',LiveGroup.TeamMemberList.Display,aElement);
      }
      zNextNode.appendChild(document.createTextNode("Next"));
      zNavigationCol.appendChild(zBackNode);
      zNavigationCol.appendChild(zNextNode);
      zNavigationRow.appendChild(zNavigationCol);
    }
    return zNavigationRow;
  },
  RemoveTable: function () {
    for (k = 0; k < LiveGroup.TeamMemberList.RemoveArray.length; k++) {
      var zCurrentList_Object = LiveGroup.TeamMemberList.RemoveArray[k];
      if (zCurrentList_Object.childNodes.length>0) {
        for (j = 0; j < zCurrentList_Object.childNodes.length; j++) {
          zCurrentList_Object.removeChild(zCurrentList_Object.childNodes[j]);
        }
      }
    }
    return true;
  },
  BackClick: function(e,aElement) {
    aElement.StartRow = (aElement.StartRow - (LiveGroup.TeamMemberList.RowCount)*2);
    LiveGroup.TeamMemberList.Display(e,aElement);
    return true;
  },
  StartClick: function(e,aElement) {
    aElement.StartRow = 0;
    LiveGroup.TeamMemberList.Display(e,aElement);
    return true;
  },
  DoNothing: function(e) {
    return false;
  },
  DontGoTo: function(e) {
    new LiveGroup.WM.Error('You need to be a team administrator to use this feature.');
    return false;
  },
  GoTo: function(e,aURL) {
    document.location = aURL;
    return false;
  }
}
LiveGroup.SiteModules = new Object();
LiveGroup.SiteModules.LinksViewer = new Object();
LiveGroup.SiteModules.LinksViewer.CompleteCallback = function(aData, aControl) {
  aControl.setup.ParentObject._receiveLinks(aData, aControl.setup.ParentObject);
}
LiveGroup.SiteModules.LinksViewer.Module = function(aLinkType, aListType) {
  this.LinkType = aLinkType;
  this.build = function() {
    if (this.Links == null) return;
    LiveGroup.Utils.RemoveSubItems(this.Container);
    if (this.Links.length < 1 || this.Links[0] == null) {
      this.NoItem = CreateBasicElement('div', null, 'NoItem');
      this.NoItem.innerHTML = 'Nothing to display, if you are this user or an admin of this team, click on New above.';
      this.Container.appendChild(this.NoItem);
    }
    this.List = CreateBasicElement('ul');
    for (var i = 0; i < this.Links.length; i++) {
      if (this.Links[i] == null) continue;
      this.Links[i].Element = CreateBasicElement('li', null, 'LG_ColorBorder');
        this.Links[i].Anchor = CreateBasicElement(aListType ? 'span' : 'a', null, aListType ? 'a' : null);
          this.Links[i].Anchor.href = unescape(this.Links[i].URL);
          this.Links[i].Anchor.innerHTML = unescape(this.Links[i].DisplayName);
        this.Links[i].Element.appendChild(this.Links[i].Anchor);
        if (this.WriteAccess) {
          this.Links[i].Edit = CreateBasicElement('span');
            this.Links[i].Edit.innerHTML = '(<a href="javascript:void(0);">edit</a>&middot;';
          this.Links[i].Element.appendChild(this.Links[i].Edit);
          this.Links[i].EditControl = new LiveGroup.ActionBar.Control({
            Title: 'Editing ' + this.LinkType,
            ItemBaseURL: '/Home',
            ContentAction: '.LinksListEdit?aObjectTypeAlias=LiveGroup_Database&aLinkType=' + this.LinkType + '&aLinkID=' + (i + 1) + '&aFlat=' + (aListType ? 'Y' : 'N'),
            OnClickURL: '.LinksListEditComplete?aObjectTypeAlias=LiveGroup_Database&aLinkType=' + this.LinkType + '&aLinkID=' + (i + 1),
            Type: 'action',
            ActionName: 'Save',
            AddFields: ['inpName', 'inpURL', 'inpDetails'],
            Trigger: this.Links[i].Edit,
            ParentObject: this
          });
          this.Links[i].Remove = CreateBasicElement('span');
            this.Links[i].Remove.innerHTML = '<a href="javascript:void(0);">remove</a>)';
          this.Links[i].Element.appendChild(this.Links[i].Remove);
          this.Links[i].RemoveControl = new LiveGroup.ActionBar.Control({
            Title: 'Removing ' + this.LinkType,
            ItemBaseURL: '/Home',
            ContentAction: '.LinksListEditComplete?aObjectTypeAlias=LiveGroup_Database&aLinkType=' + this.LinkType + '&aLinkID=' + (i + 1),
            Type: 'info',
            ActionName: 'Delete',
            Trigger: this.Links[i].Remove,
            ParentObject: this
          });
        }
        this.Links[i].DetailsDiv = CreateBasicElement('div');
          this.Links[i].DetailsDiv.innerHTML = unescape(this.Links[i].Details);
        this.Links[i].Element.appendChild(this.Links[i].DetailsDiv);
      this.List.appendChild(this.Links[i].Element);
    }
    this.Container.appendChild(this.List);
  }
  this.setNewTrigger = function(aTrigger) {
    this.AddLinkTrigger = aTrigger;
    this.AddLinkControl = new LiveGroup.ActionBar.Control({
      Title: 'Adding ' + this.LinkType,
      ItemBaseURL: '/Home',
      ContentAction: '.LinksListEdit?aObjectTypeAlias=LiveGroup_Database&aLinkType=' + this.LinkType + '&aFlat=' + (aListType ? 'Y' : 'N'),
      OnClickURL: '.LinksListEditComplete?aObjectTypeAlias=LiveGroup_Database&aLinkType=' + this.LinkType,
      Type: 'action',
      ActionName: 'Add',
      AddFields: ['inpName', 'inpURL', 'inpDetails'],
      Trigger: aTrigger,
      ParentObject: this
    });
    LiveGroup.Login.LoginDependentFunctions.push({ Func: this.updateAfterLogin, Param: this });
  }
  this.updateAfterLogin = function(aParent) {
    if (LiveGroup.Login.UserInformation.DatabaseAdmin == 'Y') {
      aParent.AddLinkTrigger.innerHTML = '(New ' + aParent.LinkType + ') &nbsp; ';
    } else {
      aParent.AddLinkTrigger.innerHTML = '&nbsp;';
    }
  }
  this.init = function() {
    this.Container = CreateBasicElement('div', null, 'LinksList');
    this.requestLinks();
  }
  this._receiveLinks = function(aData, aParent) {
    aParent.Links = aData.Links;
    aParent.WriteAccess = aData.WriteAccess;
    aParent.build();
  }
  this.requestLinks = function() {
    LiveRequest_PostRequest('/Home.LinksListGet', {aObjectTypeAlias: 'LiveGroup_Database', aLinkType: this.LinkType}, this._receiveLinks, this);
  }
  this.init();
}
LiveGroup.SiteModules.EventViewer = {
  EventItem: function(aParentList, aEventData, aTitleSize, aDescriptionSize, aAddDetails) {
    this.TitleSize = aTitleSize;
    this.DescriptionSize = aDescriptionSize;
    this.ParentList = aParentList;
    this.Data = aEventData;
    this.IsShaded = true;
    this.AddDetails = aAddDetails;
    this.quickView = function() {
      LiveGroup.Utils.RemoveSubItems(this.Container);
      this.TitleDiv = CreateBasicElement('div', null, 'Title');
        this.TitleDiv.innerHTML = this.Data.Title.length > this.TitleSize ? this.Data.Title.substring(0, this.TitleSize) + '...' : this.Data.Title;
        this.TitleDiv.title = this.Data.Title;
      this.Container.appendChild(this.TitleDiv);
      this.IconDiv = CreateBasicElement('div', null, 'Icon');
      this.Container.appendChild(this.IconDiv);
      this.DateDiv = CreateBasicElement('div', null, 'Date');
        this.DateDiv.innerHTML = this.Data.Date;
      this.Container.appendChild(this.DateDiv);
      this.refreshIcon();
      appendEventHandler(this.Container, 'onclick', this._unshade, this);
    }
    this.detailedQuickView = function(){
      LiveGroup.Utils.RemoveSubItems(this.Container);
      this.TitleDiv = CreateBasicElement('div', null, 'Title');
        this.TitleDiv.innerHTML = this.Data.Title.length > this.TitleSize ? this.Data.Title.substring(0, this.TitleSize) + '...' : this.Data.Title;
        this.TitleDiv.title = this.Data.Title;
      this.Container.appendChild(this.TitleDiv);
      this.IconDiv = CreateBasicElement('div', null, 'Icon');
      this.Container.appendChild(this.IconDiv);
      this.DescriptionDiv = CreateBasicElement('div', null, 'Description DetailedQuickView');
        this.DescriptionDiv.innerHTML += '<strong>Date: </strong>' + this.Data.Date + '<br/>';
        this.DescriptionDiv.innerHTML += '<strong>Time: </strong>' + this.Data.Member.Time + '<br/>';
        this.DescriptionDiv.innerHTML += '<strong>Creator: </strong><a href=' + unescape(this.Data.CreatorURL) + '>' + unescape(this.Data.Creator) + '</a><br/>';
        this.DescriptionDiv.innerHTML += '<strong>Type: </strong> Private<br/>';
        if (this.Data.Member.ClassList && this.Data.Member.ClassList.length > 0) {
          var zClasses = "";
          for (var i = 0; i < this.Data.Member.ClassList.length; i++) {
            zClasses += unescape(this.Data.Member.ClassList[i]);
            if (i < (this.Data.Member.ClassList.length - 1)){
              zClasses += ', ';
            }
          }
        } else {
          var zClasses = "None";
        }
        this.DescriptionDiv.innerHTML += '<strong>Classes: </strong>' + zClasses + '<br/>';
        if (this.Data.Description.length > 300) {
          var zDescription = this.Data.Description.substring(0,300) + '...';
        } else {
          var zDescription = this.Data.Description;
        }
        this.DescriptionDiv.innerHTML += '<strong>Description: </strong>' + zDescription + '<br/>';
        if (this.Data.Member.AttendeeNames.length > 0){
          var zAttendants = '<strong>Attendants: </strong>';
          for (var i=0;i<this.Data.Member.AttendeeNames.length;i++){
            if (i<10){
              zAttendeeURL = '<a href=' + unescape(this.Data.Member.AttendeeURLs[i]) + ' target=new >' + unescape(this.Data.Member.AttendeeNames[i]) + '</a>';
              zAttendants += zAttendeeURL;
              if ((i+1) < this.Data.Member.AttendeeNames.length && i != 9){
                zAttendants += ',';
              }
            }
          }
        } else {
          var zAttendants = '<strong>Attendants: </strong> None';
        }
        this.DescriptionDiv.innerHTML += zAttendants + '<br/>';
      this.DescriptionDiv.innerHTML += '<a href="">Sign up</a>';
      this.Container.appendChild(this.DescriptionDiv);
      this.refreshIcon();
      appendEventHandler(this.Container, 'onclick', this._unshade, this);
    }
    this.fullView = function() {
      removeEventHandler(this.Container, 'onclick', this._unshade, this);
      this.TmpAttending = this.Data.Member.Attending;
      LiveGroup.Utils.RemoveSubItems(this.Container);
      this.TitleDiv = CreateBasicElement('div', null, 'Title WideTitle');
        this.TitleDiv.innerHTML = this.Data.Title.length > this.TitleSize ? this.Data.Title.substring(0, this.TitleSize + 10) + '...' : this.Data.Title;
        this.TitleDiv.title = this.Data.Title;
      this.Container.appendChild(this.TitleDiv);
      if (this.AddDetails){
        this.IconDiv = CreateBasicElement('div', null, 'Icon');
        this.Container.appendChild(this.IconDiv);
      }
      this.DescriptionDiv = CreateBasicElement('div', null, 'Description');
        this.DescriptionDiv.innerHTML += '<strong>Date: </strong>' + this.Data.Date + '<br/>';
        this.DescriptionDiv.innerHTML += '<strong>Time: </strong>' + this.Data.Member.Time + '<br/>';
        this.DescriptionDiv.innerHTML += '<strong>Type: </strong> Private<br/>';
        if (this.Data.Member.AttendeeNames.length > 0){
          var zAttendants = '<strong>Attendants: </strong>';
          for (var i=0;i<this.Data.Member.AttendeeNames.length;i++){
            if (i<3){
              zAttendeeURL = '<a href=' + unescape(this.Data.Member.AttendeeURLs[i]) + ' target=new >' + unescape(this.Data.Member.AttendeeNames[i]) + '</a>';
              zAttendants += zAttendeeURL;
              if ((i+1) < this.Data.Member.AttendeeNames.length && i != 2){
                zAttendants += ',';
              }
            }
          }
        } else {
          var zAttendants = '<strong>Attendants: </strong> None';
        }
        zAttendants += '  ';
        zAttendants += '<a href=' + unescape(this.Data.Member.ViewAttendeesURL) + ' target=new >  (View All)</a><br/>';
        this.DescriptionDiv.innerHTML += zAttendants;
        if (this.Data.Description.length > 85) {
          var zDescription = this.Data.Description.substring(0,85) + '...';
        } else {
          var zDescription = this.Data.Description;
        }
        this.DescriptionDiv.innerHTML += '<strong>Description: </strong>' + zDescription;
      this.Container.appendChild(this.DescriptionDiv);
      this.AttendFormDiv = CreateBasicElement('div', null, 'AttendingForm');
        this.QuestWillYouContainer = CreateBasicElement('div', null, 'FormLine SelectIconContainer');
        this.QuestWillYouLabel = CreateBasicElement('label', null, 'AttendingLabel');
          this.QuestWillYouLabel.innerHTML = 'Will you attend this event: ';
        this.QuestWillYouContainer.appendChild(this.QuestWillYouLabel);
          this.QuestWillYouYes = CreateBasicElement('div', null, 'SelectIcon');
            this.QuestWillYouYes.title = 'Yes I will';
            appendEventHandler(this.QuestWillYouYes, 'onclick', this.switchAttendingTo, {ParentEvent: this, AttendingChoice: 'Y'});
          this.QuestWillYouContainer.appendChild(this.QuestWillYouYes);
          this.QuestWillYouNo = CreateBasicElement('div', null, 'SelectIcon');
            this.QuestWillYouNo.title = 'No I won\'t';
            appendEventHandler(this.QuestWillYouNo, 'onclick', this.switchAttendingTo, {ParentEvent: this, AttendingChoice: 'N'});
          this.QuestWillYouContainer.appendChild(this.QuestWillYouNo);
          this.QuestWillYouMaybe = CreateBasicElement('div', null, 'SelectIcon');
            this.QuestWillYouMaybe.title = 'I might';
            appendEventHandler(this.QuestWillYouMaybe, 'onclick', this.switchAttendingTo, {ParentEvent: this, AttendingChoice: 'M'});
          this.QuestWillYouContainer.appendChild(this.QuestWillYouMaybe);
        this.AttendFormDiv.appendChild(this.QuestWillYouContainer);
        if (this.Data.Member.ClassList && this.Data.Member.ClassList.length > 0) {
          this.QuestClassContainer = CreateBasicElement('div', null, 'FormLine SelectClassContainer');
            this.QuestClassLabel = CreateBasicElement('label');
              this.QuestClassLabel.innerHTML = 'Your class: ';
            this.QuestClassContainer.appendChild(this.QuestClassLabel);
            this.QuestClassSelect = CreateBasicElement('select');
            this.QuestClassEmpty = CreateBasicElement('option'); this.QuestClassSelect.appendChild(this.QuestClassEmpty);
            for (var i = 0; i < this.Data.Member.ClassList.length; i++) {
              zClass = CreateBasicElement('option');
              zClass.innerHTML = unescape(this.Data.Member.ClassList[i]);
              zClass.value = i + 1;
              if (zClass.value == this.Data.Member.CurrentClass) {
                zClass.selected = true;
              }
              this.QuestClassSelect.appendChild(zClass);
            }
            this.QuestClassContainer.appendChild(this.QuestClassSelect);
          this.AttendFormDiv.appendChild(this.QuestClassContainer);
        }
        this.QuestCommentContainer = CreateBasicElement('div');
          this.QuestCommentLabel = CreateBasicElement('label');
            this.QuestCommentLabel.innerHTML = 'Comment:';
          this.QuestCommentContainer.appendChild(this.QuestCommentLabel);
          this.QuestComment = CreateBasicElement('textarea');
          if (this.Data.Member.Comment) {
            this.QuestComment.value = unescape(this.Data.Member.Comment);
          }
          this.QuestCommentContainer.appendChild(this.QuestComment);
        this.AttendFormDiv.appendChild(this.QuestCommentContainer);
        this.QuestButtonsContainer = CreateBasicElement('div');
          this.QuestCancel = CreateBasicElement('input');
            this.QuestCancel.type = 'submit';
            this.QuestCancel.value = 'Cancel';
            appendEventHandler(this.QuestCancel, 'onclick', this._shade, this);
          this.QuestButtonsContainer.appendChild(this.QuestCancel);
          this.QuestAccept = CreateBasicElement('input');
            this.QuestAccept.type = 'submit';
            this.QuestAccept.value = 'Save';
            appendEventHandler(this.QuestAccept, 'onclick', this._save, this);
          this.QuestButtonsContainer.appendChild(this.QuestAccept);
        this.AttendFormDiv.appendChild(this.QuestButtonsContainer);
      this.Container.appendChild(this.AttendFormDiv);
      this.refreshIcon();
    }
    this.build = function() {
      this.Container = CreateBasicElement('div', null, 'Event');
      if (this.AddDetails){
        this.detailedQuickView();
      } else {
        this.quickView();
      }
      this.Container.ParentObject = this;
    }
    this.save = function() {
      aPostValues = {
        aAttending: this.TmpAttending,
        aCurrentClass: this.QuestClassSelect ? this.QuestClassSelect.value : null,
        aComment: this.QuestComment.value
      };
      LiveRequest_PostRequest(this.Data.Member.EventBaseURL + '.AddAttendee', aPostValues, this.saveComplete, this);
    }
    this._save = function(e, aParent) { aParent.save(); }
    this.saveComplete = function(aReturnCode, aParent) {
      switch (aReturnCode) {
        case 200:
          aParent.Data.Member.Attending = aParent.TmpAttending;
          aParent.Data.Member.Comment = aParent.QuestComment.value;
          aParent.Data.Member.CurrentClass = aParent.QuestClassSelect ? aParent.QuestClassSelect.value : null;
          aParent.shade();
          break;
        default:
          LiveGroup.WM.Error("The form has not been completely filled out.");
      }
    }
    this.setWillYouPos = function(aElement, aTrigger, aBase) {
      if (this.TmpAttending == aTrigger) {
        aElement.style.backgroundPosition = aBase + ' -14px';
      } else {
        aElement.style.backgroundPosition = aBase + ' 0';
      }
    }
    this.switchAttendingTo = function(e, aOpt) {
      aOpt.ParentEvent.TmpAttending = aOpt.AttendingChoice;
      aOpt.ParentEvent.refreshAttending();
    }
    this.refreshAttending = function() {
      this.setWillYouPos(this.QuestWillYouYes, 'Y', '-14px');
      this.setWillYouPos(this.QuestWillYouNo, 'N', '0');
      this.setWillYouPos(this.QuestWillYouMaybe, 'M', '-28px');
    }
    this.unshade = function() {
      if (!(this.IsShaded)) return true;
      if ((this.Data.IsMember != "Y") || LiveGroup.Login.UserInformation.LoggedInStatus != "Y") {
        LiveGroup.WM.Error('You have to be logged-in and a member of this team to see/attend events.');
        return true;
      }
      if (!(this.AddDetails)){
        this.ParentList.hideAllBut(this);
      }
      this.fullView();
      this.refreshAttending();
      this.IsShaded = false;
    }
    this._unshade = function(e, aParent) { aParent.unshade(); }
    this.shade = function() {
      this.Container.removeChild(this.AttendFormDiv);
      this.DescriptionDiv.innerHTML = this.Data.Description.length > this.DescriptionSize ? this.Data.Description.substring(0, this.DescriptionSize) + '...' : this.Data.Description;
      if (this.AddDetails){
        this.detailedQuickView();
      } else {
        this.quickView();
      }
      this.ParentList.restoreAll();
      this.refreshIcon();
      this.IsShaded = true;
    }
    this._shade = function(e, aParent) { aParent.shade(); }
    this.refreshIcon = function() {
      if (this.Data.Member)
        aAttending = this.Data.Member.Attending;
      else
        aAttending = '';
      switch (aAttending) {
        case 'Y':
          this.IconDiv.title = 'You are attending this event.';
          this.IconDiv.style.backgroundPosition = '-14px 0';
          break;
        case 'N':
          this.IconDiv.title = 'You are not attending this event.';
          this.IconDiv.style.backgroundPosition = '0 0';
          break;
        case 'M':
          this.IconDiv.title = 'You will maybe attend this event.';
          this.IconDiv.style.backgroundPosition = '-28px 0';
          break;
        default:
          if (LiveGroup.Login.UserInformation.LoggedInStatus == "Y") {
            this.IconDiv.title = 'You didn\'t make a decision yet.';
          } else {
            this.IconDiv.title = 'Team members can login to know their current status.';
          }
          this.IconDiv.style.backgroundPosition = '-42px 0';
          break;
      }
    }
    this.refresh = function(aTitleSize, aAttending) {
      if (aTitleSize != null && aTitleSize != this.TitleSize) {
        this.TitleSize = aTitlesize;
        this.TitleDiv.innerHTML = this.Data.Title.substring(0, this.TitleSize) + '...';
      }
      if (aAttending != null && aAttending != this.Data.Member.Attending) {
        this.refreshIcon();
      }
    }
    this.Data.Title = unescape(this.Data.Title);
    this.Data.Description = unescape(this.Data.Description);
    this.build();
    this.refreshIcon();
  },
  EventList: function(aItemBaseURL, aDisplayCount, aStartRow, aAddDetails) {
    this.ItemBaseURL = aItemBaseURL;
    this.TitleSize = 30;
    this.DescriptionSize = 70;
    this.Events = new Array();
    if (aDisplayCount){
      this.DisplayCount = aDisplayCount;
    } else {
      this.DisplayCount = 11;
    }
    if (aStartRow){
      this.StartRow = aStartRow;
    } else {
      this.StartRow = 1;
    }
    if (aAddDetails){
      this.AddDetails = true;
    } else {
      this.AddDetails = false;
    }
    this.build = function() {
      count = 1;
      LiveGroup.Calendar.EventCount = this.Data[(this.Data.length - 1)].TotalCount;
      if (this.Data.length == 2){
        LiveGroup.Calendar.EventCount = 0;
        var zNoEvents = DOM.createElement("div", null, "NoEventsText Event");
        zNoEvents.innerHTML = "There are no upcoming events scheduled.  If this is your player/team site and you would like to add an event, make sure you are logged in and go to the month or day tab in the calendar section.";
        this.Container.appendChild(zNoEvents);
      }
      for (var i = 0; i < this.Data.length; i++) {
        if (this.Data[i] == null) break;
        if (count > this.DisplayCount) break;
        this.Events[i] = new LiveGroup.SiteModules.EventViewer.EventItem(this, this.Data[i], this.TitleSize, this.DescriptionSize, this.AddDetails);
        this.Container.appendChild(this.Events[i].Container);
        count++;
      }
    }
    this.refresh = function() {
      for (var i = 0; i < this.Events.length; i++) {
        this.Events[i].refresh();
      }
    }
    this.hideAllBut = function(aEvent) {
      for (var i = 0; i < this.Events.length; i++) {
        if (this.Events[i] != aEvent) {
          this.Events[i].Container.style.display = 'none';
        }
      }
    }
    this.restoreAll = function(aEvent) {
      for (var i = 0; i < this.Events.length; i++) {
        this.Events[i].Container.style.display = 'block';
      }
    }
    this.load = function() {
      LiveRequest_MakeRequest(this.ItemBaseURL + '.GetEventsJSON?aRowCount=' + this.DisplayCount + '&aStartRow=' + this.StartRow, this.receiveData, this);
    }
    this.receiveData = function(aData, aParent) {
      aParent.Data = aData;
      aParent.build();
    }
    this.Container = CreateBasicElement('div');
    this.load();
  }
}
LiveGroup.SiteModules.Module = function() {
  this.type = "module";
  this.modname = "-noname-";
  this.build = function(aWidth) {};
  this.refresh = function(aWidth) {};
  this.showHover = function() {
    if (!(this.Coords)) {
      this.getCoords();
    }
    if (this.Column.Layout.Editing) {
      if (!(this.Hover)) {
        this.Hover = new LiveGroup.Hover(this);
      }
      this.Hover.show();
    }
  }
  this._showHover = function(e, aParent) { aParent.showHover(); }
  this.init = function() {
    this.Container.ParentObject = this;
  }
  this.getCoords = function() {
    this.Coords = DOM.getAbsolutePosition(this.Container);
    this.Coords.Width = parseInt(this.Container.parentNode.offsetWidth);
    this.Coords.Height = parseInt(this.Container.offsetHeight);
    return this.Coords;
  }
  this.killHover = function() {
    if (this.Hover) {
      this.Hover.die();
      delete this.Hover;
    }
  }
  this.remove = function() {
    alert('die!');
  }
  this.configPanel = function() {
    alert('configMe!');
  }
}
LiveGroup.SiteModules.ImageMod = function(aImageURL) {
  this.modname = "ImageMod";
  this.build = function(aWidth,aHeight) {
    this.Container = DOM.createElement('div', null, 'ImageMod');
    this.img = DOM.createElement('img');
    this.img.src = aImageURL;
    this.Container.appendChild(this.img);
    this.refresh(aWidth,aHeight);
    this.init();
  }
  this.refresh = function(aWidth,aHeight) {
    var zDifference = (aWidth - aHeight);
    if (zDifference < 0) {
      aHeight = "auto";
      aWidth = aWidth + "px";
    } else {
      aHeight = aHeight + "px";
      aWidth = "auto";
    }
    this.img.style.width = aWidth;
    this.img.style.height = aHeight;
  }
  this.getNatural = function() {
    if (this.img.naturalHeight) {
      this.naturalWidth = this.img.naturalWidth;
      this.naturalHeight = this.img.naturalHeight;
    } else {
      lgi = new Image();
      lgi.src = this.img.src;
      this.naturalWidth = lgi.width;
      this.naturalHeight = lgi.height;
      delete lgi;
    }
    this.naturalRatio = lgi.width / lgi.height;
  }
}
LiveGroup.SiteModules.ImageMod.prototype = new LiveGroup.SiteModules.Module;
var DOM = {
  createElement: function(aTagName, aId, aClassName, aStyle) {
    return CreateBasicElement(aTagName,aId,aClassName,aStyle);
  },
  getAbsolutePosition: function(aContainer) {
    return getAbsolutePosition(aContainer);
  },
  addEvent: function (aElement, aEvent, aFunction, aParamObject) {
    appendEventHandler(aElement, aEvent, aFunction, aParamObject);
  },
  addClass: function(aElement,aClass){
    aElement.className = aElement.className.addClass(aClass);
    return true;
  }
}
LiveGroup.SwitchOver = {
  Init: function() {
    var zTab = getElementsWithAttribute('TabArea');
    zTab.forEach(function(zTab){
      zTabInfo = new Object();
      zTabInfo.AreaId = zTab.getAttribute('TabArea');
      zTabInfo.Id = zTab.getAttribute('id');
      appendEventHandler(zTab,'onclick',LiveGroup.SwitchOver.DisplayTab,zTabInfo);
      var zTabArea = $(zTabInfo.AreaId);
      if (zTab.getAttribute('selected') == 'Y') {
        zTabArea.style.zIndex = '2';
        zTabArea.style.display = 'block';
      }
    });
  },
  DisplayTab: function(aItemArray,aParamObj) {
    zTabArea = $(aParamObj.AreaId);
    LiveGroup.SwitchOver.SelectedType = zTabArea.getAttribute('Type');
    this.setAttribute('Type',LiveGroup.SwitchOver.SelectedType);
      var zSelectedTab = getElementsWithAttribute('selected','Y');
      zSelectedTab.forEach(function(zSelectedTab){
        if (zSelectedTab.getAttribute('Type') == LiveGroup.SwitchOver.SelectedType) {
          zSelectedTab.className = 'UnSelectedTab LG_ColorAlt2InactiveBack LG_ColorAlt2InactiveFront';
          $(zSelectedTab.getAttribute('TabArea')).style.zIndex = '1';
          $(zSelectedTab.getAttribute('TabArea')).style.display = 'none';
        }
      });
    this.className = 'SelectedTab LG_ColorAlt2ActiveBack LG_ColorAlt2ActiveFront LG_ColorAlt2ActiveBackForBorder';
    this.setAttribute('selected','Y');
    zTabArea.style.display = 'block';
    zTabArea.style.zIndex = '2';
    LiveGroup.SwitchOver.CurrentArea = zTabArea;
    return true;
  }
}
appendEventHandler(window, 'onload', LiveGroup.Login.Init);
appendEventHandler(window, 'onload', RemoveLink.Init);
appendEventHandler(window, 'onload', LiveGroup.Security.Init);
appendEventHandler(window, 'onload', LiveGroup.InfoBoxInit);
appendEventHandler(window, 'onload', LiveGroup.PickThumb.Init);
appendEventHandler(window, 'onload', LiveGroup.Skins.Init);
appendEventHandler(window, 'onload', LiveGroup.Refacer.Init);
  // PSA_Traffic.ModuleJS
  // HierarchySelect.ModuleJS
function HierarchySelect(aParams){
  this.Name        = aParams.Name;
  this.Trigger     = aParams.Trigger;
  this.Input       = aParams.Input;
  this.Container   = aParams.Container;
  this.AcceptButton      = aParams.AcceptButton;
  this.CancelButton      = aParams.CancelButton;
  this.GetDataAction    = aParams.GetDataAction;
  this.ExtraParams      = aParams.ExtraParams;
  this.Id          = aParams.Name;
  this.Level       = 0;
  this.ItemArray   = [];
  this.ItemList    = {};
  this.AddItem(aParams.Item,this);
  this.OnChangeFunction = aParams.OnChangeFunction || function(){};
  this.OnCompleteFunction = aParams.OnCompleteFunction || function(){};
  HierarchySelect.Selects[this.Name] = this;
  this.Init();
}
HierarchySelect.prototype.Init = function(){
  var zStartItem = this.ItemArray[0];
  appendEventHandler(this.Trigger,'onclick',HierarchySelect.Handler.Show,{HierarchySelect:this});
  appendEventHandler(this.AcceptButton,'onclick',HierarchySelect.Handler.Accept,{HierarchySelect:this});
  appendEventHandler(this.CancelButton,'onclick',HierarchySelect.Handler.Cancel,{HierarchySelect:this});
  this.InitialLoad();
}
HierarchySelect.NONE = 0;
HierarchySelect.SOME = 1;
HierarchySelect.ALL  = 2;
HierarchySelect.prototype.InitialLoad = function(){
  aPathArray = [];
  if(this.Input.value){
    aPathArray = this.Input.value.split(',');
  }
  var zStartItem = this.ItemArray[0];
  function PathToObject(aObject,aPath){
    var zSubItems = aPath.substr(aObject.ItemPath.length+1).split('\\');
    var zAliasPath = [];
    var zParent = aObject;
    zSubItems.forEach(function(aAlias){
      zAliasPath.push(aAlias);
      var zThisPath = aObject.ItemPath+'\\'+zAliasPath.join('\\');
      if(!aObject.LookupList[zThisPath]){
        aObject.LookupList[zThisPath] = zParent.ItemList[zThisPath] = {
          ItemPath:zThisPath,
          ItemList:{}
        };
      }
      zParent = zParent.ItemList[zThisPath];
    });
    aObject.LookupList[aPath].Selected = true;
  }
  var zLoader = {
    ItemPath:zStartItem.ItemPath,
    Selected:false,
    ItemList:{},
    LookupList:{}
  };
  aPathArray.forEach(function(aPath){
    PathToObject(zLoader,aPath);
  });
  this.RequestData({HierarchySelect:this,Item:zStartItem,LoadItemList:zLoader.ItemList});
}
HierarchySelect.Selects = {};
HierarchySelect.CloseAllOtherSelects = function(aSelect){ // should this even exist?
  var zSelect;
  for(zSelect in HierarchySelect.Selects){
    if(HierarchySelect.Selects[zSelect] != aSelect){
      HierarchySelect.Selects[zSelect].Hide();
    }
  }
}
HierarchySelect.ReceiveData = function(aResults,aParams){
  var zSelect = aParams.HierarchySelect;
  aResults.forEach(function(aItem){
    zSelect.AddItem(aItem,aParams.Item);
  });
  if(aParams.LoadItemList){
    for(var zItem in aParams.LoadItemList){
      var zLoadItem = aParams.LoadItemList[zItem];
      var zThisItem = zSelect.GetItemByPath(aParams.Item,zLoadItem.ItemPath);
      if(isTrue(zThisItem.HasSubItems)){
        zSelect.RequestData({HierarchySelect:zSelect,Item:zThisItem,LoadItemList:zLoadItem.ItemList,PreSelect:zLoadItem.Selected});
      }
      zThisItem.Selected = zLoadItem.Selected;
    }
  }
  zSelect.ShowSubItems(aParams.Item);
}
HierarchySelect.Handler = {
  Show:function(e,aParams){
    aParams.HierarchySelect.Show();
    return true;
  },
  ToggleSelected:function(e,aParams){
    aParams.HierarchySelect.ToggleSelected(aParams.Item);
    return true;
  },
  ToggleSubItems:function(e,aParams){
    aParams.HierarchySelect.ToggleSubItems(aParams.Item);
    return true;
  },
  HideLevel:function(e,aParams){
    aParams.HierarchySelect.HideLevel(aParams.Level);
  },
  SelectAll:function(e,aParams){
    aParams.HierarchySelect.SelectAll(aParams.Level);
    return true;
  },
  Accept:function(e,aParams){
    aParams.HierarchySelect.Accept();
  },
  Cancel:function(e,aParams){
    aParams.HierarchySelect.Cancel();
  }
};
HierarchySelect.prototype.ShowSubItems = function(aItem){
  var zSubItems = $('SubItems_'+ this.Id +'_'+ aItem.Id);
  if(!zSubItems||hasAttribute(zSubItems,'class','Loading')){
    this.CreateSubItems(aItem);
    zSubItems = $('SubItems_'+ this.Id +'_'+ aItem.Id);
  }
  zSubItems.setAttribute('open','Y');
  RemoveClass($('Level_'+ this.Id +'_'+ aItem.Level),'Hidden');
  AddClass(zSubItems,'Show');
  if($('Item_'+ this.Id +'_'+ aItem.Id)){
    AddClass($('Item_'+ this.Id +'_'+ aItem.Id),'Open');
  }
}
HierarchySelect.prototype.CreateSubItems = function(aItem){
  var zLevel = $('LevelDiv_'+ this.Id +'_'+ aItem.Level);
  if(!zLevel){
    this.CreateLevel(aItem);
    zLevel = $('LevelDiv_'+ this.Id +'_'+ aItem.Level);
  }
  var zContainer = $('SubItems_'+ this.Id +'_'+ aItem.Id);
  if(!zContainer){
    zContainer = CreateBasicElement('DIV','SubItems_'+ this.Id +'_'+ aItem.Id,'List Show');
    zContainer.setAttribute('open','Y');
    zContainer.Item = aItem;
    zLevel.appendChild(zContainer);
  }
  if(aItem.ItemArray.length==0){
    if(!hasAttribute(zContainer,'Loading')){
      AddClass(zContainer,'Loading');
      zContainer.innerHTML = 'Loading...';
      this.RequestData({HierarchySelect:this,Item:aItem});
    }
  }else{
    RemoveClass(zContainer,'Loading');
    zContainer.innerHTML = '';
    var zSelect = this;
    if(aItem.Level>1){
      var zHeading = CreateBasicElement('h4',null,'text-align:center;');
      zHeading.innerHTML = aItem.DisplayName;
      zContainer.appendChild(zHeading);
    }
    aItem.ItemArray.forEach(function(aSubItem){
      var zItem = CreateBasicElement('DIV','Item_'+ zSelect.Id +'_'+ aSubItem.Id,'Item');
      var zIcon = CreateBasicElement('DIV','Icon_'+ zSelect.Id +'_'+ aSubItem.Id,'Icon');
      var zDisplayName = CreateBasicElement('DIV','DisplayName_'+ zSelect.Id +'_'+ aSubItem.Id,'DisplayName');
      zIcon.setAttribute('itemtype','Icon');
      zIcon.setAttribute('hoverable','Y');
      zIcon.setAttribute('hoverclass','IconHover');
      if(isTrue(aSubItem.HasSubItems)){
        zDisplayName.setAttribute('hoverable','Y');
        zDisplayName.setAttribute('hoverclass','DisplayNameHover');
      }
      zItem.appendChild(zIcon);
      zItem.appendChild(zDisplayName);
      zDisplayName.innerHTML = aSubItem.DisplayName;
      zItem.setAttribute('itemtype',(isTrue(aSubItem.HasSubItems) ? 'Group':'Item'));
      zItem.Item = aSubItem;
      if(isTrue(aSubItem.HasSubItems)){
        AddClass(zItem,'HasSubItems');
      }
      if(aSubItem.Selected){
        AddClass(zItem,'Selected');
      }
      zContainer.appendChild(zItem);
    });
    Widgets.Update(zContainer);
    aItem.ItemArray.forEach(function(aSubItem){
      var zDiv = $('Item_'+ zSelect.Id +'_'+ aSubItem.Id);
      var zIcon = $('Icon_'+ zSelect.Id +'_'+ aSubItem.Id);
      var zDisplayName = $('DisplayName_'+ zSelect.Id +'_'+ aSubItem.Id);
      var zParams = {
        HierarchySelect:zSelect,
        Item:aSubItem,
        Element:zDiv,
        IsGroup:hasAttribute(zDiv,'class','Group')
      };
      if(hasAttribute(zDiv,'class','HasSubItems')){
        appendEventHandler(zDisplayName,'onclick',HierarchySelect.Handler.ToggleSubItems,zParams);
      }
      appendEventHandler(zIcon,'onclick',HierarchySelect.Handler.ToggleSelected,zParams);
    });
  }
}
HierarchySelect.prototype.CreateLevel = function(aItem){
  var zTRow = $('TRow_'+ this.Id);
  if(!zTRow){
    var zTable = CreateBasicElement('table','Table_'+ this.Id);
    var zTBody = CreateBasicElement('tbody','TBody_'+ this.Id);
    var zTRow = CreateBasicElement('tr','TRow_'+ this.Id);
    zTable.appendChild(zTBody);
    zTBody.appendChild(zTRow);
    this.Container.appendChild(zTable);
  }
  var zTD = CreateBasicElement('td','Level_'+ this.Id +'_'+ aItem.Level ,'Level');
  var zDiv = CreateBasicElement('DIV','LevelDiv_'+ this.Id +'_'+ aItem.Level,'LevelDiv');
  var zHtml = [];
  zHtml.push('<h3><label class="WrapInput" for="All_'+ this.Id +'_'+ aItem.Level +'" id="Label_'+ this.Id +'_'+ aItem.Level +'"><input type="checkbox" name="All_'+ this.Id +'_'+ aItem.Level +'" id="All_'+ this.Id +'_'+ aItem.Level +'" value="" />All</label>');
  if(aItem.Level>1){
    zHtml.push('<div id="LevelClose_'+ this.Id +'_'+ aItem.Level +'" class="LevelClose">X</div>');
  }
  zHtml.push('</h3>');
  zHtml.push('<div class="ListContainer" id="ListContainer_'+ this.Id +'_'+ aItem.Level +'"></div>');
  setInnerHTML(zDiv, zHtml.join('\n') );
  zTD.appendChild(zDiv);
  zTRow.appendChild(zTD);
  appendEventHandler($('All_'+ this.Id +'_'+ aItem.Level),'onclick',HierarchySelect.Handler.SelectAll,{HierarchySelect:this,Level:aItem.Level});
  if(aItem.Level>1){
    appendEventHandler($('LevelClose_'+ this.Id +'_'+ aItem.Level),'onclick',HierarchySelect.Handler.HideLevel,{HierarchySelect:this,Level:aItem.Level});
  }
}
HierarchySelect.prototype.ToggleSubItems = function(aItem){
  var zElement = $('SubItems_'+ this.Id +'_'+ aItem.Id);
  if(zElement&&hasAttribute(zElement,'class','Show')){
    this.HideSubItems(aItem);
  }else{
    this.ShowSubItems(aItem);
  }
}
HierarchySelect.prototype.HideSubItems = function(aItem){
  this.HideSubItemsRecurse(aItem);
}
HierarchySelect.prototype.HideSubItemsRecurse = function(aHideItem){
  var zSelect = this;
  var zElement = $('SubItems_'+ zSelect.Id +'_'+ aHideItem.Id);
  if(zElement){
    aHideItem.ItemArray.forEach(function(aSubItem){
      zSelect.HideSubItemsRecurse(aSubItem);
    });
    zElement.setAttribute('open','N');
    RemoveClass($('Item_'+ zSelect.Id +'_'+ aHideItem.Id),'Open');
    RemoveClass(zElement,'Show');
    var zLevelContainer = $('Level_'+ zSelect.Id +'_'+ aHideItem.Level);
    var zLevelSubItems = getElementsWithAttribute('open','Y','DIV',zLevelContainer);
    if(zLevelSubItems.length==0){
      AddClass(zLevelContainer,'Hidden');
    }
  }
}
HierarchySelect.prototype.HideLevel = function(aLevel){
  var zSelect = this;
  var zLevel = aLevel;
  var zSubItems;
  while($('Level_'+ this.Id +'_'+ zLevel)){
    zSubItems = getElementsWithAttribute('open','Y','DIV',$('Level_'+ this.Id +'_'+ aLevel));
    zSubItems.forEach(function(aSubItem){
      zSelect.HideSubItemsRecurse(aSubItem.Item);
    });
    zLevel++;
  }
}
HierarchySelect.prototype.SelectItem = function(aItem){
  aItem.Selected = true;
  AddClass($('Item_'+ this.Id +'_'+ aItem.Id),'Selected');
}
HierarchySelect.prototype.DeselectItem = function(aItem){
  aItem.Selected = false;
  RemoveClass($('Item_'+ this.Id +'_'+ aItem.Id),'Selected');
}
HierarchySelect.prototype.ToggleSelected = function(aItem){
  if(aItem.Selected){
    this.DeselectItem(aItem);
  }else{
    this.SelectItem(aItem);
  }
  this.OnChangeFunction(aItem,aItem.Selected);
}
HierarchySelect.prototype.SelectAll = function(aLevel){
  var zIsChecked = $('All_'+ this.Id +'_'+ aLevel).checked;
  var zAllItems = getElementsWithAttribute('class','Item','DIV',$('Level_'+ this.Id +'_'+ aLevel));
  var zSelect = this;
  zAllItems.forEach(function(aElement){
    if(zIsChecked){
      zSelect.SelectItem(aElement.Item);
    }else{
      zSelect.DeselectItem(aElement.Item);
    }
  });
}
HierarchySelect.prototype.AddItem = function(aItem,aParentItem){
  var zLevel = aParentItem.Level + 1;
  if(!aParentItem.ItemList['i_'+ aItem.Id]){
    aParentItem.ItemList['i_'+ aItem.Id] = aItem;
    aParentItem.ItemArray.push(aItem);
    aItem.ParentItem    = aParentItem;
    aItem.ItemList      = {};
    aItem.ItemArray     = [];
    aItem.Selected      = false;
    aItem.Level         = zLevel;
    aItem.SubItemStatus  = HierarchySelect.NONE;
  }
}
HierarchySelect.prototype.RequestData = function(aParams){
  LiveRequest_MakeRequest(aParams.Item.ItemPath.toPagePath() +'.'+ this.GetDataAction + '?'+ this.ExtraParams ,HierarchySelect.ReceiveData,aParams);
}
HierarchySelect.prototype.Show = function(){
  AddClass(this.Container,'Show');
  var zCoords = getAbsolutePosition(this.Trigger);
  this.Container.style.left = (zCoords.x + 20) +'px';
  this.Container.style.top = (zCoords.y + 10) +'px';
  HierarchySelect.CloseAllOtherSelects(this);
}
HierarchySelect.prototype.Accept = function(){
  function GetSelectedRecurse(aItem,aArray){
    if(aItem.Selected){ aArray.push(aItem.ItemPath); }
    aItem.ItemArray.forEach(function(aSubItem){
      GetSelectedRecurse(aSubItem,aArray);
    });
  }
  var zSelected = [];
  GetSelectedRecurse(this,zSelected)
  this.Input.value = zSelected.join(',');
  this.OnCompleteFunction();
  this.Hide();
}
HierarchySelect.prototype.Cancel = function(){
  var zSelect = this;
  this.Hide();
  var zLevels = getElementsWithAttribute('class','Level','td',zSelect.Container);
  zLevels.forEach(function(aElement){
    aElement.parentNode.removeChild(aElement);
  });
  this.ItemArray.forEach(function(aItem){
    aItem.ItemList      = {};
    aItem.ItemArray     = [];
  });
  this.InitialLoad();
}
HierarchySelect.prototype.Hide = function(){
  RemoveClass(this.Container,'Show');
}
HierarchySelect.prototype.GetItemByPath = function(aParentItem,aItemPath){
  for(var zItem in aParentItem.ItemList){
    if(aParentItem.ItemList[zItem].ItemPath == aItemPath){
      return aParentItem.ItemList[zItem];
    }
  }
  return null;
}
  // LiveCalendar.ModuleJS
  // Cox_Traffic.ModuleJS
  // LiveContent.ModuleJS
function HighlightButton (aID){
  document.getElementById('NoImageContainer').style.border = 'none';
  document.getElementById('LeftImageContainer').style.border = 'none';
  document.getElementById('RightImageContainer').style.border = 'none';
  document.getElementById('TopImageContainer').style.border = 'none';
  document.getElementById(aID).style.border="3px coral solid";
}
var fAttachList = new AttachmentContainer('fAttachList');
  // LiveChat.ModuleJS
var LiveChat = {
  ToggleForm:'',
  ChatObject: function (aLogAlias, aSaveURL, aGetURL, aDisplayCount, aCommentsContainer, aTextAreaContainer, aMaxCommentsPerPage) {
    this.saveURL = aSaveURL;
    this.getURL = aGetURL;
    this.logAlias = aLogAlias;
    this.commentCount = 0;
    this.displayCount = aDisplayCount;
    this.CommentsContainer = aCommentsContainer;
    this.CommentContainerDiv = document.getElementById('Weblog_' + this.logAlias + '_CommentsContainer');
    this.TextAreaContainer = aTextAreaContainer;
    this.maxCommentsPerPage = aMaxCommentsPerPage;
    this.currentPage = 1;
    this.previousButton = document.getElementById('Weblog_' + aLogAlias + '_PreviousPage');
    this.nextButton = document.getElementById('Weblog_' + aLogAlias + '_NextPage');
    this.buttonsContainer = document.getElementById('Weblog_' + aLogAlias + '_ButtonsContainer');
    this.nextActive = true;
    this.previousActive = true;
    if (this.previousButton != null)
      appendEventHandler(this.previousButton, 'onclick', this.PreviousPage, this);
    if (this.previousButton != null)
      appendEventHandler(this.nextButton, 'onclick', this.NextPage, this);
    return true;
  },
  SwitchView: function(e,aChatObject) {
    var zButtonsVisibility;
    var zActivateLink_Object = $('Weblog_' + aChatObject.logAlias + '_PostComment');
    if (LiveChat.ToggleForm!='Y') {
      aChatObject.CommentsContainer.style.display = 'none';
      aChatObject.TextAreaContainer.style.display = 'block';
      zActivateLink_Object.innerHTML = 'X Cancel';
      zButtonsVisibility = 'hidden';
      LiveChat.ToggleForm = 'Y';
    } else {
      aChatObject.CommentsContainer.style.display = 'block';
      aChatObject.TextAreaContainer.style.display = 'none';
      zActivateLink_Object.innerHTML = 'Post Comment';
      zButtonsVisibility = 'visible';
      LiveChat.ToggleForm = 'N';
    }
    if (aChatObject.CommentContainerDiv != null && aChatObject.CommentContainerDiv.childNodes.length > aChatObject.maxCommentsPerPage) {
      aChatObject.buttonsContainer.style.visibility = zButtonsVisibility;
    }
    return true;
  }
}
LiveChat.ChatObject.prototype.NextPage = function (e, aLogObject) {
  if (aLogObject.nextActive) {
    aLogObject.currentPage++;
    aLogObject.RefreshComments();
  }
  return true;
}
LiveChat.ChatObject.prototype.PreviousPage = function (e, aLogObject) {
  if (aLogObject.previousActive) {
    aLogObject.currentPage--;
    aLogObject.RefreshComments();
  }
  return true;
}
LiveChat.ChatObject.prototype.Save = function () {
  var zDate = new Date();
  var zAmPm = 'am';
  var zMinutes = zDate.getMinutes();
  if (zMinutes < 10) zMinutes = '0' + zMinutes;
  var zHours = zDate.getHours();
  if (zHours > 12) { zHours -= 12; zAmPm = 'pm'; }
  if (zHours == 0) zHours = 12;
  var zYears = zDate.getFullYear();
  var zDateString = (zDate.getMonth()+1) + '/' + zDate.getDate() + '/' + zYears + ' ' + zHours + ':' + zMinutes + ' ' + zAmPm;
  var aPostValues = {'inpNewComment':$('inpNewComment_' + this.logAlias).value,'aLogAlias':this.logAlias,'aCommentDate': zDateString, 'aCurrentCommentCount':this.commentCount};
  $('inpNewComment_' + this.logAlias).disabled = true;
  if(LiveChat.ToggleForm!='') {
    LiveChat.SwitchView(null,this);
  }
  LiveRequest_PostRequest(this.saveURL, aPostValues, this.OnLoadFunction, this);
  $('inpNewComment_' + this.logAlias).value = '';
}
LiveChat.ChatObject.prototype.GetComments = function () {
  var aPostValues = {'aLogAlias':this.logAlias, 'aCurrentCommentCount':this.commentCount};
  LiveRequest_PostRequest(this.getURL, aPostValues, this.OnLoadFunction, this);
}
LiveChat.ChatObject.prototype.OnLoadFunction = function (aArray, aLogObject) {
  if ($('inpNewComment_' + aLogObject.logAlias)) $('inpNewComment_' + aLogObject.logAlias).disabled = false;
  var zComments = '';
  var zFirstCommentIndex = 0;
  if (aLogObject.displayCount >= 0) zFirstCommentIndex = aArray.length - aLogObject.displayCount;
  if (zFirstCommentIndex < 0) zFirstCommentIndex = 0;
  if (aArray.length && aArray.length > aLogObject.commentCount) {
    for (var i = zFirstCommentIndex; i < aArray.length; i++) {
      var zEvenOdd = i % 2;
      var zAvatarTag = '';
      var zLinkOpenTag = '';
      var zLinkCloseTag = '';
      if (aArray[i]['CommentorAvatar'] != "")
        zAvatarTag = '<img class="LiveChat_MiniAvatar" src="' + unescape(aArray[i]['CommentorAvatar']) + '"alt="" />';
      if (aArray[i]['Commentor'] != 'Anonymous') {
        zLinkOpenTag = '<a href="' + unescape(aArray[i]['CommentorPage']) + '">';
        zLinkCloseTag = '</a>';
      }
      zComments += '<div style="display:none;" class="LogComment LogComment_' + zEvenOdd + '">' + zLinkOpenTag + zAvatarTag + '<span class="CommentorSpan">' + unescape(aArray[i]['Commentor']) + '</span>:' + zLinkCloseTag + ' <span class="LogCommentDate">' + unescape(aArray[i]['CommentDate']) + ':</span>' + unescape(aArray[i]['Comment']) + '</div>';
    }
    $('Weblog_' + aLogObject.logAlias + '_CommentsContainer').innerHTML = zComments;
    aLogObject.RefreshComments();
    aLogObject.commentCount = aArray.length;
  }
}
LiveChat.ChatObject.prototype.RefreshComments = function () {
  if (this.CommentContainerDiv == null)
    return true;
  var pageStart = this.maxCommentsPerPage * (this.currentPage - 1);
  var pageStop = this.maxCommentsPerPage * this.currentPage - 1;
  if (this.CommentContainerDiv.childNodes.length > this.maxCommentsPerPage) {
    this.buttonsContainer.style.visibility = 'visible';
  }
  if (this.currentPage != 1) {
    this.previousButton.style.backgroundPosition = '0 -9px';
    this.previousActive = true;
  } else {
    this.previousButton.style.backgroundPosition = '0 0';
    this.previousActive = false;
  }
  if (pageStop < this.CommentContainerDiv.childNodes.length) {
    this.nextButton.style.backgroundPosition = '0 -9px';
    this.nextActive = true;
  } else {
    this.nextButton.style.backgroundPosition = '0 0';
    this.nextActive = false;
  }
  for (var i = 0; i < this.CommentContainerDiv.childNodes.length; i++) {
    if (i >= pageStart && i <= pageStop) {
      this.CommentContainerDiv.childNodes[i].style.display = 'block';
    } else {
      this.CommentContainerDiv.childNodes[i].style.display = 'none';
    }
  }
}
  // AccessManager.ModuleJS
  // LiveAdvert.ModuleJS
// End ModuleJS:Action_ModuleJS
var Layout = {
  ScaleTo:function(aParams){
    aParams.MinWidth = aParams.MinWidth || 1;
    aParams.MinHeight = aParams.MinHeight || 1;
    var zScale = Math.min(aParams.MaxWidth/aParams.Width,aParams.MaxHeight/aParams.Height);
    if(zScale*aParams.Width<aParams.MinWidth || zScale*aParams.Height<aParams.MinHeight ){
      zScale = Math.max(aParams.MinWidth/aParams.Width,aParams.MinHeight/aParams.Height);
    }
    return zScale;
  },
  getDisplayAspectRatio:function(aAspectRatio){
    var zAspectRatio = aAspectRatio.split(":");
    if(zAspectRatio[0] == 1 || zAspectRatio[1] == 1) {
      zAspectRatio[0] *= 2;
      zAspectRatio[1] *= 2;
    }
    return zAspectRatio[0] + ":" + zAspectRatio[1];
  },
  CreateWireframe:function(aParams){
    aParams.MaxWidth = aParams.MaxWidth || 250;
    aParams.MaxHeight = aParams.MaxHeight || 250;
    aParams.MinWidth = aParams.MinWidth || 1;
    aParams.MinHeight = aParams.MinHeight || 1;
    aParams.PageSpacing = aParams.PageSpacing || 10;
    aParams.IdField = aParams.IdField || 'DisplayName';
    aParams.BorderWidth = (typeof aParams.BorderWidth != "undefined" ? aParams.BorderWidth : 1);
    aParams.Layout.PageArray = aParams.Layout.PageArray || [];
    var zPageCount = aParams.Layout.PageCount || 1;
    var i,zPageData,zBackground;
    var zLeftOffset,zTopOffset;
    var zVertical = (aParams.Layout.Width > aParams.Layout.Height);
    var zOutput = {
      Multiplier:1,
      Background:null,
      Container:null,
      EmptyArea:null,
      AreaList:{},
      AreaArray:[],
      PageArray:[]
    };
    zOutput.Multiplier = Layout.ScaleTo({
      Width:aParams.Layout.Width,
      Height:aParams.Layout.Height,
      MaxWidth:aParams.MaxWidth,
      MaxHeight:aParams.MaxHeight,
      MinWidth:aParams.MinWidth,
      MinHeight:aParams.MinHeight
    });
    zOutput.Container = CreateBasicElement("div", null, "LayoutWireframe");
    var zBackgroundWidth = (aParams.UseBackground ? 17:0);
    if(aParams.Layout.PageArray.length<=0) {
      for(i=1; i<=zPageCount; i++) {
        aParams.Layout.PageArray.push({Width: aParams.Layout.Width, Height: aParams.Layout.Height});
      }
    }
    var zMaxPageWidth = 0;
    var zMaxPageHeight = 0;
    var zTotalPageWidth = 0;
    var zTotalPageHeight = 0;
    var zContainerWidth,zContainerHeight;
    aParams.Layout.PageArray.forEach(function(aPage) {
      var zWidth = (zOutput.Multiplier * parseFloat(aPage.Width))-(aParams.BorderWidth*2)+zBackgroundWidth;
      var zHeight = (zOutput.Multiplier * parseFloat(aPage.Height))-(aParams.BorderWidth*2);
      aPage.BasePageWidth = zWidth;
      aPage.BasePageHeight = zHeight;
      if(zWidth>zMaxPageWidth) {
        zMaxPageWidth = zWidth;
      }
      if(zHeight>zMaxPageHeight) {
        zMaxPageHeight = zHeight;
      }
      zTotalPageWidth += zWidth;
      zTotalPageHeight += zHeight;
    });
    if(zVertical){
      var zContainerWidth = zMaxPageWidth;
      var zContainerHeight = zTotalPageHeight + ((zPageCount-1)*aParams.PageSpacing);
    }else{
      var zContainerWidth = zTotalPageWidth + ((zPageCount-1)*aParams.PageSpacing);
      var zContainerHeight = zMaxPageHeight;
    }
    zOutput.Container.style.height = zContainerHeight + "px";
    zOutput.Container.style.width =  zContainerWidth+ "px";
    zOutput.EmptyArea = CreateBasicElement("div", null, "EmptyArea");
    zOutput.EmptyArea.style.height = zContainerHeight + "px";
    zOutput.EmptyArea.style.width = zContainerWidth + "px";
    zOutput.Container.appendChild(zOutput.EmptyArea);
    var zPageSpacingOffsetWidth = 0;
    var zPageSpacingOffsetHeight = 0;
    for(i=1;i<=zPageCount;i++){
      var zBasePageWidth = aParams.Layout.PageArray[i-1].BasePageWidth;
      var zBasePageHeight = aParams.Layout.PageArray[i-1].BasePageHeight;
      zPageData = {
        Width:aParams.Layout.PageArray[i-1].Width,
        Height:aParams.Layout.PageArray[i-1].Height,
        BasePageWidth: zBasePageWidth,
        BasePageHeight: zBasePageHeight,
        PageSpacingOffsetWidth: zPageSpacingOffsetWidth,
        PageSpacingOffsetHeight: zPageSpacingOffsetHeight,
        AspectRatio:aParams.Layout.AspectRatio,
        Duration:aParams.Layout.Duration || 0,
        Number:(aParams.Layout.IsSequence == "Y" ? 1:i),
        Id:"Page"+i,
        Background:null,
        AreaArray:[]
      };
      if(zVertical){
        zTopOffset = zPageSpacingOffsetHeight +((i-1)*aParams.PageSpacing);
        zLeftOffset = zBackgroundWidth;
      }else{
        zTopOffset = 0;
        zLeftOffset = zPageSpacingOffsetWidth +((i-1)*aParams.PageSpacing) +zBackgroundWidth;
      }
      zPageSpacingOffsetWidth += zBasePageWidth;
      zPageSpacingOffsetHeight += zBasePageHeight;
      zPageData.EmptyArea = CreateBasicElement("div", null, "EmptyPageArea");
      zPageData.EmptyArea.style.top = zTopOffset + "px";
      zPageData.EmptyArea.style.left = zLeftOffset + "px";
      zPageData.EmptyArea.style.height = zBasePageHeight + "px";
      zPageData.EmptyArea.style.width = (zBasePageWidth-zBackgroundWidth) + "px";
      zOutput.Container.appendChild(zPageData.EmptyArea);
      zOutput.PageArray.set(zPageData,zPageData.Id);
      zOutput.Container.appendChild(zPageData.EmptyArea);
    }
    if(aParams.UseBackground){
      for(i=1;i<=zPageCount;i++){
        zPageData = zOutput.PageArray.get("Page"+i);
        var zBasePageWidth = zPageData.BasePageWidth;
        var zBasePageHeight = zPageData.BasePageHeight;
        if(zVertical){
          zTopOffset = zPageData.PageSpacingOffsetHeight +((i-1)*aParams.PageSpacing);
          zLeftOffset = 0;
        }else{
          zTopOffset = 0;
          zLeftOffset = zPageData.PageSpacingOffsetWidth +((i-1)*aParams.PageSpacing);
        }
        zBackground = CreateBasicElement("div", null, "Area BackgroundArea");
        zBackground.style.width = "15px";
        zPageData.AspectRatio = aspectRatio(zPageData.Width,zPageData.Height);
        zBackground.style.height = (Math.max((zOutput.Multiplier * zPageData.Height),12)-12) + "px";
        zBackground.style.left = (zLeftOffset) + "px";
        zBackground.style.top = (zTopOffset+6) + "px";
        zBackground.setAttribute('area_aspect','Background'+ i +'_'+ zPageData.AspectRatio);
        zBackground.setAttribute('areaname_aspect','Background'+ zPageData.Number +'_'+ zPageData.AspectRatio);
        zBackground.setAttribute('areaid','Background'+ i);
        zBackground.setAttribute('areaname','Background'+ zPageData.Number);
        zBackground.setAttribute('aspectratio',zPageData.AspectRatio);
        zPageData.Background = zBackground;
        zOutput.Container.appendChild(zBackground);
      }
      zOutput.Background = zOutput.PageArray[0].Background;
    }
    var zAreaArray = aParams.Layout.AreaArray || aParams.Layout.Areas;
    zAreaArray.forEach(function(aArea){
      var zPageNumber = (aArea.PageNumber ? aArea.PageNumber:1);
      var zPageId = "Page" + zPageNumber;
      var zAreaElement = CreateBasicElement("div", null, "Area");
      zPage = zOutput.PageArray.get(zPageId);
      var zBasePageWidth = zPage.BasePageWidth;
      var zBasePageHeight = zPage.BasePageHeight;
      if(zVertical){
        zTopOffset = zPage.PageSpacingOffsetHeight +((zPageNumber-1)*aParams.PageSpacing);
        zLeftOffset = 0;
      }else{
        zTopOffset = 0;
        zLeftOffset = zPage.PageSpacingOffsetWidth +((zPageNumber-1)*aParams.PageSpacing);
      }
      zAreaElement.setAttribute('areaname_aspect',aArea.DisplayName +'_'+ aArea.AspectRatio);
      zAreaElement.setAttribute('area_aspect',aArea[aParams.IdField] +'_'+ aArea.AspectRatio);
      zAreaElement.setAttribute('areaid',aArea[aParams.IdField]);
      zAreaElement.setAttribute('areaname',aArea.DisplayName);
      zAreaElement.setAttribute('aspectratio',aArea.AspectRatio);
      zOutput.AreaList[aArea[aParams.IdField]] = zAreaElement;
      zOutput.AreaArray.push(zAreaElement);
      if(zPage){
        zPage.AreaArray.set(zAreaElement,aArea[aParams.IdField]);
      }
      zAreaElement.style.left = ((aArea.Left * zOutput.Multiplier) + zLeftOffset + zBackgroundWidth) + "px";
      zAreaElement.style.top = ((aArea.Top * zOutput.Multiplier) + zTopOffset )+ "px";
      var zDimension = ((aArea.Width * zOutput.Multiplier)-(aParams.BorderWidth*2));
      if (zDimension < 1) {zDimension = 1;}
      zAreaElement.style.width = zDimension + "px";
      zDimension = ((aArea.Height * zOutput.Multiplier)-(aParams.BorderWidth*2));
      if (zDimension < 1) {zDimension = 1;}
      zAreaElement.style.height = zDimension + "px";
      zOutput.Container.appendChild(zAreaElement);
    });
    return zOutput;
  },
  ShowAssetPreview:function(e,aAsset){
    e = fixEvent(e);
    if(Layout.CurrentAssetPreview){
      Layout.HideAssetPreview(Layout.CurrentAssetPreview);
    }
    Layout.CurrentAssetPreview = aAsset;
    if(aAsset._PreviewElement) {
      aAsset._PreviewElement.style.display = "block";
    } else {
      var zURL = aAsset.ViewFullThumbnailURL;
      var zContainer = CreateBasicElement("div",null,"AssetPreviewContainer");
      var zImg = CreateBasicElement("img");
      var zHeading = CreateBasicElement("div",null,"AssetPreviewHeader");
      zHeading.innerHTML = 'close preview';
      zImg.src    = aAsset.ViewFullThumbnailURL;
      zImg.width  = aAsset.ViewFullThumbnailWidth;
      zImg.height = aAsset.ViewFullThumbnailHeight;
      zContainer.appendChild(zHeading);
      zContainer.appendChild(zImg);
      aAsset._PreviewElement = zContainer;
      document.body.appendChild(zContainer);
      appendEventHandler(aAsset._PreviewElement, "onclick", Layout.HideAssetPreview.bind(Layout,aAsset));
    }
    PlaceElementInView(aAsset._PreviewElement, null, e.clientX + 10, e.clientY + 10);
    return true;
  },
  HideAssetPreview:function(aAsset){
    Layout.CurrentAssetPreview = null;
    aAsset._PreviewElement.style.display = "none";
    return true;
  }
};
Layout.CreateTimeline = function(aParams){
  aParams.Width = aParams.Width || 1000;
  aParams.Height = 20;
  aParams.IdField = aParams.IdField || 'DisplayName';
  aParams.BorderWidth = (typeof aParams.BorderWidth != "undefined" ? aParams.BorderWidth : 1);
  var zOutput = {
    Multiplier:1,
    Background:null,
    Container:null,
    EmptyArea:null,
    AreaList:{},
    AreaArray:[],
    PageArray:[],
    Header:null,            // timeline
    Background:null,        // video/imagery
    TrackArray:[],           // Track elements, indexed by Track Number (1 based) with ".set"
    TrackList:[]           // Track elements, indexed by Track Number (1 based) with ".set"
  };
  zOutput.Multiplier = (aParams.Width/aParams.Layout.Duration);
  zOutput.Container = CreateBasicElement("div", null, "LayoutTimeline");
  zOutput.Container.style.width = aParams.Width +'px';
  zOutput.Header = CreateBasicElement("div", null, "LayoutTimelineHeader");
  zOutput.Header.innerHTML = 'header'
  zOutput.Container.appendChild(zOutput.Header);
  aParams.Layout.AreaArray.forEach(function(aArea){
    SetArea(aArea);
  });
  zOutput.Background = CreateBasicElement("div", null, "LayoutTimelineHeader");
  zOutput.Background.innerHTML = 'background'
  zOutput.Container.appendChild(zOutput.Background);
  return zOutput;
  function SetTrack(aArea){
    var zTrack = zOutput.TrackList[aArea.DisplayName];
    if(!zTrack){
      zTrack = CreateBasicElement("div", null, "Track");
      zTrack.id = 'Track_'+ aArea[aParams.IdField];
      zTrack.style.width = aParams.Width;
      zTrack.style.height = aParams.Height + "px";
      zOutput.TrackArray.push(zTrack);
      zOutput.TrackList[aArea.DisplayName] = zTrack;
      zOutput.Container.appendChild(zTrack);
    }
    return zTrack;
  }
  function SetArea(aArea){
    var zTrack = SetTrack(aArea);
    var zAreaElement = CreateBasicElement("div", null, "Area");
    zTrack.appendChild(zAreaElement);
    zAreaElement.innerHTML = aArea.DisplayName +' ('+ (parseInt(aArea.StartTime)/1000) +'-'+ ((parseInt(aArea.StartTime) + parseInt(aArea.Duration))/1000) +')';
    zAreaElement.setAttribute('area_aspect',aArea[aParams.IdField] +'_'+ aArea.AspectRatio);
    zAreaElement.setAttribute('areaname_aspect',aArea.DisplayName +'_'+ aArea.AspectRatio);
    zAreaElement.setAttribute('areaid',aArea[aParams.IdField]);
    zAreaElement.setAttribute('aspectratio',aArea.AspectRatio);
    zAreaElement.setAttribute('areaname',aArea.DisplayName);
    zOutput.AreaArray.push(zAreaElement,aArea[aParams.IdField]);
    zOutput.AreaList[aArea[aParams.IdField]] = zAreaElement;
    zAreaElement.style.left = (aArea.StartTime * zOutput.Multiplier) + "px";
    zAreaElement.style.top = 0;
    zAreaElement.style.width = (aArea.Duration * zOutput.Multiplier)+ "px";
    zAreaElement.style.height = aParams.Height + "px";
    return zAreaElement;
  }
}
function gcd(a, b) {
   if (b == 0) {
     return a
   } else {
     return gcd(b, a % b)
   }
}
function aspectRatio(a, b) {
  var c = gcd(a,b);
  return (a/c)+":"+(b/c);
}
var StopNavigation = {
  IsSubmitting:false,
  Init:function(){
    window.onbeforeunload = StopNavigation.OnBeforeUnload;
    appendEventHandler(document.forms[0],'onsubmit',StopNavigation.OnSubmit);
  },
  OnSubmit:function(){
    StopNavigation.IsSubmitting = true;
    return true;
  },
  OnBeforeUnload:function(aEvent){
    var zIsSubmitting = StopNavigation.IsSubmitting;
    StopNavigation.IsSubmitting = false;
    if(!zIsSubmitting){
      aEvent = (aEvent ? aEvent:window.event);
      zMessage = "If you leave this page, any changes you have made will not be saved.";
      aEvent.returnValue = zMessage;
      return zMessage;
    }
  }
};
var LiveFindSearch = {
  CategoryArray: [],
  InputsArray: [],
  SearchInputContainer: null,
  SearchCriteria: null,
  ExistingValues: [],
  Init: function(aCategories,aExistingValues) {
    LiveFindSearch.CategoryArray = aCategories.makeUnique('ItemPath');
    LiveFindSearch.ExistingValues = (aExistingValues) ? aExistingValues : [];
    LiveFindSearch.SearchInputContainer = $('SearchInputs');
    LiveFindSearch.SearchCriteria = {};
    return true;
  },
  Reset: function () {
    LiveFindSearch.SearchCriteria = {};
    LiveFindSearch.SearchInputContainer.innerHTML = '';
    LiveFindSearch.InputsArray = [];
    if(LiveFindSearch.ExistingValues.length>0) {
      LiveFindSearch.AddInputsWithValues();
    }
    else {
      LiveFindSearch.AddInputs();
    }
    return true;
  },
  AddInputsWithValues: function(e) {
    if(LiveFindSearch.ExistingValues&&LiveFindSearch.ExistingValues.length>0) {
      LiveFindSearch.ExistingValues.forEach(function (aExistingValue) {
        var zInput = LiveFindSearch.AddInputs(e, aExistingValue.Category, aExistingValue.Keywords);
        LiveFindSearch.SearchCriteria[zInput.CategorySelect.id] = {Category: aExistingValue.Category, Keywords: aExistingValue.Keywords};
      });
    }
  },
  AddInputs: function(e, aCategoryValue, aKeywordValue) {
    var zInputs = LiveFindSearch.CreateInputs(aCategoryValue, aKeywordValue);
    LiveFindSearch.InputsArray.push(zInputs);
    LiveFindSearch.SearchInputContainer.appendChild(zInputs.Container);
    return zInputs;
  },
  CreateInputs: function(aCategoryValue, aKeywordValue) {
    var zContainer = CreateBasicElement('DIV','InputContainer'+LiveFindSearch.InputsArray.length,'InputContainer');
    var zCategorySelect = LiveFindSearch.CreateCategorySelect(aCategoryValue);
    zContainer.appendChild(zCategorySelect);
    var zKeyword = LiveFindSearch.CreateKeywordInput(aKeywordValue);
    zContainer.appendChild(zKeyword.Container);
    zInputs = {Container: zContainer, CategorySelect: zCategorySelect, KeywordSelect: zKeyword};
    var aInputs = zInputs;
    zInputs.CategorySelect.onchange = function(){
      LiveFindSearch.GetCategoryData(aInputs);
    };
    fLoadSelectController.AddSelect(zInputs.CategorySelect);
    return zInputs;
  },
  CreateCategorySelect: function(aCategoryValue) {
    var zSelectInput = CreateBasicElement('SELECT','CategorySelect'+LiveFindSearch.InputsArray.length,'CategorySelect');
    var zBlankOption = CreateBasicElement('OPTION');
    zSelectInput.setAttribute('name', 'inpCategory');
    zSelectInput.id = 'inpCategory' + LiveFindSearch.InputsArray.length;
    if(aCategoryValue) {
      zSelectInput.setAttribute('selectedvalue', aCategoryValue);
      zSelectInput.value = aCategoryValue;
    }
    zSelectInput.setAttribute('smartselect', 'Y');
    zSelectInput.setAttribute('stylizedselect', 'Y');
    zSelectInput.setAttribute('src', '/voig/ContentList/LiveFindDatabaseList/H/HA/HAI/HairymopDatabase/CategoryList.GetSubItemData?aLanguage=en%2Dus');
    zSelectInput.appendChild(zBlankOption);
    return zSelectInput;
  },
  CreateKeywordInput: function(aKeywordValue) {
    var zKeywordContainer = CreateBasicElement('DIV','KeywordContainer'+LiveFindSearch.InputsArray.length,'KeywordContainer');
    var zLabel = CreateBasicElement('LABEL');
    var zKeywordInput = CreateBasicElement('INPUT','inpCategoryKeywords' + LiveFindSearch.InputsArray.length);
    var zKeywordResultsContainer = CreateBasicElement('DIV','CategoryKeywordResults'+LiveFindSearch.InputsArray.length,'ResultsContainer');
    zLabel.setAttribute('for', 'inpCategoryKeywords' + LiveFindSearch.InputsArray.length);
    zLabel.innerHTML = 'Category Keywords: ';
    zKeywordInput.setAttribute('type','text');
    zKeywordInput.setAttribute('name','inpCategoryKeywords');
    zKeywordInput.setAttribute('autocomplete','off');
    if(aKeywordValue) {
      zKeywordInput.setAttribute('value', aKeywordValue)
      zKeywordInput.value = aKeywordValue;
    }
    zKeywordContainer.appendChild(zLabel);
    zKeywordContainer.appendChild(zKeywordInput);
    zKeywordContainer.appendChild(zKeywordResultsContainer);
    return {Container: zKeywordContainer, Label: zLabel, Input: zKeywordInput, ResultsContainer: zKeywordResultsContainer};
  },
  AdjustInputs: function(aInputs) {
    var zCoords = getAbsolutePosition(aInputs.KeywordSelect.Input);
    aInputs.KeywordSelect.ResultsContainer.style.top = zCoords.y+20+'px';
    aInputs.KeywordSelect.ResultsContainer.style.left = zCoords.x+'px';
    aInputs.KeywordSelect.ResultsContainer.style.width = aInputs.KeywordSelect.Input.offsetWidth+'px';
  },
  GetCategoryData: function(aInputs) {
    if(LiveFindSearch.PreviousInputs && (aInputs == LiveFindSearch.PreviousInputs)) {
      var zPreviousInputs = LiveFindSearch.PreviousInputs;
      removeEventHandler(zPreviousInputs.KeywordSelect.Input,'onkeypress',LiveFindSearch.DisableEnter,zPreviousInputs);
      removeEventHandler(zPreviousInputs.KeywordSelect.Input,'onkeydown',LiveFindSearch.ClearFilterOptions,zPreviousInputs);
      removeEventHandler(zPreviousInputs.KeywordSelect.Input,'onkeyup',LiveFindSearch.HandleKeys,zPreviousInputs);
      removeEventHandler(zPreviousInputs.KeywordSelect.ResultsContainer,'onmouseover',LiveFindSearch.ForceOpenResultsContainer,zPreviousInputs);
      removeEventHandler(zPreviousInputs.KeywordSelect.ResultsContainer,'onmouseout',LiveFindSearch.ResetForceOpenResultsContainer,zPreviousInputs);
    }
    LiveFindSearch.PreviousInputs = aInputs;
    var zSelectedCategory = LiveFindSearch.CategoryArray.get(aInputs.CategorySelect.value);
    LiveFindSearch.ResetResultsContainer(null,aInputs)
    aInputs.KeywordSelect.Input.value ='';
    if(zSelectedCategory) {
      aInputs.SelectedCategory = zSelectedCategory;
      aInputs.OptionSelected = false;
      aInputs.SelectedCategory.SelectedOption = 0;
      aInputs.SelectedCategory.PreviousOption = 0;
      aInputs.SelectedCategory.NextOption = 0;
      if(zSelectedCategory && !zSelectedCategory.Options) {
        LiveRequest_MakeRequest( zSelectedCategory.ItemPath.toPagePath() + '.GetSubItemData', LiveFindSearch.LoadCategoryData, aInputs);
      }
      else if(zSelectedCategory && zSelectedCategory.Options) {
        LiveFindSearch.SetupKeywordInput(aInputs)
      }
    }
  },
  LoadCategoryData: function(aResults,aInputs) {
    if(aResults) {
      aInputs.SelectedCategory.Options = aResults;
      LiveFindSearch.SetupKeywordInput(aInputs)
    }
  },
  SetupKeywordInput: function(aInputs) {
    aInputs.CurrentOptions = null;
    appendEventHandler(aInputs.KeywordSelect.Input,'onkeypress',LiveFindSearch.DisableEnter,aInputs);
    appendEventHandler(aInputs.KeywordSelect.Input,'onkeydown',LiveFindSearch.ClearFilterOptions,aInputs);
    appendEventHandler(aInputs.KeywordSelect.Input,'onkeyup',LiveFindSearch.HandleKeys,aInputs);
    appendEventHandler(aInputs.KeywordSelect.Input,'onblur',LiveFindSearch.HideResultsContainer,aInputs);
    appendEventHandler(aInputs.KeywordSelect.ResultsContainer,'onmouseover',LiveFindSearch.ForceOpenResultsContainer,aInputs);
    appendEventHandler(aInputs.KeywordSelect.ResultsContainer,'onmouseout',LiveFindSearch.ResetForceOpenResultsContainer,aInputs);
    LiveFindSearch.AdjustInputs(aInputs);
  },
  HideResultsContainer: function (e,aInputs) {
    if(!aInputs.KeywordSelect.ResultsContainer.ForceOpen) {
      aInputs.KeywordSelect.ResultsContainer.style.display = 'none';
      aInputs.KeywordSelect.ResultsContainer.Open = false;
      LiveFindSearch.SetCriteria(aInputs);
    }
  },
  OpenResultsContainer: function(e,aInputs) {
    aInputs.KeywordSelect.ResultsContainer.style.display = 'block';
    aInputs.KeywordSelect.ResultsContainer.Open = true;
  },
  ForceOpenResultsContainer: function (e,aInputs) {
    aInputs.KeywordSelect.ResultsContainer.ForceOpen = true;
  },
  ResetForceOpenResultsContainer: function (e,aInputs) {
    aInputs.KeywordSelect.ResultsContainer.ForceOpen = false;
  },
  ResetResultsContainer: function(e,aInputs) {
    LiveFindSearch.HideResultsContainer(e,aInputs);
    aInputs.OptionSelected = false;
    aInputs.CurrentOptions = null;
    aInputs.KeywordSelect.ResultsContainer.innerHTML = '';
  },
  DisableEnter: function (e,aInputs) {
    if(e.keyCode==13) {
      return false;
    }
    return true;
  },
  HandleKeys: function(e,aInputs) {
    if(e.keyCode == 9) {
      return false;
    }
    else {
      if(e.keyCode == 38 || e.keyCode == 37) {
        if(aInputs.CurrentOptions&&aInputs.CurrentOptions.length>0&&aInputs.KeywordSelect.ResultsContainer.Open) {
          LiveFindSearch.SelectPreviousOption(aInputs);
        }
        return true;
      }
      else if(e.keyCode == 40 || e.keyCode == 39) {
        if(aInputs.CurrentOptions&&aInputs.CurrentOptions.length>0&&aInputs.KeywordSelect.ResultsContainer.Open) {
          LiveFindSearch.SelectNextOption(aInputs);
        }
        return true;
      }
      else if(e.keyCode == 27) {
        LiveFindSearch.HideResultsContainer(e,aInputs);
        return true;
      }
      else if(e.keyCode==13) {
        if(aInputs.OptionSelected) {
          LiveFindSearch.SelectOption(e,{Inputs: aInputs, Option: aInputs.CurrentOptions[aInputs.SelectedCategory.SelectedOption].Element});
        }
        LiveFindSearch.HideResultsContainer(null,aInputs);
        CsvInput.Set({Input: $('inpSearchCriteria')})
        aInputs.KeywordSelect.Input.form.submit();
        return true;
      }
      else {
        LiveFindSearch.SetFilterOptions(aInputs);
        return true;
      }
    }
    return true;
  },
  MakeOption: function(aInputs,aOption,aOptionInnerHTML) {
    var zOptionElement = CreateBasicElement('DIV', aInputs.CategorySelect.id+'_'+aOption.Id);
    zOptionElement.innerHTML = (aOptionInnerHTML) ? aOptionInnerHTML : aOption.DisplayName;
    zOptionElement.setAttribute('keyword', aOption.DisplayName);
    zOptionElement.setAttribute('selectgroup', aInputs.CategorySelect.id);
    aOption.Element = zOptionElement;
    MakeHoverable(zOptionElement);
    MakeSelectable(zOptionElement);
    appendEventHandler(zOptionElement,'onclick',LiveFindSearch.SelectOption,{Inputs: aInputs, Option: zOptionElement});
  },
  LoadOptions: function (aInputs) {
    if(aInputs.CurrentOptions.length>0) {
      aInputs.CurrentOptions.forEach(function (aOption) {
        aInputs.KeywordSelect.ResultsContainer.appendChild(aOption.Element);
      });
      LiveFindSearch.OpenResultsContainer(null,aInputs);
    }
    else {
      LiveFindSearch.HideResultsContainer(null,aInputs);
    }
  },
  FilterOptions: function(e,aInputs) {
    LiveFindSearch.ResetResultsContainer(e,aInputs);
    aInputs.CurrentOptions = new Array();
    if(aInputs.KeywordSelect.Input.value != '') {
      aInputs.SelectedCategory.Options.forEach(function(aOption) {
        var zString = aOption.DisplayName;
        var zSubString = aInputs.KeywordSelect.Input.value;
        if(zString.toUpperCase().indexOf(zSubString.toUpperCase())>=0) {
          var zRegEx = new RegExp('('+ escape(zSubString) +')','i');
          var zOptionInnerHTML = zString.replace(zRegEx,'<span class="MatchedText">$1</span>');
          LiveFindSearch.MakeOption(aInputs,aOption,zOptionInnerHTML);
          aInputs.CurrentOptions.push(aOption);
        }
      });
    }
    else {
      if(aInputs.SelectedCategory.Options.length<=51) {
        aInputs.SelectedCategory.Options.forEach(function(aOption) {
          LiveFindSearch.MakeOption(aInputs,aOption);
          aInputs.CurrentOptions.push(aOption);
        });
      }
    }
    LiveFindSearch.LoadOptions(aInputs);
    LiveFindSearch.AdjustInputs(aInputs);
  },
  SetFilterOptions: function (aInputs) {
    LiveFindSearch.FilterOptionsTimeout = setTimeout(function () {LiveFindSearch.FilterOptions(null,aInputs);},300);
  },
  ClearFilterOptions: function (e,aInputs) {
    if(LiveFindSearch.FilterOptionsTimeout) {
      clearTimeout(LiveFindSearch.FilterOptionsTimeout);
      LiveFindSearch.FilterOptionsTimeout = false;
    }
    if(e.keyCode ==  9) {
      if(aInputs.KeywordSelect.ResultsContainer.Open) {
        LiveFindSearch.SelectNextOption(aInputs);
        return false;
      }
    }
    return true;
  },
  SelectPreviousOption: function (aInputs) {
    var zSelectedOption = null;
    var zCurrentOption = null;
    if(aInputs.CurrentOptions.length>1) {
      zCurrentOption = aInputs.CurrentOptions[aInputs.SelectedCategory.SelectedOption];
      DeSelectElement(zCurrentOption.Element);
      if(aInputs.SelectedCategory.PreviousOption > 0) {
        aInputs.SelectedCategory.SelectedOption = aInputs.SelectedCategory.PreviousOption;
        aInputs.SelectedCategory.PreviousOption = ((aInputs.SelectedCategory.SelectedOption - 1)>=0) ? aInputs.SelectedCategory.SelectedOption - 1 : 0;
      }
      else if (aInputs.SelectedCategory.PreviousOption == 0) {
        aInputs.SelectedCategory.SelectedOption = aInputs.SelectedCategory.PreviousOption;
        aInputs.SelectedCategory.PreviousOption = aInputs.CurrentOptions.length-1;
      }
      else {
        aInputs.SelectedCategory.SelectedOption = aInputs.SelectedCategory.PreviousOption;
        aInputs.SelectedCategory.PreviousOption = aInputs.CurrentOptions.length-1;
      }
      aInputs.SelectedCategory.NextOption = ((aInputs.SelectedCategory.SelectedOption + 1)>aInputs.CurrentOptions.length-1) ? 0 : (aInputs.SelectedCategory.SelectedOption + 1);
    }
    else {
      aInputs.SelectedCategory.SelectedOption = 0;
      aInputs.SelectedCategory.PreviousOption = 0;
      aInputs.SelectedCategory.NextOption = 0;
    }
    zSelectedOption = aInputs.CurrentOptions[aInputs.SelectedCategory.SelectedOption];
    SelectElement(zSelectedOption.Element);
    LiveFindSearch.SelectOption(null,{Inputs: aInputs, Option: zSelectedOption.Element},true);
    LiveFindSearch.ScrollOptionIntoView(aInputs,zSelectedOption.Element);
    zSelectedOption.Element.focus();
    LiveFindSearch.AdjustInputs(aInputs);
  },
  SelectNextOption: function (aInputs) {
    var zSelectedOption = null;
    var zCurrentOption = null;
    zCurrentOption = aInputs.CurrentOptions[aInputs.SelectedCategory.SelectedOption];
    if(aInputs.CurrentOptions.length>1) {
      DeSelectElement(zCurrentOption.Element);
      if(aInputs.SelectedCategory.NextOption < (aInputs.CurrentOptions.length-1)) {
        aInputs.SelectedCategory.SelectedOption = aInputs.SelectedCategory.NextOption;
        aInputs.SelectedCategory.NextOption = aInputs.SelectedCategory.SelectedOption + 1;
      }
      else if(aInputs.SelectedCategory.NextOption == (aInputs.CurrentOptions.length-1)) {
        aInputs.SelectedCategory.SelectedOption = aInputs.SelectedCategory.NextOption;
        aInputs.SelectedCategory.NextOption = 0;
      }
      else {
        aInputs.SelectedCategory.SelectedOption = aInputs.SelectedCategory.NextOption;
        aInputs.SelectedCategory.NextOption = 1;
      }
      aInputs.SelectedCategory.PreviousOption = ((aInputs.SelectedCategory.SelectedOption - 1)>=0) ? aInputs.SelectedCategory.SelectedOption - 1 : 0;
    }
    else {
      aInputs.SelectedCategory.SelectedOption = 0;
      aInputs.SelectedCategory.PreviousOption = 0;
      aInputs.SelectedCategory.NextOption = 0;
    }
    zSelectedOption = aInputs.CurrentOptions[aInputs.SelectedCategory.SelectedOption];
    SelectElement(zSelectedOption.Element);
    LiveFindSearch.SelectOption(null,{Inputs: aInputs, Option: zSelectedOption.Element},true);
    LiveFindSearch.ScrollOptionIntoView(aInputs,zSelectedOption.Element);
    zSelectedOption.Element.focus();
    LiveFindSearch.AdjustInputs(aInputs);
  },
  SelectOption: function(e,aParams,aDoNotHide){
    aParams.Inputs.OptionSelected = true;
    aParams.Inputs.KeywordSelect.Input.value = aParams.Option.getAttribute('keyword');
    LiveFindSearch.ResetForceOpenResultsContainer(e,aParams.Inputs)
    LiveFindSearch.SetCriteria(aParams.Inputs);
    if(!aDoNotHide) {
      LiveFindSearch.HideResultsContainer(e,aParams.Inputs);
    }
  },
  SetCriteria: function (aInputs) {
    LiveFindSearch.SearchCriteria[aInputs.CategorySelect.id] = {Category: aInputs.CategorySelect.value, Keywords: aInputs.KeywordSelect.Input.value};
  },
  ScrollOptionIntoView: function(aInputs,aOption) {
    var zSelectTop = aInputs.KeywordSelect.ResultsContainer.scrollTop;
    var zSelectHeight = aInputs.KeywordSelect.ResultsContainer.offsetHeight;
    var zSelectBottom = zSelectTop + zSelectHeight;
    var zOptionTop = aOption.offsetTop;
    var zOptionHeight = aOption.offsetHeight;
    var zOptionBottom = zOptionTop + zOptionHeight;
    if(zOptionTop < zSelectTop) {
      aInputs.KeywordSelect.ResultsContainer.scrollTop = zOptionTop;
    }
    else if(zOptionBottom > zSelectBottom) {
      aInputs.KeywordSelect.ResultsContainer.scrollTop = (zOptionTop + zOptionHeight) - zSelectHeight;
    }
    return true;
  }
};
var RecentlySubmittedUI = {
  Current:null,
  ShowDelay:100,
  ShowDuration:300,
  HideDelay:300,
  HideDuration:150,
  GetSubmissions: function () {
    $('Loading').style.display = 'block';
    AddClass($('Loading'), 'Loading');
    LiveRequest_MakeRequest('/voig/ModuleList/Search/LiveFindSearch.GetSearchItemsJS?aLanguage=en%2Dus&aMaxResults=10',RecentlySubmittedUI.LoadSubmissions);
  },
  LoadSubmissions: function (aSubmissions) {
    var zHTMLArray = new Array();
    $('Loading').style.display = 'none';
    RemoveClass($('Loading'),'Loading');
    if(aSubmissions) {
      aSubmissions.forEach(function(aSubmission) {
        var zSubmissionThumbnail;
        var zSubmissionElement = CreateBasicElement('DIV','Submission_'+aSubmission.ObjectCode,'RecentSubmission');
        var zSubmissionDate = FloatDate(aSubmission.SubmissionDate)
        setInnerHTML(zSubmissionElement,'<a href="'+aSubmission.ItemPath.toPagePath()+'.ViewFull">' + aSubmission.DisplayName+'</a> - ' + (zSubmissionDate.getMonth()+1) + '/' +zSubmissionDate.getDate() + '/'+zSubmissionDate.getYear());
        if(aSubmission.ThumbnailURL||aSubmission.AssetText) {
          var zPreviewElement = CreateBasicElement('DIV','SubmissionPreview_'+aSubmission.ObjectCode,'SubmissionPreview');
          AddClass(zPreviewElement,'Hidden');
          if(aSubmission.ThumbnailURL) {
            zSubmissionThumbnail = new Image();
            zSubmissionThumbnail.src = aSubmission.ThumbnailURL;
            var zPreview = CreateBasicElement('IMG','PreviewImage_'+aSubmission.ObjectCode);
            zPreview.setAttribute('src', zSubmissionThumbnail.src);
            zPreviewElement.appendChild(zPreview);
          }
          else if(aSubmission.AssetText) {
           var zPreview = CreateBasicElement('DIV','PreviewText_'+aSubmission.ObjectCode);
           zPreview.innerHTML = aSubmission.AssetText.substr(0,512)+'...';
           zPreviewElement.appendChild(zPreview);
         }
          zSubmissionElement.Trigger = zSubmissionElement;
          zSubmissionElement.ZoomElement = zPreviewElement;
          zSubmissionElement.Image = zPreview;
          zSubmissionElement.ZoomElement.Trigger = zSubmissionElement;
          zSubmissionElement.ZoomElement.ZoomElement = zPreviewElement;
          zSubmissionElement.ZoomElement.Image = zPreview;
          appendEventHandler(zSubmissionElement.Trigger,'onmouseover',RecentlySubmittedUI.SetShow,zSubmissionElement);
          appendEventHandler(zSubmissionElement.Trigger,'onmouseout',RecentlySubmittedUI.SetHide,zSubmissionElement);
          appendEventHandler(zSubmissionElement.ZoomElement,'onmouseover',RecentlySubmittedUI.SetShow,zSubmissionElement);
          appendEventHandler(zSubmissionElement.ZoomElement,'onmouseout',RecentlySubmittedUI.SetHide,zSubmissionElement);
          zSubmissionElement.appendChild(zPreviewElement);
        }
        $('RecentlySubmittedItems').appendChild(zSubmissionElement);
      });
    }
  },
  SetShow:function(e,aElement){
    var zSelf = aElement.Trigger;
    aElement.IsOver = true;
    RecentlySubmittedUI.ClearHide(zSelf);
    if(!aElement.Trigger.ImageZoomShowing){
      var zClientY = getAbsolutePosition(aElement).y;
      aElement.Trigger.ShowTimeout = setTimeout(function(){
        RecentlySubmittedUI.Show(zSelf,zClientY);
      },RecentlySubmittedUI.ShowDelay);
    }
  },
  SetHide:function(e,aElement){
    aElement.IsOver = false;
    if(aElement.Trigger.ImageZoomShowing && !(aElement.Trigger.IsOver || aElement.ZoomElement.IsOver)){
      var zSelf = aElement.Trigger;
      clearTimeout(aElement.Trigger.ShowTimeout);
      this.Trigger.HideTimeout = setTimeout(function(){
        RecentlySubmittedUI.Hide(zSelf);
      },RecentlySubmittedUI.HideDelay);
    }
  },
  ClearHide:function(aElement){
    if(aElement.Trigger.HideTimeout){
      clearTimeout(aElement.Trigger.HideTimeout);
      aElement.Trigger.HideTimeout = null;
    }
  },
  Show:function(aElement,aStartPoint){
    if(RecentlySubmittedUI.Current){
      RemoveClass(RecentlySubmittedUI.Current.ZoomElement,'Show');
    }
    RecentlySubmittedUI.Current = aElement.Trigger;
    if(aElement.Trigger.IsOver){
      var zCoords = getAbsolutePosition(aElement)
      aElement.Trigger.ImageZoomShowing = true;
      aElement.Trigger.ShowTimeout = null;
      aElement.ZoomElement.style.top = (zCoords.y+15)+'px';
      aElement.ZoomElement.style.left = (zCoords.x+80)+'px';
      aElement.ZoomElement.style.opacity = '0';
      aElement.ZoomElement.style.filter = 'alpha(opacity=0)';
      aElement.ZoomElement.style.display = 'block';
      AddClass(aElement.ZoomElement,'Visible');
      RecentlySubmittedUI.FadeIn(aElement.Trigger,aStartPoint);
    }
  },
  Hide:function(aElement){
    aElement.Trigger.ImageZoomShowing = false;
    RecentlySubmittedUI.FadeOut(aElement.Trigger);
  },
  Close:function(e,aParams){
    if(aParams.Trigger.FadeType=='Out'){
      ReplaceClass(aParams.ZoomElement,'Visible','Hidden');
    }
  },
  FadeIn:function(aElement,aStartPoint){
    aElement.Trigger.FadeType = 'In';
    Tween.Run({
      Element:aElement.Trigger,
      Function:RecentlySubmittedUI.DoFadeIn,
      Duration:RecentlySubmittedUI.ShowDuration,
      StartPoint:aStartPoint,
      StartValue:0,
      EndValue:1,
      Method:'sineIn'
    });
  },
  FadeOut:function(aElement){
    aElement.Trigger.FadeType = 'Out';
    Tween.Run({
      Element:aElement.Trigger,
      Function:RecentlySubmittedUI.DoFadeOut,
      Duration:RecentlySubmittedUI.HideDuration,
      StartValue:1,
      EndValue:0,
      Method:'sineIn',
      OnCompleteFunction:function(aParams){
        RemoveClass(aParams.Element.ZoomElement,'Show');
      }
    });
  },
  DoFadeIn:function(aParams){
    if(aParams.Element.Trigger.FadeType=='In'){
      aParams.Element.ZoomElement.style.opacity = aParams.CurrentValue;
      aParams.Element.ZoomElement.style.filter = 'alpha(opacity=' + aParams.CurrentValue*100 + ')';
    }
  },
  DoFadeOut:function(aParams){
    if(aParams.Element.Trigger.FadeType=='Out'){
      aParams.Element.ZoomElement.style.opacity = aParams.CurrentValue;
      aParams.Element.ZoomElement.style.filter = 'alpha(opacity=' + aParams.CurrentValue*100 + ')';
    }
    if(aParams.CurrentValue == aParams.EndValue) {
      aParams.Element.ZoomElement.style.display = 'none';
    }
  }
};
function FloatDate(aValue) {
  if (aValue) {
    aValue = (parseFloat(aValue)-25569)*24*60*60*1000;
    var zDate = new Date(aValue);
    zDate.setMinutes(zDate.getMinutes()+zDate.getTimezoneOffset())
    return zDate;
  }
}
