function VSHelpIconCover(bottom, top, ignoreSize) {
    var location = GetElementPosition(bottom);
    top.style.position = 'absolute';
    top.style.top = location[1] + 'px';
    top.style.left = location[0] + 'px';
    if (!ignoreSize) {
        top.style.height = bottom.offsetHeight + 'px';
        top.style.width = bottom.offsetWidth + 'px';
    }
}

function GetScreenHeight()
{
    var y;
    var test1 = document.body.scrollHeight;
    var test2 = document.body.offsetHeight;
    if (test1 > test2) // all but Explorer Mac
    {
	    y = document.body.scrollHeight;
    }
    else // Explorer Mac;
         //would also work in Explorer 6 Strict, Mozilla and Safari
    {
	    y = document.body.offsetHeight;
    }
    
    return y;
}

function resizeIframe(framePage, iframeID) { 
if(self==parent) return false; /* Checks that page is in iframe. */ 
else if(document.getElementById&&document.all) /* Sniffs for IE5+.*/ 

var FramePageHeight = framePage.scrollHeight + 10; /* framePage 
is the ID of the framed page's BODY tag. The added 10 pixels prevent an 
unnecessary scrollbar. */ 

if(parent.document.getElementById(iframeID) != null)
{
parent.document.getElementById(iframeID).style.height=FramePageHeight; 
}
/* "iframeID" is the ID of the inline frame in the parent page. */ 
} 
function writeFlash(flashdata)
{
    document.write(flashdata);
}
function ENav(control, RecordID) { SetPageData('TargetControl', control); SetPageData('RecordID',RecordID); document.forms[0].submit();}
function VNav(control, RecordID) { SetPageData('TargetControl', control); SetPageData('RecordID', RecordID); SetPageData('ViewMode', 'Y'); document.forms[0].submit();}
function SetPageData(Key,Value)
{ var arr; var data; var DataLen; var Updated; var i; arr = document.getElementById('__PageData').value.split('|'); DataLen = arr.length - 1; data = ""; for (i=0; i<DataLen; i+=2)
{ if (i != 0) data += '|'; data += arr[i]; data += '|'; if (Key.toUpperCase() == arr[i].toUpperCase())
{ data += Value; Updated = true;}
else
{ data += arr[i+1];}
}
if (!Updated)
{ if (DataLen > 0) data += '|'; { data += Key; data += '|'; data += Value;}
}

document.getElementById('__PageData').value = data;}

/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
//var tipobj=document.all? document.getElementById('dhtmltooltip') : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){

if(document.getElementById('dhtmltooltip') == null)
{
    //document.writeln('<div id="dhtmltooltip"></div>');
}
else
{
if (ns6||ie){
if (typeof thewidth!="undefined") document.getElementById('dhtmltooltip').style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") document.getElementById('dhtmltooltip').style.backgroundColor=thecolor
//alert(thetext);
if(document.getElementById('dhtmltooltip').innerHTML!=thetext)
{
    document.getElementById('dhtmltooltip').innerHTML=thetext;
}
enabletip=true;
return false;
}
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<document.getElementById('dhtmltooltip').offsetWidth)
//move the horizontal position of the menu to the left by it's width
document.getElementById('dhtmltooltip').style.left=ie? ietruebody().scrollLeft+event.clientX-document.getElementById('dhtmltooltip').offsetWidth+"px" : window.pageXOffset+e.clientX-document.getElementById('dhtmltooltip').offsetWidth+"px"
else if (curX<leftedge)
document.getElementById('dhtmltooltip').style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
document.getElementById('dhtmltooltip').style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<document.getElementById('dhtmltooltip').offsetHeight)
document.getElementById('dhtmltooltip').style.top=ie? ietruebody().scrollTop+event.clientY-document.getElementById('dhtmltooltip').offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-document.getElementById('dhtmltooltip').offsetHeight-offsetypoint+"px"
else
document.getElementById('dhtmltooltip').style.top=curY+offsetypoint+"px"
document.getElementById('dhtmltooltip').style.visibility="visible"
}
}

function hideddrivetip(){
if(document.getElementById('dhtmltooltip'))
{
if (ns6||ie){
enabletip=false;
document.getElementById('dhtmltooltip').style.visibility="hidden"
document.getElementById('dhtmltooltip').style.left="-1000px"
document.getElementById('dhtmltooltip').style.backgroundColor=''
document.getElementById('dhtmltooltip').style.width=''
}
}
}

document.onmousemove=positiontip;
function OpenPopupWindow(QueryString, PopupName)
{ 
    OpenWindow('Popup.aspx?' + QueryString, PopupName);
}

function OpenWindow(URL, PopupName, myWidth, myHeight)
{ 
if(myWidth == null)
{ myWidth = 1000;}
if(myHeight == null)
{ myHeight = 670;}
            var left = (screen.width - myWidth) / 2;
            var top = ((screen.height - myHeight - 80) / 2) - 10;
if(PopupName == null)
{ PopupName = 'OpenWindow';}

   var win;
   try
   {
      win = window.open(URL, PopupName.replace(' ',''), 'height=' + myHeight + ', width=' + myWidth + ', left=' + left + ', top='+ top +', resizable=1 location=0, menubar=0, scrollbars=1, toolbar=0, status=1'); 
      win.focus();
   }
   catch(ex)
   {
      alert('A popup blocker has prevented this window from opening.\r\nTrying holding the CTRL key on the keyboard and click the link again, or disable your popup blocker for this website.');
   }
}
function OpenModalWindow(QueryString, PopupName, myWidth, myHeight, myScrollbar)
{ if(myWidth == null)
{ myWidth = 1000;}
if(myHeight == null)
{ myHeight = 670;}
if(myScrollbar == null)
{ myScrollbar = 'yes';}
            var left = (screen.width - myWidth) / 2;
            var top = ((screen.height - myHeight- 80) / 2) - 10;
if(PopupName == null)
{ PopupName = 'ModalPopup';}
window.showModalDialog('PopupModal.aspx?' + QueryString, window, 'dialogHeight: ' + myHeight +'px; dialogWidth: ' + myWidth +'px; edge: Raised; center: Yes; help: Yes; resizable: No; status: No; ScrollBars: ' + myScrollbar + ';');}

function OpenModalWindowWithPage(QueryString, PopupName, myWidth, myHeight, myScrollbar)
{ if(myWidth == null)
{ myWidth = 1000;}
if(myHeight == null)
{ myHeight = 670;}
if(myScrollbar == null)
{ myScrollbar = 'yes';}
            var left = (screen.width - myWidth) / 2;
            var top = ((screen.height - myHeight- 80) / 2) - 10;
if(PopupName == null)
{ PopupName = 'ModalPopup';}
window.showModalDialog(QueryString, window, 'dialogHeight: ' + myHeight +'px; dialogWidth: ' + myWidth +'px; edge: Raised; center: Yes; help: Yes; resizable: No; status: No; ScrollBars: ' + myScrollbar + ';');}


function NumbersOnly()
{ try
{ if(window.event.ctrlKey && (window.event.keyCode == 88 || window.event.keyCode == 86 || window.event.keyCode == 67))
{ 
   window.event.returnValue=true;
}
else if(!window.event.shiftKey &&
( (window.event.keyCode > 95 && window.event.keyCode <106) || (window.event.keyCode > 44 && window.event.keyCode <58) || window.event.keyCode ==8 || window.event.keyCode ==9 || window.event.keyCode ==37 || window.event.keyCode ==39)
)
{ window.event.returnValue=true;}
else if(window.event.shiftKey && window.event.keyCode == 9)
{ window.event.returnValue=true;}
else
{ window.event.returnValue=false;}
}
catch(e){}
}

function NumbersAndPeriodOnly(obj)
{

 try
{ 
    if(window.event.ctrlKey && (window.event.keyCode == 88 || window.event.keyCode == 86 || window.event.keyCode == 67))
    { 
       window.event.returnValue=true;
    }
    else if((window.event.keyCode ==110|| window.event.keyCode ==190) && obj != null && obj.value.indexOf('.') > 0)
    {
        window.event.returnValue=false;
    }
    else if(!window.event.shiftKey &&
    ( (window.event.keyCode > 95 && window.event.keyCode <106) || (window.event.keyCode > 44 && window.event.keyCode <58) || window.event.keyCode ==8 || window.event.keyCode ==9 || window.event.keyCode ==37 || window.event.keyCode ==39 || window.event.keyCode ==110|| window.event.keyCode ==190)
    )
    { window.event.returnValue=true;}
    else if(window.event.shiftKey && window.event.keyCode == 9)
    { 
        window.event.returnValue=true;
    }
    else
    { 
        window.event.returnValue=false;
    }
}
catch(e){}
}
function MaskSSN(s)
{
    val = s.value.replace(/\D/gi, "");
    valid = new RegExp(/^(?!000)([0-9]\d{2}|7([0-9]\d|7[012]))([ -]?)(?!00)\d\d\3(?!0000)\d{4}$/)
    if (val != "" && val.match(valid))
    {
        parts = val.match(/(\d{3})(\d{2})(\d{4})/);
        if (parts && parts.length == 4)
            s.value = parts[1] + "-" + parts[2] + "-" + parts[3];
    }
    else
    {
        s.value = "";
    }
}
function MaskPhone(s)
{ var sNewValue = s.value; var iLength = 0; var err = false; var zChar = new Array(' ', '(', ')', '-', '.'); sNewValue = ParseChar(sNewValue, zChar); if (isNaN(sNewValue)) { err = true; alert("Not a valid phone number.  Type 10 digits, or in the format (999) 999-9999.");}
else { if (sNewValue.length == 10)
iLength = 10; else if (sNewValue.length == 0)
sNewValue = ""; else if (sNewValue.length < 10)
{ err = true; alert("Not a valid phone number.  Type 10 digits, or in the format (999) 999-9999.");}
else if (sNewValue.length > 10)
{ iLength = 10; if (sNewValue.charAt(0) == "1" && sNewValue.length == 11)
{ sNewValue = sNewValue.substring(1,11);}
else
sNewValue = sNewValue.substring(0,10); err = true; alert("Not a valid phone number.  Type 10 digits, or in the format (999) 999-9999.");}
}
if (!err) { sNewValue = FormatPhone(sNewValue,iLength); s.value = sNewValue;}
else { s.value = sNewValue; s.select(); s.focus();}
}
function FormatPhone(sPhone, iLength)
{ var sNewPhone = ""; if (iLength == 10)
{ sNewPhone = "(" + sPhone.substring(0,3) + ") " + sPhone.substring(3,6) + "-" + sPhone.substring(6,10); return sNewPhone;}
else
return sPhone;}
function ParseChar(sStr, sChar)
{ if (sChar.length == null)
{ zChar = new Array(sChar);}
else zChar = sChar; for (i=0; i<zChar.length; i++)
{ sNewStr = ""; var iStart = 0; var iEnd = sStr.indexOf(sChar[i]); while (iEnd != -1)
{ sNewStr += sStr.substring(iStart, iEnd); iStart = iEnd + 1; iEnd = sStr.indexOf(sChar[i], iStart);}
sNewStr += sStr.substring(sStr.lastIndexOf(sChar[i]) + 1, sStr.length); sStr = sNewStr;}
return sNewStr;}
function MaskDate(s)
{ var sNewValue = s.value.split('\\').join('/').split('-').join('/').split('.').join('/'); var iLength = 0; var err = false; var arr = sNewValue.split('/'); for(var i = 0; i < arr.length; i++)
{ if(arr[i].length == 1)
{ arr[i] = "0" + arr[i];}
}
sNewValue = arr.join('/'); var zChar = new Array('/', '-', '.'); sNewValue = ParseChar(sNewValue, zChar); if (isNaN(sNewValue)) { err = true; alert("Not a valid date.  Type the digits, or in the format MM/DD/YYYY.");}
else { if (sNewValue.length == 8)
iLength = 8; else if (sNewValue.length == 0)
sNewValue = ""; else if (sNewValue.length <= 6)
{ err = true; alert("Not a valid date.  Type the digits, or in the format MM/DD/YYYY.");}
else if (sNewValue.length > 8)
{ iLength = 8; sNewValue = sNewValue.substring(0,8); err = true; alert("Not a valid date.  Type the digits, or in the format MM/DD/YYYY.");}
else if (sNewValue.length == 7)
{ if (s.value.substr(2, 1) == "/" || s.value.substr(2, 1) == "." || s.value.substr(2, 1) == "-")
{ sNewValue = sNewValue.substr(0, 2) + "0" + sNewValue.substr(2, 1) + sNewValue.substr(3, 4)
}
else if (s.value.substr(1, 1) == "/" || s.value.substr(1, 1) == "." || s.value.substr(1, 1) == "-")
{ sNewValue = "0" + sNewValue.substr(0, 1) + sNewValue.substr(1, 2) + sNewValue.substr(3, 4)
}
else if (sNewValue.substr(0, 1) >= "1" && sNewValue.substr(0, 1) <= "9" &&
sNewValue.substr(1, 2) >= "01" && sNewValue.substr(1, 2) <= "31")
{ sNewValue = "0" + sNewValue.substr(0, 1) + sNewValue.substr(1, 2) + sNewValue.substr(3, 4)
}
else if (sNewValue.substr(0, 2) >= "01" && sNewValue.substr(0, 2) <= "12" &&
sNewValue.substr(2, 1) >= "1" && sNewValue.substr(2, 1) <= "9")
{ sNewValue = sNewValue.substr(0, 2) + "0" + sNewValue.substr(2, 1) + sNewValue.substr(3, 4)
}
else
{ err = true; alert("Not a valid date.  Type the digits, or in the format MM/DD/YYYY.");}
}
}
if (!err) { sNewValue = FormatDate(sNewValue); s.value = sNewValue;}
else { s.value = sNewValue; s.select(); s.focus();}
}
function FormatDate(sDate)
{ var sNewDate = ""; if (sDate.length > 0)
sNewDate = sDate.substr(0,2) + "/" + sDate.substr(2,2) + "/" + sDate.substr(4,4); return sNewDate;}


// Cross-browser event handling
// by Scott Andrew LePera
// http://www.scottandrew.com/weblog/articles/cbs-events

// Modified 2004-08-10 by Andrew Grgeory to work around Konqueror bug
// Modified 2004-06-04 by Andrew Gregory to support legacy (NS3,4) browsers
// http://www.scss.com.au/family/andrew/

// eg. addEvent(imgObj, 'mousedown', processEvent, false);
function addEvent(obj, evType, fn, useCapture) {
  // work around Konqueror bug #57913 which prevents
  // window.addEventListener('load',...) from working
  var ua = navigator.userAgent;
  var konq = ua.indexOf('KHTML') != -1 && ua.indexOf('Safari') == -1 && obj == window && evType == 'load';
  // don't use addEventListener for Konq, have Konq fall back to the old
  // obj.onload method
  if (obj.addEventListener && !konq) {
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent) {
    return obj.attachEvent('on' + evType, fn);
  } else {
    if (!obj.cb_events) {
      obj.cb_events = new Object();
      obj.cb_ftemp = null;
    }
    var events = obj.cb_events[evType];
    if (!events) {
      events = new Array();
      obj.cb_events[evType] = events;
    }
    var i = 0;
    while ((i < events.length) && (events[i] != fn)) {
      i++;
    }
    if (i == events.length) {
      events[i] = fn;
      obj['on' + evType] = new Function("var ret=false,e=this.cb_events['"+evType+"'];if(e){for(var i=0;i<e.length;i++){this.cb_ftemp=e[i];ret=this.cb_ftemp()||ret;}return ret;}");
    }
    return true;
  }
}

// eg. removeEvent(imgObj, 'mousedown', processEvent, false);
function removeEvent(obj, evType, fn, useCapture) {
  // work around Konqueror bug #57913 which prevents
  // window.addEventListener('load',...) from working
  var ua = navigator.userAgent;
  var konq = ua.indexOf('KHTML') != -1 && ua.indexOf('Safari') == -1 && obj == window && evType == 'load';
  // don't use addEventListener for Konq, have Konq fall back to the old
  // obj.onload method
  if (obj.removeEventListener && !konq) {
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent) {
    return obj.detachEvent('on' + evType, fn);
  } else {
    var ret = false;
    if (obj.cb_events) {
      var events = obj.cb_events[evType];
      if (events) {
        // remove any matching functions from the events array, shuffling items
        // down to fill in the space before truncating the array
        var dest = 0;
        for (var src = 0; src < events.length; src++) {
          if (dest != src) {
            events[dest] = events[src];
          }
          if (events[dest] == fn) {
            ret = true;
          } else {
            dest++;
          }
        }
        events.length = dest;
      }
    }
    return ret;
  }
}


function GetElementPosition(obj) {
	var curleft = 0;
	var curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
