/******************************************************************************
 *  DHTML Tooltip Rollover Object
 *  Copyright (C) 2003 Giovanni Glass <momendo@yahoo.com>
 *  http://www.giovanniglass.com
 *
 * $Id: do_it.js,v 1.5 2004/06/17 20:22:50 whurley Exp $
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 ******************************************************************************
 * Function Use:
 * 1. Instantiate an instance of the Tip function definition.
 *    # instanceName = new Tip(instanceName_string, name_of_DIV_object_string)
 * 2. Define the tooltip code in the contructTip() method.
 * 3. To align your the tip with anchors, make sure anchors have an id and name
 *
 *****************************************************************************/

// declare our global popup reference
var newwindow;

function Tip(whoAmI, obj)
{
	this.whoAmI  = "" + whoAmI;
	this.isIE    = (document.all) ? true : false;
	this.isMoz   = (!this.isIE && document.getElementById) ? true : false;
	this.isNS4   = (!this.isIE && !this.isMoz && document.layer) ? true : false;
	this.whatID  = "" + obj;
	this.stuff   = "";
	this.timerID;
	this.timerID2;
	this.mouseOnTop = false;

	this.showTooltip = function()
	{
		var totalArguments = arguments.length;
		var onOff = arguments[0] ? true : false;
		var arg1 = arguments[1];
		var arg2 = arguments[2];
		var arg3 = arguments[3];
		var arg4 = arguments[4];
		var menuTimeout = 0;
		var menuTimein = 0;
		this.stuff = arg1;

		if (onOff) {
			clearTimeout(this.timerID);
			this.timerID = setTimeout(this.whoAmI + '.tooltipShowHide(1, ' + this.whoAmI +  '.stuff, ' + arg2 + ', ' + arg3 + ', ' + arg4 + ');//hideSelectBoxes();', menuTimein);
		} else {
			clearTimeout(this.timerID);
			this.timerID = setTimeout(this.whoAmI + '.tooltipShowHide(0)', menuTimeout);
		}
	}

	this.tooltipShowHide = function(state, code, offsetx, offsety)
	{
		this.tooltip = (this.isNS4) ? document.eval(this.whatID) : document.getElementById(this.whatID);

		if (this.timerID) clearTimeout(this.timerID);
		if (state) {
	 		if (this.isNS4) {
				var theString = "<LAYER onmouseout=\""
				                + this.whoAmI
				                + ".showTooltip(0)\">"
				                + this.constructTip(code)
				                + "</LAYER>";
				this.tooltip.document.write(theString);
				this.tooltip.document.close();
				this.tooltip.left = offsetx;
				this.tooltip.top  = offsety;
				this.tooltip.visibility = "show";
			} else if (this.isMoz || this.isIE) {
				this.tooltip.innerHTML  = this.constructTip(code);
				this.tooltip.style.left = offsetx;
				this.tooltip.style.top  = offsety;
				this.tooltip.style.visibility = "visible";
			}
		} else {
			if (this.isNS4) {
				this.tooltip.visibility = "hidden";
			} else if (this.isMoz || this.isIE) {
				this.tooltip.style.visibility = "hidden";
			}
		}
		showSelectBoxes();
	}

	this.constructTip = function(code)
	{
		var tipFront = "";
		var tipBack  = "";
		return tipFront + code + tipBack;
	}

// ===================================================================
// The following code was created by Matt Kruse.
// Modified by Giovanni Glass
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download.
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

	this.getAnchorPosition = function(anchorname)
	{
		var useWindow=false;
		var coordinates=new Object();
		var x=0,y=0;
		var use_gebi=false, use_css=false, use_layers=false;
		if (document.getElementById) { use_gebi=true; }
		else if (document.all) { use_css=true; }
		else if (document.layers) { use_layers=true; };
		if (use_gebi && document.all) {
			x=this.AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
			y=this.AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		} else if (use_gebi) {
			var o=document.getElementById(anchorname);
			x=this.AnchorPosition_getPageOffsetLeft(o);
			y=this.AnchorPosition_getPageOffsetTop(o);
		} else if (use_css) {
			x=this.AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
			y=this.AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		} else if (use_layers) {
			var found=0;
			for (var i=0; i<document.anchors.length; i++) {
				if (document.anchors[i].name==anchorname) { found=1; break; };
			}
			if (found==0) {
				coordinates.x=0; coordinates.y=0; return coordinates;
			}
			x=document.anchors[i].x;
			y=document.anchors[i].y;
		} else {
			coordinates.x=0; coordinates.y=0; return coordinates;
		}
		coordinates.x=x;
		coordinates.y=y;
		return coordinates;
	}

	this.AnchorPosition_getPageOffsetLeft = function(el)
	{
		var ol = el.offsetLeft;
		while ((el=el.offsetParent) != null) { ol += el.offsetLeft; };
		return ol;
	}

	this.AnchorPosition_getPageOffsetTop = function(el)
	{
		var ot = el.offsetTop;
		while((el=el.offsetParent) != null) { ot += el.offsetTop; };
		return ot;
	}

	this.getAnchorX = function(name)
	{
		var x =	this.getAnchorPosition(name);
		return x.x;
	}

	this.getAnchorY = function(name)
	{
		var x =	this.getAnchorPosition(name);
		return x.y;
	}
}

tipper = new Tip('tipper', "smallTooltip");

/*
 * Perfect Centered Popup Window
 * Written by Giovanni Glass
 */

function openit(sURL, x, y) {
	var s_width = screen.availWidth;
	var s_height = screen.availHeight;
	if (s_height < 600) {var c_height = s_height} else {var c_height = (s_height - 150)};

	var xWidth = parseInt((x || x !=null) ? x : 600);
	var xPos = parseInt((s_width - ((x || x != null) ? x : xWidth) - 10) * .5);
	var yHeight = parseInt((y || y !=null) ? y : c_height);
	var yPos = parseInt((s_height - yHeight - 30) * .5);

//alert(xWidth + ', ' + xPos + ', ' + yHeight + ', ' + yPos);

	newwindow = window.open(
		sURL,
		"popupnav",
		"scrollbars=yes,\
		toolbar=no,\
		directories=no,\
		menubar=no,\
		resizable=yes,\
		status=no,\
		width=" + xWidth
		+ ",height=" + yHeight
		+ ",left="+ xPos
		+ ",top=" + yPos);

}

function popupAlert(stringType)
{
	switch(stringType) {
	case 'completeFormForward':
		alert('Please make sure you complete or cancel the popup form before continuing on with the application.');
	break;
	case 'completeFormBackward':
		alert('Please make sure you complete or cancel the popup form before returning to a previous page within the application.');
	break;
	}
	window.newwindow.focus();
}
/*
function checkPopupState()
{
	try {
		void(newwindow.closed);
	} catch(e) {
//		alert('Popup does not exist!');
		return false;
	}

	var temp = !newwindow.closed ? true : false;

	if (temp) {
		return true;
	} else {
		window.newwindow = null;
//		alert(window.newwindow)
		return false;
	}
}
*/
/******************************************************************************
 *  DHTML Graphic Library
 *  Copyright (C) 2003 Giovanni Glass <momendo@yahoo.com>
 *  http://www.giovanniglass.com
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *****************************************************************************/

function gfxLib()
{
	this.isIE    = (document.all) ? true : false;
	this.isMoz   = (!this.isIE && document.getElementById) ? true : false;

	this.visibility = function(objString, toggle)
	{
		doc = document.getElementById(objString).style;
		doc.visibility = toggle ? "visible" : "hidden";
	}

	this.position = function(objString, x, y)
	{
		doc = document.getElementById(objString).style;
		doc.left = x + 'px';
		doc.top =  y + 'px';
	}

  this.opacity = function(objString, v)
  {
    doc = document.getElementById(objString).style;
    if (this.isIE)
        doc.filter = 'alpha(opacity=' + v + ')';
    if (this.isMoz)
        doc.MozOpacity = v / 100;
  }

	this.size = function(objString, x, y)
	{
	  doc = document.getElementById(objString).style;
	  doc.width  = x + 'px';
	  doc.height = y + 'px';
	}
}

// Instantiate gfxlib immediately
gfx = new gfxLib();

// Rollover Images
function rollChangeImages() {
  if (document.images) {
    for (var i=0; i<arguments.length; i+=2) {
      document.getElementById(arguments[i]).src = eval(arguments[i+1] + ".src");
    }
  }
}

if (document.images) {
  sbImg1on = new Image(); sbImg1on.src = "images/nav/sb1lit.gif";
  sbImg2on = new Image(); sbImg2on.src = "images/nav/sb2lit.gif";
  sbImg3on = new Image(); sbImg3on.src = "images/nav/sb3lit.gif";
  sbImg4on = new Image(); sbImg4on.src = "images/nav/sb4lit.gif";
  sbImg5on = new Image(); sbImg5on.src = "images/nav/sb5lit.gif";
  sbImg6on = new Image(); sbImg6on.src = "images/nav/sb6lit.gif";
  sbImg7on = new Image(); sbImg7on.src = "images/nav/sb7lit.gif";
  sbImg8on = new Image(); sbImg8on.src = "images/nav/sb8lit.gif";

  sbImg1off = new Image(); sbImg1off.src = "images/nav/sb1off.gif";
  sbImg2off = new Image(); sbImg2off.src = "images/nav/sb2off.gif";
  sbImg3off = new Image(); sbImg3off.src = "images/nav/sb3off.gif";
  sbImg4off = new Image(); sbImg4off.src = "images/nav/sb4off.gif";
  sbImg5off = new Image(); sbImg5off.src = "images/nav/sb5off.gif";
  sbImg6off = new Image(); sbImg6off.src = "images/nav/sb6off.gif";
  sbImg7off = new Image(); sbImg7off.src = "images/nav/sb7off.gif";
  sbImg8off = new Image(); sbImg8off.src = "images/nav/sb8off.gif";
}

/*
 * Catch keys on form boxes
 */
function numeralsOnly(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
        ((evt.which) ? evt.which : 0));
//alert(charCode);
    if (charCode != 39 && charCode != 37 && charCode != 44 && charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) {
//        alert("Enter numerals only in this field.");
        return false;
    }
    return true;
}
function lettersOnly(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
        ((evt.which) ? evt.which : 0));
//alert(charCode);
    if (charCode != 39 && charCode != 37 && charCode != 32 && charCode != 44 && charCode != 46 && charCode > 31 && (charCode < 65 || charCode > 90) &&
        (charCode < 97 || charCode > 122)) {
//        alert("Enter letters only.");
        return false;
    }
    return true;
}

function characters4name(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
        ((evt.which) ? evt.which : 0));
//alert(charCode);
 	if (charCode==39 || charCode==37 || charCode==44)
 		return false;

    if (charCode != 45 && charCode != 32 && charCode != 46 && charCode > 31
    	&& (charCode < 65 || charCode > 90)
    	&& (charCode < 97 || charCode > 122)) {
//        alert("Enter letters only.");
        return false;
    }
    return true;
}





/******************************************************************************
 *  Salary to Hourly Calculator
 *  Copyright (C) 2003 Giovanni Glass <momendo@yahoo.com>
 *  http://www.giovanniglass.com
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 ******************************************************************************
 * Function Use:
 * 1. Instantiate an instance of the Jobber function definition.
 * 2. Set your hour, rate, and amount fields using job.X.paymets.Y.TYPE.
 *
 * // instantiate
 * job1 = new Jobber();
 *
 * // set reference to object
 * job1.setFieldGroup(array);
 *
 * // apply event to set things in motion
 * onchange="caller(this);"
 *****************************************************************************/
// Resources for this script. They should be redefined by correspondent page
// accordingly to current language settings.
// Default values are provided.
var jobberModificationRateHours = 'Modifying the rate or hour columns will blank this row\'s gross amount field. Do you wish to do this?';
var jobberModificationGross = 'Modifying the Gross amount column will blank this row\'s rate and hour fields. Do you wish to do this?';

function Jobber()
{
  this.field = null;
  this.regEx_notNumbers = /[^0-9\.]/g;
  this.regEx_leadingZeros = /^0+/;
  this.regEx_manyDots = /\.+/g;
  this.stringDot = ".";

  this.findKey = function(stringType) {
    returnObj = new Object();
    returnObj.x = 0;
    returnObj.y = 0;
    for(var i = 0; i < this.field.length; i++) {
      for (var j = 0; j < this.field[i].length; j++) {
        if(this.field[i][j] == stringType) {
          returnObj.x = j;
          returnObj.y = i;
          return returnObj;
        }
      }
    }
    return false;
  }

  this.doIt = function(obj, eventFired) {
    var numberArray = new Array();
    var set0, set1, set2, set3;
    var setValue1 = '';
    var setValue2 = '';
    var setValue3 = '';
    var runningTotal = 0;
    var finalNumber = '';
    var toggle = false;
    var tempArray = null;
    var result = new Object();

    // determine mode, ask to switch to opposite type
    tempArray = obj.id.split(this.stringDot);
	result = this.findKey(obj.id);
//alert('result.x: ' + result.x + '\nresult.y: ' + result.y)
    if(eventFired) {
      if(tempArray[tempArray.length-1] == "amount") { // amount box
//alert('found ' + obj.id + ' currently set as '+ (this.field[result.y][4] ? 'hourly' : 'salary'))
        if(this.field[result.y][4] == true) {
          if(this.salary(false)) {
            // change our mode
            this.field[result.y][4] = false;
          }
		}
      } else if(tempArray[tempArray.length-1] == "hours" ||
                tempArray[tempArray.length-1] == "rate") { // rate or hour box
        if(this.field[result.y][4] == false) {
          if(!this.salary(true)) {
            obj.value = '';
          } else {
            // change our mode
            this.field[result.y][4] = true;
          }
        }
      }
    }

    set0 = document.getElementById(this.field[0][0]);

    for(var i = 0; i < this.field.length; i++) {
      finalNumber = '';

      if(this.field[i][1] == "" || this.field[i][1] == null) { break };

      set1 = document.getElementById(this.field[i][1]);
      set2 = document.getElementById(this.field[i][2]);
      set3 = document.getElementById(this.field[i][3]);
      toggle = this.field[i][4];

      if(toggle) { // hour mode
        setValue1 = set1.value.replace(this.regEx_notNumbers, '');
        setValue1 = setValue1.replace(this.regEx_manyDots, '.');
        setValue1 = setValue1.replace(this.regEx_leadingZeros, '');
        setValue2 = set2.value.replace(this.regEx_notNumbers, '');
        setValue2 = setValue2.replace(this.regEx_manyDots, '.');
        setValue2 = setValue2.replace(this.regEx_leadingZeros, '');
        if (setValue1 == '') { setValue1 = "0.00"; set1.value = "0.00"; };
        if (setValue2 == '') { setValue2 = "0.00"; set2.value = "0.00"; };
        numberArray = setValue1.split(this.stringDot);

        if (numberArray.length > 1) {
          for (var j = 0; j < numberArray.length; j++) {
            finalNumber = finalNumber + ((j == numberArray.length - 1) ? '.' : '') + numberArray[j];
          }
        } else {
          finalNumber = setValue1 + '.00';
        }

        setValue1 = parseFloat(finalNumber);
        setValue1 = Math.round(setValue1 * 100) / 100;
        if(setValue1 > 999999999999.99) { setValue1 = 999999999999.99; finalNumber = 999999999999.99};
        set1.value = this.formatValue(finalNumber, "###,###,###,###.##");

        finalNumber = "";
        numberArray = null;
        numberArray = setValue2.split(this.stringDot);

        if (numberArray.length > 1) {
          for (var j = 0; j < numberArray.length; j++) {
            finalNumber = finalNumber + ((j == numberArray.length - 1) ? '.' : '') + numberArray[j];
          }
        } else {
          finalNumber = setValue2 + '.00';
        }

        setValue2 = parseFloat(finalNumber);
        setValue2 = Math.round(setValue2 * 100) / 100;
        if(setValue2 > 999999999999.99) { setValue2 = 999999999999.99; finalNumber = 999999999999.99};
        set2.value = this.formatValue(finalNumber, "###,###,###,###.##");

        setValue3 = parseFloat(setValue1) * parseFloat(setValue2);
        set3.value = this.formatValue(setValue3, "###,###,###,###.##");
      } else { // salary mode
        set1.value = '';
        set2.value = '';
        setValue3 = set3.value.replace(this.regEx_notNumbers, '');
        setValue3 = setValue3.replace(this.regEx_manyDots, '.');
        setValue3 = setValue3.replace(this.regEx_leadingZeros, '');
        if (setValue3 == '') { setValue3 = "0.00"; set3.value = "0.00"; };

        numberArray = setValue3.split(this.stringDot);
        if (numberArray.length > 1) {
        for (var j = 0; j < numberArray.length; j++) {
//      alert('setValue3 = ' + setValue3+ '\nparts = ' + j + '\nnumberArray at part= ' + numberArray[j] + '\nfinalNumber = ' + finalNumber);
          finalNumber = finalNumber + ((j == numberArray.length - 1) ? '.' : '') + numberArray[j];
          }
        } else {
          finalNumber = setValue3 + '.00';
        }

        setValue3 = parseFloat(finalNumber);
        setValue3 = Math.round(setValue3 * 100) / 100;
        if(setValue3 > 999999999999.99) { setValue3 = 999999999999.99; finalNumber = 999999999999.99};
        set3.value = this.formatValue(finalNumber, "###,###,###,###.##");
      } // end toggle

      runningTotal += setValue3;
    }

    set0.value = this.formatValue(runningTotal, "###,###,###,###,###,###.##");
  }

  this.setFieldGroup = function(obj) {
    this.field = obj;
  }

  this.salary = function(confirmType) {
    if (confirmType) {
      return confirm(jobberModificationRateHours);
    } else {
      return confirm(jobberModificationGross);
    }
  }

  this.formatValue = function(argvalue, format)
  {
     var numOfDecimal = 0;
     if(format.indexOf(".") != -1) {
       numOfDecimal = format.substring(format.indexOf(".") + 1, format.length).length;
     }
     argvalue = this.formatDecimal(argvalue, true, numOfDecimal);

     argvalueBeforeDot = argvalue.substring(0, argvalue.indexOf("."));
     retValue = argvalue.substring(argvalue.indexOf("."), argvalue.length);

     strBeforeDot = format.substring(0, format.indexOf("."));

     for(var n = strBeforeDot.length - 1; n >= 0; n--) {
       oneformatchar = strBeforeDot.substring(n, n + 1);
       if(oneformatchar == "#") {
         if(argvalueBeforeDot.length > 0) {
           argvalueonechar = argvalueBeforeDot.substring(argvalueBeforeDot.length - 1, argvalueBeforeDot.length);
           retValue = argvalueonechar + retValue;
           argvalueBeforeDot = argvalueBeforeDot.substring(0, argvalueBeforeDot.length - 1);
         }
       } else {
         if(argvalueBeforeDot.length > 0 || n == 0) {
           retValue = oneformatchar + retValue;
         }
       }
     }
     return retValue;
  }

  this.formatDecimal = function(argvalue, addzero, decimaln)
  {
     var numOfDecimal = (decimaln == null) ? 2 : decimaln;
     var number = 1;

     number = Math.pow(10, numOfDecimal);

     argvalue = Math.round(parseFloat(argvalue) * number) / number;
     argvalue = "" + argvalue;

     if(argvalue.indexOf(".") == 0) {
       argvalue = "0" + argvalue;
     }

     if(addzero == true) {
       if(argvalue.indexOf(".") == -1) {
         argvalue = argvalue + ".";
       }

       while((argvalue.indexOf(".") + 1) > (argvalue.length - numOfDecimal)) {
         argvalue = argvalue + "0";
       }
     }
     return argvalue;
  }
}

/* setup our environment */
job0 = new Jobber(); job1 = new Jobber(); job2 = new Jobber(); job3 = new Jobber(); job4 = new Jobber(); job5 = new Jobber(); job6 = new Jobber(); job7 = new Jobber(); job8 = new Jobber(); job9 = new Jobber();
job10 = new Jobber(); job11 = new Jobber(); job12 = new Jobber(); job13 = new Jobber(); job14 = new Jobber(); job15 = new Jobber(); job16 = new Jobber(); job17 = new Jobber(); job18 = new Jobber(); job19 = new Jobber();
job20 = new Jobber(); job21 = new Jobber(); job22 = new Jobber(); job23 = new Jobber(); job24 = new Jobber(); job25 = new Jobber(); job26 = new Jobber(); job27 = new Jobber(); job28 = new Jobber(); job29 = new Jobber();

var dummyArray = null;
function makeArray() {
  dummyArray = null;
  dummyArray = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]];
}

function figureItOut()
{
  var calculateImmediately = true; // calc now or wait until an event occurs
  var totalHourlyIterator = 0; // count number of hour type indicators
  var list;
  var mode = false;
  var list2 = new Array();
  var splitOnDot = ".";
  var tempString = "";
  var iterator = 0;
  var testStringRegEx = "";
  var tempSubIterator = 0;
  var groups = 0;
  var groupArray = new Array();
  var testState1 = "";
  var testState2 = "";

  for (var tempArray = 0; tempArray < 50; tempArray++) {
    groupArray[tempArray] = new Array();
  }
  makeArray();

  list = document.getElementsByTagName("input");
  testRegEx = /job\.[0-9]+?\.main|(.+?\.[0-9]+?\.(rate|amount|hours))/i;
  for(var i = 0; i < list.length; i++) {
    if (testRegEx.test(list[i].id)) {
      list2[iterator] = list[i].id;
      iterator++;
    }
  }

  for (var j = 0; j < list2.length; j++) {
    tempString = list2[j].split(splitOnDot);
    if(tempString[2] == "main") {
      groupArray[groups][0] = list2[j];
      groups++;
    }
  }

  for (var cG = 0; cG < groups; cG++) {
    tempSubIterator = 0;
    for (var k = 0; k < list2.length; k++) {
      testStringRegEx = "/job\\." + cG + "\\..+?\\.[0-9]+?\\.amount/i";
      if (eval(testStringRegEx).test(list2[k])) {
        tempSubIterator++;
      }
    }
    groupArray[cG][1] = parseFloat(tempSubIterator);
  }

  for (var totalGroups = 0; totalGroups < groups; totalGroups++) {
    for (var totalItems = 0; totalItems < groupArray[totalGroups][1]; totalItems++) {
      totalHourlyIterator = 0;
      dummyArray[totalItems][0] = groupArray[totalGroups][0];
      dummyArray[totalItems][1] = new String("job." + totalGroups + ".payment." + totalItems + ".hours");
      dummyArray[totalItems][2] = new String("job." + totalGroups + ".payment." + totalItems + ".rate");
      dummyArray[totalItems][3] = new String("job." + totalGroups + ".payment." + totalItems + ".amount");

      testState1 = parseFloat(document.getElementById(dummyArray[totalItems][1]).value);
      testState2 = parseFloat(document.getElementById(dummyArray[totalItems][2]).value);
      testState3 = parseFloat(document.getElementById(dummyArray[totalItems][3]).value);

      // default behavior is hourly if everything is empty or 0 or NaN
      if((testState1 == "" || testState1 == "0.00" || parseFloat(testState1) == 0 || isNaN(testState1)) &&
         (testState2 == "" || testState2 == "0.00" || parseFloat(testState2) == 0 || isNaN(testState2)) &&
         (testState3 == "" || testState3 == "0.00" || parseFloat(testState3) == 0 || isNaN(testState3))) {
        totalHourlyIterator++;
      }

      if(testState1 != "" &&
         testState1 != "0.00" &&
         parseFloat(testState1) != 0 &&
         !isNaN(testState1)) {
         totalHourlyIterator++;
      }

      if(testState2 != "" &&
         testState2 != "0.00" &&
         parseFloat(testState2) != 0 &&
         !isNaN(testState2)) {
         totalHourlyIterator++;
       }

      // set our toggle per row
      if(totalHourlyIterator > 0) {
        dummyArray[totalItems][4] = true; // hour mode
        mode = true;
      } else {
        dummyArray[totalItems][4] = false; // salary mode
        mode = false;
      }
    }

    eval("job" + totalGroups).setFieldGroup(dummyArray);

    // calculate immediately?
    if(calculateImmediately) {
    var dumbObj = mode ? dummyArray[0][1] : dummyArray[0][3];
      eval("job" + totalGroups).doIt(document.getElementById(dumbObj), false);
    }

    dummyArray = null;
    makeArray();
  }
}

function caller(type)
{
  var stringDot = ".";
  var tempArray = "";
  var tempID = type.id;
  optionRegEx = /job\..+?/i;
  tempArray = tempID.split(stringDot);
  if(optionRegEx.test(tempID)) {
      eval("job" + tempArray[1]).doIt(type, true);
  }
}

/*
 * Purpose: Confirm password boxes are identical
 */
function checkPassBoxes(strForm, obj1, obj2)
{
	if (obj1 == "" || obj2 == "") {
		alert('Passwords can not be blank! Please enter your password.');
	} else if (obj1 == obj2) {
		// both equal
		document.getElementById(strForm).submit();
	} else {
		// no equal
		alert('Passwords do no match! Please retype your password');
	}
}

function hideSelectBoxes() {
	var selectBoxes = document.getElementsByTagName("select");
	for(var i = 0; i < selectBoxes.length; i++) {
		if(!selectBoxes[i].id == "") {
			selectBoxes[i].style.visibility = 'hidden';
		}
	}
}

function showSelectBoxes() {
	var selectBoxes = document.getElementsByTagName("select");
	for(var i = 0; i < selectBoxes.length; i++) {
		if(!selectBoxes[i].id == "") {
			selectBoxes[i].style.visibility = 'visible';
		}
	}
}

		function SSCCookie(document, name, hours, path, domain, secure) {
			this.$doc = document;
			this.$name = name;
			if (hours) this.$expiration = new Date((new Date()).getTime() + hours * 3600000); else this.$expiration = null;
			if (path) this.$path = path; else this.$path = null;
			if (domain) this.$domain = domain; else this.$domain = null;
			if (secure) this.$secure = true; else this.$secure = false;
		}

		function SSCCookieWrite() {
			var cookieval = "";
			for(var prop in this) {
				if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function') || prop == '') continue;
				if (cookieval != "") cookieval += '&';
				cookieval += prop + ":" + escape(this[prop]);
			}

			var cookie = this.$name + "=" + cookieval;
			if (this.$expiration) cookie += '; expires=' + this.$expiration.toGMTString();
			if (this.$path) cookie += '; path=' + this.$path;
			if (this.$domain) cookie += '; domain=' + this.$domain;
			if (this.$secure) cookie += '; secure';
			this.$doc.cookie = cookie;
		}

		function SSCCookieRead() {
			var allcookies = this.$doc.cookie;
			if (allcookies=="") {
				return false;
			}

			var start = allcookies.indexOf(this.$name + '=');
			if (start == -1) {
				return false;
			}

			start += this.$name.length + 1;
			var end = allcookies.indexOf(';', start);
			if (end == -1) end = allcookies.length;
			var cookieval = allcookies.substring(start, end);
			var a = cookieval.split('&');
			for (var i=0; i<a.length; i++) a[i] = a[i].split(':');
			for (var i=0; i<a.length; i++) this[a[i][0]] = unescape(a[i][1]);
			return true;
		}

		function SSCCookieDelete() {
			var cookie = this.$name + '=';
			if (this.$path) cookie += '; path=' + this.$path;
			if (this.$domain) cookie += '; domain=' + this.$domain;
			cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';
			this.$doc.cookie = cookie;
		}

		new SSCCookie();
		SSCCookie.prototype.write = SSCCookieWrite;
		SSCCookie.prototype.del = SSCCookieDelete;
		SSCCookie.prototype.read = SSCCookieRead;

      function setFontSize(type)
	  {
	    var tempArray = new Array;
	    tagArray = ["P","UL","TD","DIV","SPAN","SELECT","OPTION","INPUT"]

	    switch (type) {
	  	  case 1:
	  		for(var i = 0; i < tagArray.length; i++) {
	  		  tempArray = document.getElementsByTagName(tagArray[i]);
	  		  for(var j = 0; j < tempArray.length; j++) {
	  		  tempArray[j].style.fontSize = "8.5pt";
	  		  }
	  		}

	  		tempArray = document.getElementsByTagName("TH");
	  		for(var j = 0; j < tempArray.length; j++) {
	  		  tempArray[j].style.fontSize = "9pt";
	  		}

	  		tempArray = document.getElementsByTagName("H1");
	  		for(var j = 0; j < tempArray.length; j++) {
	  		  tempArray[j].style.fontSize = "12pt";
	  		}

	  		tempArray = document.getElementsByTagName("H2");
	  		for(var j = 0; j < tempArray.length; j++) {
	  		  tempArray[j].style.fontSize = "10pt";
	  		}
	  	  break;
	  	  case 2:
	  		for(var i = 0; i < tagArray.length; i++) {
	  		  tempArray = document.getElementsByTagName(tagArray[i]);
	  		  for(var j = 0; j < tempArray.length; j++) {
	  		    tempArray[j].style.fontSize = "10pt";
	  		  }
	  		}

	  		tempArray = document.getElementsByTagName("TH");
	  		for(var j = 0; j < tempArray.length; j++) {
	  		  tempArray[j].style.fontSize = "11pt";
	  		}

	  		tempArray = document.getElementsByTagName("H1");
	  		for(var j = 0; j < tempArray.length; j++) {
	  		  tempArray[j].style.fontSize = "14pt";
	  		}

	  		tempArray = document.getElementsByTagName("H2");
	  		for(var j = 0; j < tempArray.length; j++) {
	  		  tempArray[j].style.fontSize = "12pt";
	  		}
	  	  break;
	  	  case 3:
	  		for(var i = 0; i < tagArray.length; i++) {
	  		  tempArray = document.getElementsByTagName(tagArray[i]);
	  		  for(var j = 0; j < tempArray.length; j++) {
	  		    tempArray[j].style.fontSize = "12pt";
	  		  }
	  		}

	  		tempArray = document.getElementsByTagName("TH");
	  		for(var j = 0; j < tempArray.length; j++) {
	  		  tempArray[j].style.fontSize = "13pt";
	  		}

	  		tempArray = document.getElementsByTagName("H1");
	  		for(var j = 0; j < tempArray.length; j++) {
	  		  tempArray[j].style.fontSize = "16pt";
	  		}

	  		tempArray = document.getElementsByTagName("H2");
	  		for(var j = 0; j < tempArray.length; j++) {
	  		  tempArray[j].style.fontSize = "12pt";
	  		}
	  	  break;
	  	  case 4:
	  		for(var i = 0; i < tagArray.length; i++) {
	  		  tempArray = document.getElementsByTagName(tagArray[i]);
	  		  for(var j = 0; j < tempArray.length; j++) {
	  		    tempArray[j].style.fontSize = "14pt";
	  		  }
	  		}

	  		tempArray = document.getElementsByTagName("TH");
	  		for(var j = 0; j < tempArray.length; j++) {
	  		  tempArray[j].style.fontSize = "15pt";
	  		}

	  		tempArray = document.getElementsByTagName("H1");
	  		for(var j = 0; j < tempArray.length; j++) {
	  		  tempArray[j].style.fontSize = "18pt";
	  		}

	  		tempArray = document.getElementsByTagName("H2");
	  		for(var j = 0; j < tempArray.length; j++) {
	  		  tempArray[j].style.fontSize = "14pt";
	  		}
	  	  break;
	    }

		if(switchClassCookie.read() && switchClassCookie.fontSizer) {
		  switchClassCookie.fontSizer = type;
		  switchClassCookie.write();
		}

		if (document.getElementById("fontSize1")) {
			swap_em(type);
		}
	}

	var switchClassCookie = new SSCCookie(document, "SSCFontClass", 365, "/");

	function persistantFont(fontSizer)
	{
	  if(!switchClassCookie.read() || !switchClassCookie.fontSizer) {
	    switchClassCookie.fontSizer = fontSizer;
	    switchClassCookie.write();
	  } else {
	    setFontSize(parseFloat(switchClassCookie.fontSizer));
	  }
	}

	function swap_em(img_name) {
		switch (img_name){
			case 1:
				document.getElementById("fontSize1").src="images/size1_on_new.gif";
				document.getElementById("fontSize2").src="images/size2_off_new.gif";
				document.getElementById("fontSize3").src="images/size3_off_new.gif";
				document.getElementById("fontSize4").src="images/size4_off_new.gif";
				break;
			case 2:
				document.getElementById("fontSize1").src="images/size1_off_new.gif";
				document.getElementById("fontSize2").src="images/size2_on_new.gif";
				document.getElementById("fontSize3").src="images/size3_off_new.gif";
				document.getElementById("fontSize4").src="images/size4_off_new.gif";
				break;
			case 3:
				document.getElementById("fontSize1").src="images/size1_off_new.gif";
				document.getElementById("fontSize2").src="images/size2_off_new.gif";
				document.getElementById("fontSize3").src="images/size3_on_new.gif";
				document.getElementById("fontSize4").src="images/size4_off_new.gif";
				break;
			case 4:
				document.getElementById("fontSize1").src="images/size1_off_new.gif";
				document.getElementById("fontSize2").src="images/size2_off_new.gif";
				document.getElementById("fontSize3").src="images/size3_off_new.gif";
				document.getElementById("fontSize4").src="images/size4_on_new.gif";
				break;
		}
	}



	var notDCResident = new SSCCookie(document, "SSCDCResident", 365, "/");

	function checkNotResident(mytype)
	{
	  var type = (mytype == "1") ? 1 : 0;
	  if(type == null || type == "" || typeof type == "undefined") {
	    if(!notDCResident.read() || !notDCResident.noShow) {
	      notDCResident.noShow = 0;
	      notDCResident.write();
	      return false;
	    } else {
	      return ((notDCResident.noShow == "1") ? 1 : 0);
	    }
	  } else {
	    if(!notDCResident.read() || !notDCResident.noShow) {
	      notDCResident.noShow = type;
	      notDCResident.write();
	      return false;
	    } else {
	      notDCResident.noShow = type;
	      notDCResident.write();
	    }
	  }
	}
