      
			
	// browser check
	var isNav = false;  // default
	var isIE = false;   // default
	var isNav4 = false; // default
	var isNav6 = false; // default
	var isDOM = false; // default	
	var isOpera = false; 
		
	// dhtml dom variables
	var collStr = ""; // default
	var styleStr = ""; // default
	
	if(document.layers){
		isNav4 = true;
		isNav = true;
	}
	if(document.all){
		isIE = true;
		collStr = "all.";
		styleStr = ".style";
	}
	if(document.layers){
		isNav4 = true;
		isNav = true;
	}
	if(document.all){
		isIE = true;
		collStr = "all.";
		styleStr = ".style";
	}
	if(!document.all && document.getElementById){
		isDOM = true;
		isNav6 = true;
		isNav = true;
	}
	if(navigator.userAgent.indexOf('Opera') != -1) isOpera = true;
	
// sets all option values that are blank equal to their text value
/*
  function setAllDDownValues(){
    for(var j=0; j &lt; document.forms.length; j++){
      var oForm = document.forms[j];

      for(var i=0; i &lt; document.forms[j].elements.length; i++){

        var oElem = document.forms[j].elements[i];

        if(oElem.tagName.toLowerCase() == 'select'){
          for(var k=0;k &lt; oElem.options.length; k++){

            if(oElem.options[k].value == ""){
              oElem.options[k].value = oElem.options[k].text;
              alert(oElem.options[k].value + " = " + oElem.options[k].text);
            }
          }//end for loop k
        }
      }//end for loop i
    }// end for loop j
  }
  */
	
	function selectSingleDDOption(oDDown, newValue)
	{
    for(var i=0; i < oDDown.length; i++){
      if(oDDown.options[i].value == newValue){
        oDDown.options[i].selected = true;
        return; 
      }
    }
	}
	
	
  // generic utility funcition used to select an option w/in a Select field
  function setSelectedDDownOption(oDDown, newValue){
    for(var i=0; i < oDDown.length; i++){
      if(oDDown.options[i].value == newValue){
        oDDown.options[i].selected = true;
        //return; // removed this return b/c we want to select any duplicate values
      }
    }
  }
  // generic utility funcition used to unselect an option w/in a Select field
  function setUnselectedDDownOption(oDDown, newValue){
    for(var i=0; i < oDDown.length; i++){
      if(oDDown.options[i].value == newValue){
        oDDown.options[i].selected = false;
        //return; // removed this return b/c we want to select any duplicate values
      }
    }
  }

// call this function to in your alert
function getIllegalCharactersWarningString() {
   return "Names can't include leading or trailing spaces, carriage returns, line feeds, unprintable characters, or any of the following characters:\n\t , \" ' < > \\ / & * ?";
}

//if a value is numeric, returns true
function isNumeric(val){
  if (isNaN(val)==true){
    return false;
  }
  else return true;
}

function isInteger(val){
  var isNum = isNumeric(val);
  if (isNum == true){
    if (val.indexOf('.') != -1){ //if there is a decimal place
      return false; //it's a number, but not an integer, return false
    }
    else return true; // it's an integer, return true
  }
  else return false;//not a number, return false
}

// returns an array of all form fields that are ancestors of an object
function getAllChildFormFieldObjs(obj){
  var formFieldObjArray= new Array();

  if(isIE){
    var len = obj.all.length;
    for(var i =0;i<len;i++){
      if(obj.all[i].tagName == "INPUT"){
        formFieldObjArray[formFieldObjArray.length] = obj.all[i];
      }
      if(obj.all[i].tagName == "SELECT"){
        formFieldObjArray[formFieldObjArray.length] = obj.all[i];
      }
      if(obj.all[i].tagName == "TEXTAREA"){
        formFieldObjArray[formFieldObjArray.length] = obj.all[i];
      }
    }
  }
  // NS is simplier b/c NS requires that all form fields be nested w/in form tags, while IE doens't
  if(isNav){
    formFieldObjArray = obj.elements;
  }

  return formFieldObjArray;
}

// grabs all the form field objects and builds a url string of name=value pairs
// note: [form].elements does NOT grab <input type="image"> fields
function getFormValuesAsUrlStr(oForm){
  var elemStr = "";
  var oElemArray = oForm.elements;

  for(var i=0;i<oElemArray.length;i++){
    var oElem = oElemArray[i];
    var eType = oElem.type.toLowerCase();

    if( (eType == "text") || (eType == "hidden") || (eType == "image")
      || (eType == "button") || (eType == "submit") || (eType == "textarea") ){
      elemStr += oElem.name + "=" + oElem.value + "&";
    }
    if( (eType == "checkbox") || (eType == "radio") ){
      if(oElem.checked == true){
        elemStr += oElem.name + "=" + oElem.value + "&";
      }
    }
    if(eType == "select-multiple"){
      for(var j=0;j<oElem.options.length;j++){
        if(oElem.options[j].selected == true){
          elemStr += oElem.name + "=" + oElem.options[j].value + "&";
        }
      }
    }
    if(eType == "select-one"){
      for(var j=0;j<oElem.options.length;j++){
        if(oElem.options[j].selected == true){
          elemStr += oElem.name + "=" + oElem.options[j].value + "&";
          break;
        }
      }
    }

  }// end i

  return elemStr;
}

// this will take all checkboxes that are nested in <form> tags
// and uncheck them
function uncheckAllChxBoxes()
{
  var checkBoxArray = new Array();
  for(var j=0;j<document.forms.length;j++){
    var oForm = document.forms[j];
    var formFields = getAllChildFormFieldObjs(oForm);
    for(var i=0;i < formFields.length; i++){
      if(formFields[i].type.toLowerCase() == 'checkbox'){
        formFields[i].checked = false;
      }
    }// end i
  }// end j
}


// opens an error window
function popupErrorMsg(msg){
  var errorWin = window.open('','errorWin','resizable=yes,height=250,width=435');
  errorWin.document.open();
  errorWin.document.writeln('<html><head>');
  errorWin.document.writeln('</head>');
  errorWin.document.writeln('<body bgcolor="#FFFFFF" link="#000066" vlink="#660066" alink="#660066" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">');
  errorWin.document.writeln('<table cellSpacing="0" cellPadding="4" border="0" height="100%" width="100%">');
  errorWin.document.writeln('<tr><td valign="middle" align="center" class="tdheader4">');
  errorWin.document.writeln('<b><font color="#ff0000">Error: </font></b>');
  errorWin.document.writeln(msg);
  errorWin.document.writeln('</td></tr></table></body></html>');
  errorWin.document.close();
}

function doVoid(){
  // a dummy func
}

// returns the x and y coordinates of the center of a window.
function getWindowCenter(win){
  var h;
  var w;
  var x;
  var y;
  var coor = new Array();
  if(isIE){
    h = Math.round(window.document.body.clientHeight/2);
    w = Math.round(window.document.body.clientWidth/2);
  }
  if(isNav){
    h = Math.round(window.innerHeight/2);
    w = Math.round(window.innerWidth/2);
  }
  if( (!isNav) && (!isIE) ){
    h = 600;
    w = 800;
  }
  coor[0] = w;
  coor[1] = h;
  return coor;
}

// returns the width and height of the window obj
function getWindowDimensions(win)
{
  var h;
  var w;
  var x;
  var y;
  var coor = new Array();
  if(isIE){
    h = window.document.body.clientHeight;
    w = window.document.body.clientWidth;
  }
  if(isDOM){
    h = window.innerHeight;
    w = window.innerWidth;
		var d = window.outerWidth - window.innerWidth;
		// NS alters the width when there is a Horiz. scroll, 
		// this corrects that...
		if(isOpera == false)
		{
			var scrollWidthDiff = window.innerWidth - window.document.width;
			w = w - scrollWidthDiff;
		}
  }
  if( (!isDOM) && (!isIE) ){
    h = 600;
    w = 800;
  }
  coor[0] = w;
  coor[1] = h;
  return coor;
}

// determines whether screen resolution 
// is below 1024 px width.
function isLowResScreen(){
	isLow = false;
	if(screen.availWidth < 1024) isLow = true;
	return isLow;
}
	
	function makeImgThumb(oImg)
	{
		var w = Math.round(oImg.width/4);
		oImg.width = w;
	}

/****************************************************************
*
* START func's that control a modal popup window
*
****************************************************************/
// global variables
window.onfocus = confirmWinFocus;
var confirmWin = null;// default
var confirmWinAction = void(0);// default
var confirmWinMessage = "";// default

// Fires when user focuses on this window after
// opening a new 'modal window' via openModalWindow(action).
function confirmWinFocus(){
  if(confirmWin != null){
    confirmWin.focus();
  }
}

// Fires when client wants a custom modal popup window.
// Also sets the 'action' you want the modal window to perform
// on this window.
function openModalWindow(action, message){
  var xyCoordin = getWindowCenter(this);
  var x = xyCoordin[0] - 155;
  var y = xyCoordin[1] ;

  confirmWinMessage = message
  confirmWinAction = action;
  confirmWin =
    eval("window.open('modalDialog.html','modalDialog','screenX=" + x + ",screenY=" + y + ",left=" + x + ",top=" + y + ",resizable=yes,height=130,width=310')");
  return confirmWin;
}

// Fired by a modal window (see openModalWindow()). Used by
// modal windows to determine what action to perform on their
// parent window.
function getModalAction(){
  return confirmWinAction;
}

function getModalMessage(){
  return confirmWinMessage;
}

function closeModalWin(){
  if(confirmWin != null){
    confirmWin.close();
    confirmWin = null;
    window.onfocus = null;
  }
}

// erases record of modal window when user closes the modal window.
function eraseModalWinRecord(){
    confirmWin = null;
    window.onfocus = null;
}

/****************************************************************
*
* END func's that control a modal popup window
*
****************************************************************/


/****************************************************************
*
* START string helper functions
*
****************************************************************/

function stripSurroundingSpaces( string )
{
  // strips all whitespace characters ( [ \t\n\r\f\v] ) from the beginning and end of the string
  return (string.replace(/^\s+/,'')).replace(/\s+$/,'');

  // strips all non-word characters ( [^a-zA-Z0-9] ) from the beginning and end of the string
  //return (string.replace(/^\W+/,'')).replace(/\W+$/,'');
}


function stringHasThisChar(string,chr){
  if (string.indexOf(chr) == -1){
    return false;
  }
  else return true;
}

//If an <input type=text> value is an empty string (only contains spaces), it returns true
function txtFieldValueIsEmptyString(oElem){
  var oElemLength=oElem.value.length;
  var count = 0;
  for (var i=0;i<oElemLength;i++){
    if (oElem.value.charAt(i) == " "){
      count++
    }
  }
  if (oElemLength == count) return true;
  else return false;
}

// detects if a string is empty
function isEmptyString(str){
  var strLen = str.length;
  var count = 0;
  if(str == "") return true;

  for (var i=0; i<strLen ;i++){
    if (str.charAt(i) == " "){
      count++
    }
  }
  if (strLen == count) return true;
  else return false;
}

function removeLeadingAndTrailingWhiteSpace(val){
  if(hasLeadingWhiteSpace(val) == true){
    val = removeLeadingWhiteSpace(val);
  }
  if(hasTraillingWhiteSpace(val) == true){
    val = removeTraillingWhiteSpace(val);
  }
  return val
}

function hasLeadingWhiteSpace(val){
  if(val.charAt(0)== " "){
    return true;
  }
  else return false;
}

function hasTraillingWhiteSpace(val){
  if(val.charAt(val.length-1)== " "){
    return true;
  }
  else return false;
}

function removeLeadingWhiteSpace(val){
  var tempLen = val.length;
  val = val.slice(1,tempLen);
  return val;
}

function removeTraillingWhiteSpace(val){
  var tempLen = val.length -1;
  val = val.slice(0,tempLen);
  return val;
}

function stripLeadingZero (num) {
   while (num.substring(0,1) == "0" && num.length > 1) {
      num = num.substring(1);
   }
   return num;
}

function stringContainsASpace(string) {
    var temp = string.search(/ /);

    if(temp == -1)  // the string does not contain a space
        return false;
    else
        return true;
}

function removeCommas(str){
  var regExp = eval('/\\,/g');
  str = str.replace(regExp, '');
  return str;
}

function removeSpaces(str){
  var regExp = eval('/\ /g');
  str = str.replace(regExp, '');
  return str;
}

// Escape single and double quotes
function escapeQuotes( val )
{
    var escVal1 = escapeSingleQuotes(val);
  var escVal2 = escapeDoubleQuotes(escVal1);
    return escVal2;
}
function escapeSingleQuotes( val )
{
    var regexp = /\'/g;
    var escVal = val.replace(regexp, "\'");

    return escVal;
}
function escapeDoubleQuotes( val )
{
    var regexp = /\"/g;
    var escVal = val.replace(regexp, '\"');

    return escVal;
}
function unescapeQuotes( val )
{
    var regexp1 = /\\\"/g;
    var regexp2 = /\\\'/g;
    var escVal1 = val.replace(regexp1, '"');
    var escVal2 = escVal1.replace(regexp2, "'");

    return escVal2;
}

function escapeAmp(val){

    var regexp = /\&/g;
    var escVal = val.replace(regexp, "&amp;");

    return escVal;
}

function escapePound(val){

    var regexp = /\#/g;
    var escVal = val.replace(regexp, "\#");

    return escVal;
}

// Convert single and double quotes to HTML query-string equivalents
function HTMLizeQuotes( val )
{
    var regexp1 = /\"/g;
    var regexp2 = /\'/g;
    var escVal1 = val.replace(regexp1, '&quot;');
    var escVal2 = escVal1.replace(regexp2, '&#039;');

    return escVal2;
}

// Convert double quotes to HTML query-string equivalents
function HTMLizeDoubleQuotes( val )
{
    var regexp1 = /\"/g;
    var escVal1 = val.replace(regexp1, '&quot;');
    return escVal1;
}

function unHTMLizeQuotes( val )
{
    var regexp1 = /quot;/g;
    var regexp2 = /\&\#039;/g;
    var escVal1 = val.replace(regexp1, '"');
    var escVal2 = escVal1.replace(regexp2, '\'');

    return escVal2;
}


// Convert double quotes to HTML query-string equivalents
function XMLizeDoubleQuotes( val )
{
    var regexp1 = /\"/g;
    var escVal1 = val.replace(regexp1, '&#x22;');
    return escVal1;
}

function unXMLizeDoubleQuotes( val )
{
    var regexp1 = /&#x22;/g;
    var escVal1 = val.replace(regexp1, '"');

    return escVal2;
}
// See Also: getIllegalCharactersWarningString (next one down)
function hasStdIllegalCharacters(str){
  var hasDoubleQuote = inputHasThisChar(str,"\""); //inputhasChar() is in framework/js/validationUtil.js
  var hasSingleQuote = inputHasThisChar(str,"\'");
  //var hasColon = inputHasThisChar(elemOrString,":");
  //var hasComma = inputHasThisChar(elemOrString,",");
  if ((hasDoubleQuote) || (hasSingleQuote)){
    return true;
  }
  else return false;
}
function inputHasThisChar(str,character){
  if (str.indexOf(character) == -1){
      return false;
  }
  else return true;
}

function hasAnkleBrackets(str){
  if(str.indexOf('>') != -1) return true;
  if(str.indexOf('<') != -1) return true;
  return false;
}

// grabs the file name from a full file + path string
function getFileName(fullPath){
	var fileName = "";
	if(isEmptyString(fullPath) == false)
	{
		// set AdPictureOld value so system can grab it and delete previous img file on server
		var slashIndex = fullPath.lastIndexOf("/");
		if(slashIndex != -1){
			fileName = fullPath.substr(slashIndex + 1);
			if(fileName == 'null'){
				fileName = "";
			}
		}else{
			fileName = fullPath;
		}				
	}		
	return fileName;
}

/****************************************************************
*
* END string helper functions
*
****************************************************************/


/* for/in func
var someArray = new Array();
someArray['key1'] = 'some str or obj';
someArray['key2'] = 'some str or obj 2';

for(prop in someArray){
	var val = someArray[prop];
}
*/


/****************************************************************
*
* START dhtml helper functions
*
****************************************************************/

	// get obj. by ID
	function getObjByID(id)
	{
		if (isDOM) return document.getElementById(id);
		if (isIE) return document.all[id];
		if (isNav4) return document.layers[id];
	}
	
	// get the style object
	function getStyleObj(id){
		if(isIE || isDOM || isNav4){
			return getObjByID(id).style;
		}
	}
	
	// opens an email window. Designed to avoid email harvestors
	function openEmail(part1,part2)
		{
			document.location.href = (part1 + part2);
		}
	
/****************************************************************
*
* END dhtml helper functions
*
****************************************************************/
