//YAHOO.util.Event.addListener( window, 'load', function( e )
YAHOO.util.Event.onDOMReady( function( e )
{
	// custom events
	YAHOO.UP.events.add( 'form-sendall' );
	YAHOO.UP.events.add( 'form-resetall' );
	YAHOO.UP.events.add( 'form-errorall' );
	var forms = document.getElementsByTagName( 'form' );
	if( forms.length > 0 )
	{
		YAHOO.UP.util.each( forms, function( j, form )
		{
			YAHOO.UP.events.add( 'form-send-' + form.getAttribute( 'id' ) );
			YAHOO.UP.events.add( 'form-reset-' + form.getAttribute( 'id' ) );
			YAHOO.UP.events.add( 'form-error-' + form.getAttribute( 'id' ) );
		} );
	}

	// close error message
	var closeLinks = Ext.query( 'div.result div.message span.close, div.result div.message button.close' );
	YAHOO.util.Dom.addClass( closeLinks, 'clickable' );
	YAHOO.util.Event.addListener( closeLinks, 'click', function( e )
	{
		YAHOO.UP.util.hide( this.parentNode.parentNode );
		YAHOO.util.Event.stopEvent( e );
	} );

	/*	fixes 'LABEL Object Resets Focus' in IE 6
		http://support.microsoft.com/kb/314279 */
	var labels = document.getElementsByTagName( 'label' );
	YAHOO.util.Event.addListener( labels, 'click', function( e )
	{
		if( document.getElementById( this.htmlFor ) && document.getElementById( this.htmlFor ).nodeName.toLowerCase() == 'select' )
		{
			try {
				document.getElementById( this.htmlFor ).focus();
			} catch(e) {}
			YAHOO.util.Event.preventDefault( e );
		}
	} );
} );

// fake Ext for Ext.DomQuery
Ext.DomQuery.matchers.push( {
	re: /^(?:([\[\{])(?:@)?([\w-]+(?:\:[\w-]+))\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
	select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
} );
Ext.queryOne = function( path, root )
{
	var query = Ext.query( path, root );
	return query.length > 0 ? query[ 0 ] : null;
};

String.prototype.substringBefore = function( subject )
{
	var occursAt = this.indexOf( subject );
	return this.substr( 0, occursAt );
};
String.prototype.substringBeforeLast = function( subject )
{
	var occursAt = this.lastIndexOf( subject );
	return this.substr( 0, occursAt );
};
/* String.prototype.substringAfterLast = function( subject )
{
	var occursAt = this.lastIndexOf( subject );
	return this.substr( occursAt + 1 );
}; */

/* Fixes 'Don't modify name attribute' bug in IE 6
 * Code from: http://www.easy-reader.net/archives/2005/09/02/death-to-bad-dom-implementations/
 */
document.createNamedElement = function( type, name )
{
	var element;
	try {
		element = document.createElement( '<'+type+' name="'+name+'">' );
	} catch (e) {}
	if( !element || !element.name )
	{
		element = document.createElement(type)
		element.name = name;
	}
	return element;
};
YAHOO.namespace( 'valdi.env.browser' );
YAHOO.valdi.env.browser.isIE = function()
{
	// <3 jquery code
	var b = navigator.userAgent.toLowerCase();
	return /msie/.test(b) && !/opera/.test(b);
};

// a temporary data cache.
YAHOO.namespace( 'UP.cache' );
YAHOO.UP.cache._store = {};
YAHOO.UP.cache.add = function( key, value )
{
	YAHOO.UP.cache._store[ key ] = value;
};
YAHOO.UP.cache.addsub = function( key, subkey, value )
{
	if( !YAHOO.UP.cache._store[ key ] ) YAHOO.UP.cache._store[ key ] = {};
	YAHOO.UP.cache._store[ key ][ subkey ] = value;
};
YAHOO.UP.cache.has = function( key, subkey )
{
	if( subkey != null ) return YAHOO.UP.cache._store[ key ] != null && YAHOO.UP.cache._store[ key ][ subkey ] != null;
	return YAHOO.UP.cache._store[ key ] != null;
};
YAHOO.UP.cache.get = function( key, subkey )
{
	if( subkey != null ) return YAHOO.UP.cache._store[ key ] != null ? YAHOO.UP.cache._store[ key ][ subkey ] : null;
	return YAHOO.UP.cache._store[ key ];
};
YAHOO.UP.cache.remove = function( key, subkey )
{
	if( subkey != null && YAHOO.UP.cache._store[ key ] && YAHOO.UP.cache._store[ key ][ subkey ] ) delete YAHOO.UP.cache._store[ key ][ subkey ];
	else if( YAHOO.UP.cache._store[ key ] ) delete YAHOO.UP.cache._store[ key ];
};
YAHOO.UP.cache.clear = function( e ) // on unload
{
	delete YAHOO.UP.cache._store;
};

YAHOO.namespace( 'UP.events' );
YAHOO.UP.events.add = function( name, scope, silent )
{
	YAHOO.UP.cache.addsub( 'events', name, new YAHOO.util.CustomEvent( name, scope, silent, YAHOO.util.CustomEvent.FLAT ) );
};
YAHOO.UP.events.subscribe = function( name, callback, obj, bScope )
{
	YAHOO.UP.cache.get( 'events', name ).subscribe( callback, obj, bScope );
};
YAHOO.UP.events.fire = function( name, obj )
{
	YAHOO.UP.cache.get( 'events', name ).fire( obj );
};
/* alt + character performs a callback. */
YAHOO.UP.events.accesskey = function( character, callback )
{
	YAHOO.util.Event.addListener( document, 'keydown', function( e, character )
	{
		if( e.altKey && String.fromCharCode( YAHOO.util.Event.getCharCode( e ) ).toLowerCase() == character.toLowerCase() )
		{
			callback();
			YAHOO.util.Event.stopEvent( e );
		}
	}, character );
};

YAHOO.namespace( 'UP.util' );
YAHOO.UP.util.each = function( obj, func, args )
{
	// nicely written code (args was modified) is from jQuery
	/* if( !YAHOO.lang.isArray( obj ) && !YAHOO.lang.isObject( obj ) )
		func.apply( obj, [0, obj, args] );
	else  */
	if ( obj && !obj['length'] )
		for ( var i in obj )
			func.apply( obj[i], [i, obj[i], args] );
	else if( obj && obj[ 'length' ] )
		for ( var i = 0, ol = obj['length']; i < ol; i++ )
			if ( func.apply( obj[i], [i, obj[i], args] ) === false ) break;
	return obj;
};
/* returns if the primary class is being added or not (className or 'shown') */
YAHOO.UP.util.toggle = function( elements , /* optional */className, /* optional */toggleToClassName )
{
	var added = 0, taken = 0;
	YAHOO.UP.util.each( elements, function( j , element )
	{
		if( className && YAHOO.util.Dom.hasClass( element, className ) ) {
			YAHOO.util.Dom.removeClass( element, className );
			if( toggleToClassName ) YAHOO.util.Dom.addClass( element, toggleToClassName );
			taken++;
		} else if( className ) {
			if( toggleToClassName ) YAHOO.util.Dom.removeClass( element, toggleToClassName );
			YAHOO.util.Dom.addClass( element, className );
			added++;
		} else if( YAHOO.util.Dom.hasClass( element, 'hidden' ) ) {
			YAHOO.UP.util.show( element );
			added++;
		} else {
			YAHOO.UP.util.hide( element );
			taken++;
		}
	} );
	return added >= taken;
};
YAHOO.UP.util.isShown = function( elements )
{
	if( !YAHOO.util.Dom.hasClass( elements, 'shown' ) )
	{
		return false;
	}
	return true;
};
YAHOO.UP.util.show = function( elements )
{
	YAHOO.util.Dom.removeClass( elements, 'hidden' );
	YAHOO.util.Dom.addClass( elements, 'shown' );
};
YAHOO.UP.util.isHidden = function( elements )
{
	if( !YAHOO.util.Dom.hasClass( elements, 'hidden' ) )
	{
		return false;
	}
	return true;
};
YAHOO.UP.util.hide = function( elements )
{
	YAHOO.util.Dom.removeClass( elements, 'shown' );
	YAHOO.util.Dom.addClass( elements, 'hidden' );
};
YAHOO.UP.util.showLoading = function( element, cancelCallback )
{
	if( YAHOO.lang.isString( element ) ) element = YAHOO.util.Dom.get( element );

	var blockerDiv = document.createElement( 'div' );
	YAHOO.util.Dom.addClass( blockerDiv, 'blockerDiv' );

	// @TODO
	if( YAHOO.valdi.env.browser.isIE() )
	{
		var iframeShim = document.createElement( 'iframe' );
		iframeShim.src = 'javascript:false;document.write("");';
		iframeShim.setAttribute( 'scrolling', 'no' );
		iframeShim.setAttribute( 'frameBorder', '0' );
		blockerDiv.appendChild( iframeShim );
	}
	element.insertBefore( blockerDiv, element.firstChild );

	YAHOO.util.Dom.setStyle( blockerDiv, 'background-color', '#fff' );
	YAHOO.util.Dom.setStyle( blockerDiv, 'position', 'absolute' );
	YAHOO.util.Dom.setStyle( blockerDiv, 'cursor', 'progress' );
	YAHOO.util.Dom.setStyle( blockerDiv, 'left', ( YAHOO.util.Dom.getX( element ) - 2 ) + 'px' );
	YAHOO.util.Dom.setStyle( blockerDiv, 'top', ( YAHOO.util.Dom.getY( element ) - 2 ) + 'px' );
	YAHOO.util.Dom.setStyle( blockerDiv, 'width', ( element.offsetWidth + 4 ) + 'px' ); // resize with window
	YAHOO.util.Dom.setStyle( blockerDiv, 'height', ( element.offsetHeight + 4 ) + 'px' );
	YAHOO.util.Dom.setStyle( blockerDiv, 'z-index', '9998' );
	YAHOO.util.Dom.setStyle( blockerDiv, 'opacity', 0.4 );

	// @TODO
	if( YAHOO.valdi.env.browser.isIE() )
	{
		YAHOO.util.Dom.setStyle( iframeShim, 'width', '100%' );
		YAHOO.util.Dom.setStyle( iframeShim, 'height', '100%' );
		YAHOO.util.Dom.setStyle( iframeShim, 'overflow', 'hidden' );
		YAHOO.util.Dom.setStyle( iframeShim, 'border', 0 );
	}

	/* var style = [
		'background-color:#fff',
		'position:absolute',
		'cursor:progress',
		'left:' + ( YAHOO.util.Dom.getX( element ) - 2 ) + 'px',
		'top:' + ( YAHOO.util.Dom.getY( element ) - 2 ) + 'px',
		'width:' + ( element.offsetWidth + 4 ) + 'px',
		'height:' + ( element.offsetHeight + 4 ) + 'px',
		'z-index:9998',
		'opacity:0.4'
	];
	var loadingStyle = [
		'width:154px',
		'position:absolute',
		'top:' + ( YAHOO.util.Dom.getY( element ) - 2 ) + 'px',
		'right:' + ( YAHOO.util.Dom.getViewportWidth() - YAHOO.util.Dom.getX( element ) - Math.round(element.offsetWidth/2) - Math.round(loading.offsetWidth/2) ) + 'px',
		'z-index:9999'
	];
	var newElement = YAHOO.valdi.element( [
		'div.blockerDiv[style="' + style.join( ';' ) + ';"]',
		{
			'div.pleaseWait.blockerDiv[style="' + loadingStyle.join( ';' ) + ';"]' : [
				'img[src="images/processing.gif"]',
				{ 'div[style="float:left"]' : [ '#Please Wait...', 'br' ] }
			]
		}
	], element, YAHOO.valdi.element.UNSHIFT ); */

	var loading = document.createElement( 'div' );
	YAHOO.util.Dom.setStyle( loading, 'width', '154px' );
	var loadingImage = document.createElement( 'img' );
	loadingImage.setAttribute( 'src', 'images/processing.gif' );
	loading.appendChild( loadingImage );
	YAHOO.util.Dom.addClass( loading, 'pleaseWait' );
	YAHOO.util.Dom.addClass( loading, 'blockerDiv' );
	var loadingContent = document.createElement( 'div' );
	YAHOO.util.Dom.setStyle( loadingContent, 'float', 'left' );
	loadingContent.appendChild( document.createTextNode( 'Please Wait...' ) );
	loadingContent.appendChild( document.createElement( 'br' ) );
	// @TODO
	if( cancelCallback )
	{
		var cancel = document.createElement( 'a' );
		YAHOO.util.Dom.addClass( cancel, 'clickable' );
		cancel.appendChild( document.createTextNode( 'Cancel' ) );
		YAHOO.util.Event.addListener( cancel, 'click', cancelCallback );
		loadingContent.appendChild( cancel );
	}
	loading.appendChild( loadingContent );
	element.insertBefore( loading, element.firstChild );
	YAHOO.util.Dom.setStyle( loading, 'position', 'absolute' );
	YAHOO.util.Dom.setStyle( loading, 'top', ( YAHOO.util.Dom.getY( element ) - 2 ) + 'px' );
	YAHOO.util.Dom.setStyle( loading, 'right', ( YAHOO.util.Dom.getViewportWidth() - YAHOO.util.Dom.getX( element ) - Math.round(element.offsetWidth/2) - Math.round(loading.offsetWidth/2) ) + 'px' );
	YAHOO.util.Dom.setStyle( loading, 'z-index', '9999' );

	// NOT @TODO
	/* var loadingText = document.createElement( 'span' );
	loadingText.appendChild( document.createTextNode( 'Loading...' ) );
	YAHOO.util.Dom.addClass( loadingText, 'blockerDiv' );
	element.insertBefore( loadingText, element.firstChild );
	YAHOO.util.Dom.setStyle( loadingText, 'position', 'absolute' );
	YAHOO.util.Dom.setStyle( loadingText, 'background-color', '#c44' );
	YAHOO.util.Dom.setStyle( loadingText, 'top', ( YAHOO.util.Dom.getY( element ) - 2 ) + 'px' );
	YAHOO.util.Dom.setStyle( loadingText, 'right', ( YAHOO.util.Dom.getViewportWidth() - YAHOO.util.Dom.getX( element ) - element.offsetWidth ) + 'px' );
	YAHOO.util.Dom.setStyle( loadingText, 'padding', '2px 3px' );
	YAHOO.util.Dom.setStyle( loadingText, 'color', '#fff' );
	YAHOO.util.Dom.setStyle( loadingText, 'z-index', '9999' ); */
};
YAHOO.UP.util.hideLoading = function( element )
{
	if( YAHOO.lang.isString( element ) ) element = YAHOO.util.Dom.get( element );
	var blockerDivs = Ext.query( 'div.blockerDiv', element );
	for( var j = 0; j < blockerDivs.length; j ++ )
	{
		element.removeChild( blockerDivs[ j ] );
	}
	/* if( YAHOO.valdi.env.browser.isIE() && Ext.query( 'select', element ).length > 0 )
		YAHOO.util.Dom.setStyle( Ext.query( 'select', element ), 'visibility', 'visible' ); */
};
YAHOO.UP.util.autoComplete = function( rootNode, /* object */ nameValuePairs )
{
	// by Id
	var autoCompleteNodes = Ext.query( 'span[valdi:autoCompleteById], input[valdi:autoCompleteById]', rootNode );
	YAHOO.UP.util.each( autoCompleteNodes, function( j, targetNode )
	{
		var myElement = document.getElementById( targetNode.getAttribute( 'valdi:autoCompleteById' ) );
		if( myElement && YAHOO.UP.form.getElement( myElement ) )
		{
			myElement = YAHOO.UP.form.getElement( myElement );
			if( myElement && targetNode.nodeName.toLowerCase() == 'span' ) targetNode.innerHTML = YAHOO.UP.form.getValue( myElement ) + ' ';
			else if( myElement && targetNode.nodeName.toLowerCase() == 'input' ) YAHOO.UP.form.setValue( targetNode, YAHOO.UP.form.getValue( myElement ) );
		} else if( myElement ) {
			if( myElement && targetNode.nodeName.toLowerCase() == 'span' ) targetNode.innerHTML = myElement.innerHTML;
			else if( myElement && targetNode.nodeName.toLowerCase() == 'input' ) YAHOO.UP.form.setValue( targetNode, myElement.innerHTML );
		}
	} );

	// by Function Call
	var autoCompleteNodes = Ext.query( 'span[valdi:autoCompleteByFunction]', rootNode );
	YAHOO.UP.util.each( autoCompleteNodes, function( j, span )
	{
		span.innerHTML = YAHOO.UP.util.getFunction( span.getAttribute( 'valdi:autoCompleteByFunction' ) )() + ' ';
	} );

	// by name value pairs
	if( nameValuePairs != null )
	{
		YAHOO.UP.util.each( Ext.query( 'span[valdi:autoCompleteName]', rootNode ), function( j, span )
		{
			var newValue = nameValuePairs[ span.getAttribute( 'valdi:autoCompleteName' ) ];
			if( newValue != null && newValue != '' )
			{
				span.innerHTML = newValue + ' ';
			} else {
				span.innerHTML = '';
			}
		} );
	}
};
YAHOO.namespace( 'UP.util.Array' );
YAHOO.UP.util.Array.hasValue = function( arg1, arg2 )
{
	var a, b;
	if( YAHOO.UP.util.Math.XOR( YAHOO.lang.isArray( arg1 ), YAHOO.lang.isArray( arg2 ) ) )
	{
		if( YAHOO.lang.isArray( arg1 ) )
		{
			a = arg1;
			b = arg2;
		} else {
			a = arg2;
			b = arg1;
		}
	} else {
		throw new Error( 'You cannot pass two Arrays into the hasValue function.' );
	}
	for( var j in a )
	{
		if( a[ j ] == b ) return true;
	}
	return false;
};
/* accepts only alphabetic characters (and a dot) */
YAHOO.UP.util.getFunction = function( /* String */functionName )
{
	functionName = functionName.replace( /[^(A-Z)^(a-z)^.^(0-9)]/g, '' );
	if( functionName.indexOf( '.' ) > -1 )
	{
		var split = functionName.split( '.' );
		var placeHolder = window;
		for( var j = 0; j < split.length; j++ )
		{
			if( !placeHolder[ split[ j ] ] )
			{
				break;
			} else if( j == split.length - 1 ) { // last loop iteration
				return placeHolder[ split[ j ] ];
			} else {
				placeHolder = placeHolder[ split[ j ] ];
			}
		}
	} else if( window[ functionName ] ) {
		return window[ functionName ];
	}
	throw new Error( 'Function name ' + functionName + ' could not be found.' );
};

YAHOO.namespace( 'UP.util.String' );
YAHOO.UP.util.String.each = function( str, obj, func )
{
	if( obj instanceof Array )
	{
		for( var j = 0; j < obj.length; j++ )
		{
			str += func( j, obj[ j ] );
		}
	} else {
		str += func( null, obj );
	}
	return str;
};
YAHOO.UP.util.String.simpleReplace = function( str, searchFor, replaceWith )
{
	// if searchFor does not occur in the string
	var indexOccurs = str.indexOf( searchFor );
	if( -1 == indexOccurs )
	{
		return str.toString();
	} else {
		var newString = str.substring( 0, indexOccurs ) + replaceWith + str.substr( indexOccurs + searchFor.length );
		return YAHOO.UP.util.String.simpleReplace( newString, searchFor, replaceWith );
	}
};
YAHOO.UP.util.String.trim = function( str )
{
   return str.replace(/^\s*|\s*$/g,"");
};
YAHOO.UP.util.String.count = function( haystack, needle )
{
	return haystack.split( needle ) instanceof Array ? haystack.split( needle ).length - 1 : 0;
};
/* pass in a negative number for indexFromEnd to return the substring */
YAHOO.UP.util.String.substrNegative = function( str, indexFromEnd, resultLength ) // indexFromEnd begins with 1
{
	if( resultLength != null ) return str.substr( str.length - Math.abs( indexFromEnd ), resultLength );
	else return str.substr( str.length - Math.abs( indexFromEnd ) );
};
YAHOO.namespace( 'UP.util.Time' );
YAHOO.UP.util.Time.padFormat = function( hour, minute, second )
{
	return ( hour < 10 ? '0' + hour : hour ) + ':' + ( minute < 10 ? '0' + minute : minute ) + ( second != null ? ':' + ( second < 10 ? '0' + second : second ) : '' );
};
YAHOO.UP.util.Time.isDaylightSavings = function( dateObj )
{
	return dateObj.toString().indexOf( 'DT' ) != -1 || dateObj.toString().indexOf( 'Daylight Time' ) != -1;
};
/* returns a 3 character representation of the time zone. */
YAHOO.UP.util.Time.getTimeZone = function( dateObj )
{
	// DT is IE and Daylight Time is Firefox
	var timeZoneOffset = dateObj.getTimezoneOffset();
	var hoursOffset = Math.floor( timeZoneOffset / 60 );

	return YAHOO.UP.util.Time.getTimeZoneFromHourOffset( hoursOffset, YAHOO.UP.util.Time.isDaylightSavings( dateObj ) );
};
YAHOO.UP.util.Time.getTimeZoneFromHourOffset = function( hoursOffset, bIsDaylightSavings )
{
	var timeZoneString = '';

	if( hoursOffset == -3 && bIsDaylightSavings ) timeZoneString = 'ADT';
	//else if( hoursOffset == 3 ) timeZoneString = '';
	else if( hoursOffset == -4 && bIsDaylightSavings ) timeZoneString = 'EDT';
	else if( hoursOffset == -4 ) timeZoneString = 'AST';
	else if( hoursOffset == -5 && bIsDaylightSavings ) timeZoneString = 'CDT';
	else if( hoursOffset == -5 ) timeZoneString = 'EST';
	else if( hoursOffset == -6 && bIsDaylightSavings ) timeZoneString = 'MDT';
	else if( hoursOffset == -6 ) timeZoneString = 'CST';
	else if( hoursOffset == -7 && bIsDaylightSavings ) timeZoneString = 'PDT';
	else if( hoursOffset == -7 ) timeZoneString = 'MST';
	else if( hoursOffset == -8 && !bIsDaylightSavings ) timeZoneString = 'PST';

	return timeZoneString;
};
YAHOO.UP.util.Time.getLocalTimeZone = function()
{
	return YAHOO.UP.util.Time.getTimeZone( new Date() );
};
YAHOO.UP.util.Time.defaultTimeZone = function( formElement )
{
	if( formElement && formElement.value == '' ) formElement.value = YAHOO.UP.util.Time.getLocalTimeZone().substr( 0, 1 );
};
YAHOO.namespace( 'UP.util.Date' );
// standardized ISO8601 times with a time zone offset have already been localized.
// quasi ISO8601 times with a time zone offset are expressed in UTC and need to be localized manually.
YAHOO.namespace( 'UP.util.Date.ISO8601' );
YAHOO.UP.util.Date.ISO8601.getTimeZoneOffset = function( dateStr ) // in minutes
{
	var minutes = 0;
	if( dateStr.indexOf( '+' ) > -1 || dateStr.indexOf( '-' ) > dateStr.lastIndexOf( ':' ) ) {
		var hours = parseInt( YAHOO.UP.util.String.substrNegative( dateStr, -5, 2 ), 10 );
		minutes = parseInt( YAHOO.UP.util.String.substrNegative( dateStr, -2 ), 10 );
		minutes += hours*60;
		if( dateStr.indexOf( '-' ) > -1 ) minutes *= -1;
	}
	return minutes;
};
YAHOO.UP.util.Date.ISO8601.getDate = function( dateStr )
{
	var year 	= parseInt( dateStr.substr( 0, 4 ), 10 );
	var month 	= parseInt( dateStr.substr( 5, 2 ), 10 ) - 1;
	var day 	= parseInt( dateStr.substr( 8, 2 ), 10 );
	var hours 	= parseInt( dateStr.substr( 11, 2 ), 10 );
	var minutes = parseInt( dateStr.substr( 14, 2 ), 10 );
	return new Date( year, month, day, hours, minutes );
};
// this function is global to all iso8601 types, but is a highly visible function, so it was streamlined to the above, which is the only format we're getting anyway.
/* YAHOO.UP.util.Date.ISO8601.getDate = function( dateStr )
{
	var date = new Date();
	date.setFullYear( parseInt( dateStr.substr( 0, 4 ), 10 ) );
	if( dateStr.length >= 7 ) { // YYYY-MM
		date.setMonth( parseInt( dateStr.substr( 5, 2 ), 10 ) - 1 );
	}
	if( dateStr.length >= 10 ) { // YYYY-MM-DD
		date.setDate( parseInt( dateStr.substr( 8, 2 ), 10 ) );
	}
	if( dateStr.length >= 17 ) // YYYY-MM-DDThh:mmZ [+HH:MM,-HH:MM] 17 or 22
	{
		date.setHours( parseInt( dateStr.substr( 11, 2 ), 10 ) );
		date.setMinutes( parseInt( dateStr.substr( 14, 2 ), 10 ) );
	}
	if( dateStr.length == 20 || dateStr.length == 25 || dateStr.indexOf( '.' ) > -1 ) { // YYYY-MM-DDThh:mm:ssZ [+HH:MM,-HH:MM]
		date.setSeconds( parseInt( dateStr.substr( 17, 2 ), 10 ) );
	}
	if( dateStr.indexOf( '.' ) > -1 ) // YYYY-MM-DDThh:mm:ss.sZ [+HH:MM,-HH:MM], .s can be multiple digits
	{
		// these digits are the fraction of a second (ie: 0.2 seconds), not milliseconds by default
		var end;
		if( dateStr.indexOf( 'Z' ) > -1 ) end = dateStr.indexOf( 'Z' ) - 1;
		else if( dateStr.indexOf( '+' ) > -1 ) end = dateStr.indexOf( '+' ) - 1;
		else if( dateStr.indexOf( '-' ) > -1 ) end = dateStr.indexOf( '-' ) - 1;
		var fraction = parseFloat( '0' + dateStr.substring( dateStr.indexOf( '.' ), end ), 10 );
		date.setMilliseconds( fraction * 1000 );
	}

	// there is no setTimeZoneOffset so we'll just have to return a local time.
	return date;
}; */
YAHOO.UP.util.Date.ISO8601.normalizeQuasi = function( dateStr )
{
	var date = YAHOO.UP.util.Date.ISO8601.getDate( dateStr );
	var minutes = YAHOO.UP.util.Date.ISO8601.getTimeZoneOffset( dateStr );
	if( minutes != 0 ) {
		var newTime = date.getTime() + minutes*60*1000;
		date.setTime( newTime );
	}
	return date;
};
YAHOO.UP.util.Date.ISO8601.format = function( dateParam, formatStr )
{
	return YAHOO.UP.util.Date.format( YAHOO.UP.util.Date.ISO8601.normalizeQuasi( dateParam ), formatStr, YAHOO.UP.util.Date.ISO8601.getTimeZoneOffset( dateParam ) );
};

/*
	A: AM or PM
	a: am or pm
	D: day of the week abbreviation (3 letters)
	d: day of the month, with leading zeros
	j: day of the month, without leading zeros
	m: month, with leading zeros (one-based)
	M: month abbreviation (3 letters);
	Y: four digit year
	y: two digit year
	H: 24 hour based hour, with leading zeros
	h: 12 hour based hour, with leading zeros
	i: minutes, with leading zeros
	s: seconds, with leading zeros
	T: time zone abbreviation (3 letters)
	E: time zone abbreviation (1 letter)
*/
YAHOO.UP.util.Date.format = function( dateObj, formatStr, overrideOffset )
{
	var dayOfTheWeek = [ 'Sun','Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ];
	var month = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ];

	if( overrideOffset == null ) overrideOffset = -1 * dateObj.getTimezoneOffset(); // 0;
	if( formatStr.indexOf( 'd' ) > -1 ) formatStr = formatStr.replace( /d/g, ( dateObj.getDate() < 10 ? '0' : '' ) + dateObj.getDate() );
	else if( formatStr.indexOf( 'j' ) > -1 ) formatStr = formatStr.replace( /j/g, dateObj.getDate() );
	if( formatStr.indexOf( 'm' ) > -1 ) formatStr = formatStr.replace( /m/g, ( dateObj.getMonth() + 1 < 10 ? '0' : '' ) + ( dateObj.getMonth() + 1 ) );
	if( formatStr.indexOf( 'Y' ) > -1 ) formatStr = formatStr.replace( /Y/g, dateObj.getFullYear() );
	else if( formatStr.indexOf( 'y' ) > -1 ) formatStr = formatStr.replace( /y/g, YAHOO.UP.util.String.substrNegative( dateObj.getFullYear().toString(), -2 ) );
	if( formatStr.indexOf( 'H' ) > -1 ) formatStr = formatStr.replace( /H/g, ( dateObj.getHours() < 10 ? '0' : '' ) + dateObj.getHours() );
	else if( formatStr.indexOf( 'h' ) > -1 ) formatStr = formatStr.replace( /h/g, ( dateObj.getHours() % 12 < 10 ? '0' : '' ) + ( dateObj.getHours() % 12 ) );
	if( formatStr.indexOf( 'i' ) > -1 ) formatStr = formatStr.replace( /i/g, ( dateObj.getMinutes() < 10 ? '0' : '' ) + dateObj.getMinutes() );
	if( formatStr.indexOf( 's' ) > -1 ) formatStr = formatStr.replace( /s/g, ( dateObj.getSeconds() < 10 ? '0' : '' ) + dateObj.getSeconds() );

	// two pass for those that put letters in the result 
	var hasDay = formatStr.indexOf( 'D' ) > -1;
	var hasMonth = formatStr.indexOf( 'M' ) > -1;
	var hasZone = formatStr.indexOf( 'T' ) > -1;
	var hasZoneShort = formatStr.indexOf( 'E' ) > -1;
	var hasAMPM = formatStr.indexOf( 'A' ) > -1 || formatStr.indexOf( 'a' ) > -1;

	if( hasDay ) formatStr = formatStr.replace( /D/g, '__D__' );
	if( hasMonth ) formatStr = formatStr.replace( /M/g, '__M__' );
	if( hasZone ) formatStr = formatStr.replace( /T/g, '__T__' );
	else if( hasZoneShort ) formatStr = formatStr.replace( /E/g, '__E__' );
	if( hasAMPM )
	{
		formatStr = formatStr.replace( /a/g, '__a__' );
		formatStr = formatStr.replace( /A/g, '__A__' );
	}

	if( hasDay ) formatStr = formatStr.replace( /__D__/g, dayOfTheWeek[ dateObj.getDay() ] );
	if( hasMonth ) formatStr = formatStr.replace( /__M__/g, month[ dateObj.getMonth() ] );

	var timeZoneStr = YAHOO.UP.util.Time.getTimeZoneFromHourOffset( Math.floor( overrideOffset / 60 ), YAHOO.UP.util.Time.isDaylightSavings( dateObj ) );
	if( hasZone ) formatStr = formatStr.replace( /__T__/g, timeZoneStr );
	else if( hasZoneShort ) formatStr = formatStr.replace( /__E__/g, timeZoneStr.substr( 0, 1 ) );
	if( hasAMPM )
	{
		formatStr = formatStr.replace( /__a__/g, dateObj.getHours() >= 12 ? 'pm' : 'am' );
		formatStr = formatStr.replace( /__A__/g, dateObj.getHours() >= 12 ? 'PM' : 'AM' );
	}

	return formatStr;
};
YAHOO.UP.util.Date.padFormat = function( day, month, year )
{
	return ( month < 10 ? '0' + month : month ) + '/' + ( day < 10 ? '0' + day : day ) + '/' + year;
};
YAHOO.UP.util.Date.padShortFormat = function( dateObj )
{
	return YAHOO.UP.util.Date.padFormat( dateObj.getDate(), YAHOO.UP.util.Date.getMonth( dateObj.getMonth() + 1 ), dateObj.getFullYear() );
};
YAHOO.UP.util.Date.padLongFormat = function( dateObj )
{
	return YAHOO.UP.util.Date.getDayOfWeek( dateObj ) + ' ' + dateObj.getDate() + ' ' + YAHOO.UP.util.Date.getMonth( dateObj.getMonth() + 1 ) + ' ' + dateObj.getFullYear();
};
/* Returns full string representation of the month
 * Does not use the standard 0 based month from JavaScript,
 * the month index starts with 1.
 */
YAHOO.UP.util.Date.getMonth = function( /* int */month )
{
	return [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ][ month - 1 ];
};
YAHOO.UP.util.Date.getDayOfWeek = function( /* Date Object */dateObj )
{
	return [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ][ dateObj.getDay() ];
};
YAHOO.UP.util.Date.getDaysInMonth = function( /* four digit int */year, /* int */month )
{
	if( month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12 ) return 31;
	else if( month == 2 && year % 4 == 0 && ( year % 100 != 0 || year % 400 == 0 ) ) return 29;
	else if( month == 2 ) return 28;
	else return 30;
};
YAHOO.UP.util.Date.isDaylightSavingTime = function( /* Date Object */date )
{
	var firstSundayOfApril = new Date( date.getFullYear(), 3, 1 );
	if( firstSundayOfApril.getDay() > 0 ) firstSundayOfApril.setDate( 8 - firstSundayOfApril.getDay() );
	var lastSundayOfOctober = new Date( date.getFullYear(), 9, 31 );
	lastSundayOfOctober.setDate( 31 - lastSundayOfOctober.getDay() );
	var secondSundayOfMarch = new Date( date.getFullYear(), 2, 1 );
	if( secondSundayOfMarch.getDay() > 0 ) secondSundayOfMarch.setDate( 15 - secondSundayOfMarch.getDay() );

	if( date.getFullYear() <= 2006 && date.getTime() >= firstSundayOfApril.getTime() && date.getTime() < lastSundayOfOctober.getTime() ) {
		return true;
	} else if( date.getFullYear() >= 2007 && date.getTime() >= secondSundayOfMarch.getTime() && date.getTime() < lastSundayOfOctober.getTime() ) {
		return true;
	} else {
		return false;
	}
};
YAHOO.namespace( 'UP.util.Math' );
/* JavaScript will return a 00 on a 09 or a 08,
 * if you don't explicitly say to parse in base 10 */
YAHOO.UP.util.Math.parseInt = function( str )
{
	return parseInt( str, 10 );
};
YAHOO.UP.util.Math.isNumeric = function( str )
{
	return ( new RegExp( '^[0-9]{' + str.length + '}$' ) ).test( str );
};
/* Logical XOR in JavaScript with Variable number of Arguments 
*/
YAHOO.UP.util.Math.XOR = function()
{
	var b = false;
	for( var j = 0; j < arguments.length; j++ )
	{
		if( arguments[ j ] && !b ) b = true;
		else if( arguments[ j ] && b ) return false;
	}
	return b;
};

YAHOO.namespace( 'UP.util.keyboard' );
YAHOO.UP.util.keyboard.isDisplayKey = function( e )
{
	var code = YAHOO.util.Event.getCharCode( e );
	//if( code >= 112 && code <= 123 ) alert( e.charCode + ' ' + e.keyCode );
	return code >= 33 && code <= 34
		|| ( code == 35 && e.shiftKey ) // # [normally Home]
		|| ( code == 36 && e.shiftKey ) // $ [normally End]
		|| ( code == 37 && e.shiftKey ) // % [normally Left Arrow]
		|| code == 38
		|| ( code == 39 && e.shiftKey ) // ' [normally Right Arrow]
		|| ( code >= 40 && code <= 45 )
		|| ( code == 46 && e.shiftKey ) // . [normally Delete]
		|| ( code >= 47 && code <= 111 )
		|| ( code >= 112 && code <= 123 &&
				( e.charCode > 0 && e.keyCode == 0)  // [p-q{] when charCode > 0, [f1-f12] when charCode == 0 (Firefox)
				|| ( e.charCode == null && e.keyCode > 0 )// [f1-f12] don't even fire events in IE.
			)
		|| ( code >= 124 && code <= 126 )
		|| e.ctrlKey
		|| e.altKey
}
YAHOO.UP.util.keyboard.isUtilityKey = function( e )
{
	var code = YAHOO.util.Event.getCharCode( e );

	return code == 8 // backspace
		|| code == 46 // delete
		|| code == 13 // enter
		/* || ( code == 188 && !event.shiftKey ) */ // comma 
		|| code == 32 // space
		|| code == 9 // tab
		|| code == 37 
		|| code == 38
		|| code == 39
		|| code == 40 // arrow keys
		|| code == 27 // escape
		|| code == 35 // end
		|| code == 36; // home
}
YAHOO.namespace( 'UP.dataTable' ); // modifications to the yui datatable
YAHOO.UP.dataTable.append = function( dataTable, arrayData )
{
	var records = dataTable._oRecordSet.append( arrayData );
	dataTable.appendRows( records );
};
YAHOO.UP.dataTable.replace = function( dataTable, arrayData, bReset )
{
	if( bReset == null ) bReset = true;

	if( bReset ) dataTable._oRecordSet.reset();
	dataTable._oRecordSet.addRecords( arrayData );
	dataTable.populateTable();
};
YAHOO.namespace( 'UP.xml' );
YAHOO.UP.xml.get = function( query, node )
{
	return YAHOO.UP.xml.value( Ext.queryOne( query, node ) );
};
YAHOO.UP.xml.value = function( node )
{
	return node && node.childNodes.length > 0 ? node.firstChild.nodeValue : '';
};
// returns the index of the node wrt the parent's children
YAHOO.UP.xml.getNodeIndex = function( node )
{
	var firstChild = node.parentNode.firstChild;
	if( node == firstChild )
	{
		return 0;
	} else {
		var j = 1;
		while( node.previousSibling != firstChild && j < 100 )
		{
			node = node.previousSibling;
			j++;
		}
		return j;
	}
};
YAHOO.UP.xml.getFirstChildNode = function( root, nodeName )
{
	var query = Ext.query( nodeName, root );
	//if( YAHOO.lang.isFunction( root.getElementsByTagName ) && root.getElementsByTagName( nodeName ).length > 0 && root.getElementsByTagName( nodeName )[ 0 ].firstChild != null )
	if( query.length > 0 && query[ 0 ].firstChild != null )
	{
		return YAHOO.UP.xml.value( query[ 0 ] );
	} else {
		return '';
	}
};
YAHOO.UP.xml.mapNodes = function( nodes, nodeMappings, indexStart, indexLength )
{
	var indexEnd;
	if( indexStart == null )
	{
		indexStart = 0;
		indexEnd = nodes.length;
	} else if( indexLength != null ) {
		indexEnd = indexStart + indexLength;
	} else {
		indexEnd = nodes.length;
	}

	var finalArray = [];
	YAHOO.UP.util.each( nodes, function( j, node )
	{
		if( j >= indexStart && j < indexEnd )
		{
			var tempObject = {};
			YAHOO.UP.util.each( nodeMappings, function( targetNodeName, sourceNodeName )
			{
				if( sourceNodeName == '' )
				{
					tempObject[ targetNodeName ] = '';
				} else if( YAHOO.lang.isString( sourceNodeName ) ) {
					tempObject[ targetNodeName ] = YAHOO.UP.xml.getFirstChildNode( node, sourceNodeName );
				} else if( YAHOO.lang.isObject( sourceNodeName ) ) {
					if( YAHOO.lang.isFunction( sourceNodeName[ 'source' ] ) )
					{
						tempObject[ sourceNodeName[ 'target' ] ] = sourceNodeName[ 'source' ]( j, node );
					} else {
						tempObject[ sourceNodeName[ 'target' ] ] = YAHOO.UP.xml.getFirstChildNode( node, sourceNodeName[ 'source' ] );
					}
				} else {
					throw new Error( 'Invalid format passed into mapNodes.  Must be a key-value pair or an object.' );
				}
			} );
			finalArray.push( tempObject );
		} else if( j >= indexEnd ) {
			return finalArray;
		}
	} );
	return finalArray;
};

YAHOO.namespace( 'UP.util.Cookie' );
/* YAHOO.UP.util.Cookie = function( document, name, hours, path, domain, secure )
{
	if( (navigator.appName == 'Microsoft Internet Explorer') && (navigator.appVersion.indexOf( '2.' ) == 0) )
		return;
	else
	{
		this._document = document;
		this._name = name;
		this._expiration = hours ? new Date( (new Date()).getTime() + hours * 3600000 ) : null;
		this._path = path ? path : null;
		this._domain = domain ? domain : null;
		this._secure = secure ? true : false;
	}
};
YAHOO.UP.util.Cookie.prototype.set = function()
{
	var cookieVal = '';
	for( var prop in this )
	{
		if( prop.charAt(0) == '_' || ((typeof this[prop]) == 'function') )
			continue;
		if( cookieVal != '' )
			cookieVal += '&';
		cookieVal += prop + ':' + escape( this[prop].toString().replace(/^\s*|\s*$/g,"") );
	}
	var cookie = this._name + '=' + cookieVal;
	if( this._expiration )
		cookie += '; expires=' + this._expiration.toGMTString();
	if( this._path )
		cookie += '; path=' + this._path;
	if( this._domain )
		cookie += '; domain=' + this._domain;
	if( this._secure )
		cookie += '; secure';
	this._document.cookie = cookie;
}; */

YAHOO.UP.util.Cookie.get = function( name, _document )
{
	if( _document == null ) _document = document;
	var variables = {};	
	var allCookies = _document.cookie;
	if( allCookies == '' ) return '';
	var start = allCookies.indexOf( name + '=' );
	if( start == -1 ) return '';
	start += name.length + 1;
	var end = allCookies.indexOf( ';', start );
	if( end == -1 )	end = allCookies.length;
	return allCookies.substring( start, end );
};
YAHOO.namespace( 'UP.util.uri' );
YAHOO.UP.util.uri = new function()
{
	/* 	location is a string with get encoded parameters, can be
		window.location.search with the ? stripped or window.location.hash
		with the # stripped.
	 */
	this._getParameters = function( location )
	{
		var keyPairs = {};
		if( location != null && location != '' )
		{
			var params = location.split('&');
			for(var j = 0; j < params.length; j++)
			{
				if( params[ j ].indexOf( '=' ) > -1 )
				{
					var equalsAt 	= params[j].indexOf('=');
					var key 		= params[j].substring(0,equalsAt);
					var value		= params[j].substring(equalsAt + 1).replace(/^\s*|\s*$/g,"");
					keyPairs[ key ] =  value;
				} else {
					keyPairs[ params[ j ] ] = '';
				}
			}
		}
		return keyPairs;
	};

	this.currentGet = null;
	this.getGet = function()
	{
		if( !this.currentGet ) this.currentGet = this._getParameters( window.location.search.substring( 1 ) );
		return this.currentGet;
	};
	this.getGetValue = function( key )
	{
		return this.getGet()[ key ] ? this.getGet()[ key ] : '';
	};
	this.setGetValue = function( key, value )
	{
		if( !this.currentGet ) this.getGet();
		this.currentGet[ key ] = value;
	};
	this.removeGetValue = function( key )
	{
		if( !this.currentGet ) this.getGet();
		delete this.currentGet[ key ];
	};
	this.getGetString = function()
	{
		var str = '?';
		var params = this.getGet();
		for( var j in params )
		{
			if( str != '?' ) str += '&';
			str += j + '=' + params[ j ];
		}
		return str;
	};

	this.currentHash = null;
	this.getHash = function()
	{
		//if( !this.currentHash ) 
		this.currentHash = this._getParameters( window.location.hash.substring( 1 ) );
		return this.currentHash;
	};
	this.getHashValue = function( key )
	{
		return this.getHash()[ key ] && this.getHash()[ key ].length > 0 ? this.getHash()[ key ] : null;
	};
	this.setHashValue = function( key, value )
	{
		//if( !this.currentHash ) this.getHash();
		this.getHash();
		this.currentHash[ key ] = value;
		window.location.hash = this.getHashString();
	};
	this.removeHashValue = function( key )
	{
		// if( !this.currentHash ) this.getHash();
		this.getHash();
		delete this.currentHash[ key ];
		window.location.hash = this.getHashString();
	};
	this.getHashString = function()
	{
		var str = '#';
		var params = this.getHash();
		for( var j in params )
		{
			if( str != '#' ) str += '&';
			str += j + '=' + params[ j ];
		}
		return str;
	};

	this.getBaseUri = function()
	{
		var uri = window.location.href;
		if( uri.indexOf( '#' ) > -1 ) uri = uri.substr( 0, uri.indexOf( '#' ) );
		if( uri.indexOf( '?' ) > -1 ) uri = uri.substr( 0, uri.indexOf( '?' ) );
		return uri;
	};

	this.getCompleteUri = function()
	{
		return this.getBaseUri() + this.getGetString() + this.getHashString();
	};

	this.redirect = function()
	{
		window.location.href = this.getCompleteUri();
	};
};

YAHOO.namespace( 'YAHOO.UP.app' );
YAHOO.UP.app.isDebug = function()
{
	return YAHOO.UP.util.uri.getGetValue( 'debug' ) == 'true';
};
YAHOO.UP.app.displayErrorMessage = function( message, detail )
{
	var errorMessage = YAHOO.util.Dom.get( 'errorMessage' );
	YAHOO.UP.util.hide( Ext.query( 'div.result' ) );
	YAHOO.UP.util.show( errorMessage );
	var shortenedDetail = detail && detail.length > 200 ? detail.substr( 0, 200 ) + '...' : detail;
	YAHOO.UP.util.autoComplete( errorMessage, { 'errorMessage': message, 'detail': shortenedDetail } );
	YAHOO.UP.app.addLogMessage( message, detail );
};
YAHOO.UP.app.hideErrorMessage = function()
{
	YAHOO.UP.util.hide( Ext.query( 'div.result' ) );
};
YAHOO.UP.app.addLogMessage = function( message, detail )
{
	var messages = Ext.query( '#messages ol' );
	if( messages.length > 0 )
	{
		var messageDiv = document.createElement( 'li' );
		if( detail ) messageDiv.setAttribute( 'title', detail );
		messageDiv.appendChild( document.createTextNode( YAHOO.UP.util.Date.format(new Date(), 'H:i:s A ' ) + message ) );
		if( detail )
		{
			var clipboardLink = document.createElement( 'a' );
			clipboardLink.appendChild( document.createTextNode( 'Copy Full Error to Clipboard' ) );
			YAHOO.util.Dom.addClass( clipboardLink, 'clickable' );
			YAHOO.util.Dom.addClass( clipboardLink, 'link' );
			YAHOO.util.Event.addListener( clipboardLink, 'click', function( e ) {
				YAHOO.UP.app.copyToClipBoard( this.parentNode.getAttribute( 'title' ) );
			} );
			messageDiv.appendChild( clipboardLink );
		}
		messages[ 0 ].appendChild( messageDiv );
	}
};
YAHOO.UP.app.copyToClipBoard = function( message, successMessage )
{
	if( successMessage == null ) successMessage = 'Success.  You may now paste at your leisure.';
	if( window.clipboardData )
	{
		window.clipboardData.setData( "Text", message );
		alert( successMessage );
	} else {
		alert( 'Your browser does not support clipboard access.' );
		alert( message );
	}
};

YAHOO.namespace( 'YAHOO.UP.ajax' );
YAHOO.UP.ajax.quickSend = function( requestName, target, message, successCallback, contextElement )
{
	return YAHOO.UP.ajax.send( requestName, target, message, successCallback, null, null, contextElement );
};
YAHOO.UP.ajax.send = function( requestName, target, message, successCallback, failureCallback, overrideTimeout, contextElement, argument )
{
	if( YAHOO.UP.cache.has( 'ajax', requestName ) ) YAHOO.UP.ajax.abort( requestName, contextElement );

	var trgt;
	var msg;
	if( overrideTimeout == null ) overrideTimeout = 60000;
	else if( overrideTimeout < 1000 ) overrideTimeout = overrideTimeout * 1000;

	if( requestName == null || target == null || message == null )
		throw new Error( 'requestName, target, and message are all required when calling send()' );

	if( YAHOO.lang.isString( message ) )
		msg = message;
	else if( YAHOO.lang.isArray( message ) )
		msg = message.join( "\n" );
	else if( YAHOO.lang.isFunction( message ) )
		msg = message();

	if( YAHOO.lang.isString( target ) )
		trgt = target;
	else if( YAHOO.lang.isFunction( target ) )
		trgt = target();

	var callback = {
		success: function(o)
		{
			if( YAHOO.UP.app.isDebug() ) alert( o.responseText );
			if( o.argument != null && o.argument[ 'context' ] != null ) YAHOO.UP.util.hideLoading( o.argument[ 'context' ] );
			if( o.responseXML == null && o.responseText.indexOf( 'login.fcc' ) > -1 )
			{
				YAHOO.UP.app.displayErrorMessage( 'You are not authenticated to perform this action.  Please refresh the page to authenticate yourself.' );
				return;
			}
			var root = o.responseXML.documentElement; 
			if( root.getElementsByTagName( 'faultstring' ).length > 0 )
			{
				var faultstring = root.getElementsByTagName( 'faultstring' )[0].firstChild.nodeValue;
				var str = '';
				YAHOO.UP.util.each( root.getElementsByTagName( 'detail' )[0].childNodes, function( j, textNode )
				{
					if( textNode.nodeValue != null ) str += textNode.nodeValue;
				} );
				YAHOO.UP.app.displayErrorMessage( faultstring, str ); // root.getElementsByTagName( 'detail' )[0].firstChild.nodeValue
				if( YAHOO.lang.isFunction( failureCallback ) )
					failureCallback( o, o.argument );
			} else {
				YAHOO.UP.app.hideErrorMessage();
				YAHOO.UP.cache.addsub( 'ajax-response', requestName, root );
				if( YAHOO.lang.isFunction( successCallback ) )
					successCallback( o, o.argument );
			}
		}, 
		failure: function( o )
		{
			if( o.argument != null && o.argument[ 'context' ] != null ) YAHOO.UP.util.hideLoading( o.argument[ 'context' ] );
			YAHOO.UP.util.hide( Ext.query( 'div.result' ) );
			YAHOO.UP.util.show( YAHOO.util.Dom.get( 'sendFailureMessage' ) );
			YAHOO.UP.util.autoComplete( YAHOO.util.Dom.get( 'sendFailureMessage' ), { 'status': o.status, 'statusText': o.statusText } );
			if( YAHOO.lang.isFunction( failureCallback ) )
				failureCallback( o, o.argument );
		}
	};
	if( contextElement != null || argument != null )
	{
		callback[ 'argument' ] = {};
		if( contextElement != null ) callback[ 'argument' ][ 'context' ] = contextElement;
		if( argument != null ) callback[ 'argument' ][ 'argument' ] = argument;
	}

	if( contextElement != null ) YAHOO.UP.util.showLoading( contextElement, function( e )
	{
		YAHOO.UP.ajax.abort( requestName, contextElement );
		//failureCallback( null, argument );
	} );
	if( !YAHOO.UP.app.isDebug() ) callback[ 'timeout' ] = overrideTimeout;

	YAHOO.util.Connect._use_default_post_header = false;
	YAHOO.util.Connect.initHeader( 'Content-Type', 'text/xml', false );
	var ajaxCall = YAHOO.util.Connect.asyncRequest( 'POST', trgt, callback, msg ); 

	YAHOO.UP.cache.addsub( 'ajax', requestName, ajaxCall );
};
YAHOO.UP.ajax.abort = function( requestName, contextElement )
{
	var ajaxCall = YAHOO.UP.cache.get( 'ajax', requestName );
	if( YAHOO.util.Connect.isCallInProgress( ajaxCall ) )
	{
		if( contextElement != null ) YAHOO.UP.util.hideLoading( contextElement );
		YAHOO.UP.app.addLogMessage( 'The service call was aborted at your request. (' + requestName + ')' );
		YAHOO.util.Connect.abort( ajaxCall );
	}
};
