
	// browser check
	var isNav = false;  // default
	var isIE = false;   // default
	var isIE6 = false; // default;
	var isIE7 = false;
	var isIE55 = false; // default;
	var isIE5 = false; // default;
	var isNav4 = false; // default
	var isNav6 = false; // default
	var isNav7 = false; // default
	var isDOM = false; // default	
		
	// 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";
		/*@cc_on
			@if (@_jscript_version >= 5.7)
				isIE7 = true;
			@elif (@_jscript_version >= 5.5)
				isIE6 = true;
			@elif (@_jscript_version >= 5.5)
				isIE55 = true;
			@else
				isIE5 = true;
			@end
		@*/
		//if (document.documentElement && document.documentElement.scrollTop) isIE6 = true;
	}
	if(!document.all && document.getElementById){
		isDOM = true;
		isNav6 = true;
		isNav = true;
		isNav7 = true;
	}
	/*
		// Sniff pre v.86 versions of Safari
		
		var agt = navigator.userAgent.toLowerCase();
		var appVer = navigator.appVersion.toLowerCase();
		
		var is_safari = (agt.indexOf("safari") != -1);
		var build = appVer.substring(appVer.lastIndexOf("/")+1);
		
		if (build < 86) {
		document.write('<style type="text/css">li:hover ul { display: none } </style>');
		}	
	*/
	
	// 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; 
      }
    }
	}
	
  //used to select an option w/in a Select field, 
	// but NOT based on value, rather text
  function setSelectedDDownOptionByTxt(oDDown, newValue){
    for(var i=0; i < oDDown.length; i++){
      if(oDDown.options[i].text.toLowerCase() == newValue.toLowerCase()){
        oDDown.options[i].selected = true;
        //return; // removed this return b/c we want to select any duplicate values
      }
    }
  }
	
  // 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
      }
    }
  }
	
  // 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
      }
    }
  }
	
  // used to select/unselect all options w/in a Select field
  function toggleAllDDownOptions(oDDown, isSel){
    for(var i=0; i < oDDown.length; i++){
  		oDDown.options[i].selected = isSel;
    }
  }
	
	// returns an array values that correspond to selected options
	function getSelectedDDownOptions(oDDown){
		var opts = new Array();
		if(oDDown == null) return opts;
		if(oDDown.options){
	   	for(var j=0;j<oDDown.options.length;j++){
	     	if(oDDown.options[j].selected == true){
	       opts[opts.length] = oDDown.options[j].value;
	     	}
	   	}
		}
		return opts;
	}
	
	// detects whether value is contained in dropdown field
	function isInDDown(oDDown, newValue)
	{
		if(newValue == null) return false;
    for(var i=0; i < oDDown.length; i++){
      if(oDDown.options[i].value == newValue)  return true;
    }
		return false;
	}
	
	// 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 , \" ' < > \\ / & * ?";
	}


	function isEmail(string) {
	    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	        return true;
	    else
	        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
	}
	
	// this will take all checkboxes that are nested in <form> obj
	// and check them
	function checkAllChxBoxes(oForm){
		var formFields = oForm.elements;
		for(var i=0;i < formFields.length; i++){
			if(formFields[i].type.toLowerCase() == 'checkbox'){
			  formFields[i].checked = true;
			}
		}// end i
	}
	// this will take all checkboxes that are nested in <form> obj
	// and uncheck them
	function uncheckAllChxBoxes(oForm){
		var formFields = oForm.elements;
		for(var i=0;i < formFields.length; i++){
			if(formFields[i].type.toLowerCase() == 'checkbox'){
			  formFields[i].checked = false;
			}
		}// end i
	}
	

	// better implementation of the above "uncheckAllChxBoxes" and "checkAllChxBoxes"
	function toggleAllChxBoxesInForm(oForm,checkIt){
		var formFields = oForm.elements;
		for(var i=0;i < formFields.length; i++){
			if(formFields[i].type.toLowerCase() == 'checkbox'){
			  formFields[i].checked = checkIt;
			}
		}// end i
	}
		
	// this will take all checkboxes that share the same name uncheck them
	function toggleAllChxBoxes(oChbx, bool){
		if(oChbx == null) return;
		if(oChbx.length){
			for(var i=0;i < oChbx.length; i++){
				oChbx[i].checked = bool;
			}
		}else oChbx.checked = bool;
	}
	
	// this will take all checkboxes that match a certain value and 
	// check/uncheck based on "checkIt" boolean 
	function setCheckboxes(oChkbx,val,checkIt)
	{
		if( (val == '') || (val == null) ) return;
		if(oChkbx.length){
			for(var i=0;i<oChkbx.length;i++){
				if(oChkbx[i].value == val) oChkbx[i].checked = checkIt;
			}
		}else{
			if(oChkbx.value == val) oChkbx.checked = checkIt;
		}
	}
	
	function getAllChxBoxes(oForm){
	  var checkBoxArray = new Array();
		var formFields = oForm.elements;
		for(var i=0;i < formFields.length; i++){
			if(formFields[i].type.toLowerCase() == 'checkbox'){
			  checkBoxArray[checkBoxArray.length] = formFields[i];
			}
		}// end i
		return checkBoxArray;
	}
	
	function getSelectedChxBoxes(oChkbx){
		var boxes = new Array(); 
	  if(oChkbx == null)  return boxes;
		if(oChkbx.length){
			for(var i=0;i < oChkbx.length; i++){
				if(oChkbx[i].checked) boxes[boxes.length] = oChkbx[i];
			}// end i
		}else {
			if(oChkbx.checked) boxes[boxes.length] = oChkbx;
		}
		return boxes;
	}
	
	function getSelectedRadioValue(oRadio)
	{
		var val = null;
		for(var i=0;i<oRadio.length;i++)
		{
			if(oRadio[i].checked) val = oRadio[i].value;
		}
		return val;
	}
	
	function setSelectedRadioValue(oRadio, val)
	{
		if( (val == '') || (val == null) ) return;
		for(var i=0;i<oRadio.length;i++)
		{
			if(oRadio[i].value == val) oRadio[i].checked = true;
		}
	}

	// get type="file" objects that match a name string pattern
	function getFileElems(oForm, fileNameMatch)
	{
		var elems = new Array();
		var len = oForm.elements.length;
		for(var i=0;i < len;i++){
			var oElem = oForm.elements[i];
			if(oForm.elements[i].tagName.toLowerCase() == "input" && (oElem.type.toLowerCase() == "file") 
			&& !isEmptyString(oElem.value) )
			{
				if(fileNameMatch == null){
					elems[elems.length] = oElem;
				}else if( oElem.name.toLowerCase().indexOf(fileNameMatch) > -1 ) elems[elems.length] = oElem;
			}// end input check
		}// end i
		return elems;
	}

	
	/****************************************************************
	*
	* START func's that control a popup window
	*
	****************************************************************/
	
	
		/*
		NOT USED YET!!!!
		example call: open_win('URL_TO_OPEN',400,400,1,1,1,1,1,1,1,1,5,'win1');return false
		windowopen.js
		V 1.0
		copyright Andrew Holt 
		This script is free to use provided this notice remains.
		Full instructions can be found @ http://www.webdevtips.com/webdevtips/js/openwindow.shtml
		*/
		function open_win(what_link,the_x,the_y,toolbar,addressbar,directories,statusbar,menubar,scrollbar,resize,history,pos,wname){ 
		var the_url = what_link;
		the_x -= 0;
		the_y -= 0;
		var how_wide = screen.availWidth;
		var how_high = screen.availHeight;
		if(toolbar == "0"){var the_toolbar = "no";}else{var the_toolbar = "yes";}
		if(addressbar == "0"){var the_addressbar = "no";}else{var the_addressbar = "yes";}
		if(directories == "0"){var the_directories = "no";}else{var the_directories = "yes";}
		if(statusbar == "0"){var the_statusbar = "no";}else{var the_statusbar = "yes";}
		if(menubar == "0"){var the_menubar = "no";}else{var the_menubar = "yes";}
		if(scrollbar == "0"){var the_scrollbars = "no";}else{var the_scrollbars = "yes";}
		if(resize == "0"){var the_do_resize =  "no";}else{var the_do_resize = "yes";}
		if(history == "0"){var the_copy_history = "no";}else{var the_copy_history = "yes";}
		if(pos == 1){top_pos=0;left_pos=0;}
		if(pos == 2){top_pos = 0;left_pos = (how_wide/2) -  (the_x/2);}
		if(pos == 3){top_pos = 0;left_pos = how_wide - the_x;}
		if(pos == 4){top_pos = (how_high/2) -  (the_y/2);left_pos = 0;}
		if(pos == 5){top_pos = (how_high/2) -  (the_y/2);left_pos = (how_wide/2) -  (the_x/2);}
		if(pos == 6){top_pos = (how_high/2) -  (the_y/2);left_pos = how_wide - the_x;}
		if(pos == 7){top_pos = how_high - the_y;left_pos = 0;}
		if(pos == 8){top_pos = how_high - the_y;left_pos = (how_wide/2) -  (the_x/2);}
		if(pos == 9){top_pos = how_high - the_y;left_pos = how_wide - the_x;}
		if (window.outerWidth ){
		var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",outerWidth="+the_x+",outerHeight="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
		wname=window.open(the_url, wname, option);
		wname.focus();
		}
		else
		{
		var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",Width="+the_x+",Height="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
		if (!wname.closed && wname.location){
		wname.location.href=the_url;
		}
		else
		{
		wname=window.open(the_url, wname, option);
		//wname.resizeTo(the_x,the_y);
		wname.focus();
		wname.location.href=the_url;
		}
		}
		} 
	
	
	// 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();
	}
	
	
	// opens an error window
	function popupImgAsHtml(src,alt,title,winName,winAttrib){
		if(winAttrib == null) winAttrib = 'resizable=yes';
		if(winName == null) winName = 'image window';
		if(alt == null) alt = '';
		if(title == null) title = '';
	  var win = window.open('');
	  win.document.open();
	  win.document.writeln('<html><head><title>' + winName + '</title>');
	  win.document.writeln('</head>');
	  win.document.writeln('<body bgcolor="#FFFFFF" link="#000066" vlink="#660066" alink="#660066" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">');
	  win.document.writeln('<br /><a href="javascript:window.close()">close window</a>');
	  win.document.writeln('<table cellSpacing="0" cellPadding="4" border="0" height="100%" width="100%">');
	  win.document.writeln('<tr><td valign="middle" align="center" class="tdheader4">');
	  win.document.writeln('<img onclick="opener.setCurrentImgFieldValue(this.src)" src="' + src + '" alt="' + alt + '" title="' + title + '" />');
	  win.document.writeln('</td></tr></table><br><br>' + src + '</body></html>');
	  win.document.close();
	}
	
	function doVoid(){
	  // a dummy func
	}
	
	// NOT TESTED!!!!!
	// Centers an object
	function centerObjInWin(objID, objWidth, objHeight){
	  var xyCoordin = getWindowCenter(this);
	  var x = xyCoordin[0] - (Math.round(objWidth/2));
	  var y = xyCoordin[1] - (Math.round(objHeight/2));
		var styleObj = getStyleObj(objID);
		if(styleObj == null) return;
		styleObj.left = x;
		styleObj.top = y;
	}
	
	// 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(win.document.body.clientHeight/2);
	    w = Math.round(win.document.body.clientWidth/2);
	  }
	  if(isNav){
	    h = Math.round(win.innerHeight/2);
	    w = Math.round(win.innerWidth/2);
	  }
	  if( (!isNav) && (!isIE) ){
	    h = 600;
	    w = 800;
	  }
	  coor[0] = w;
	  coor[1] = h;
	  return coor;
	}
	
	// returns the x and y coordinates of the center of a window.
	function centerObj(oID,w,h){
		alert('foo70');
		//var hOffset = document.body.scrollTop;
		var hOffset = getScrollTop(window);
		var oStyled = getStyleObj(oID);
alert(hOffset);
		oStyled.position = 'absolute';
		oStyled.top = '50%';
		oStyled.marginTop = -(h/2) + hOffset;
		/*
	  var h,w,x,y;
	  var coor = new Array();
	  if(isIE){
			//document.body.scrollLeft" and "document.body.scrollTop"
			//screenTop+document.body.clientHeight/2-popheight/2 
	   // h = Math.round((win.document.body.clientHeight + document.body.scrollTop)/2);
			h = Math.round((screenTop+document.body.clientHeight)/2);
			
	    //w = Math.round(win.document.body.clientWidth/2);
			w = Math.round((screenLeft+document.body.clientWidth)/2);
	  }
	  if(isNav){
	    h = Math.round(win.innerHeight/2);
	    w = Math.round(win.innerWidth/2);
	  }
	  if( (!isNav) && (!isIE) ){
	    h = 600;
	    w = 800;
	  }
	  coor[0] = w;
	  coor[1] = h;
	  return coor;
		*/
	}
		
		
		
		
// Window properties  v1.1
// documentation: http://www.dithered.com/javascript/window_properties/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)
function getInnerWidth(win) {
  var winWidth;
  if (win.innerWidth) {
    winWidth = win.innerWidth;
  }
  else if (win.document.documentElement && win.document.documentElement.clientWidth) {
    winWidth = win.document.documentElement.clientWidth;
  }
  else if (document.body) {
    winWidth = win.document.body.clientWidth;
  }
  return winWidth;
}

function getInnerHeight(win) {
  var winHeight;
  if (win.innerHeight) {
    winHeight = win.innerHeight;
  }
  else if (win.document.documentElement && win.document.documentElement.clientHeight) {
    winHeight = win.document.documentElement.clientHeight;
  }
  else if (win.document.body) {
    winHeight = win.document.body.clientHeight;
  }
  return winHeight;
}

function getScrollTop(win) {
   var scrollTop = 0;
   if (win.pageYOffset) {
      scrollTop = win.pageYOffset;
   }
   else if (win.document.documentElement && win.document.documentElement.scrollTop) {
      scrollTop = win.document.body.scrollTop;
   }
   else if (win.document.body) {
      scrollTop = win.document.body.scrollTop;
   }
   return scrollTop;
}

function getScrollLeft(win) {
   var scrollLeft = 0;
   if (win.pageXOffset) {
      scrollLeft = win.pageXOffset;
   }
   else if (win.document.documentElement && win.document.documentElement.scrollLeft) {
      scrollLeft = win.document.body.scrollLeft;
   }
   else if (win.document.body) {
      scrollLeft = win.document.body.scrollLeft;
   }
   return scrollLeft;
}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
	function makeImgThumb(oImg)
	{
		var w = Math.round(oImg.width/4);
		oImg.width = w;
	}
		
		
	// detects if form needs to be submitted as a multipart (for files)
	function isMultipartEnctypeForm(oForm){
		var len = oForm.elements.length;
		for(var i=0;i < len;i++){
			var oElem = oForm.elements[i];
			if(oForm.elements[i].tagName == "INPUT"){
				if(oElem.type.toLowerCase() == "file")
				{
					if(oElem.value != '') return true;
				}
			}// end input check
		}// end i
		return false;
	}
	
	/****************************************************************
	*
	* 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){
			if(confirmWin.focus) 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 general 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+$/,'');
	
	//return string.replace( /^[ \n\r\t]+|[ \n\r\t]+$/g, "" );
	
	// strips all empty spaces
	//return (string.replace(/^ +/,'')).replace(/ +$/,'');

  // strips all non-word characters ( [^a-zA-Z0-9] ) from the beginning and end of the string
  //return (string.replace(/^\W+/,'')).replace(/\W+$/,'');
}

function convertDoubleSpacesToSingle( str ){
	str = str.replace(/\s\s/,' ');
	if(str.indexOf('  ') > -1) stripDoubleSpaces(str);
	else return str;
}



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){
	if(str == null) return str;
  var regExp = eval('/\\,/g');
  str = str.replace(regExp, '');
  return str;
}

function removeSpaces(str){
  var regExp = eval('/\ /g');
  str = str.replace(regExp, '');
  return str;
}

function removePeriods(str){
  var regExp = eval('/\./g');
  str = str.replace(regExp, '');
  return str;
}

// capitalizes everly first letter of each word: Xxxx Xxx Xxxxxxxx
function capitalize(x) {
   return (x.replace(/\b[a-z]/g,
       function (str, n) {
           return str.toUpperCase();
       }
   ));
}

// used to dynamically build mailto email addresses
function buildEmail(name, domain, subj){
	var url = "mailto:" + name + "@" + domain;
	if(subj != null) url += "&subject=" + subj;
	return url;
}

/****************************************************************
*
* END general string helper functions
*
****************************************************************/

/****************************************************************
*
* Start encoding/escaping string helper functions
*
****************************************************************/

// escapes illegal DB chars for form submission
function escapeIllegalChars(oForm){
	var len = oForm.elements.length;
	for(var i=0;i < len;i++){
		if(oForm.elements[i].tagName == "TEXTAREA"){	
			oForm.elements[i].value = escapeQuotes(oForm.elements[i].value);
		}
		if(oForm.elements[i].tagName == "INPUT"){
			if( (oForm.elements[i].type.toLowerCase() != "file") && (oForm.elements[i].type.toLowerCase() != "file")){
				oForm.elements[i].value = escapeQuotes(oForm.elements[i].value);
			}
		}
	}
}


function encodeIllegalSqlChars(oForm){
	var len = oForm.elements.length;
	for(var i=0;i < len;i++){
		var oElem = oForm.elements[i];
		if(oElem.tagName == "TEXTAREA"){	
			oElem.value = encodeAllIllegalSqlChars(oElem.value);
		}
		if(oForm.elements[i].tagName == "INPUT"){
			if( (oElem.type.toLowerCase() != "file") && (oElem.type.toLowerCase() != "file"))
			{
				if( (oElem.value.indexOf('http://') == -1) && (oElem.value.indexOf('https://') == -1) )
					oElem.value = encodeAllIllegalSqlChars(oElem.value);
			}
		}
	}

}

// encodes illegal xml chars for xsl parsing 
// (have used for urls stored in DB and displayed with xml/xsl)
function encodeIllegalXmlChars(oForm){
	var len = oForm.elements.length;
	for(var i=0;i < len;i++){
		var oElem = oForm.elements[i];
		if(oElem.tagName == "TEXTAREA"){	
			oElem.value = encodeAllIllegalXmlChars(oElem.value);
		}
		if(oForm.elements[i].tagName == "INPUT"){
			if( (oElem.type.toLowerCase() != "file") && (oElem.type.toLowerCase() != "file"))
			{
				if( (oElem.value.indexOf('http://') == -1) && (oElem.value.indexOf('https://') == -1) )
					oElem.value = encodeAllIllegalXmlChars(oElem.value);
				else
					oElem.value = encodeIllegalUrlXmlChars(oElem.value);
			}
		}
	}
}

/*
	Not all excluded characters will break a parser like xerces, but IE and Mozilla parsers will/could break on these...
*/
function encodeAllIllegalXmlChars( val )
{

		//pattern = /\&&/g;
		//val =  val.replace(pattern,"&#038;$1");
		var pattern = /\&/g;
		val =  val.replace(pattern,"&#038;");
		//pattern = / \& /g;// old pattern, used in ?
		//val =  val.replace(pattern," &amp; ")
		pattern = /\&#038;(#[0-9]{3};)/g;
		val =  val.replace(pattern,"&$1");
		pattern = /\&#038;#038;/g;
		val =  val.replace(pattern,"&#038;");
		pattern = /\&#038;nbsp;/g;
		val =  val.replace(pattern,"&#160;");
		pattern = /\&#038;amp;/g;
		val =  val.replace(pattern,"&amp;");
		pattern = /\&#038;apos;/g;
		val =  val.replace(pattern,"&#039;");
		pattern = /\</g;
		val = val.replace(pattern,"&#060;");
		pattern = /\*/g;
		val = val.replace(pattern,"&#042;");
		pattern = /\$/g;
		val = val.replace(pattern,"&#036;");	
		pattern = /\?/g;
		val = val.replace(pattern,"&#034;");
		pattern = /\?/g;
		val = val.replace(pattern,"&#034;");
		pattern = /\?/g;
		val = val.replace(pattern,"&#176;");
		//pattern = /\"/g;
		//val =  val.replace(pattern,"&#034;"); 
		pattern = /\'/g;
		val =  val.replace(pattern,"&#039;");
		pattern = /\?/g;
		val =  val.replace(pattern,"&#039;");
		pattern = /\-/g;
		val =  val.replace(pattern,"&#045;");
		pattern = /\+/g;
		val =  val.replace(pattern,"&#043;");
		pattern = eval('/[^A-z0-9_ \\/(\\s)!@#&\$%\*\(\)\?=;\.\[\]\>\<,\\/\-]/g;');
		val =  val.replace(pattern," ");
    return val;
}

/*
	undo encodings for xml parsers
*/
function unencodeAllIllegalXmlChars( val )
{
		var pattern = /\&#038;/g;
		val =  val.replace(pattern,"&");
		//pattern = /\&#160;/g;
		//val =  val.replace(pattern," ");
		pattern = /\&amp;/g;
		val =  val.replace(pattern,"&");
		pattern = /\&#060;/g;
		val = val.replace(pattern,"<");
		pattern = /\&#042;/g;
		val = val.replace(pattern,"*");
		pattern = /\&#045;/g;
		val = val.replace(pattern,"-");
		pattern = /\&#036;/g;
		val = val.replace(pattern,"$");	
		pattern = /\&#034;/g;
		val = val.replace(pattern,"\"");
		pattern = /\&#039;/g;
		val =  val.replace(pattern,"'");
		//pattern = /\&#176;/g;
		//val = val.replace(pattern,"?");
    return val;
}

/*
	Not certain which characters are actually illegal :-)
*/
function encodeAllIllegalSqlChars( val )
{
		var pattern = /\'/g;
		val =  val.replace(pattern,"&#039;");
		//var pattern = /\"/g;
		//val = val.replace(pattern,"&#034;");	 
		pattern = /\?/g;
		val = val.replace(pattern,"&#034;");
		pattern = /\?/g;
		val = val.replace(pattern,"&#034;");
		pattern = /\?/g;
		val =  val.replace(pattern,"&#039;");	 
		pattern = /\+/g;
		val =  val.replace(pattern,"&#043;");
		pattern = eval('/[^a-zA-Z0-9_ "\\/(\\s)<>\*\.\!\|@#&\$%&;:=\)\(,\'\{\}?\-]/g;');
		val =  val.replace(pattern," ");
    return val;
}

// Encoding xml url data is different from other xml string data
function encodeIllegalUrlXmlChars( val )
{
    var regexp2Quote = /\"/g;
    var val = val.replace(regexp2Quote, '&quot;');
		var regexpApos = /\'/g;
    val = val.replace(regexpApos, "&apos;");
		var regexpAmp = /\&/g;
		val =  val.replace(regexpAmp,"&amp;");
    return val;
}

function unencodeAmp(val){
    var regexp = /\&amp\;/g;
    var val = val.replace(regexp, "&");
		return val;
}

function encodeQuotes(val){
    var regexp = /\'/g;
    var val = val.replace(regexp, "&#039;");
    regexp = /\"/g;
    val = val.replace(regexp, "&#034;");
		return val;
}

function urlEncodeQuotes(val){
	return val.replace(/\"/g,'%22').replace(/\'/g, '%27');
}

// Escape single and double quotes 2x
function doubleEscapeQuotes( val )
{
	var escVal1 = doubleEscapeSingleQuotes(val);
  var escVal2 = doubleEscapeDoubleQuotes(escVal1);
	return escVal2;
}
function doubleEscapeSingleQuotes( val )
{
    var regexp = /\'/g;
    var escVal = val.replace(regexp, "\\'");

    return escVal;
}
function doubleEscapeDoubleQuotes( val )
{
    var regexp = /\"/g;
    var escVal = val.replace(regexp, '\\"');
    return escVal;
}

// Escape single and double quotes
function escapeQuotes( val )
{
	var escVal1 = escapeSingleQuotes(val);
  var escVal2 = escapeDoubleQuotes(escVal1);
	return escVal2;
}
function escapeSingleQuotes( val )
{
		if((val == null) || (val == '')) return 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;
}

// escapes all quotes in any written form field
function HTMLizeQuotesInForm(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 == "textarea") ){
      oElem.value = HTMLizeQuotes(oElem.value);
    }
  }
}

function HTMLizeLineBreaks(val){
  var pattern = /([^>])[\n\r]([^<])/g;
  val = val.replace(pattern, "$1<br \/>$2");
	//pattern = /\&\#060;/g;// encoded version of <
	//val = val.replace(pattern, "<");
	return val;
}

// makes '\n' a '<br />' but only if the \n is not abutting a tag. 
// This allows line breaks for text but not between tags like <td> or <table>
function HTMLizeDoubleLineBreaks(val){
  var pattern = /([^>])[\n\r]{2}([^<])/g;
  val = val.replace(pattern, "$1<br \/>$2");
	return val;
}

// 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;
}

function XMLizeQuotes(val)
{
    var regexp1 = /\"/g;
    var regexp2 = /\'/g;
    var escVal1 = val.replace(regexp1, '&#x22;');
    var escVal2 = escVal1.replace(regexp2, '&#039;');

    return escVal2;
}

// Convert double quotes to HTML query-string equivalents
function XMLizeDoubleQuotes( val )
{
    var regexp1 = /\"/g;
    var escVal1 = val.replace(regexp1, '&#x22;');
    return escVal1;
}

// Convert single quotes to HTML query-string equivalents
function XMLizeSingleQuotes( val )
{
    var regexp1 = /\'/g;
    var escVal1 = val.replace(regexp1, '&#039;');
    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)
	{
		var slashIndex = fullPath.lastIndexOf("/");
		if(slashIndex == -1) slashIndex = fullPath.lastIndexOf("\\");
		
		if(slashIndex != -1){
			fileName = fullPath.substr(slashIndex + 1);
			if(fileName.toLowerCase() == 'null'){
				fileName = "";
			}
		}else{
			fileName = fullPath;
		}				
	}		
	return fileName;
}

/****************************************************************
*
* END encoding string helper functions
*
****************************************************************/

/****************************************************************
*
* START Number helper functions
*
*****************************************************************/

//if a value is numeric, returns true
function isNumeric(val){
  if (isNaN(val)==true){
    return false;
  }
  else return true;
}

// returns t/f if integer/not
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
}

//if a value is a currency (ie 3,000.00), returns true
function isCurrency(val){
	
	if(val == null) return false;
	if(isEmptyString(val) == true) return false;
	if(val.indexOf(" ") != -1) return false;

	val = stripSurroundingSpaces(val);
	val = removeCommas(val);
  if(isNaN(val) == true){
    return false;
  }
  return true;
}

/* 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];
}
*/

/****************************************************************
*
* END Number helper functions
*
*****************************************************************/

/****************************************************************
*
* 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];
		return null;
	}
	
	// get the style object
	function getStyleObj(id){
		if(getObjByID(id) == null) return null;
		if(isIE || isDOM || isNav4){
			return getObjByID(id).style;
		}
		else return getObjByID(id);
	}

	// grab tag/class-specific child nodes. Returns array of matching nodes.
	// clsName is optional
	function getNodesFromObj_filterByTagClass(oPNode,tgNames, clsName)
	{
		if(oPNode == null || !oPNode.getElementsByTagName) return new Array();
		var ndes = new Array();
		for(var j=0; j < tgNames.length; j++)
		{
			var all = oPNode.getElementsByTagName(tgNames[j]);
			for(var i=0;i<all.length;i++)
			{
				if(all[i].nodeName.toLowerCase() == tgNames[j].toLowerCase() )
				{
					if(clsName != null){
						if(all[i].className.toLowerCase() == clsName.toLowerCase())  ndes[ndes.length] = all[i];
					}else ndes[ndes.length] = all[i];
				}
			}
		}
		return ndes;
	}
	
	// show object
	function showObj(id)
	{
		styleObj = getStyleObj(id);
		if(styleObj == null) return;
		styleObj.display = 'inline';
		styleObj.visibility = 'visible';
	}
	
	// show/hide object
	function showHideObj(id,show,vis,dis)
	{
		styleObj = getStyleObj(id);
		if(styleObj == null) return;
		if(show == true){
			if(vis == true) styleObj.visibility = 'visible';
			if(dis == true) styleObj.display = 'inline';
		}else if(show == false){
			if(vis == true) styleObj.visibility = 'hidden';
			if(dis == true) styleObj.display = 'none';
		}
	}
	
	// hide object
	function hideObj(id)
	{
		styleObj = getStyleObj(id);
		if(styleObj == null) return;
		styleObj.visibility = 'hidden';
		styleObj.display = 'none';
	}
	
	function showObjToggle(id)
	{
		styleObj = getStyleObj(id);
		if(styleObj == null) return;
		if(styleObj.visibility == 'hidden' || styleObj.display == 'none')
		{
			styleObj.display = 'inline';
			styleObj.visibility = 'visible';
		}else{
			styleObj.visibility = 'hidden';
			styleObj.display = 'none';
		}
	}
	
	
	// set background color for table rows
	function highlightRow(id,color)
	{
		var oRow = getObjByID(id);
		if(oRow == null) return;// older browser
		var oRowStyle = getStyleObj(oRow.id);
		oRowStyle.backgroundColor = color;
		oRowStyle.cursor = 'hand';
	}	
	
	
/****************************************************************
*
* END dhtml helper functions
*
****************************************************************/
