//since evalScripts is true, if any script tags come back, those scripts will run (needed for some of our pages)
//do not use this to call 3rd party urls where unsafe script tags may be returned
//if you need to load in potentially unsafe content, call ajaxExternalUpdater instead
function ajaxUpdater(id, url, loadingmsg) {
	//location.hash = '#' + id;
	var y = windx.getPageScroll()[1]; //remember the y scroll position (and avoid the boink!)
	var h = $('container').getHeight().toString() + 'px'; //remember the original height of the wrapper
	$('container').setStyle({height: h}); //explicitly the height of the wrapper so when we display the loading message, it doesn't shift the page around
	showLoading(id, loadingmsg);
	new Ajax.Updater(id, url, {
		asynchronous:true,
		evalScripts:true,
		onComplete: function() {
			initPage(id); //initialize the new content we just loaded
			self.scrollTo(0,y); //scroll back to the original scroll position
			$('container').setStyle({height: 'auto'}); //reset the height to whatever it really needs
		}
	});
}

//evalScripts is false so no script tags will be executed
//use this to make a call to 3rd party urls that may contain unsafe scripts
function ajaxExternalUpdater(id, url, loadingmsg) {
	var y = windx.getPageScroll()[1]; //remember the y scroll position (and avoid the boink!)
	var h = $('container').getHeight().toString() + 'px'; //remember the original height of the wrapper
	$('container').setStyle({height: h}); //explicitly the height of the wrapper so when we display the loading message, it doesn't shift the page around
	showLoading(id, loadingmsg);
	new Ajax.Updater(id, url, {
		asynchronous:true,
		evalScripts:false,
		onComplete: function() {
			initPage(id); //initialize the new content we just loaded
			self.scrollTo(0,y); //scroll back to the original scroll position
			$('container').setStyle({height: 'auto'}); //reset the height to whatever it really needs
		}
	});
}

//make an ajax call and put the returned html into a windx
function ajaxWindx(url, windxid, title, windxstyles, windxcontentstyles) {
	new Ajax.Request(url, {
		onSuccess: function(transport) {
			//show the windx with the html in it
			windx.showHTML(windxid, title, transport.responseText, windxstyles, windxcontentstyles);
			//check if there's a response, and redirect if needed
			var json = getJSONResponse(windx.makeID(windxid));
		},
		onFailure: function() {
			//an error occurred, show a message
			windx.showHTML(windxid, title, 'Something went wrong...');
		},
		onComplete: function() {
			initPage(windx.makeID(windxid)); //initialize the new content we just loaded
		}
	});
}

//make an ajax call and redirect if needed (based on the response that comes back)
//otherwise show the message and show validation errors if any
function ajaxRedirector(transport, id) {
	try {
		$(id).update(transport.responseText); //dump out the response to the screen (it should contain a jsonresponse)
		var json = getJSONResponse(id);
		//TODO: display message in response.cfm instead of here thru JS????
		//new Insertion.Top(id, json.message.unescapeHTML()); //insert the response's message at the top of the other HTML we just dumped into the DOM
		initPage(id); //initialize the new content we just loaded
	} catch(err) { //catch any errors that occurred (particularly the badly formed json error)
		new Insertion.Top(id, err.message); //print the error message to the screen
	}
}
// Post a form with ajax
// EX: ajaxPost(Event.findElement(e, 'form'),'resultsid', '_pageyourecalling.cfm',  'string loading message ', '');
function ajaxPost(form, resultid, requestedURL, loadingmsg, failuremsg) {
	var success = false; //need to keep track of when the onSuccess event runs
	try {
		if(!requestedURL) {requestedURL = form.action;} //default requestedURL to the form action if it was not passed in
		new Ajax.Request(requestedURL, {
			onLoading: function(request) {
				//don't do this if the onSuccess event already fired!!
				//sometimes the onSuccess runs before onLoading and messes it all up
				if(!success) {
					if(!loadingmsg) {loadingmsg = 'working . . . ';}
					showLoading(resultid, loadingmsg);
				}
			},
			onSuccess: function(transport) {
				//flag it so the onLoaded event doesn't run after this runs
				success = true;
				ajaxRedirector(transport, resultid);
			},
			onFailure: function() {
				if(!failuremsg) {failuremsg = 'Error occured processing request.';}
				$(resultid).update(failuremsg);
			},
			method: 'post',
			parameters: $(form).serialize(true) //serialize all the form fields from the form which the clicked button belongs to
		});
	}
	catch(err){
		new Insertion.Top(resultid, err.message); //print the error message to the resultid
	}
}

//pull the json response out of the given element id
function getJSONResponse(id) {
	var jsonresponse = $$('.jsonresponse').first(); //find the jsonresponse that is now in the DOM
	if(jsonresponse) {
		var json = jsonresponse.value.evalJSON(); //parse out the actual json
		//if(json.status.toUpperCase() == 'OK') { //if the response status is OK
			if(json.redirect.url.length > 0) {//if the redirect URL has a length redirect
				location.href = json.redirect.url.unescapeHTML(); //redirect if we need to
			}
		//}
		return json;
	} else {
		return null;
	}
}

//clear out all the errors from a form
//if no form is passed in, loop over all forms on the page
//and clear out all errors on all the forms
function clearAllValidationErrors(form) {
	if(form) {
		$(form).getElements().each(function(elem) {
			elem.removeClassName("error");
		});
	} else {
		$$('form').each(function(frm) {
			clearAllValidationErrors(frm);
		});
	}
}

//show the validation errors by looping over the fields in the response
//flag each invalid field with the "error" css class
function showValidationErrors() {
	var jsonresponse = document.getElementsByClassName('jsonresponse').first(); //find the jsonresponse that is now in the DOM
	var json = jsonresponse.value.evalJSON(); //parse out the actual json
	var firstone = true;
	var fields = json.fields;
	for(var f = 0; f < fields.length; f++) {
		if(fields[f].valid) {
			$(fields[f].id).removeClassName("error");
		} else {
			$(fields[f].id).addClassName("error");
			if(firstone) {
				//activate the first error field in the form
				$(fields[f].id).activate();
				firstone = false;
			}
		}
	}
}

//find the first field in the form that has an error and active it (focus then select)
//if no form is passed in, loop over all forms on the page
function activateFirstErrorField(form) {
	var foundit = false;
	if(form) {
		$(form).getElements().each(function(elem) {
			if(elem.hasClassName("error")) {
				elem.activate();
				foundit = true;
				throw $break; //stop looping over the field elements
			}
		});
		return foundit;
	} else {
		$$('form').each(function(frm) {
			if(activateFirstErrorField(frm)) {
				throw $break; //stop looping over the forms
			}
		});
		return foundit;
	}
}

//make all the elements the same height
//pass in the elements using the $ function
//ex: makeSameHeight($('elem1', 'elem2'));
function makeSameHeight(elements) {
	if(elements.length > 1) { //check to make sure more than 1 element was passed in
		var h = elements.invoke('getHeight').max() + 'px'; //find the max height
		elements.invoke('setStyle', {height:h}); //reset the height on each element to the max height
	}
}
//reset the height of an element if it falls short of the minheight
//used for IE, since it ignores the minheight
//pass in the element using the $ function
//ex: setMinHeight($('elem1', 'elem2'), 100)
function setMinHeight(element, minheight) {
	var element = $(element);
	if(element.getHeight() < minheight) {
		element.setStyle({height: minheight + 'px'});
	}
}

//show the loading graphic & message
function showLoading(id) {
	//ex: showLoading('searchresults');
	//ex: showLoading('searchresults', 'searching...');
	//ex: showLoading('searchresults', 'searching...', 'ajaxloaderimage2');
	//ex: showLoading('searchresults', 'searching...', 'ajaxloaderimage2', false);
	//ex: showLoading('searchresults', null, null, false);
	var message = null;
	var img = null;
	var clearContents = true;
	if(arguments.length >= 2) {
		var message = arguments[1];
	}
	if(arguments.length >= 3) {
		var img = arguments[2];
	}
	if(arguments.length >= 4) {
		var clearContents = arguments[3];
	}
	
	//clear out the contents of the target element if needed
	if(clearContents) {
		$(id).update();
	}
	//if a null message is passed in, give it a default
	if(message == null) {
		message = 'loading';
	}
	//now insert the message at the top of the element (whether it's been cleared out or not)
	new Insertion.Top(id, message);
	//if a null img was passed in, use the default
	if(img == null) {
		img = 'ajaxloaderimage';
	}
	//make sure this image was preloaded in the DOM, then insert it at the top of the element (before the message if it was added)
	if($(img) != null) {
		new Insertion.Top(id, $(img).innerHTML + '&nbsp;');
	}
	//new Insertion.Top(id, '<br clear="all"/>');
}

//function to run when the quick search runs
function doQuickSearch(e) {
	//since we've got 2 forms here, let's make sure we clear out all the validation error flags on BOTH forms
	clearAllValidationErrors('frmPolicyQuickSearch');
	clearAllValidationErrors('frmAccountQuickSearch');
	ajaxPost(Event.findElement(e, 'form'), 'quickSearchResults', null, 'searching...');
	Event.stop(e);
}

//popup a windx, the <a> tag contains all the info we need
//ex: <a href="someurlhere" id="idoflink" class="popupwindx" windxstyles="{top:'10px'}" windxcontentstyles="{height:'200px'}">link text</a>
function popupWindx(atag) {
	var url = atag.href; //grab the url from the tag's href
	var title = atag.title; //grab the url from the tag's href
	var name = atag.name; //grab the window name from the tag's name
	if(name.length == 0) {
		name = atag.id; //if no name, then use the id
	}
	if(name.length == 0) {
		name = 'popupwindx'; //if no name or id, then just give it a generic name
	}
	var windxstyles = atag.readAttribute('windxstyles'); //grab the styles for the windx
	if(!windxstyles) { //if windxstyles is not defined in the tag
		windxstyles = "{}"; //create an empty windxstyles
	}
	windxstyles = windxstyles.evalJSON(); //convert it to JSON
	var windxcontentstyles = atag.readAttribute('windxcontentstyles'); //grab the styles for the windx content
	if(!windxcontentstyles) { //if windxcontentstyles is not defined in the tag
		windxcontentstyles = "{}"; //create an empty windxcontentstyles
	}
	windxcontentstyles = windxcontentstyles.evalJSON(); //convert it to JSON
	var height = atag.readAttribute('wheight'); //grab the height of the windxcontent
	if(height) { //if a height was defined in the tag
		windxcontentstyles.height = height; //add the height to the windxcontentstyles JSON
	}
	var width = atag.readAttribute('wwidth'); //grab the width of the windxbox
	if(width) { //if a width was defined in the tag
		windxstyles.width = width; //add the width to the windxstyles JSON
	}
	var scrolltop = atag.readAttribute('wscrolltop'); //grab the top of the windxbox (# px from current scrolled position)
	if(scrolltop) { //if scrolltop was defined in the tag
		windxstyles.scrolltop = scrolltop; //add the scrolltop to the windxstyles JSON
	}
	ajaxWindx(url, name, title, windxstyles, windxcontentstyles); //popup the windx, making an ajax call for the content
}

//popup a window, the <a> tag contains all the info we need
//ex: <a href="someurlhere" id="idoflink" class="popup" pheight="100" pwidth="200" pfeatures="otherwindowfeatures">link text</a>
function popupWindow(atag) {
	var url = atag.href; //grab the url from the tag's href
	var name = atag.name; //grab the window name from the tag's name
	if(name.length == 0) {
		name = atag.id; //if no name, then use the id
	}
	if(name.length == 0) {
		name = 'popupwindow'; //if no name or id, then just give it a generic name
	}
	var features = atag.readAttribute('pfeatures'); //grab the popup features from the tag
	if(!features || features.length == 0) {
		features = 'scrollbars=1,resizable=yes'; //if no features specified, use these as default
	}
	var height = atag.readAttribute('pheight'); //grab the height of the window
	if(height && !isNaN(height)) {
		features += ',height=' + height; //if we found a height, add it to the features
	}
	if(features.indexOf('height') == -1) {
		features += ',height=500'; //add a default height
	}
	var width = atag.readAttribute('pwidth'); //grab the width of the window
	if(width && !isNaN(width)) {
		features += ',width=' + width; //if we found a width, add it to the features
	}
	if(features.indexOf('width') == -1) {
		features += ',width=700'; //add a default width
	}
	openWindow(url, name, features);
}

//open a new window and start by showing a loading graphic
function openWindow(url, name, features, loading) {
	var loadingholder = document.createElement('div'); //create a new container for the loading graphic (but don't add it to the document)
	showLoading(loadingholder, loading); //show the loading graphic in this new container
	if(name.length == 0) {
		name = 'popupwindow'; //if no name or id, then just give it a generic name
	}
	name = name + Date.parse(new Date()); //make each window name unique
	if(!features || features.length == 0) {
		features = 'scrollbars=1,resizable=yes,height=500,width=700'; //if no features specified, use these as default
	}
	newWindow = window.open('', name, features); //open up the new popup window (empty at first)
	newWindow.document.write(loadingholder.innerHTML); //add the loading graphic to the new window
	loadingholder = null; //wipe out the container we just created
	if(url && url.length) { //check to make sure there's a url to go to
		newWindow.location.href = url; //move to the new url
	}
	return newWindow;
}

//checks length of indicated current field, and auto tabs to the indicated next field if length equals or exceeds specified value
function autoFieldTab(e, curField, nextField, valLen){
	if(($F(curField).length >= valLen) && (e.keyCode!=9) && (e.keyCode!=16)){
		$(nextField).focus();
	}
}

//initialize the watermark in the element
function initWatermark(elem) {
	var watermark = elem.readAttribute('watermark').strip(); //find the watermark text to use
	switch(elem.tagName.toUpperCase()) { //check the type of element
		case 'INPUT': //if it's an input tag, check the input type
			switch(elem.type.toUpperCase()) {
				case 'TEXT': //it's a text box
					if(elem.value.blank()) { //is the text box value blank?
						elem.value = watermark; //reset the value to the watermark
					}
					break;
			}
			break;
	}
	setWatermarkStyles(elem); //now set up the watermark styles
}

//clear the watermark in the element
function clearWatermark(elem) {
	var watermark = elem.readAttribute('watermark').strip(); //find the watermark text to use
	switch(elem.tagName.toUpperCase()) { //check the type of element
		case 'INPUT': //if it's an input tag, check the input type
			switch(elem.type.toUpperCase()) {
				case 'TEXT': //it's a text box
					if(elem.value.strip() == watermark) { //does the text box value match the watermark?
						elem.value = ''; //clear out the watermark text
					}
					break;
			}
			break;
	}
	setWatermarkStyles(elem); //now set up the watermark styles
}

//set up the styles for how the watermark should appear
function setWatermarkStyles(elem) {
	var addWatermark = false; //boolean to indicate whether we need to add the watermark css class or not
	var watermark = elem.readAttribute('watermark').strip(); //find the watermark text to use
	switch(elem.tagName.toUpperCase()) { //check the type of element
		case 'INPUT': //if it's an input tag, check the input type
			switch(elem.type.toUpperCase()) {
				case 'TEXT': //it's a text box
					if(elem.value.strip() == watermark) { //is the text box value blank or the same as the watermark text?
						addWatermark = true; //indicate we want to add the watermark styles
					}
				break;
			}
			break;
	}
	if(addWatermark) { //if we need to add the watermark styles
		elem.addClassName('watermark'); //add the watermark css class to the element
	} else {
		elem.removeClassName('watermark'); //remove the watermark css class from the element
	}
}

//handles calender popups (requires lib/CalendarPopup.js)
//call using showCalendar('field','anchor');
//where "field" is the form field to be modified and "anchor" is the tag id for the tag to anchor the popup to
//code assumes the tag also has the watermark attribute defined
var dateField='';
function showCalendar(calenderField,calenderAnchor){
	var cal=new CalendarPopup();
	cal.showYearNavigation();
	cal.setReturnFunction("setDateField('"+calenderField+"');window.opener.showCalendarReturn");
	cal.showCalendar(calenderAnchor);
}
function setDateField(field){dateField=field;}
function showCalendarReturn(y, m, d){
	$(dateField).value = m.toPaddedString(2) + "/" + d.toPaddedString(2) + "/" + y;
	initWatermark($(dateField));
	$(dateField).simulate('change');
}


//run some code after the window loads
Event.observe(window, 'load', function(e){
	//bind the quick search link to handle the click event
	if($("togglequicksearch")) {
		Event.observe('togglequicksearch', 'click', function(e) {
			var url = $(Event.element(e)).readAttribute('qsform'); //grab the url for the quick search form from the qsform attribute of this a tag
			ajaxWindx(url, 'quicksearch', 'Quick Search', {width:'410px'}); //make the ajax call and show the quick search in a windx
			Event.stop(e);
		});
	}
	//set the last menu option to drop down aligned with the right edge of the li above it in the nav
	/*if ($("nav_OurAgency")) { 
		var r = $("nav_OurAgency").getWidth() - $("nav_OurAgency").up('li').getWidth() + 1;
		$("nav_OurAgency").setStyle({'left': '-' + r +'px'});
	}*/
	// loop over the nav to find items with menus to bind this function to remove select boxes (needed for IE)
	$$('div#nav ul li ul').each(function(menuTop) {
		menuTop.up('li').observe('mouseover', function(e){$$('select').invoke('setStyle', {visibility:'hidden'});});
		menuTop.up('li').observe('mouseout', function(e){$$('select').invoke('setStyle', {visibility:''});});
	});
	initPage(); //call init Page
});

//initialize the page by setting up some commonly used functionality
//called on window.load and from any ajax call that updates the DOM
//pass in the id of the element you want to initializa (pass nothing to initialize the entire page)
function initPage(id) {
	//TODO:speed up this function (especially for large datagrids)
	//new Insertion.Bottom('wrapper', 'Prototype version: ' + Prototype.Version + '<br>');
	//new Insertion.Bottom('wrapper', '1: ' + new Date() + '<br>');
	try {
		csshover.init(); //found in csshover.js - adds hover abilities to IE 5 & 6 elements
	} catch(err) {
		//csshover.js only gets loaded for IE 5 & 6
		//other browsers will throw an error, so we'll catch it and ignore it
	}
	//new Insertion.Bottom('wrapper', '2: ' + new Date() + '<br>');
	var cssSelector = '';
	if($(id)) { //if an id is passed in, set up the cssSelector
		cssSelector = '#' + $(id).id;
	}
	//new Insertion.Bottom('wrapper', '3: ' + new Date() + '<br>');
	//bind the click event to any quicklinks (for the popup windx)
	$$(cssSelector + ' a.quicklink').invoke('observe', 'click', function(e) {
		popupWindx(Event.findElement(e, 'a')); //grab the a tag that was clicked and open a popup windx from it
		Event.stop(e);
	});
	//new Insertion.Bottom('wrapper', '4: ' + new Date() + '<br>');
	//all quicklinks are not shown by default, now show them since they rely on javascript anyways
	$$(cssSelector + ' a.quicklink').invoke('setStyle', {display:'inline'});
	//new Insertion.Bottom('wrapper', '5: ' + new Date() + '<br>');
	//bind the click event to any popups
	$$(cssSelector + ' a.popup').invoke('observe', 'click', function(e) {
		popupWindow(Event.findElement(e, 'a')); //open a popup window from the a tag that was clicked
		Event.stop(e);
	});
	//new Insertion.Bottom('wrapper', '6: ' + new Date() + '<br>');
	//bind the click event to any windx popups
	$$(cssSelector + ' a.popupwindx').invoke('observe', 'click', function(e) {
		popupWindx(Event.findElement(e, 'a')); //grab the a tag that was clicked and open a popup windx from it
		Event.stop(e);
	});
	//new Insertion.Bottom('wrapper', '7: ' + new Date() + '<br>');
	//find each radio button & checkbox and turn off the border, then, if it's inside a detailbox, change it's bgcolor to match the detailbox
	$$(cssSelector + ' input[type="radio"]', cssSelector + ' input[type="checkbox"]').each(function(rc){
		rc.setStyle({border:'none'}); //remove the border
		var db = rc.up('div.detailbox'); //go up the dom til we find a detailbox (if it exists)
		if(db) { //is the radio/checkbox inside a detailbox?
			rc.setStyle({'background-color':db.getStyle('background-color')}); //change the bgcolor to match that of the detailbox
		}
		var dg = rc.up('table.datagrid'); //go up the dom til we find a datagrid (if it exists)
		if(dg) { //is the radio/checkbox inside a datagrid?
			var tr = rc.up('tr'); //go up the dom til we find a table row (if it exists)
			if(tr) { //is the radio/checkbox inside a table row?
				rc.setStyle({'background-color':tr.getStyle('background-color')}); //change the bgcolor to match that of the table row
			}
		}
	});
	//new Insertion.Bottom('wrapper', '9: ' + new Date() + '<br>');
	//by default, datagrids inside detailboxes have auto cursors
	//if one of these datagrids have a link with the datagridrowclick class, then give the datagrid a pointer (hand) cursor
	$$(cssSelector + ' div.detailbox table.datagrid').each(function(datagrid) { //loop over each datagrid that's inside a detailbox
		if(datagrid.down('a.datagridrowclick')) { //check if this datagrid has a link (a.datagridrowclick)
			datagrid.setStyle({'cursor':'pointer'}); //change the cursor to be a pointer (hand)
		}
	});
	//new Insertion.Bottom('wrapper', '10: ' + new Date() + '<br>');
	//find all elements that need a watermark
	$$(cssSelector + ' input[watermark]').each(function(elem){
		initWatermark(elem); //initialize the element
		elem.observe('keyup', function(e){ //when a key is pressed and released
			setWatermarkStyles(Event.element(e)); //set the watermark styles
		});
		elem.observe('focus', function(e){ //when the element gains focus
			clearWatermark(Event.element(e)); //clear out the watermark text if it's there
		});
		elem.observe('blur', function(e){ //when the element loses focus
			initWatermark(Event.element(e)); //initialize the element
		});
	});
	//new Insertion.Bottom('wrapper', '11: ' + new Date() + '<br>');
	//bind the click event to any datagrid so it highlites the selected row
	//will also look for a default link (a.datagridrowclick) to go to when a user clicks on the row instead of the link
	//more specific functionality is added later for each specific datagrid
	//(just bind another click event to each row)
	//new Insertion.Bottom('wrapper', 'length: ' + $$(cssSelector + ' table.datagrid tbody tr').length + '<br>');
	$$(cssSelector + ' table.datagrid tbody tr').each(function(tr) { //loop over each data row in the datagrid, exclude header
		Event.observe(tr, 'click', function(e) { //add onclick event to each <tr>
			var elem = Event.element(e); //find the element that was clicked
			var row = Event.findElement(e, 'tr'); //find the <tr> row that was clicked
			var table = Event.findElement(e, 'table'); //find the <table> that holds the element that was clicked
			$(table).getElementsBySelector('tbody tr').each(function(tr) { //loop over each data row, exclude header
				tr.removeClassName("selected"); //de-select all modules
			});
			row.addClassName("selected"); //select the current module
			if(elem.tagName.toUpperCase() == 'INPUT') {
				//do nothing if the user clicked on an input tag
			} else if(elem.tagName.toUpperCase() != 'A') { //if it was not a link, find the default link
				var atag = row.down('a.datagridrowclick'); //try to find the default link to use when clicking this row
				if(atag) { //check if a link was found
					if(atag.hasClassName('popupwindx')) { //check if it's a popupwindx
						popupWindx(atag); //open the link in a new windx
					} else if(atag.hasClassName('popup') || atag.target == "_blank") { //check if it's a popup window
						popupWindow(atag); //open the link in a new window
					} else {
						location.href = atag.href; //go to the href of the link we just found
					}
					Event.stop(e);
				}
			}
		});
	});
	//new Insertion.Bottom('wrapper', '12: ' + new Date() + '<br>');
	//initialize any datagrid pagers that are found in the page
	$$(cssSelector + ' div.datagridpager').each(function(pager) { //loop over each pager
		var form = pager.readAttribute('form'); //find what form this pager is dealing with
		var functiontocall = pager.readAttribute('functiontocall'); //find the function we need to call
		var pagecount = parseInt(pager.readAttribute('pagecount')); //find how many total pages there are
		pager.getElementsBySelector('form select').each(function (sel) { //find any <select> tags in the pager
			Event.observe(sel, 'change', function(e) { //add onchange event to each <select>
				eval(functiontocall + '("' + form + '", "' + $F(sel) + '")'); //call the function that will do the paging/search
				Event.stop(e); //stop the click event from bubbling up any further
			});
		});
		pager.getElementsBySelector('a[page]').each(function (atag) { //loop over each <a> in the pager
			Event.observe(atag, 'click', function(e) { //add onclick event to each <a>
				var page = parseInt(atag.readAttribute('page'));
				if(page <= 0 || page > pagecount) { //check to make sure we're going to a valid page
					//alert("can't go there");
				} else {
					eval(functiontocall + '("' + form + '", "' + page + '")'); //call the function that will do the paging/search
				}
				Event.stop(e); //stop the click event from bubbling up any further
			});
		});
	});
	//new Insertion.Bottom('wrapper', '13: ' + new Date() + '<br>');
	//reset heights for IE, since it ignores the min-height
	setMinHeight($('wrapper'), 378); //should match what's set in styles.css
	if($('subContent')){
		setMinHeight($('subContent'), 350); //should match what's set in styles.css
	}
	//new Insertion.Bottom('wrapper', '14: ' + new Date() + '<br>');
}

