﻿// *** Textbox Watermark ***
function hideWatermark(obj, waterMarkText)
  {
      if(obj.value == waterMarkText)
      {
          obj.value="";
          obj.className = "textBox";
      }
  }
  function showWatermark(obj, waterMarkText)
  {
      if(obj.value == "")
      {
  	    obj.value=waterMarkText;
        obj.className = "textBoxWatermark";
      }
      else
      {
          obj.className = "textBox";
      }
  }
  
// Copyright (C) 2005-2008 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: http://www.php-development.ru/
// *** Popup Control ***
function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }

  if (c["xoffset"] != undefined){
    left += c["xoffset"];
  }
  if (c["yoffset"] != undefined){
    top += c["yoffset"];
  }
  
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

function at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);
  at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

function at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);
  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

// *** at_attach *****

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name
// xoffset,yoffset - adjust the position (*** ADDED)

function at_attach(parent, child, showtype, position, cursor, xoffset, yoffset)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;
 
  if (xoffset != undefined){
    c["xoffset"] = xoffset;
  }
  if (yoffset != undefined){
    c["yoffset"] = yoffset;
  }
  
  c.style.position   = "absolute";
  c.style.visibility = "hidden";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}

//AJAX Effects
function showProg(modElementID){
        var d = document.getElementById("prg");
        var c = document.getElementById(modElementID);
        var h = 0;
        var w = 0;
        if(c.offsetHeight){
            h =  c.offsetHeight;
        } else if(c.style.pixelHeight){
            h =c.style.pixelHeight; 
        }
        if(c.offsetWidth){
            w = c.offsetWidth;
        } else if(c.style.pixelWidth){
            w =c.style.pixelWidth;   
        }
        d.style.display = "";
        d.style.height = h + 'px';
        d.style.width=w + 'px'; 
        var xy = YAHOO.util.Dom.getXY(modElementID);  
        YAHOO.util.Dom.setXY('prg', xy); 
    }

    function fadeElement(elementID) {
        try {
                showProg(elementID);
                var ctl = document.getElementById(elementID);
                if (ctl != undefined) {
                    ctl.setAttribute("class", "postbackProgress"); 
                    ctl.setAttribute("className", "postbackProgress"); 
                }
        } catch (err){
        }
    }
    
    function showElement(elementID){
        try {
            var prgCtl = document.getElementById("prg");
            prgCtl.style.display = 'none';
            var ctl = document.getElementById(elementID);
            ctl.setAttribute("class", ""); 
            ctl.setAttribute("className", ""); 
        } catch (err){
        }
    }

// Partial Postback Support
    function getModuleIDFromTarget(eventTarget){
        var IDTokens = eventTarget.split('_');
        IDTokens.pop();
        return IDTokens.join('_');
    }

// Rollingitem Support
    var rollingItemOffsetFromMouse = [15, 15];

    if (document.getElementById || document.all) {
        document.write('<div id="rollingItemDiv">');
        document.write('</div>');
    }
    function getRollingItem() {
        if (document.getElementById)
            return document.getElementById("rollingItemDiv")
        else if (document.all)
            return document.all.rollingItemimagid
    }

    function getBody() {
        return (!window.opera && document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
    }

    function showRollingItem(itemHTML) {
        document.onmousemove = rollingFollowMouse;
        currentRollingItemHeight = 0;
        newHTML = '<div>';
        newHTML = newHTML + itemHTML;
        newHTML = newHTML + '</div>';
        var rollingItem = getRollingItem();
        rollingItem.innerHTML = newHTML;
        rollingItem.style.display = "inline";
    }

    function hideRollingItem() {
        document.onmousemove = ""
        var rollingItem = getRollingItem();
        rollingItem.style.innerHTML = " ";
        rollingItem.style.display = "none"
        rollingItem.style.left = "-500px"
    }

    function rollingFollowMouse(e) {
        var xcoord = rollingItemOffsetFromMouse[0]
        var ycoord = rollingItemOffsetFromMouse[1]
        var docwidth = document.all ? getBody().scrollLeft + getBody().clientWidth : pageXOffset + window.innerWidth - 15
        var docheight = document.all ? Math.min(getBody().scrollHeight, getBody().clientHeight) : Math.min(window.innerHeight)
        if (typeof e != "undefined") {
            xcoord += e.pageX;
            if (docheight - e.pageY < (currentRollingItemHeight)) {
                if (document.body) {
                    scrollTop = Math.max(getBody().scrollTop, document.body.scrollTop);
                } else {
                    scrollTop = getBody().scrollTop;
                }
                ycoord += e.pageY - Math.max(0, (currentRollingItemHeight + e.pageY - docheight - scrollTop));
            } else {
                ycoord += e.pageY;
            }
        } else if (typeof window.event != "undefined") {
            xcoord += getBody().scrollLeft + event.clientX
            if (docheight - event.clientY < (currentRollingItemHeight)) {
                ycoord += event.clientY + getBody().scrollTop - Math.max(0, (0 + currentRollingItemHeight + event.clientY - docheight));
            } else {
                ycoord += getBody().scrollTop + event.clientY;
            }
        }

        if (ycoord < 0) { ycoord = ycoord * -1; }
        var rollingItem = getRollingItem();
        rollingItem.style.left = xcoord + "px"
        rollingItem.style.top = ycoord + "px"
    }