/*
 * jQuery Tooltip plugin 1.3
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
 * http://docs.jquery.com/Plugins/Tooltip
 *
 * Copyright (c) 2006 - 2008 Jörn Zaefferer
 *
 * $Id: jquery.tooltip.js 5741 2008-06-21 15:22:16Z joern.zaefferer $
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
 
;(function(jQuery) {
	
		// the tooltip element
	var helper = {},
		// the current tooltipped element
		current,
		// the title of the current element, used for restoring
		title,
		// timeout id for delayed tooltips
		tID,
		// IE 5.5 or 6
		IE = jQuery.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent),
		// flag for mouse tracking
		track = false;
	
	jQuery.tooltip = {
		blocked: false,
		defaults: {
			delay: 200,
			fade: false,
			showURL: true,
			extraClass: "",
			top: 15,
			left: 15,
			id: "tooltip"
		},
		block: function() {
			jQuery.tooltip.blocked = !jQuery.tooltip.blocked;
		}
	};
	
	jQuery.fn.extend({
		tooltip: function(settings) {
			settings = jQuery.extend({}, jQuery.tooltip.defaults, settings);
			createHelper(settings);
			return this.each(function() {
					jQuery.data(this, "tooltip", settings);
					this.tOpacity = helper.parent.css("opacity");
					// copy tooltip into its own expando and remove the title
					this.tooltipText = this.title;
					jQuery(this).removeAttr("title");
					// also remove alt attribute to prevent default tooltip in IE
					this.alt = "";
				})
				.mouseover(save)
				.mouseout(hide)
				.click(hide);
		},
		fixPNG: IE ? function() {
			return this.each(function () {
				var image = jQuery(this).css('backgroundImage');
				if (image.match(/^url\(["']?(.*\.png)["']?\)$/i)) {
					image = RegExp.$1;
					jQuery(this).css({
						'backgroundImage': 'none',
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
					}).each(function () {
						var position = jQuery(this).css('position');
						if (position != 'absolute' && position != 'relative')
							jQuery(this).css('position', 'relative');
					});
				}
			});
		} : function() { return this; },
		unfixPNG: IE ? function() {
			return this.each(function () {
				jQuery(this).css({'filter': '', backgroundImage: ''});
			});
		} : function() { return this; },
		hideWhenEmpty: function() {
			return this.each(function() {
				jQuery(this)[ jQuery(this).html() ? "show" : "hide" ]();
			});
		},
		url: function() {
			return this.attr('href') || this.attr('src');
		}
	});
	
	function createHelper(settings) {
		// there can be only one tooltip helper
		if( helper.parent )
			return;
		// create the helper, h3 for title, div for url
		helper.parent = jQuery('<div id="' + settings.id + '"><h3></h3><div class="body"></div><div class="url"></div></div>')
			// add to document
			.appendTo(document.body)
			// hide it at first
			.hide();
			
		// apply bgiframe if available
		if ( jQuery.fn.bgiframe )
			helper.parent.bgiframe();
		
		// save references to title and url elements
		helper.title = jQuery('h3', helper.parent);
		helper.body = jQuery('div.body', helper.parent);
		helper.url = jQuery('div.url', helper.parent);
	}
	
	function settings(element) {
		return jQuery.data(element, "tooltip");
	}
	
	// main event handler to start showing tooltips
	function handle(event) {
		// show helper, either with timeout or on instant
		if( settings(this).delay )
			tID = setTimeout(show, settings(this).delay);
		else
			show();
		
		// if selected, update the helper position when the mouse moves
		track = !!settings(this).track;
		jQuery(document.body).bind('mousemove', update);
			
		// update at least once
		update(event);
	}
	
	// save elements title before the tooltip is displayed
	function save() {
		// if this is the current source, or it has no title (occurs with click event), stop
		if ( jQuery.tooltip.blocked || this == current || (!this.tooltipText && !settings(this).bodyHandler) )
			return;

		// save current
		current = this;
		title = this.tooltipText;
		
		if ( settings(this).bodyHandler ) {
			helper.title.hide();
			var bodyContent = settings(this).bodyHandler.call(this);
			if (bodyContent.nodeType || bodyContent.jquery) {
				helper.body.empty().append(bodyContent)
			} else {
				helper.body.html( bodyContent );
			}
			helper.body.show();
		} else if ( settings(this).showBody ) {
			var parts = title.split(settings(this).showBody);
			helper.title.html(parts.shift()).show();
			helper.body.empty();
			for(var i = 0, part; (part = parts[i]); i++) {
				if(i > 0)
					helper.body.append("<br/>");
				helper.body.append(part);
			}
			helper.body.hideWhenEmpty();
		} else {
			helper.title.html(title).show();
			helper.body.hide();
		}
		
		// if element has href or src, add and show it, otherwise hide it
		if( settings(this).showURL && jQuery(this).url() )
			helper.url.html( jQuery(this).url().replace('http://', '') ).show();
		else 
			helper.url.hide();
		
		// add an optional class for this tip
		helper.parent.addClass(settings(this).extraClass);

		// fix PNG background for IE
		if (settings(this).fixPNG )
			helper.parent.fixPNG();
			
		handle.apply(this, arguments);
	}
	
	// delete timeout and show helper
	function show() {
		tID = null;
		if ((!IE || !jQuery.fn.bgiframe) && settings(current).fade) {
			if (helper.parent.is(":animated"))
				helper.parent.stop().show().fadeTo(settings(current).fade, current.tOpacity);
			else
				helper.parent.is(':visible') ? helper.parent.fadeTo(settings(current).fade, current.tOpacity) : helper.parent.fadeIn(settings(current).fade);
		} else {
			helper.parent.show();
		}
		update();
	}
	
	/**
	 * callback for mousemove
	 * updates the helper position
	 * removes itself when no current element
	 */
	function update(event)	{
		if(jQuery.tooltip.blocked)
			return;
		
		if (event && event.target.tagName == "OPTION") {
			return;
		}
		
		// stop updating when tracking is disabled and the tooltip is visible
		if ( !track && helper.parent.is(":visible")) {
			jQuery(document.body).unbind('mousemove', update)
		}
		
		// if no current element is available, remove this listener
		if( current == null ) {
			jQuery(document.body).unbind('mousemove', update);
			return;	
		}
		
		// remove position helper classes
		helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");
		
		var left = helper.parent[0].offsetLeft;
		var top = helper.parent[0].offsetTop;
		if (event) {
			// position the helper 15 pixel to bottom right, starting from mouse position
			left = event.pageX + settings(current).left;
			top = event.pageY + settings(current).top;
			var right='auto';
			if (settings(current).positionLeft) {
				right = jQuery(window).width() - left;
				left = 'auto';
			}
			helper.parent.css({
				left: left,
				right: right,
				top: top
			});
		}
		
		var v = viewport(),
			h = helper.parent[0];
		// check horizontal position
		if (v.x + v.cx < h.offsetLeft + h.offsetWidth) {
			left -= h.offsetWidth + 20 + settings(current).left;
			helper.parent.css({left: left + 'px'}).addClass("viewport-right");
		}
		// check vertical position
		if (v.y + v.cy < h.offsetTop + h.offsetHeight) {
			top -= h.offsetHeight + 20 + settings(current).top;
			helper.parent.css({top: top + 'px'}).addClass("viewport-bottom");
		}
	}
	
	function viewport() {
		return {
			x: jQuery(window).scrollLeft(),
			y: jQuery(window).scrollTop(),
			cx: jQuery(window).width(),
			cy: jQuery(window).height()
		};
	}
	
	// hide helper and restore added classes and the title
	function hide(event) {
		if(jQuery.tooltip.blocked)
			return;
		// clear timeout if possible
		if(tID)
			clearTimeout(tID);
		// no more current element
		current = null;
		
		var tsettings = settings(this);
		function complete() {
			helper.parent.removeClass( tsettings.extraClass ).hide().css("opacity", "");
		}
		if ((!IE || !jQuery.fn.bgiframe) && tsettings.fade) {
			if (helper.parent.is(':animated'))
				helper.parent.stop().fadeTo(tsettings.fade, 0, complete);
			else
				helper.parent.stop().fadeOut(tsettings.fade, complete);
		} else
			complete();
		
		if( settings(this).fixPNG )
			helper.parent.unfixPNG();
	}
	
})(jQuery);

(function(jQuery) {
					
jQuery.fn.statBar = function() {

	jQuery(this).each(function(){
		var timer = function(ul) {
			if (ul.$pause || jQuery('> li', ul).size() == 1 ) {
				return;
			}
			var li 	= jQuery('> li:first-child', ul)[0];
			var h	= jQuery(li).outerHeight() + 1;
			var i 	= 0;
			ul.$animate = setInterval(function() {
				if (ul.$pause || jQuery('> li', ul).size() == 1) {
					return;
				}
				if ((h + i) == 0) {
					clearInterval(ul.$animate);
					jQuery('> li:last-child', ul).after(li);
					ul.style.top = '0px';
				} else {
					ul.style.top = (i--) + 'px';
				}
			}, 75);
		};

		jQuery(this).hover(function() {
				jQuery('> ul', this)[0].$pause = true;
			}, function() {
				var ul = jQuery('> ul', this)[0];
				ul.$pause = false;
				clearInterval(ul.$interval);
				ul.$interval = setInterval(function(){ timer(ul); }, 4500);
			});

		var ul = jQuery('> ul', this)[0];

		ul.$top = 0;
		ul.$interval = setInterval(function(){ timer(ul); }, 4500);
	});
}
jQuery.fn.statBarClear = function(id) {
	if (id) {
		jQuery('> ul > li', this).remove("#"+id);
		jQuery('> ul', this).css("top","0px");
	} else {
		jQuery('> ul', this).empty();
		jQuery('> ul', this).get(0).innerHTML = '<li></li>';
		jQuery('> ul', this).css("top","0px");
	}
}
jQuery.fn.statBarAlert = function(newstat, id) {
	if (jQuery('ul > li:first', this).get(0).innerHTML == "") {
		jQuery('ul > li:first', this).get(0).innerHTML = newstat;
		if (id) { jQuery('ul > li:first',this).attr("id",id); }	
		jQuery('ul > li:first',this).css({color: "red", 'text-decoration': "blink"});
} else {
		if (id) {
			jQuery('<li id="' + id + '" style="color: red; text-decoration: blink;">' + newstat + '</li>').insertBefore('ul > li:first-child',this);
		} else {
			jQuery('<li style="color: red; text-decoration: blink;">' + newstat + '</li>').insertBefore('ul > li:first-child',this);
		}
	}
	var ul = jQuery('> ul', this)[1];

	ul.$top = 0;
	clearInterval(ul.$interval);
	clearInterval(ul.$animate);
//	ul.$interval = setInterval(function(){ timer(ul); }, 7000);
}
jQuery.fn.statBarAdd = function(newstat, id) {
	if (jQuery('ul > li:first', this).get(0).innerHTML == "") {
		jQuery('ul > li:first', this).get(0).innerHTML = newstat;
		if (id) { jQuery('ul > li:first',this).attr("id",id); }	
	} else {
		if (id) {
			jQuery('<li id="' + id + '">' + newstat + '</li>').insertAfter('ul > li:first-child',this);
		} else {
			jQuery('<li>' + newstat + '</li>').insertAfter('ul > li:first-child',this);
		}
	}
}
jQuery.fn.statBarAddLast = function(newstat, id) {
if (jQuery('ul > li:first', this).get(0).innerHTML == "") {
		jQuery('ul > li:first', this).get(0).innerHTML = newstat;
		if (id) { jQuery('ul > li:first',this).attr("id",id); }	
	} else { 
		if (id) {
			jQuery('<li id="' + id + '">' + newstat + '</li>').insertAfter('ul > li:last-child',this);
		} else {
			jQuery('<li>' + newstat + '</li>').insertAfter('ul > li:last-child',this);
		}
	}
}


})(jQuery);

(function(jQuery) {
	jQuery.fn.statLocal = function(text,timer) {
		if (timer > 0) {
			var	timeout = timer * 1000;
			jQuery(this).get(0).innerHTML = text;
			clearTimeout(t);
			var t = setTimeout('document.getElementById("status").innerHTML = ""',timeout);
		} else {
			jQuery(this).get(0).innerHTML = text;
		}
	}
})(jQuery);


jQuery.fn.setlcol = function(content, notround) {
	if (document.getElementById('mainlcol')) {
		if (content) {
			jQuery("div#mainlcol").get(0).innerHTML = ''; 
			jQuery("div#mainlcol").get(0).innerHTML = content; 
		} else {
			if (jQuery("div#mainlcol").length > 0 && jQuery("div#mainlcol").get(0).innerHTML == '') {
				jQuery("div#mainlcol").get(0).innerHTML = '<!-- -->';
			}
		} 
		if	(jQuery("div#mainlcol").get(0).offsetHeight > 0 && jQuery("div#mainlcol > img.lcolround").size() == 0 && notround != 1) {
				jQuery("div#mainlcol").prepend('<img class="lcolround" src=\"/admin/images/lcol_01.png\" style="visibility=visible;">');
				jQuery("div#mainlcol").append('<img class="lcolround" src=\"/admin/images/lcol_03.png\" style="visibility=visible;">');
		}
	}
};
/*
 * Date picker plugin for jQuery
 * http://kelvinluck.com/assets/jquery/datePicker
 *
 * Copyright (c) 2006 Kelvin Luck (kelvnluck.com)
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * $LastChangedDate: 2007-02-13 11:32:41 +0000 (Tue, 13 Feb 2007) $
 * $Rev: 1334 $
 */

jQuery.datePicker = function()
{
	// so that firebug console.log statements don't break IE
	if (window.console == undefined) { window.console = {log:function(){}}; }

	var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
	var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
	var navLinks = {p:'Prev', n:'Next', c:'Close', b:'Choose date'};
	var dateFormat = 'dmy';
	var dateSeparator = "/";
	var _drawingMonth = false;
	var _firstDayOfWeek;
	var _firstDate;
	var _lastDate;

	var _selectedDate;
	var _openCal;

	var _zeroPad = function(num) {
		var s = '0'+num;
		return s.substring(s.length-2)
		//return ('0'+num).substring(-2); // doesn't work on IE :(
	};
	var _strToDate = function(dIn)
	{
		switch (dateFormat) {
			case 'ymd':
				dParts = dIn.split(dateSeparator);
				return new Date(dParts[0], Number(dParts[1])-1, dParts[2]);
			case 'dmy':
				dParts = dIn.split(dateSeparator);
				return new Date(dParts[2], Number(dParts[1])-1, Number(dParts[0]));
			case 'dmmy':
				dParts = dIn.split(dateSeparator);
				for (var m=0; m<12; m++) {
					if (dParts[1].toLowerCase() == months[m].substr(0,3).toLowerCase())  {
						return new Date(Number(dParts[2]), m, Number(dParts[0]));
					}
				}
				return undefined;
			case 'mdy':
			default:
				var parts = parts ? parts : [2, 1, 0];
				dParts = dIn.split(dateSeparator);
				return new Date(dParts[2], Number(dParts[0])-1, Number(dParts[1]));
		}
	};
	var _dateToStr = function(d)
	{
		var dY = d.getFullYear();
		var dM = _zeroPad(d.getMonth()+1);
		var dD = _zeroPad(d.getDate());
		switch (dateFormat) {
			case 'ymd':
				return dY + dateSeparator + dM + dateSeparator + dD;
			case 'dmy':
				return dD + dateSeparator + dM + dateSeparator + dY;
			case 'dmmy':
				return dD + dateSeparator + months[d.getMonth()].substr(0,3) + dateSeparator + dY;
			case 'mdy':
			default:
				return dM + dateSeparator + dD + dateSeparator + dY;
		}
	};

	var _getCalendarDiv = function(dIn)
	{
		var today = new Date();
		if (dIn == undefined) {
			// start from this month.
			d = new Date(today.getFullYear(), today.getMonth(), 1);
		} else {
			// start from the passed in date
			d = dIn;
			d.setDate(1);
		}
		// check that date is within allowed limits:
		if ((d.getMonth() < _firstDate.getMonth() && d.getFullYear() == _firstDate.getFullYear()) || d.getFullYear() < _firstDate.getFullYear()) {
			d = new Date(_firstDate.getFullYear(), _firstDate.getMonth(), 1);;
		} else if ((d.getMonth() > _lastDate.getMonth() && d.getFullYear() == _lastDate.getFullYear()) || d.getFullYear() > _lastDate.getFullYear()) {
			d = new Date(_lastDate.getFullYear(), _lastDate.getMonth(), 1);;
		}

		var jCalDiv = jQuery("<div>").attr('class','popup-calendar');
		var firstMonth = true;
		var firstDate = _firstDate.getDate();

		// create prev and next links
		var prevLinkDiv = '';
		if (!(d.getMonth() == _firstDate.getMonth() && d.getFullYear() == _firstDate.getFullYear())) {
			// not in first display month so show a previous link
			firstMonth = false;
			var lastMonth = d.getMonth() == 0 ? new Date(d.getFullYear()-1, 11, 1) : new Date(d.getFullYear(), d.getMonth()-1, 1);
			var prevLink = jQuery("<a>").attr('href', 'javascript:;').html(navLinks.p).click(function()
			{
				jQuery.datePicker.changeMonth(lastMonth, this);
				return false;
			});
			prevLinkDiv = jQuery("<div>").attr('class','link-prev').html('&lt;').append(prevLink);
		}

		var finalMonth = true;
		var lastDate = _lastDate.getDate();
		nextLinkDiv = '';
		if (!(d.getMonth() == _lastDate.getMonth() && d.getFullYear() == _lastDate.getFullYear())) {
			// in the last month - no next link
			finalMonth = false;
			var nextMonth = new Date(d.getFullYear(), d.getMonth()+1, 1);
			var nextLink = jQuery("<a>").attr('href', 'javascript:;').html(navLinks.n).click(function()
			{
				jQuery.datePicker.changeMonth(nextMonth, this);
				return false;
			});
			nextLinkDiv = jQuery("<div>").attr('class','link-next').html('&gt;').prepend(nextLink);
		}

		var closeLink = jQuery("<a>").attr('href','javascript:;').html(navLinks.c).click(function()
		{
			jQuery.datePicker.closeCalendar();
		});

		jCalDiv.append(
			jQuery("<div>").attr('class', 'link-close').append(closeLink),
			jQuery("<h3>").html(months[d.getMonth()] + ' ' + d.getFullYear())
		);
		var headRow = jQuery("<tr>");
		for (var i=_firstDayOfWeek; i<_firstDayOfWeek+7; i++) {
			var weekday = i%7;
			var day = days[weekday];
			headRow.append(
				jQuery("<th>").attr({'scope':'col', 'abbr':day, 'title':day, 'class':(weekday == 0 || weekday == 6 ? 'weekend' : 'weekday')}).html(day.substr(0, 1))
			);
		}

		var tBody = jQuery("<tbody>");

		var lastDay = (new Date(d.getFullYear(), d.getMonth()+1, 0)).getDate();
		var curDay = _firstDayOfWeek - d.getDay();
		if (curDay > 0) curDay -= 7;

		var todayDate = (new Date()).getDate();
		var thisMonth = d.getMonth() == today.getMonth() && d.getFullYear() == today.getFullYear();

		var w = 0;
		while (w++<6) {
			var thisRow = jQuery("<tr>");
			for (var i=0; i<7; i++) {
				var weekday = (_firstDayOfWeek + i) % 7;
				var atts = {'class':(weekday == 0 || weekday == 6 ? 'weekend ' : 'weekday ')};

				if (curDay < 0 || curDay >= lastDay) {
					dayStr = ' ';
				} else if (firstMonth && curDay < firstDate-1) {
					dayStr = curDay+1;
					atts['class'] += 'inactive';
				} else if (finalMonth && curDay > lastDate-1) {
					dayStr = curDay+1;
					atts['class'] += 'inactive';
				} else {
					d.setDate(curDay+1);
					var dStr = _dateToStr(d);
					dayStr = jQuery("<a>").attr({'href':'javascript:;', 'rel':dStr}).html(curDay+1).click(function(e)
					{
						jQuery.datePicker.selectDate(jQuery.attr(this, 'rel'), this);
						return false;
					})[0];
					if (_selectedDate && _selectedDate==dStr) {
						jQuery(dayStr).attr('class','selected');
					}
				}

				if (thisMonth && curDay+1 == todayDate) {
					atts['class'] += 'today';
				}
				thisRow.append(jQuery("<td>").attr(atts).append(dayStr));
				curDay++;
			}
			tBody.append(thisRow);
		}

		jCalDiv.append(
			jQuery("<table>").attr('cellspacing',2).attr('id','calendar-table').append("<thead>")
			.find("thead").append(headRow).parent().append(tBody.children())
		).append(prevLinkDiv).append(nextLinkDiv);

		if (jQuery.browser.msie) {

			// we put a styled iframe behind the calendar so HTML SELECT elements don't show through
			var iframe = [	'<iframe class="bgiframe" tabindex="-1" ',
		 					'style="display:block; position:absolute;',
							'top: 0;',
							'left:0;',
							'z-index:-1; filter:Alpha(Opacity=\'0\');',
							'width:3000px;',
							'height:3000px"/>'].join('');
			jCalDiv.append(document.createElement(iframe));
		}
		jCalDiv.css({'display':'block'});
		return jCalDiv[0];
	};
	var _draw = function(c)
	{
		// explicitly empty the calendar before removing it to reduce the (MASSIVE!) memory leak in IE
		// still not perfect but a lot better!
		// Strangely if you chain the methods it reacts differently - when chained opening the calendar on
		// IE uses a bunch of memory and pressing next/prev doubles this memory. When you close the calendar
		// the memory is freed. If they aren't chained then pressing next or previous doesn't double the used
		// memory so only one chunk of memory is used when you open the calendar (which is also freed when you
		// close the calendar).
		jQuery('div.popup-calendar a', _openCal[0]).unbind();
		jQuery('div.popup-calendar', _openCal[0]).empty();
		jQuery('div.popup-calendar', _openCal[0]).remove();
		_openCal.append(c);
	};
	var _closeDatePicker = function()
	{
		jQuery('div.popup-calendar a', _openCal).unbind();
		jQuery('div.popup-calendar', _openCal).empty();
		jQuery('div.popup-calendar', _openCal).css({'display':'none'});

		/*
		if (jQuery.browser.msie) {
			_openCal.unbind('keypress', _handleKeys);
		} else {
			jQuery(window).unbind('keypress', _handleKeys);
		}
		*/
		jQuery(document).unbind('mousedown', _checkMouse);
		delete _openCal;
		_openCal = null;
	};
	var _handleKeys = function(e)
	{
		var key = e.keyCode ? e.keyCode : (e.which ? e.which: 0);
		//console.log('KEY!! ' + key);
		if (key == 27) {
			_closeDatePicker();
		}
		return false;
	};
	var _checkMouse = function(e)
	{
		if (!_drawingMonth) {
			var target = jQuery.browser.msie ? window.event.srcElement : e.target;
			var cp = jQuery(target).findClosestParent('div.popup-calendar');
			if (cp.get(0).className != 'date-picker-holder') {
				_closeDatePicker();
			}
		}
	};

	return {
		getChooseDateStr: function()
		{
			return navLinks.b;
		},
		show: function()
		{
			if (_openCal) {
				_closeDatePicker();
			}
			this.blur();
				var input = jQuery('input', jQuery(this).findClosestParent('input')[0])[0];
			_firstDate = input._startDate;
			_lastDate = input._endDate;
			_firstDayOfWeek = input._firstDayOfWeek;
			_openCal = jQuery(this).findClosestParent('div.popup-calendar');
			
			var d = jQuery(input).val();
			if (d != '') {
				if (_dateToStr(_strToDate(d)) == d) {
					_selectedDate = d;
					_draw(_getCalendarDiv(_strToDate(d)));
				} else {
					// invalid date in the input field - just default to this month
					_selectedDate = false;
					_draw(_getCalendarDiv());
				}
			} else {
				_selectedDate = false;
				_draw(_getCalendarDiv());
			}
			/*
			if (jQuery.browser == "msie") {
				_openCal.bind('keypress', _handleKeys);
			} else {
				jQuery(window).bind('keypress', _handleKeys);
			}
			*/
			jQuery(document).bind('mousedown', _checkMouse);
		},
		changeMonth: function(d, e)
		{
			_drawingMonth = true;
			_draw(_getCalendarDiv(d));
			_drawingMonth = false;
		},
		selectDate: function(d, ele)
		{
			selectedDate = d;
			var $theInput = jQuery('input', jQuery(ele).findClosestParent('input')[0]);
			$theInput.val(d);
			$theInput.trigger('change');
			_closeDatePicker(ele);
		},
		closeCalendar: function()
		{
			_closeDatePicker(this);
		},
		setInited: function(i)
		{
			i._inited = true;
		},
		isInited: function(i)
		{
			return i._inited != undefined;
		},
		setDateFormat: function(format,separator)
		{
			// set's the format that selected dates are returned in.
			// options are 'dmy' (european), 'mdy' (americian) and 'ymd' (unicode)
			dateFormat = format.toLowerCase();
			dateSeparator = separator?separator:"/";
		},
		/**
		* Function: setLanguageStrings
		*
		* Allows you to localise the calendar by passing in relevant text for the english strings in the plugin.
		*
		* Arguments:
		* days		-	Array, e.g. ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
		* months	-	Array, e.g. ['January', 'Febuary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
		* navLinks	-	Object, e.g. {p:'Prev', n:'Next', c:'Close', b:'Choose date'}
		**/
		setLanguageStrings: function(aDays, aMonths, aNavLinks)
		{
			days = aDays;
			months = aMonths;
			navLinks = aNavLinks;
		},
		/**
		* Function: setDateWindow
		*
		* Used internally to set the start and end dates for a given date select
		*
		* Arguments:
		* i			-	The id of the INPUT element this date window is for
		* w			-	The date window - an object containing startDate and endDate properties
		*				each in the current format as set in a call to setDateFormat (or in the
		*				default format dmy if setDateFormat hasn't been called).
		*				e.g. {startDate:'01/03/2006', endDate:'11/04/2006}
		**/
		setDateWindow: function(i, w)
		{
			if (w == undefined) w = {};
			if (w.startDate == undefined) {
				i._startDate = new Date();
			} else {
				i._startDate = _strToDate(w.startDate);
			}
			if (w.endDate == undefined) {
				i._endDate = new Date();
				i._endDate.setFullYear(i._endDate.getFullYear()+5);
			} else {
				i._endDate = _strToDate(w.endDate);
			};
			i._firstDayOfWeek = w.firstDayOfWeek == undefined ? 0 : w.firstDayOfWeek;
		}
	};
}();
jQuery.fn.findClosestParent = function(s)
{
	var ele = this;
	while (true) {
		if (jQuery(s, ele[0]).length > 0) {
			return (ele);
		}
		ele = ele.parent();
		if(ele[0].length == 0) {
			return false;
		}
	}
};
jQuery.fn.datePicker = function(a)
{
	this.each(function() {
		if(this.nodeName.toLowerCase() != 'input') return;
		jQuery.datePicker.setDateWindow(this, a);
		if (!jQuery.datePicker.isInited(this)) {
			var chooseDate = jQuery.datePicker.getChooseDateStr();
			var calBut;
			if(a && a.inputClick){
				calBut = jQuery(this).attr('title', chooseDate).addClass('date-picker');
			}
			else {
				calBut = jQuery("<a>").attr({'href':'javascript:;',
'class':'date-picker', 'title':chooseDate})
				.append("<span>" + chooseDate + "</span>");
			}
			jQuery(this).wrap(
				'<div class="date-picker-holder"></div>'
			).before(
				jQuery("<div>").attr({'class':'popup-calendar'})
			).after(
				calBut
			);
			calBut.bind('click', jQuery.datePicker.show);
			jQuery.datePicker.setInited(this);
		}
	});
	return this;
};
/*
<!-- Generated calendar HTML looks like this - style with CSS -->
<div class="popup-calendar">
	<div class="link-close"><a href="#">Close</a></div>
	<h3>July 2006</h3>
	<table cellspacing="2">
		<thead>
			<tr>
				<th scope="col" abbr="Monday" title="Monday" class="weekday">M</th>
				<th scope="col" abbr="Tuesday" title="Tuesday" class="weekday">T</th>
				<th scope="col" abbr="Wednesday" title="Wednesday" class="weekday">W</th>
				<th scope="col" abbr="Thursday" title="Thursday" class="weekday">T</th>
				<th scope="col" abbr="Friday" title="Friday" class="weekday">F</th>
				<th scope="col" abbr="Saturday" title="Saturday" class="weekday">S</th>
				<th scope="col" abbr="Sunday" title="Sunday" class="weekday">S</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td class="weekday">&nbsp;</td>
				<td class="weekday">&nbsp;</td>
				<td class="weekday">&nbsp;</td>
				<td class="inactive weekday">1</td>
				<td class="inactive weekday">2</td>
				<td class="inactive weekend">3</td>
				<td class="inactive weekend">4</td>
			</tr>
			<tr>
				<td class="inactive weekday">5</td>
				<td class="inactive weekday">6</td>
				<td class="inactive weekday">7</td>
				<td class="today weekday"><a href="#">8</a></td>
				<td class="weekday"><a href="#">9</a></td>
				<td class="weekend"><a href="#">10</a></td>
				<td class="weekend"><a href="#">11</a></td>
			</tr>
			<tr>
				<td class="weekday"><a href="#">12</a></td>
				<td class="weekday"><a href="#">13</a></td>
				<td class="weekday"><a href="#">14</a></td>
				<td class="weekday"><a href="#">15</a></td>
				<td class="weekday"><a href="#">16</a></td>
				<td class="weekend"><a href="#">17</a></td>
				<td class="weekend"><a href="#" class="selected">18</a></td>
			</tr>
			<tr>
				<td class="weekday"><a href="#">19</a></td>
				<td class="weekday"><a href="#">20</a></td>
				<td class="weekday"><a href="#">21</a></td>
				<td class="weekday"><a href="#">22</a></td>
				<td class="weekday"><a href="#">23</a></td>
				<td class="weekend"><a href="#">24</a></td>
				<td class="weekend"><a href="#">25</a></td>
			</tr>
			<tr>
				<td class="weekday"><a href="#">26</a></td>
				<td class="weekday"><a href="#">27</a></td>
				<td class="weekday"><a href="#">28</a></td>
				<td class="weekday"><a href="#">29</a></td>
				<td class="weekday"><a href="#">30</a></td>
				<td class="weekend">&nbsp;</td>
				<td class="weekend">&nbsp;</td>
			</tr>
		</tbody>
	</table>
	<div class="link-prev"><a href="#">Prev</a></div>
	<div class="link-next"><a href="#">Next</a></div>
</div>
*/
/*
 * jQuery corner plugin
 *
 * version 1.7 (1/26/2007)
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

/**
 * The corner() method provides a simple way of styling DOM elements.  
 *
 * corner() takes a single string argument:  jQuery().corner("effect corners width")
 *
 *   effect:  The name of the effect to apply, such as round or bevel. 
 *            If you don't specify an effect, rounding is used.
 *
 *   corners: The corners can be one or more of top, bottom, tr, tl, br, or bl. 
 *            By default, all four corners are adorned. 
 *
 *   width:   The width specifies the width of the effect; in the case of rounded corners this 
 *            will be the radius of the width. 
 *            Specify this value using the px suffix such as 10px, and yes it must be pixels.
 *
 * For more details see: http://methvin.com/jquery/jq-corner.html
 * For a full demo see:  http://malsup.com/jquery/corner/
 *
 *
 * @example jQuery('.adorn').corner();
 * @desc Create round, 10px corners 
 *
 * @example jQuery('.adorn').corner("25px");
 * @desc Create round, 25px corners 
 *
 * @example jQuery('.adorn').corner("notch bottom");
 * @desc Create notched, 10px corners on bottom only
 *
 * @example jQuery('.adorn').corner("tr dog 25px");
 * @desc Create dogeared, 25px corner on the top-right corner only
 *
 * @example jQuery('.adorn').corner("round 8px").parent().css('padding', '4px').corner("round 10px");
 * @desc Create a rounded border effect by styling both the element and its parent
 * 
 * @name corner
 * @type jQuery
 * @param String options Options which control the corner style
 * @cat Plugins/Corner
 * @return jQuery
 * @author Dave Methvin (dave.methvin@gmail.com)
 * @author Mike Alsup (malsup@gmail.com)
 */
jQuery.fn.corner = function(o) {
    function hex2(s) {
        var s = parseInt(s).toString(16);
        return ( s.length < 2 ) ? '0'+s : s;
    };
    function gpc(node) {
        for ( ; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode  ) {
            var v = jQuery.css(node,'backgroundColor');
            if ( v.indexOf('rgb') >= 0 ) { 
                rgb = v.match(/\d+/g); 
                return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
            }
            if ( v && v != 'transparent' )
                return v;
        }
        return '#ffffff';
    };
    function getW(i) {
        switch(fx) {
        case 'round':  return Math.round(width*(1-Math.cos(Math.asin(i/width))));
        case 'cool':   return Math.round(width*(1+Math.cos(Math.asin(i/width))));
        case 'sharp':  return Math.round(width*(1-Math.cos(Math.acos(i/width))));
        case 'bite':   return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
        case 'slide':  return Math.round(width*(Math.atan2(i,width/i)));
        case 'jut':    return Math.round(width*(Math.atan2(width,(width-i-1))));
        case 'curl':   return Math.round(width*(Math.atan(i)));
        case 'tear':   return Math.round(width*(Math.cos(i)));
        case 'wicked': return Math.round(width*(Math.tan(i)));
        case 'long':   return Math.round(width*(Math.sqrt(i)));
        case 'sculpt': return Math.round(width*(Math.log((width-i-1),width)));
        case 'dog':    return (i&1) ? (i+1) : width;
        case 'dog2':   return (i&2) ? (i+1) : width;
        case 'dog3':   return (i&3) ? (i+1) : width;
        case 'fray':   return (i%2)*width;
        case 'notch':  return width; 
        case 'bevel':  return i+1;
        }
    };
    o = (o||"").toLowerCase();
    var keep = /keep/.test(o);                       // keep borders?
    var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);  // corner color
    var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);  // strip color
    var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width
    var re = /round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;

    var fx = ((o.match(re)||['round'])[0]);
    var edges = { T:0, B:1 };
    var opts = {
        TL:  /top|tl/.test(o),       TR:  /top|tr/.test(o),
        BL:  /bottom|bl/.test(o),    BR:  /bottom|br/.test(o)
    };
    if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
        opts = { TL:1, TR:1, BL:1, BR:1 };
    var strip = document.createElement('div');
    strip.style.overflow = 'hidden';
    strip.style.height = '1px';
    strip.style.backgroundColor = sc || 'transparent';
    strip.style.borderStyle = 'solid';
    return this.each(function(index){
        var pad = {
            T: parseInt(jQuery.css(this,'paddingTop'))||0,     R: parseInt(jQuery.css(this,'paddingRight'))||0,
            B: parseInt(jQuery.css(this,'paddingBottom'))||0,  L: parseInt(jQuery.css(this,'paddingLeft'))||0
        };

        if (jQuery.browser.msie) this.style.zoom = 1; // force 'hasLayout' in IE
        if (!keep) this.style.border = 'none';
        strip.style.borderColor = cc || gpc(this.parentNode);
        var cssHeight = jQuery.curCSS(this, 'height');

        for (var j in edges) {
            var bot = edges[j];
            strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
            var d = document.createElement('div');
            var ds = d.style;

            bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);

            if (bot && cssHeight != 'auto') {
                if (jQuery.css(this,'position') == 'static')
                    this.style.position = 'relative';
                ds.position = 'absolute';
                ds.bottom = ds.left = ds.padding = ds.margin = '0';
                if (jQuery.browser.msie)
                    ds.setExpression('width', 'this.parentNode.offsetWidth');
                else
                    ds.width = '100%';
            }
            else {
                ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' : 
                                    (pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';                
            }

            for (var i=0; i < width; i++) {
                var w = Math.max(0,getW(i));
                var e = strip.cloneNode(false);
                e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
                bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
            }
        }
    });
};
(function(jQuery) {

	var cWidth,
		// outside width of container
		cHeight,
		// outside height of container
		cBkg;
		// url of image to crop
	
	// the public plugin method
		jQuery.fn.setContainer = function(settings) { //used to predefine container for image cropper
			// setup configuration
			settings = jQuery.extend({}, arguments.callee.defaults, settings);
			this.height(settings.cHeight);
			this.width(settings.cWidth);
			var maskOffsetTop = (settings.cHeight-settings.mHeight)/2 + 50;
			var maskOffsetLeft = (settings.cWidth-settings.mWidth)/2 + 50;
			this.css("background-image","url(" + settings.cBkg + ")");
			jQuery('#resizeMask').height(settings.cHeight);
			jQuery('#resizeMask').width(settings.cWidth);
			jQuery('#resizeMe').css("background-image","url(" + settings.cBkg + ")");
			jQuery('#resizeMe').height(settings.mHeight);
			jQuery('#resizeMe').width(settings.mWidth);
			jQuery('#resizeMe').css("background-image","url(" + settings.cBkg + ")");
			jQuery('#resizeMe').css("top",maskOffsetTop + "px");
			jQuery('#resizeMe').css("left",maskOffsetLeft + "px");
			jQuery('#resizeMe').css("background-position",(-maskOffsetLeft+50) + "px " + (-maskOffsetTop+50) + "px");
		}
	
	jQuery.fn.setContainer.defaults = {
		cWidth: 650,
		cHeight: 450,
		cBkg: 'http://ufaithag.crystalmoments.us/UFAOGlogos.jpg',
		mWidth: 200,
		mHeight: 200
	};
})(jQuery)
function toggleLoadingAnimation(show) {
	//show = 1 reveals, else hide
	if (show) {
		jQuery("#loadingStatus").show();
	} else {
		jQuery("#loadingStatus").hide();
	}
}
function toggleLoadingAnimationLocal(show) {
	//show = 1 reveals, else hide
	if (show) {
		jQuery("#loadingStatusLocal").show();
	} else {
		jQuery("#loadingStatusLocal").hide();
	}
}
/*
 * jQuery Impromptu
 * By: Trent Richardson [http://trentrichardson.com]
 * Version 2.6
 * Last Modified: 5/26/2009
 * 
 * Copyright 2009 Trent Richardson
 * Dual licensed under the MIT and GPL licenses.
 * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
 * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
 * 
 */
(function($){$.prompt=function(message,options){options=$.extend({},$.prompt.defaults,options);$.prompt.currentPrefix=options.prefix;var ie6=($.browser.msie&&$.browser.version<7);var $body=$(document.body);var $window=$(window);var msgbox='<div class="'+options.prefix+'box" id="'+options.prefix+'box">';if(options.useiframe&&(($('object, applet').length>0)||ie6)){msgbox+='<iframe src="javascript:false;" style="display:block;position:absolute;z-index:-1;" class="'+options.prefix+'fade" id="'+options.prefix+'fade"></iframe>';}else{if(ie6){$('select').css('visibility','hidden');}msgbox+='<div class="'+options.prefix+'fade" id="'+options.prefix+'fade"></div>';}msgbox+='<div class="'+options.prefix+'" id="'+options.prefix+'"><div class="'+options.prefix+'container"><div class="';msgbox+=options.prefix+'close">X</div><div id="'+options.prefix+'states"></div>';msgbox+='</div></div></div>';var $jqib=$(msgbox).appendTo($body);var $jqi=$jqib.children('#'+options.prefix);var $jqif=$jqib.children('#'+options.prefix+'fade');if(message.constructor==String){message={state0:{html:message,buttons:options.buttons,focus:options.focus,submit:options.submit}};}var states="";$.each(message,function(statename,stateobj){stateobj=$.extend({},$.prompt.defaults.state,stateobj);message[statename]=stateobj;states+='<div id="'+options.prefix+'_state_'+statename+'" class="'+options.prefix+'_state" style="display:none;"><div class="'+options.prefix+'message">'+stateobj.html+'</div><div class="'+options.prefix+'buttons">';$.each(stateobj.buttons,function(k,v){states+='<button name="'+options.prefix+'_'+statename+'_button'+k+'" id="'+options.prefix+'_'+statename+'_button'+k+'" value="'+v+'">'+k+'</button>';});states+='</div></div>';});$jqi.find('#'+options.prefix+'states').html(states).children('.'+options.prefix+'_state:first').css('display','block');$jqi.find('.'+options.prefix+'buttons:empty').css('display','none');$.each(message,function(statename,stateobj){var $state=$jqi.find('#'+options.prefix+'_state_'+statename);$state.children('.'+options.prefix+'buttons').children('button').click(function(){var msg=$state.children('.'+options.prefix+'message');var clicked=stateobj.buttons[$(this).text()];var forminputs={};$.each($jqi.find('#'+options.prefix+'states :input').serializeArray(),function(i,obj){if(forminputs[obj.name]===undefined){forminputs[obj.name]=obj.value;}else if(typeof forminputs[obj.name]==Array){forminputs[obj.name].push(obj.value);}else{forminputs[obj.name]=[forminputs[obj.name],obj.value];}});var close=stateobj.submit(clicked,msg,forminputs);if(close===undefined||close){removePrompt(true,clicked,msg,forminputs);}});$state.find('.'+options.prefix+'buttons button:eq('+stateobj.focus+')').addClass(options.prefix+'defaultbutton');});var ie6scroll=function(){$jqib.css({top:$window.scrollTop()});};var fadeClicked=function(){if(options.persistent){var i=0;$jqib.addClass(options.prefix+'warning');var intervalid=setInterval(function(){$jqib.toggleClass(options.prefix+'warning');if(i++>1){clearInterval(intervalid);$jqib.removeClass(options.prefix+'warning');}},100);}else{removePrompt();}};var keyPressEventHandler=function(e){var key=(window.event)?event.keyCode:e.keyCode;if(key==27){removePrompt();}if(key==9){var $inputels=$(':input:enabled:visible',$jqib);var fwd=!e.shiftKey&&e.target==$inputels[$inputels.length-1];var back=e.shiftKey&&e.target==$inputels[0];if(fwd||back){setTimeout(function(){if(!$inputels)return;var el=$inputels[back===true?$inputels.length-1:0];if(el)el.focus();},10);return false;}}};var positionPrompt=function(){$jqib.css({position:(ie6)?"absolute":"fixed",height:$window.height(),width:"100%",top:(ie6)?$window.scrollTop():0,left:0,right:0,bottom:0});$jqif.css({position:"absolute",height:$window.height(),width:"100%",top:0,left:0,right:0,bottom:0});$jqi.css({position:"absolute",top:options.top,left:"50%",marginLeft:(($jqi.outerWidth()/2)*-1)});};var stylePrompt=function(){$jqif.css({zIndex:options.zIndex,display:"none",opacity:options.opacity});$jqi.css({zIndex:options.zIndex+1,display:"none"});$jqib.css({zIndex:options.zIndex});};var removePrompt=function(callCallback,clicked,msg,formvals){$jqi.remove();if(ie6){$body.unbind('scroll',ie6scroll);}$window.unbind('resize',positionPrompt);$jqif.fadeOut(options.overlayspeed,function(){$jqif.unbind('click',fadeClicked);$jqif.remove();if(callCallback){options.callback(clicked,msg,formvals);}$jqib.unbind('keypress',keyPressEventHandler);$jqib.remove();if(ie6&&!options.useiframe){$('select').css('visibility','visible');}});};positionPrompt();stylePrompt();if(ie6){$window.scroll(ie6scroll);}$jqif.click(fadeClicked);$window.resize(positionPrompt);$jqib.bind("keydown keypress",keyPressEventHandler);$jqi.find('.'+options.prefix+'close').click(removePrompt);$jqif.fadeIn(options.overlayspeed);$jqi[options.show](options.promptspeed,options.loaded);$jqi.find('#'+options.prefix+'states .'+options.prefix+'_state:first .'+options.prefix+'defaultbutton').focus();return $jqib;};$.prompt.defaults={prefix:'jqi',buttons:{Ok:true},loaded:function(){},submit:function(){return true;},callback:function(){},opacity:0.6,zIndex:999,overlayspeed:'slow',promptspeed:'fast',show:'fadeIn',focus:0,useiframe:false,top:"15%",persistent:true,state:{html:'',buttons:{Ok:true},focus:0,submit:function(){return true;}}};$.prompt.currentPrefix=$.prompt.defaults.prefix;$.prompt.setDefaults=function(o){$.prompt.defaults=$.extend({},$.prompt.defaults,o);};$.prompt.setStateDefaults=function(o){$.prompt.defaults.state=$.extend({},$.prompt.defaults.state,o);};$.prompt.getStateContent=function(state){return $('#'+$.prompt.currentPrefix+'_state_'+state);};$.prompt.goToState=function(state){$('.'+$.prompt.currentPrefix+'_state').slideUp('slow');$('#'+$.prompt.currentPrefix+'_state_'+state).slideDown('slow',function(){$(this).find('.'+$.prompt.currentPrefix+'defaultbutton').focus();});};$.prompt.nextState=function(){var $next=$('.'+$.prompt.currentPrefix+'_state:visible').next();$('.'+$.prompt.currentPrefix+'_state').slideUp('slow');$next.slideDown('slow',function(){$next.find('.'+$.prompt.currentPrefix+'defaultbutton').focus();});};$.prompt.prevState=function(){var $next=$('.'+$.prompt.currentPrefix+'_state:visible').prev();$('.'+$.prompt.currentPrefix+'_state').slideUp('slow');$next.slideDown('slow',function(){$next.find('.'+$.prompt.currentPrefix+'defaultbutton').focus();});};$.prompt.close=function(){$('#'+$.prompt.currentPrefix+'box').fadeOut('fast',function(){$(this).remove();});};})(jQuery);
/*
 * Jonathan Howard
 *
 * jQuery Pause
 * version 0.2
 *
 * Requires: jQuery 1.0 (tested with svn as of 7/20/2006)
 *
 * Feel free to do whatever you'd like with this, just please give credit where
 * credit is do.
 *
 *
 *
 * pause() will hold everything in the queue for a given number of milliseconds,
 * or 1000 milliseconds if none is given.
 *
 *
 *
 * unpause() will clear the queue of everything of a given type, or 'fx' if no
 * type is given.
 */

jQuery.fn.pause = function(milli,type) {
	milli = milli || 1000;
	type = type || "fx";
	return this.queue(type,function(){
		var self = this;
		setTimeout(function(){
			jQuery(self).dequeue();
		},milli);
	});
};

jQuery.fn.clearQueue = jQuery.fn.unpause = function(type) {
	return this.each(function(){
		type = type || "fx";
		if(this.queue && this.queue[type]) {
			this.queue[type].length = 0;
		}
	});
};
//select zip code info from db
function getZipCodeInfo(zipcode,city,state,loc) {
	jQuery('#'+loc).after('<img id="loader'+loc+'" src="/images/loading-small.gif" />');
	jQuery.ajax({
		type : 'POST',
		dataType : 'json',
		url  : '/?ajax=1&method=getZipInfo',
		data : 'zipcode='+zipcode,
		success : function (zipinfo) {
			jQuery('#loader'+loc).remove();
			if (zipinfo[0].status=='success') {
				if (city) {
					jQuery('#'+city).attr('value',zipinfo[0].city);
				} else {
					jQuery('#City').attr('value',zipinfo[0].city);
				}
				if (state) {
					jQuery('#'+state+' option').attr('selected','');
					jQuery('#'+state+' option#'+zipinfo[0].state.substring(0,2)).attr('selected','selected');
				} else {
					jQuery('#State option').attr('selected','');
					jQuery('#State option#'+zipinfo[0].state.substring(0,2)).attr('selected','selected');
				}
			}
		}
	});	
}
function getPrimaryAddress(userid,prefix,loc) {
	jQuery('#'+loc).after('<img id="addressload'+loc+'" src="/images/loading-small.gif" />');
	jQuery.ajax({
		type : 'POST',
		dataType : 'json',
		url  : '/?ajax=1&method=getPrimaryAddress',
		data : 'userid='+userid,
		success : function (response) {
			jQuery('#addressload'+loc).remove();
			if (response[0].status=='success') {
				if (prefix) {
					jQuery('#'+prefix+'FirstName').attr('value',response[0].firstname);
					jQuery('#'+prefix+'LastName').attr('value',response[0].lastname);
					jQuery('#'+prefix+'Address').attr('value',response[0].address);
					jQuery('#'+prefix+'City').attr('value',response[0].city);
					jQuery('#'+prefix+'State option').attr('selected','');
					jQuery('#'+prefix+'State option#'+response[0].state.substring(0,2)).attr('selected','selected');
					jQuery('#'+prefix+'Zip').attr('value',response[0].zip);
				} else {
					jQuery('#FirstName').attr('value',response[0].firstname);
					jQuery('#LastName').attr('value',response[0].lastname);
					jQuery('#Address').attr('value',response[0].address);
					jQuery('#City').attr('value',response[0].city);
					jQuery('#State option').attr('selected','');
					jQuery('#State option#'+response[0].state.substring(0,2)).attr('selected','selected');
					jQuery('#Zip').attr('value',response[0].zip);
				}
			} 
		}
	});	
}
function getPaymentHistory(selection) {
	var filterBy = document.getElementById("filterBy").options[selection].value;
	jQuery('#filterBy').after('<img id="filterload" src="/images/loading-small.gif" />');
	jQuery.ajax({
		type : 'POST',
		dataType : 'html',
		url  : '/?ajax=1&method=getContributionsPaymentHistory',
		data : 'filterBy='+filterBy,
		success : function (html) {
			jQuery('#filterBy').remove();
			jQuery('#paymentList').get(0).innerHTML = html;
			setPaymentToggle();
		}
	});	
}
function setPaymentToggle() {
	jQuery(document).ready(function() {
		jQuery('span.paymentToggle').click(function () {
			jQuery('#payment'+jQuery(this).attr('id').substring(6)).toggle();
			if (jQuery(this).html() == "+") {
				jQuery(this).html("-");
			} else {
				jQuery(this).html("+");
			}
		});
	});
}
function limitChars(textid, limit, infodiv)
{
	var text = $('#'+textid).val();	
	var textlength = text.length;
	if(textlength > limit)
	{
		$('#' + infodiv).html('Limit reached!');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
	{
		$('#' + infodiv).html(limit - textlength);
		return true;
	}
}
function lockButton(submitButton) {
	jQuery(submitButton).attr("float","left").after('<img src="/images/indicator-dark.gif" width="16" height="16" />').attr("disabled","disabled");
}
/*
* cacheImage: a jQuery plugin
*
* cacheImage is a simple jQuery plugin for pre-caching images. The
* plugin can be used to eliminate flashes of unstyled content (FOUC) and
* improve perceived page load time. Callbacks for load, error and abort
* events are provided.
*
* For usage and examples, visit:
* http://github.com/alexrabarts/jquery-cacheimage
*
* Licensed under the MIT:
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright (c) 2008 Stateless Systems (http://statelesssystems.com)
*
* @author Alex Rabarts (alexrabarts -at- gmail -dawt- com)
* @requires jQuery v1.2 or later
* @version 0.1
*/
 
 (function ($) {
   $.extend($, {
     cacheImage: function (src, options) {
       if (typeof src === 'object') {
         $.each(src, function () {
           $.cacheImage(String(this), options);
         });
       }
 
       var image = new Image();
 
       options = options || {};
 
       $.each(['load', 'error', 'abort'], function () { // Callbacks
         var e = String(this);
         if (typeof options[e] === 'function') { $(image)[e](options[e]); }
       });
 
       image.src = src;
 
       return image;
     }
   });
 
   $.extend($.fn, {
     cacheImage: function (options) {
       return this.each(function () {
         $.cacheImage(this.src, options);
       });
     }
   });
 })(jQuery);
 jQuery.extend({
    BgImageTransitions: []
});

jQuery.fn.extend({
    BgImageTransition: function(src, options) {
        if( !src ){ return jQuery; }

        //copy css from the element to the helper element function
        function copyCSS( from, to ){
            jQuery(['border-bottom-color', 'border-bottom-style', 'border-bottom-width', 'border-left-color',
            'border-left-style', 'border-left-width', 'border-right-color', 'border-right-style',
            'border-right-width', 'border-spacing', 'border-top-color', 'border-top-style',
            'border-top-width', 'bottom', 'height', 'left', 'margin-bottom', 'margin-left',
            'margin-right', 'margin-top', 'marker-offset', 'max-height', 'max-width', 'min-height',
            'min-width', 'opacity', 'outline-color', 'outline-offset', 'outline-width',
            'padding-bottom', 'padding-left', 'padding-right', 'padding-top', 
            'width', 'z-index']).each( function(i,v){
                jQuery(to).css( v, jQuery(from).css( v ) );
            });
        }

        //make sure there is a zIndex set - we will the helperElement to be *above* the original one
        if( !this.css('zIndex') ){
            this.css('zIndex',1);
        }

        //default plugin settings
        var settings = jQuery.extend({
            effect: {opacity: 'toggle'},
            duration: 'slow',
            easing: 'linear',
            callback: function(){},
            helperElementId: this.attr('id')+'2',
            zindex: parseInt(this.css('zIndex'),10)+1
        }, options);

        //check the bgImageTransition array and see whether there is already a helperElement for the original one. Generate one, if not
        var helperElement = null;
	var position = this.position();
        if( !jQuery.BgImageTransitions[this.attr('id')] ){
            helperElement = this.clone();
            copyCSS( this, helperElement );
            helperElement.css('zIndex', settings.zindex);
            helperElement.css('display', 'none');
	    helperElement.css('position', 'absolute');
	    helperElement.css('top', position.top);
	    helperElement.css('left', position.left);
            helperElement.attr('id', settings.helperElementId );
	    helperElement.insertAfter(this);
            jQuery.BgImageTransitions[this.attr('id')] = helperElement;
        }
        else{
            helperElement = jQuery.BgImageTransitions[this.attr('id')];
        }

        //load the image file into cache first, so that we get a nice and fast load. Make the transition when the image has been loaded in cache
        var tempImage = new Image();

        jQuery(tempImage).load( function(){
            var newImage = ( helperElement.css('display') == 'block' ) ? jQuery(this) : jQuery(helperElement);
            newImage.css('backgroundImage', 'url('+tempImage.src+')');
            helperElement.animate( settings.effect, settings.duration, settings.easing, settings.callback );
        });

        tempImage.src = src;

        return jQuery;
    }
});
/*! Copyright (c) 2008 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Version: 1.0.3
 * Requires jQuery 1.1.3+
 * Docs: http://docs.jquery.com/Plugins/livequery
 */

(function(jQuery) {
	
jQuery.extend(jQuery.fn, {
	livequery: function(type, fn, fn2) {
		var self = this, q;
		
		// Handle different call patterns
		if (jQuery.isFunction(type))
			fn2 = fn, fn = type, type = undefined;
			
		// See if Live Query already exists
		jQuery.each( jQuery.livequery.queries, function(i, query) {
			if ( self.selector == query.selector && self.context == query.context &&
				type == query.type && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) )
					// Found the query, exit the each loop
					return (q = query) && false;
		});
		
		// Create new Live Query if it wasn't found
		q = q || new jQuery.livequery(this.selector, this.context, type, fn, fn2);
		
		// Make sure it is running
		q.stopped = false;
		
		// Run it immediately for the first time
		q.run();
		
		// Contnue the chain
		return this;
	},
	
	expire: function(type, fn, fn2) {
		var self = this;
		
		// Handle different call patterns
		if (jQuery.isFunction(type))
			fn2 = fn, fn = type, type = undefined;
			
		// Find the Live Query based on arguments and stop it
		jQuery.each( jQuery.livequery.queries, function(i, query) {
			if ( self.selector == query.selector && self.context == query.context && 
				(!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped )
					jQuery.livequery.stop(query.id);
		});
		
		// Continue the chain
		return this;
	}
});

jQuery.livequery = function(selector, context, type, fn, fn2) {
	this.selector = selector;
	this.context  = context || document;
	this.type     = type;
	this.fn       = fn;
	this.fn2      = fn2;
	this.elements = [];
	this.stopped  = false;
	
	// The id is the index of the Live Query in jQuery.livequery.queries
	this.id = jQuery.livequery.queries.push(this)-1;
	
	// Mark the functions for matching later on
	fn.$lqguid = fn.$lqguid || jQuery.livequery.guid++;
	if (fn2) fn2.$lqguid = fn2.$lqguid || jQuery.livequery.guid++;
	
	// Return the Live Query
	return this;
};

jQuery.livequery.prototype = {
	stop: function() {
		var query = this;
		
		if ( this.type )
			// Unbind all bound events
			this.elements.unbind(this.type, this.fn);
		else if (this.fn2)
			// Call the second function for all matched elements
			this.elements.each(function(i, el) {
				query.fn2.apply(el);
			});
			
		// Clear out matched elements
		this.elements = [];
		
		// Stop the Live Query from running until restarted
		this.stopped = true;
	},
	
	run: function() {
		// Short-circuit if stopped
		if ( this.stopped ) return;
		var query = this;
		
		var oEls = this.elements,
			els  = jQuery(this.selector, this.context),
			nEls = els.not(oEls);
		
		// Set elements to the latest set of matched elements
		this.elements = els;
		
		if (this.type) {
			// Bind events to newly matched elements
			nEls.bind(this.type, this.fn);
			
			// Unbind events to elements no longer matched
			if (oEls.length > 0)
				jQuery.each(oEls, function(i, el) {
					if ( jQuery.inArray(el, els) < 0 )
						jQuery.event.remove(el, query.type, query.fn);
				});
		}
		else {
			// Call the first function for newly matched elements
			nEls.each(function() {
				query.fn.apply(this);
			});
			
			// Call the second function for elements no longer matched
			if ( this.fn2 && oEls.length > 0 )
				jQuery.each(oEls, function(i, el) {
					if ( jQuery.inArray(el, els) < 0 )
						query.fn2.apply(el);
				});
		}
	}
};

jQuery.extend(jQuery.livequery, {
	guid: 0,
	queries: [],
	queue: [],
	running: false,
	timeout: null,
	
	checkQueue: function() {
		if ( jQuery.livequery.running && jQuery.livequery.queue.length ) {
			var length = jQuery.livequery.queue.length;
			// Run each Live Query currently in the queue
			while ( length-- )
				jQuery.livequery.queries[ jQuery.livequery.queue.shift() ].run();
		}
	},
	
	pause: function() {
		// Don't run anymore Live Queries until restarted
		jQuery.livequery.running = false;
	},
	
	play: function() {
		// Restart Live Queries
		jQuery.livequery.running = true;
		// Request a run of the Live Queries
		jQuery.livequery.run();
	},
	
	registerPlugin: function() {
		jQuery.each( arguments, function(i,n) {
			// Short-circuit if the method doesn't exist
			if (!jQuery.fn[n]) return;
			
			// Save a reference to the original method
			var old = jQuery.fn[n];
			
			// Create a new method
			jQuery.fn[n] = function() {
				// Call the original method
				var r = old.apply(this, arguments);
				
				// Request a run of the Live Queries
				jQuery.livequery.run();
				
				// Return the original methods result
				return r;
			}
		});
	},
	
	run: function(id) {
		if (id != undefined) {
			// Put the particular Live Query in the queue if it doesn't already exist
			if ( jQuery.inArray(id, jQuery.livequery.queue) < 0 )
				jQuery.livequery.queue.push( id );
		}
		else
			// Put each Live Query in the queue if it doesn't already exist
			jQuery.each( jQuery.livequery.queries, function(id) {
				if ( jQuery.inArray(id, jQuery.livequery.queue) < 0 )
					jQuery.livequery.queue.push( id );
			});
		
		// Clear timeout if it already exists
		if (jQuery.livequery.timeout) clearTimeout(jQuery.livequery.timeout);
		// Create a timeout to check the queue and actually run the Live Queries
		jQuery.livequery.timeout = setTimeout(jQuery.livequery.checkQueue, 20);
	},
	
	stop: function(id) {
		if (id != undefined)
			// Stop are particular Live Query
			jQuery.livequery.queries[ id ].stop();
		else
			// Stop all Live Queries
			jQuery.each( jQuery.livequery.queries, function(id) {
				jQuery.livequery.queries[ id ].stop();
			});
	}
});

// Register core DOM manipulation methods
jQuery.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove');

// Run Live Queries when the Document is ready
jQuery(function() { jQuery.livequery.play(); });


// Save a reference to the original init method
var init = jQuery.prototype.init;

// Create a new init method that exposes two new properties: selector and context
jQuery.prototype.init = function(a,c) {
	// Call the original init and save the result
	var r = init.apply(this, arguments);
	
	// Copy over properties if they exist already
	if (a && a.selector)
		r.context = a.context, r.selector = a.selector;
		
	// Set properties
	if ( typeof a == 'string' )
		r.context = c || document, r.selector = a;
	
	// Return the result
	return r;
};

// Give the init function the jQuery prototype for later instantiation (needed after Rev 4091)
jQuery.prototype.init.prototype = jQuery.prototype;
	
})(jQuery);