// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
// ===================================================================
/* SOURCE FILE: AnchorPosition.js */
function getAnchorPosition(anchorname) {
   var useWindow = false;
   var coordinates = new Object();
   var x = 0, y = 0;
   var use_gebi = false, use_css = false, use_layers = false;
   if(document.getElementById) {
      use_gebi = true;
      }
   else if(document.all) {
      use_css = true;
      }
   else if(document.layers) {
      use_layers = true;
      }
   if(use_gebi && document.all) {
      x = AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
      y = AnchorPosition_getPageOffsetTop(document.all[anchorname]);
      }
   else if(use_gebi) {
      var o = document.getElementById(anchorname);
      x = AnchorPosition_getPageOffsetLeft(o);
      y = AnchorPosition_getPageOffsetTop(o);
      }
   else if(use_css) {
      x = AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
      y = AnchorPosition_getPageOffsetTop(document.all[anchorname]);
      }
   else if(use_layers) {
      var found = 0;
      for(var i = 0; i < document.anchors.length; i++) {
         if(document.anchors[i].name == anchorname) {
            found = 1;
            break;
            }
         }
      if(found == 0) {
         coordinates.x = 0;
         coordinates.y = 0;
         return coordinates;
         }
      x = document.anchors[i].x;
      y = document.anchors[i].y;
      }
   else {
      coordinates.x = 0;
      coordinates.y = 0;
      return coordinates;
      }
   coordinates.x = x;
   coordinates.y = y;
   return coordinates;
   }
function getAnchorWindowPosition(anchorname) {
   var coordinates = getAnchorPosition(anchorname);
   var x = 0;
   var y = 0;
   if(document.getElementById) {
      if(isNaN(window.screenX)) {
         x = coordinates.x - document.body.scrollLeft + window.screenLeft;
         y = coordinates.y - document.body.scrollTop + window.screenTop;
         }
      else {
         x = coordinates.x + window.screenX + (window.outerWidth - window.innerWidth) - window.pageXOffset;
         y = coordinates.y + window.screenY + (window.outerHeight - 24 - window.innerHeight) - window.pageYOffset;
         }
      }
   else if(document.all) {
      x = coordinates.x - document.body.scrollLeft + window.screenLeft;
      y = coordinates.y - document.body.scrollTop + window.screenTop;
      }
   else if(document.layers) {
      x = coordinates.x + window.screenX + (window.outerWidth - window.innerWidth) - window.pageXOffset;
      y = coordinates.y + window.screenY + (window.outerHeight - 24 - window.innerHeight) - window.pageYOffset;
      }
   coordinates.x = x;
   coordinates.y = y;
   return coordinates;
   }
function AnchorPosition_getPageOffsetLeft(el) {
   var ol = el.offsetLeft;
   while((el = el.offsetParent) != null) {
      ol += el.offsetLeft;
      }
   return ol;
   }
function AnchorPosition_getWindowOffsetLeft(el) {
   return AnchorPosition_getPageOffsetLeft(el) - document.body.scrollLeft;
   }
function AnchorPosition_getPageOffsetTop(el) {
   var ot = el.offsetTop;
   while((el = el.offsetParent) != null) {
      ot += el.offsetTop;
      }
   return ot;
   }
function AnchorPosition_getWindowOffsetTop(el) {
   return AnchorPosition_getPageOffsetTop(el) - document.body.scrollTop;
   }
   
   
/* SOURCE FILE: PopupWindow.js */
function PopupWindow_getXYPosition(anchorname) {
   var coordinates;
   if(this.type == "WINDOW") {
      coordinates = getAnchorWindowPosition(anchorname);
      }
   else {
      coordinates = getAnchorPosition(anchorname);
      }
   this.x = coordinates.x;
   this.y = coordinates.y;
   }
function PopupWindow_setSize(width, height) {
   this.width = width;
   this.height = height;
   }
function PopupWindow_populate(contents) {
   this.contents = contents;
   this.populated = false;
   }
function PopupWindow_setUrl(url) {
   this.url = url;
   }
function PopupWindow_setWindowProperties(props) {
   this.windowProperties = props;
   }
function PopupWindow_refresh() {
   if(this.divName != null) {
      if(this.use_gebi) {
         document.getElementById(this.divName).innerHTML = this.contents;
         }
      else if(this.use_css) {
         document.all[this.divName].innerHTML = this.contents;
         }
      else if(this.use_layers) {
         var d = document.layers[this.divName];
         d.document.open();
         d.document.writeln(this.contents);
         d.document.close();
         }
      }
   else {
      if(this.popupWindow != null && !this.popupWindow.closed) {
         if(this.url != "") {
            this.popupWindow.location.href = this.url;
            }
         else {
            this.popupWindow.document.open();
            this.popupWindow.document.writeln(this.contents);
            this.popupWindow.document.close();
            }
         this.popupWindow.focus();
         }
      }
   }
function PopupWindow_showPopup(anchorname) {
   this.getXYPosition(anchorname);
   this.x += this.offsetX;
   this.y += this.offsetY;
   
   document.onMouseMove = function(e) {
	e = e || window.event;
	
	initMouseX = e || window.event;
	initMouseX = initMouseX.clientX;
	
	initMouseY = e || window.event;
	initMouseY = initMouseY.clientY;		
	
	alert(initMouseX + " - " + initMouseY);
	// moveDIV(initDIV, initDIVX - initMouseX + getX(e), initDIVY - initMouseY + getY(e));
   }
   
   if(!this.populated && (this.contents != "")) {
      this.populated = true;
      this.refresh();
      }
   
   if(this.divName != null) {
  
      if(this.use_gebi) {
         document.getElementById(this.divName).style.left = this.x + "px";
         document.getElementById(this.divName).style.top = this.y + "px";
         document.getElementById(this.divName).style.visibility = "visible";
         }
      else if(this.use_css) {
         document.all[this.divName].style.left = this.x;
         document.all[this.divName].style.top = this.y;
         document.all[this.divName].style.visibility = "visible";
         }
      else if(this.use_layers) {
         document.layers[this.divName].left = this.x;
         document.layers[this.divName].top = this.y;
         document.layers[this.divName].visibility = "visible";
         }
      }
   else {
      if(this.popupWindow == null || this.popupWindow.closed) {
         if(this.x < 0) {
            this.x = 0;
            }
         if(this.y < 0) {
            this.y = 0;
            }
         if(screen && screen.availHeight) {
            if((this.y + this.height) > screen.availHeight) {
               this.y = screen.availHeight - this.height;
               }
            }
         if(screen && screen.availWidth) {
            if((this.x + this.width) > screen.availWidth) {
               this.x = screen.availWidth - this.width;
               }
            }
         var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*']) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled);
         this.popupWindow = window.open(avoidAboutBlank ? "" : "about:blank", "window_" + anchorname, this.windowProperties + ",width=" + this.width + ",height=" + this.height + ",screenX=" + this.x + ",left=" + this.x + ",screenY=" + this.y + ",top=" + this.y + "");
         }
      this.refresh();
      }
   }
function PopupWindow_hidePopup() {
   if(this.divName != null) {
      if(this.use_gebi) {
         document.getElementById(this.divName).style.visibility = "hidden";
         }
      else if(this.use_css) {
         document.all[this.divName].style.visibility = "hidden";
         }
      else if(this.use_layers) {
         document.layers[this.divName].visibility = "hidden";
         }
      }
   else {
      if(this.popupWindow && !this.popupWindow.closed) {
         this.popupWindow.close();
         this.popupWindow = null;
         }
      }
   }
function PopupWindow_isClicked(e) {
    if(this.divName != null) {
        if(this.use_layers) {
            var clickX = e.pageX;
            var clickY = e.pageY;
            var t = document.layers[this.divName];
            if((clickX > t.left) && (clickX < t.left + t.clip.width) && (clickY > t.top) && (clickY < t.top + t.clip.height)) {
                return true;
            } else {
                return false;
            }
        } else if(document.all) {
            var t = window.event.srcElement;
            while(t.parentElement != null) {
                if(t.id == this.divName) {
                    return true;
                }
                t = t.parentElement;
            }
    		checkColor();
            return false;
        } else if(this.use_gebi && e) {
            var t = e.originalTarget;
            try{
                while(t.parentNode != null) {
                    if(t.id == this.divName) {
                        return true;
                    }
                    t = t.parentNode;
                }
            } catch(err){}
            checkColor();
            return false;
        }
        return false;
    }
    return false;
}
function PopupWindow_hideIfNotClicked(e) {
   if(this.autoHideEnabled && !this.isClicked(e)) {
      this.hidePopup();
      }
   }
function PopupWindow_autoHide() {
   this.autoHideEnabled = true;
   }
function PopupWindow_hidePopupWindows(e) {
   for(var i = 0; i < popupWindowObjects.length; i++) {
      if(popupWindowObjects[i] != null) {
         var p = popupWindowObjects[i];
         p.hideIfNotClicked(e);
         }
      }
   }
function PopupWindow_attachListener() {
   if(document.layers) {
      document.captureEvents(Event.MOUSEUP);
      }
   window.popupWindowOldEventListener = document.onmouseup;
   if(window.popupWindowOldEventListener != null) {
      document.onmouseup = new Function("window.popupWindowOldEventListener();PopupWindow_hidePopupWindows();");
      }
   else {
      document.onmouseup = PopupWindow_hidePopupWindows;
      }
   }
function PopupWindow() {
   if(!window.popupWindowIndex) {
      window.popupWindowIndex = 0;
      }
   if(!window.popupWindowObjects) {
      window.popupWindowObjects = new Array();
      }
   if(!window.listenerAttached) {
      window.listenerAttached = true;
      PopupWindow_attachListener();
      }
   this.index = popupWindowIndex++;
   popupWindowObjects[this.index] = this;
   this.divName = null;
   this.popupWindow = null;
   this.width = 0;
   this.height = 0;
   this.populated = false;
   this.visible = false;
   this.autoHideEnabled = false;
   this.contents = "";
   this.url = "";
   this.windowProperties = "toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";
   if(arguments.length > 0) {
      this.type = "DIV";
      this.divName = arguments[0];
      }
   else {
      this.type = "WINDOW";
      }
   this.use_gebi = false;
   this.use_css = false;
   this.use_layers = false;
   if(document.getElementById) {
      this.use_gebi = true;
      }
   else if(document.all) {
      this.use_css = true;
      }
   else if(document.layers) {
      this.use_layers = true;
      }
   else {
      this.type = "WINDOW";
      }
   this.offsetX = 0;
   this.offsetY = 0;
   this.getXYPosition = PopupWindow_getXYPosition;
   this.populate = PopupWindow_populate;
   this.setUrl = PopupWindow_setUrl;
   this.setWindowProperties = PopupWindow_setWindowProperties;
   this.refresh = PopupWindow_refresh;
   this.showPopup = PopupWindow_showPopup;
   this.hidePopup = PopupWindow_hidePopup;
   this.setSize = PopupWindow_setSize;
   this.isClicked = PopupWindow_isClicked;
   this.autoHide = PopupWindow_autoHide;
   this.hideIfNotClicked = PopupWindow_hideIfNotClicked;
   }
   
   
/* SOURCE FILE: ColorPicker2.js */
ColorPicker_targetInput = null;
function ColorPicker_writeDiv() {
   document.writeln("<DIV ID=\"colorPickerDiv\" STYLE=\"position:absolute;visibility:hidden;\"> </DIV>");
   }
function ColorPicker_show(anchorname) {
   this.showPopup(anchorname);
   }
function ColorPicker_pickColor(color, obj) {
   obj.hidePopup();
   pickColor(color);
   window.ColorPicker_entrycolor = - 1;
   }
function ColorPicker_hoverColor(color, obj) {
   pickColor(color);
   window.document.getElementById("colorPickerSelectedColorValue").innerHTML = color;
   }

function checkColor() {
	// alert(window.ColorPicker_entrycolor);
   if(window.ColorPicker_entrycolor != - 1) {
      changeColorBox(ColorPicker_targetBox, window.ColorPicker_entrycolor);
      }
   }
function pickColor(color) {
   if(ColorPicker_targetInput == null) {
      alert("Target Input is null, which means you either didn't use the 'select' function or you have no defined your own 'pickColor' function to handle the picked color!");
      return;
      }
   ColorPicker_targetInput.value = color.substring(1);
   changeColorBox(ColorPicker_targetBox, color);
   }
function ColorPicker_select(inputobj, linkname, outputbox) {
   if(inputobj.type != "text" && inputobj.type != "hidden" && inputobj.type != "textarea") {
      alert("colorpicker.select: Input object passed is not a valid form input object");
      window.ColorPicker_targetInput = null;
      return;
      }
   window.ColorPicker_targetInput = inputobj;
   window.ColorPicker_targetBox = outputbox;
   window.ColorPicker_entrycolor = $(window.ColorPicker_targetBox).style.backgroundColor;
   this.show(linkname);
   }
function ColorPicker_highlightColor(c) {
   var thedoc = (arguments.length > 1) ? arguments[1] : window.document;
   var d = thedoc.getElementById("colorPickerSelectedColor");
   d.style.backgroundColor = c;
   d = thedoc.getElementById("colorPickerSelectedColorValue");
   d.innerHTML = c;
   }
function ColorPicker() {
   window.ColorPicker_entrycolor = -1;
   ColorPicker_writeDiv();
   var windowMode = false;
   if(arguments.length == 0) {
      var divname = "colorPickerDiv";
      }
   else if(arguments[0] == "window") {
      var divname = '';
      windowMode = true;
      }
   else {
      var divname = arguments[0];
      }
   if(divname != "") {
      var cp = new PopupWindow(divname);
      }
   else {
      var cp = new PopupWindow();
      cp.setSize(225, 180);
      }
   cp.currentValue = "#FFFFFF";
   cp.writeDiv = ColorPicker_writeDiv;
   cp.highlightColor = ColorPicker_highlightColor;
   cp.show = ColorPicker_show;
   cp.select = ColorPicker_select;
   var colors = new Array("#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#ffd5d5", "#ffdfd5", "#ffead5", "#fff4d5", "#ffffd5", "#f4ffd5", "#eaffd5", "#dfffd5", "#d5ffd5", "#d5ffea", "#d5fff4", "#d5ffff", "#d5f4ff", "#d5eaff", "#d5dfff", "#d5d5ff", "#dfd5ff", "#ead5ff", "#f4d5ff", "#ffd5ff", "#ffd5f4", "#ffd5ea", "#ffd5df", "#ffaaaa", "#ffbfaa", "#ffd5aa", "#ffeaaa", "#ffffaa", "#eaffaa", "#d5ffaa", "#bfffaa", "#aaffaa", "#aaffbf", "#aaffea", "#aaffff", "#aaeaff", "#aad5ff", "#aabfff", "#aaaaff", "#bfaaff", "#d5aaff", "#eaaaff", "#ffaaff", "#ffaaea", "#ffaad5", "#ffaabf", "#ff8080", "#ff9f80", "#ffbf80", "#ffdf80", "#ffff80", "#dfff80", "#bfff80", "#9fff80", "#80ff80", "#80ff9f", "#80ffdf", "#80ffff", "#80dfff", "#80bfff", "#809fff", "#8080ff", "#9f80ff", "#bf80ff", "#df80ff", "#ff80ff", "#ff80df", "#ff80bf", "#ff809f", "#ff5555", "#ff8055", "#ffaa55", "#ffd555", "#ffff55", "#d5ff55", "#aaff55", "#80ff55", "#55ff55", "#55ff80", "#55ffd5", "#55ffff", "#55d5ff", "#55aaff", "#5580ff", "#5555ff", "#8055ff", "#aa55ff", "#d555ff", "#ff55ff", "#ff55d5", "#ff55aa", "#ff5580", "#ff2a2a", "#ff602a", "#ff952a", "#ffca2a", "#ffff2a", "#caff2a", "#95ff2a", "#60ff2a", "#2aff2a", "#2aff60", "#2affca", "#2affff", "#2acaff", "#2a95ff", "#2a60ff", "#2a2aff", "#602aff", "#952aff", "#ca2aff", "#ff2aff", "#ff2aca", "#ff2a95", "#ff2a60", "#ff0000", "#ff4000", "#ff8000", "#ffbf00", "#ffff00", "#bfff00", "#80ff00", "#40ff00", "#00ff00", "#00ff40", "#00ffbf", "#00ffff", "#00bfff", "#0080ff", "#0040ff", "#0000ff", "#4000ff", "#8000ff", "#bf00ff", "#ff00ff", "#ff00bf", "#ff0080", "#ff0040", "#d50000", "#d53500", "#d56a00", "#d59f00", "#d5d500", "#9fd500", "#6ad500", "#35d500", "#00d500", "#00d535", "#00d59f", "#00d5d5", "#009fd5", "#006ad5", "#0035d5", "#0000d5", "#3500d5", "#6a00d5", "#9f00d5", "#d500d5", "#d5009f", "#d5006a", "#d50035", "#aa0000", "#aa2b00", "#aa5500", "#aa8000", "#aaaa00", "#80aa00", "#55aa00", "#2baa00", "#00aa00", "#00aa2b", "#00aa80", "#00aaaa", "#0080aa", "#0055aa", "#002baa", "#0000aa", "#2b00aa", "#5500aa", "#8000aa", "#aa00aa", "#aa0080", "#aa0055", "#aa002b", "#800000", "#802000", "#804000", "#806000", "#808000", "#608000", "#408000", "#208000", "#008000", "#008020", "#008060", "#008080", "#006080", "#004080", "#002080", "#000080", "#200080", "#400080", "#600080", "#800080", "#800060", "#800040", "#800020", "#550000", "#551500", "#552b00", "#554000", "#555500", "#405500", "#2b5500", "#155500", "#005500", "#005515", "#005540", "#005555", "#004055", "#002b55", "#001555", "#000055", "#150055", "#2b0055", "#400055", "#550055", "#550040", "#55002b", "#550015", "#2b0000", "#2b0b00", "#2b1500", "#2b2000", "#2b2b00", "#202b00", "#152b00", "#0b2b00", "#002b00", "#002b0b", "#002b20", "#002b2b", "#00202b", "#00152b", "#000b2b", "#00002b", "#0b002b", "#15002b", "#20002b", "#2b002b", "#2b0020", "#2b0015", "#2b000b", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#000000", "#050505", "#0a0a0a", "#0f0f0f", "#151515", "#1a1a1a", "#1f1f1f", "#252525", "#2a2a2a", "#2f2f2f", "#353535", "#3a3a3a", "#3f3f3f", "#454545", "#4a4a4a", "#4f4f4f", "#555555", "#5a5a5a", "#5f5f5f", "#656565", "#6a6a6a", "#6f6f6f", "#757575", "#7a7a7a", "#858585", "#8a8a8a", "#8f8f8f", "#959595", "#9a9a9a", "#9f9f9f", "#a5a5a5", "#aaaaaa", "#afafaf", "#b5b5b5", "#bababa", "#bfbfbf", "#c5c5c5", "#cacaca", "#cfcfcf", "#d5d5d5", "#dadada", "#dfdfdf", "#e5e5e5", "#eaeaea", "#efefef", "#f5f5f5", "#fafafa" );
   var total = colors.length;
   var width = 23;
   var cp_contents = "";
   var windowRef = (windowMode) ? "window.opener." : "";
   if(windowMode) {
      cp_contents += "<HTML><HEAD><TITLE>Select Color</TITLE></HEAD>";
      cp_contents += "<BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0><CENTER>";
      }
   cp_contents += "<div style='border: 1px solid #333'><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>";
   var use_highlight = (document.getElementById || document.all) ? true : false;
   for(var i = 0; i < total; i++) {
      if((i % width) == 0) {
         cp_contents += "<TR>";
         }
      if(use_highlight) {
         var mo = 'onMouseOver="' + windowRef + 'ColorPicker_highlightColor(\'' + colors[i] + '\',window.document)"';
         }
      else {
         mo = "";
         }
      cp_contents += '<TD BGCOLOR="' + colors[i] + '"><FONT SIZE="-3"><A HREF="#" onClick="' + windowRef + 'ColorPicker_pickColor(\'' + colors[i] + '\',' + windowRef + 'window.popupWindowObjects[' + cp.index + ']);return false;" onmouseover="' + windowRef + 'ColorPicker_hoverColor(\'' + colors[i] + '\',' + windowRef + 'window.popupWindowObjects[' + cp.index + ']);return false;" ' + mo + ' STYLE="text-decoration:none;">&nbsp;&nbsp;&nbsp;</A></FONT></TD>';
      if( ((i + 1) >= total) || (((i + 1) % width) == 0)) {
         cp_contents += "</TR>";
         }
      }
   if(document.getElementById) {
      var width1 = Math.floor(width / 2);
      var width2 = width - width1;
      cp_contents += "<TR><TD COLSPAN='" + width1 + "' BGCOLOR='#ffffff' ID='colorPickerSelectedColor'>&nbsp;</TD><TD COLSPAN='" + width2 + "' ALIGN='RIGHT' ID='colorPickerSelectedColorValue' bgcolor='#ffffff' style='font-weight:bold; font-size: 10px;'>#FFFFFF</TD></TR>";
      }
   cp_contents += "</TABLE></div>";
   if(windowMode) {
      cp_contents += "</CENTER></BODY></HTML>";
      }
   cp.populate(cp_contents + "\n");
   cp.offsetY = 15;
   cp.autoHide();
   return cp;
   }