// JavaScript Document

var validatorObject;

/*
  function dateChanged(calendar) {
    // Beware that this function is called even if the end-user only
    // changed the month/year.  In order to determine if a date was
    // clicked you can use the dateClicked property of the calendar:
    if (calendar.dateClicked) {
      // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
      var y = calendar.date.getFullYear();
      var m = calendar.date.getMonth();     // integer, 0..11
      var d = calendar.date.getDate();      // integer, 1..31
      // redirect...
	  calendarElement = calendar.params.flat;
	  //alert(calendarElement.id);  // params.flat is a refernce to the calendar div

	   //Find out what question I'm in

   	  //If the element has a goto then run nextquestion

   	  if ($(calendarElement).attr("goto") != null){
   			nextQuestion($(calendarElement));
	  }

  	//Set the values for the month and day and year

      //window.location = "/" + y + "/" + m + "/" + d + "/index.php";
    }
  };
*/


function asyncAction(controllerAction, successFunction) {
	postData = "action=" + controllerAction + "&async_action=Y";

	if (typeof successFunction != 'function'){
		successFunction = standardAsyncResponseHandler
	}

	$.ajax({
	   type: "POST",
	   url: "/controller.php",
	   data: postData,
	   datatype: "xml",
	   success: successFunction,
	   error: function (XMLHttpRequest, textStatus, errorThrown)
		{
			tb_show(textStatus,'#TB_parameter','',XMLHttpRequest.status+' '+XMLHttpRequest.responseText,'error');
		}
	 });
}

function standardAsyncResponseHandler(msg){
   	 $("errorMessage",msg).each(function(){
		  if ($(this).text() != 'Success') {
			  tb_show('Error','#TB_parameter','',$(this).text(),'error');
		  }
		  });

	$("row",msg).each(function(){
		  tb_show($("RESQ_TITLE",this).text(),'#TB_parameter','',$("RESQ_MESSAGE",this).text().replace(/\n/g, "<br />"),'popup');
   		});
}

function onCalendarUpdate(calendar){
	name = calendar.params.name
	if (name == "startdate" || name == "enddate"){
	$('#cal_data_' + name).attr('timestamp',calendar.date.getTime());
		if ($('#cal_data_enddate').val() != '' && $('#cal_data_startdate').val() != '' ){
			oStartDate = new Date();
			numberOfHours = ($('#cal_data_enddate').attr('timestamp') - $('#cal_data_startdate').attr('timestamp')) / 3600000;
			if ( $("#timebilled").attr("manuallyEdited") != 'Y'){
				$("#timebilled").val(Math.round(numberOfHours*100)/100);
			}
		}
	}

	if(typeof customOnCalendarUpdate == 'function') {
		customOnCalendarUpdate(name, calendar);
	}

}

function isPositiveNumeric(sText) {
		   var ValidChars = "0123456789.";
		   var IsNumber=true;
		   var Char;

			if (sText.length == 0){
				return false;
			}

		   for (i = 0; i < sText.length && IsNumber == true; i++)
			  {
			  Char = sText.charAt(i);
			  if (ValidChars.indexOf(Char) == -1)
				 {
				 IsNumber = false;
				 }
			  }
		   return IsNumber;

		   }


function count_business_days(d1, d2) {         // input given as Date objects

				  var bday;
				  var sdate;
				  var edate;

				   if (d1 == d2){
						return 1;
				   }

				   if (d1 > d2) {
						 sdate = new Date(d2);
						 edate = new Date(d1);
				   } else {
						 sdate = new Date(d1);
						 edate = new Date(d2);
				   }

				   bday = 0;
				  while ( sdate.getTime() <= edate.getTime() ){
						if (sdate.getDay() > 0 && sdate.getDay() < 6) {
							  bday = bday + 1;
						}
						sdate = new Date(sdate.getTime() + 86400000);
				  }

				  if (d1 > d2) {
				  	 bday = (bday - 1) * -1;   //It should be negative and not inclusive
				  }

				  return bday;


			}


var IE=window.external&&(navigator.platform=="Win32"||(window.ScriptEngine&&ScriptEngine().indexOf("InScript")+1));
var FF=(navigator.userAgent.toLowerCase().indexOf("firefox")+1)?true:false;
var OP=window.opera&&window.print;
var NS=window.netscape&&!OP;


function tryClipboard(data){
	if(window.clipboardData||NS){
		if(IE&&!FF){
			if(!window.clipboardData.setData("Text",data))	{
				alert("Data was not copied to clipboard!");
				return false;
			}
		} else {
			try{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect")
			}catch(e){
				if(confirm("Your current Internet Security settings do not allow data copying to clipboard. \nTry to find instructions?")){
					if (FF) {
					alert('In the firefox address bar, type in: "about:config" (no quotes), and hit enter.' +
						'In the "filter" box you now see, type in the word "signed", and you should only have one result coming' +
						"up. It's set to DISABLED. Double-click it, and it should change to ENABLED. Close the window. \n\n" +
						"From then on, firefox will warn you when a website tries to access your clipboard, and you can " +
						'tell it to "always allow this site...."');
					} else {
						alert('We do not have specific instruction for your browser');
					}
				} else
					alert("Data was not copied to clipboard!");
					return false;
				}
				try {
					nsIClip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard)
				} catch(e){
					return false;
				}
				try{
					nsITran = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable)
				} catch(e){
					return false;
				}
				nsITran.addDataFlavor("text/unicode");
				nsISupport = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
				nsISupport.data = data;
				nsITran.setTransferData("text/unicode",nsISupport,data.length*2);
				try{
					nsIClipInterface = Components.interfaces.nsIClipboard
				} catch(e){
					return false;
				}
				nsIClip.setData(nsITran,null,nsIClipInterface.kGlobalClipboard);
		}
	} else {
		if(OP){
			alert("Opera is not supported");
		} else {
			alert("Your browser doesn't support copy to clipboard feature.");
			return false;
		}
	}
	return true;
}


function menuActionHandler(action,gridname,col0) {
			switch(action){
				case "ExcelExport":
					window.location = '/excelReports/excelReport.php?name=' + gridname;
					break;
				case "CopyToClipboard":
					mygrid = eval("my_" + gridname + "_grid");
					//alert("my_" + gridname + "_grid\n" + mygrid.name + '\n' +	mygrid.serialize());
					mygrid.setSerializationLevel(true,true);
					mygrid.enableCSVHeader(true);
					mygrid.setCSVDelimiter("\t");
					data = mygrid.serializeToCSV();
					tryClipboard(data);
					break;
				case "Debug":
					alert(gridname);//.html());
					window.clipboardData.setData("Text",gridname);
					break;
				case "GridURL":
					//Instructions on how to get this to work on FF http://www.febooti.com/support/website-help/website-javascript-copy-clipboard.html
					//window.clipboardData.setData("Text","/gridload/xmlData.php?name=calllist");
					window.open("/gridload/xmlData.php?name=" + gridname);
					break;
				case "GridURLDebug":
					window.open("/gridload/xmlData.php?name=" + gridname + "&debug=Y");
					break;
				case "ResizeAll":
					mygrid = eval("my_" + gridname + "_grid");
					var cols = mygrid.getColumnsNum();
					for (var cInd=0;cInd<mygrid.getColumnsNum();cInd++) {
						mygrid.adjustColumnSize(cInd)
					}
					if (col0 != 0) {
						mygrid.setColWidth(0, col0);

					}
					//if mygrid.getColumnSize
					break;
			}

}


function onMenuSelect(menuitemId,grid_Id,elementClicked){
			//var data=grid_Id.split("_"); //rowId_colInd
			var arg = menuitemId.split("_");

			if ($(elementClicked).hasClass("objbox")){
				parentDiv = $(elementClicked).parents("div").get(0);
			} else {
				parentDiv = $(elementClicked).parents(".objbox").get(0);
				parentDiv = $(parentDiv).parents("div").get(0);
			}

			divID = $(parentDiv).attr('id');
			gridname = divID.substring(8);
			menuActionHandler(arg[0],gridname);

	    }

// prototype a "getPrintHTML" func for the grid controls (mostly = dhtmlx's "printView" func with some changes
dhtmlXGridObject.prototype.getPrintHTML = function(whichCols) {
	// use whichcols to specify which ones to not? print
	// currently unused but gotta be done
	var html = "";
//	var html="<style>TD {font-family:Arial;text-align:center};</style>";
//	html+="<base href='"+document.location.href+"'></base>";
	html += '<table width="100%" border="2px" cellpadding="0" cellspacing="0" class="gridControl">';

	var row_length = this.rowsCol.length;
	var col_length = this._cCount;
	var width = this._printWidth();
	html += '<tr>';

	for (var i=0;i<col_length;i++){
		if ((this._hrrar && this._hrrar[i]) || (whichCols && whichCols[i]))
			continue;
		var colspan=(this.hdr.rows[1].cells[this.hdr.rows[1]._childIndexes?this.hdr.rows[1]._childIndexes[parseInt(i)]:i].colSpan||1);
		for (var j=1;j<colspan;j++)
			width[i]+=width[j];
		html += '<th width="'+width[i]+'%" colspan="'+colspan+'">'+this.getHeaderCol(i)+'</td>';
		i+=colspan-1
	};
	html += '</tr>';
	for (var i=2;i<this.hdr.rows.length;i++)
		html+="<tr>"+this.hdr.rows[i].innerHTML+"</tr>";

	for (var i=0;i<row_length;i++){
		html += '<tr>';
		for (var j=0;j<col_length;j++){

			if ((this._hrrar && this._hrrar[j]) || (whichCols && whichCols[j]))
				continue;
			var c=this.cells(this.rowsCol[i].idd, j);

			if (c.getImage)
				var value = c.cell.innerHTML;
			else
				var value = c.getValue();

			// ok so, take the contents of c.cell and see if there are any *things* in it that we don't want
			// but, we want to remove the whole column so...hm

			// if there is a carat in the data, remove it and everything that comes after it
			var pos = value.indexOf('^');
			if (pos != -1) {
				// find the carat
				value = value.substr(0, pos);
			}

			var color = this.columnColor[j]?'background-color:'+this.columnColor[j]+';':'';
			var align = this.cellAlign[j]?'text-align:'+this.cellAlign[j]+';':'';
			html += '<td style="'+color+align+'">'+(value===""?"&nbsp;":value)+'</td>'
		};
		html += '</tr>'
	};
	if (this.ftr)
		for (var i=1;i<this.ftr.childNodes[0].rows.length;i++)
			html+="<tr>"+this.ftr.rows[i].innerHTML+"</tr>";

	html += '</table>';

	return html;
};

function dhtmlxGridPrint(gridroot, appendTo, d) { // PRINT HANDLER FOR DHTMLX GRID CONTROLS
	// the id is gridbox_<<theGridName>>
	// and the corresponding js grid object is
	// my_<<theGridName>>_grid

	var doNotPrintColRules = { // the boolean value of true for a column = do not print.  False or null = go ahead and print
		'ActiveCalls':					[true] // do not print the first column ('select' checkboxes)
		,'user_projecttasks':		[true] // first col is magnifying glass
		,'projecttaskevents':		[true] // first col is magnifying glass
		,'ProjectDocuments':		[false, false, false, false, false, false, true] // last (7th) col is download link
	}

	var rawName = gridroot.id.replace('gridbox_','');
	var thething = 'my_' + rawName + '_grid';

	var printCols = doNotPrintColRules[rawName] ? doNotPrintColRules[rawName] : [];

	if (window[thething]) {
		var newDiv = appendTo.appendChild(d.createElement('div'));
		newDiv.innerHTML = window[thething].getPrintHTML(printCols);
	}
	// strip out columns depending on which grid this is
	switch (rawName) {
		default:
			// all the cols are good
		break
	}
}

function formPrintRecursive(formRoot, appendTo, d) {
	switch (formRoot.nodeType) {
		case 1:// it's an HTML element, not a text node
			//alert('html el');
			switch (formRoot.tagName.toLowerCase()) {
				case 'button':
					// ignore
				break;
				case 'input':
					switch (formRoot.type) {
						case 'hidden':
						case 'button':
						case 'submit':
							// dont do anything
							//alert("ignoring " + formRoot.type);
						break;
						default:
							//alert(formRoot.type);
							//alert('processing an INPUT');
							var span = appendTo.appendChild(d.createElement('span'));
							span.appendChild(d.createTextNode(formRoot.value));
						break;
					}
				break;
				case 'select':
					var span = appendTo.appendChild(d.createElement('span'));
					span.appendChild(d.createTextNode(formRoot.value));
				break;
				case 'textarea':
					var span = appendTo.appendChild(d.createElement('span'));
					span.appendChild(d.createTextNode(formRoot.value));
				break;
				case 'div':
					if (formRoot.className != 'S360ClickButton') {
						var thing = appendTo.appendChild(d.createElement(formRoot.tagName));
						var children = formRoot.childNodes;
						for (var i=0; i < children.length; i++) {
							//alert('about to process child ' + children[i].innerHTML);
							formPrintRecursive(children[i], thing, d);
						}
					}
				break;
				case 'script': // no scripts
				break;
				default:
					var thing = appendTo.appendChild(d.createElement(formRoot.tagName));
					var children = formRoot.childNodes;
					for (var i=0; i < children.length; i++) {
						//alert('about to process child ' + children[i].innerHTML);
						formPrintRecursive(children[i], thing, d);
					}
				break;
			}
		break;
		case 3: // its a text node
			appendTo.appendChild(d.createTextNode(formRoot.nodeValue));
		break;
	}
}

function cloneDOMTree(cloneFrom, cloneTo, d) {

	// these can be className, tagName or id
	// DONE: supports AND logic if two or more elements are specified
	var doNotPrint = [
		{className:'dynarch-horiz-menu'} // main menu
		,{className:'dynarch-popup-menu'} // the popup (hidden) part of the main menu
		,{id:'printer-friendly-switch'} // the printer friendly button
		,{id:'menu'} // another part of the main menu
		,{tagName:'script'} // any script tags
		,{className:'menuTable'} // the right-click menu for grids
		,{className:'bottomButtonRow'} // the 'Print Selected Report' button and other buttons next to it
		,{className:'invisibleForm'} // this appears to be a display=none version of an input form for the current (view only) page
		,{className:'submit',tagName:'p'}
	];

	var printHandlers = [
		{className:'gridbox', handler:dhtmlxGridPrint}
		,{tagName:'fieldset', className:'standard', handler:formPrintRecursive}
	]; // all the print handlers need to accept 3 params -> the node we are testing, the container on the new page, and the new page's document node (for createElement etc)
		// JF TODO - try to get the document node from the new page's container that way we can skip passing a param

	var appendChildrenTo = null; // where to append any child nodes to
	if (cloneFrom.nodeName == 'BODY') {
		// if this is the body, we already have a new body so don't create it.
		appendChildrenTo = cloneTo;
	} else {
		appendChildrenTo = null;
		switch (cloneFrom.nodeType) {
			case 3: // this is a text node
				cloneTo.appendChild(d.createTextNode(cloneFrom.nodeValue));
			break;
			case 2: // this is an attribute node
				// this never gets hit because we're not iterating thru attributes
			break;
			case 1: // this is an element node
				var appendIt = true; // whether or not to append this node
				var useDefaultHandler = true; // if we have a custom print handler for this node, this becomes false

				for (var i=0; i < printHandlers.length; i++) {
					var ph = printHandlers[i];
					// the printhandlers are responsible for appending (or not) any content for this node AND ALL CHILDREN

					if (ph['tagName'] != null && ph['handler'] != null && cloneFrom.nodeName.toUpperCase() == ph['tagName'].toUpperCase()) {
						ph['handler'](cloneFrom, cloneTo, d); // we assume that all of the children are handled by this func
						useDefaultHandler = false;
						appendIt = false;
						break; // only ONE print handler per element - so be careful to match the elements well
					}

					if (ph['id'] != null && ph['handler'] != null && cloneFrom.id.toUpperCase() == ph['id'].toUpperCase()) {
						ph['handler'](cloneFrom, cloneTo, d); // we assume that all of the children are handled by this func
						useDefaultHandler = false;
						appendIt = false;
						break;
					}

					if (ph['className'] != null && ph['handler'] != null && cloneFrom.className.toUpperCase().indexOf(ph['className'].toUpperCase()) != -1) {
						ph['handler'](cloneFrom, cloneTo, d); // we assume that all of the children are handled by this func
						useDefaultHandler = false;
						appendIt = false;
						break;
					}
				}
				if (useDefaultHandler) {
					// check the donotprint rules and if this element matches don't copy it

					for (var i=0; i < doNotPrint.length; i++) {
						var dnp = doNotPrint[i];
						var ruleApplies = true;

						for (var ruleType in dnp) { // supported:  If two or more rule types are specified, use AND logic (so both must be true for the item to NOT be copied to the print friendly page)
							switch (ruleType) { // assume that the rule applies and try to disprove it
								case 'tagName':
									if (cloneFrom.nodeName.toUpperCase() != dnp[ruleType].toUpperCase()) { // the the tagName does not match
										ruleApplies = false;
									}
								break;
								case 'id':
									if (cloneFrom.id.toUpperCase() != dnp[ruleType].toUpperCase()) { // the id does not match
										ruleApplies = false;
									}
								break;
								case 'className':
									if (cloneFrom.className.toUpperCase().indexOf(dnp[ruleType].toUpperCase()) == -1) { // the className was not found in the class string
										ruleApplies = false;
									}
								break;
							}
							if (!ruleApplies) break; // we have disproven the rule and don't need to keep checking
						}

						if (ruleApplies) { // we have a rule that definitely applies, so don't bother checking the other rules
							appendIt = false;
							break;
						}

					}
				}
				if (appendIt) {
					var newNode = cloneTo.appendChild(cloneFrom.cloneNode(false));
					appendChildrenTo = newNode;
				}
			break;
		}
	}
	// iterate through the children of this node, recursively calling this function
	var theKids = cloneFrom.childNodes;
	if (appendChildrenTo != null) { // this will be NULL if we have invoked a custom print handler for this element, or if a "no print" rule was matched
		for (var i=0; i < theKids.length; i++) {
			cloneDOMTree(theKids[i], appendChildrenTo, d);
		}
	}

}


	    /**
 * Initialize the button for switching between printer/non-printer friendly view.
 */
$(document).ready(
	function() {
		// Get current page name
		var sPath = window.location.pathname;
		var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

		// prepare mousedown/up events for buttons
		$("fieldset.standard p.submit input, .bottomButtonRow input, fieldset.standard button").bind("mousedown", function (e) {$(this).addClass("down");});
		$("fieldset.standard p.submit input, .bottomButtonRow input, fieldset.standard button").bind("mouseout mouseup", function (e) {$(this).removeClass("down");});
	}
);

// Add commas to number at thousands
// From: http://www.mredkj.com/javascript/numberFormat.html#addcommas
function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

// eXcell type is defined here
// More info: http://www.dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Custom_excell_creation.html#grid_cexc
function eXcell_price2(cell)
{
	// Default pattern, just copy it
	if (cell)
	{
		this.cell = cell;
		this.grid = this.cell.parentNode.grid;
	}

	// Read-only cell doesn't have edit method
	this.edit = function(){}

	// The cell is read-only, that's why it is always in the disabled state
	this.isDisabled = function(){ return true; }

	// Set the value of the cell
	this.setValue = function(val)
	{
		// Convert value to a number
		val = Number(val);

		// Set color depending on value
		var color = 'green';
		if (val < 0)
		{
			color = 'red';
		}

		// Format number
		val = val.toFixed(2);
		val = addCommas(val);

		// Create Value
		this.setCValue('<span style="padding-right:2px;color:'+color+';"><span>$</span><span>'+val+'</span></span>', val);
	}

	this.getValue = function()
	{
		return this.cell.childNodes[0].childNodes[1].innerHTML;
	}
}
// Nest all other methods from base class
eXcell_price2.prototype = new eXcell;



function createLoadingDiv(container) {
	var loadingDiv = container.appendChild(container.ownerDocument.createElement('div'));
	loadingDiv.id = container.id + "_LOADINGDIV";
	loadingDiv.className = 'grid_blocking_div';

	var centeredDiv = loadingDiv.appendChild(container.ownerDocument.createElement('div'));
	centeredDiv.className = 'centered_div';

	var loadingText = centeredDiv.appendChild(container.ownerDocument.createTextNode('Loading Grid Data'));

	var loadingBR = centeredDiv.appendChild(container.ownerDocument.createElement('br'));

	var loadingImg = centeredDiv.appendChild(container.ownerDocument.createElement('img'));
	loadingImg.src = '/images/loadingAnimation.gif';
}

function destroyLoadingDiv(container) {
	var loadingDiv = container.ownerDocument.getElementById(container.id + "_LOADINGDIV");
	loadingDiv.parentNode.removeChild(loadingDiv);
}


// add filters to some grids using the dhtmlx grid filtering and a custom filter selection screen
function gridFilters(data) {
	var btn = document.getElementById(data.id);
	var offset = $(btn).offset();
	offset.top += $(btn).outerHeight();

	var theGrid = window['my_' + data.grid + '_grid'];
	if (theGrid.filterPage) {
		if (theGrid.filterPage.style.display == 'none') {
			theGrid.filterPage.style.display = '';
			theGrid.filterPage.style.top = offset.top + 'px';
			theGrid.filterPage.style.left = offset.left + 'px';
		} else {
			theGrid.filterPage.style.display = 'none';
			return;
		}
	} else {
		var c = document.body.appendChild(document.createElement('div'));
		c.className = 'filterOptionsScreen';

		c.style.top = offset.top + 'px';
		c.style.left = offset.left + 'px';
		c.appendChild(document.createElement('h3')).appendChild(document.createTextNode('Filters'));

		for (var f in data.filters) {
			switch (f) {
				case 'date':
					var fd = data.filters[f];
					switch (fd.type) {
						case 'between':
							var fromControl = c.appendChild(document.createElement('p'));
							fromControl.appendChild(document.createElement('label')).appendChild(document.createTextNode('Start Date'));
							var fromInput = fromControl.appendChild(document.createElement('input'));
							fromInput.type = 'text';

							var toControl = c.appendChild(document.createElement('p'));
							toControl.appendChild(document.createElement('label')).appendChild(document.createTextNode('End Date'));
							var toInput = toControl.appendChild(document.createElement('input'));
							toInput.type = 'text';

						break;
						default:

						break;
					}
				break;
				default:

				break;
			}
		}
		var buttonContainer = c.appendChild(document.createElement('p'));
		buttonContainer.style.textAlign = 'center';
		var applyFilterButton = buttonContainer.appendChild(document.createElement('button'));
		applyFilterButton.innerHTML = 'Apply Filter';
		applyFilterButton.onclick = function () {
			var toControl = this.parentNode.previousSibling.getElementsByTagName('input')[0];
			var fromControl = this.parentNode.previousSibling.previousSibling.getElementsByTagName('input')[0];
			if (toControl.value.length == 0 && fromControl.value.length == 0) {
				// just clear  the filter
				theGrid.filterBy(4, null);
				return false;
			}
			if (isNaN(Date.parse(fromControl.value))) {
				alert('The Start Date in your filter is invalid.');
				return false;
			}
			if (isNaN(Date.parse(toControl.value))) {
				alert('The End Date in your filter in invalid.');
				return false;
			}
			// hide the filter page
			theGrid.filterPage.style.display = 'none';
			theGrid.filterBy(4, function(data) {
				if (isNaN(Date.parse(data))) {
					return false;
				}
			 	if (Date.parse(data) >= Date.parse(fromControl.value) && Date.parse(data) <= Date.parse(toControl.value)) {
			 		return true;
			 	}
			 	return false;
			});
			return false;
		};

		var clearFilterButton = buttonContainer.appendChild(document.createElement('button'));
		clearFilterButton.innerHTML = 'Clear Filter';
		clearFilterButton.onclick = function () {
			var inputEls = theGrid.filterPage.getElementsByTagName('input');
			for (var i=0; i < inputEls.length; i++) {
				inputEls[i].value = '';
			}
			theGrid.filterPage.style.display = 'none';
			theGrid.filterBy(2, null);
			return false;
		};

		theGrid.filterPage = c;
	}
}

