//====================================
// DDL Misc
// From Dawson's DHTML Library
//
// Version: 1.04
//
// Author:   Dawson Cowals
// Created:  04-14-2003
// Modified: 04-14-2003
//
//====================================

// GLOBALS
var popup;


//call: hilit(this,true,true)   -- to hilit a field and select it's contents
//call: hilit(this,true,false)  -- to hilit a field without selecting it's contents
//call: hilit(this,false,false) -- to turn the hilit off
function hilit (source,doHilit,doSelect) {

    //aSource = event.srcElement;
    //aParent = aSource.parentElement;

    if (doHilit) {
      //hilit color
      cellColor  = "#996666";
      fieldcellColor = "#cc9999";

      if (doSelect) {
    	//if we are in a text input box, select it
        source.select();
      }
    } else {
      //original color
      cellColor  = "#669999";
      fieldcellColor = "#ffffff";
    }

    source.style.backgroundColor = fieldcellColor;
    //aParent.style.backgroundColor = cellColor;
}

//call by: copyValue(this,document.formid.fieldname)
function copyValue (source,target) {

  target.value = source.value;
  target.focus();
  target.select();

}

//used to put a value into a hidden form input field, ie AccountId
//call by: setValue(document.formid.fieldname, '207-20')
function setValue(target, value) {

  target.value = value;

}

function todaysDate(target) {
  var today    = new Date();
  var dateNow  = parseInt(today.getDate());
  var monthNow = parseInt(today.getMonth());
  var yearNow  = today.getYear();

  if (monthNow < 9) {
    monthString = "0" + (monthNow + 1) + "";
  } else {
    monthString = "" + (monthNow + 1) + "";
  }

  if (dateNow <= 9) {
    dayString = "0" + dateNow + "";
  } else {
    dayString = dateNow;
  }

  target.value = monthString + "/" + dayString + "/" + yearNow;

}

function getRandom(low,high) {

  var myRand = Math.floor(Math.random() * (high+1)) + low;
  return (myRand);

}


/*
 * openPopup is a popup window function for use by help and faq pages.
 * Contributed by Dawson 03-05-2002.
 *
 * URL         -- URL of document to load in the window
 * name        -- name for the window (for html reference)
 * width       -- window width in pixels
 * height      -- window height in pixels
 * resize      -- allow window to be resized
 * scroll      -- show scroll bars in window
 * status      -- show status bar in window
 * tools       -- show tool bar in window
 */
function openPopup(URL,name,width,height,resize,scroll,status,tools,location) {
  if (popup != null && !popup.closed) {
     popup.close();
  }

  var settings;
  settings  = "width="+width+",height="+height+",resizable="+resize+",";
  settings += "scrollbars="+scroll+",status="+status+",toolbar="+tools+",location="+location;

  popup=window.open(URL, name, settings);
  popup.focus();
}

