function setSidebarFade( el, on )
{
	//el.style.backgroundColor = ( on ) ? '#F0F0F0' : 'transparent';
}

function popupexample( mylink, windowname, width, height )
{
	return popup1( mylink, windowname, width, height, 20, 20, 'no', 'no', 'yes', 'no', 'no', 'no' );
}

function popup( mylink, windowname, width, height )
{
	return popup1( mylink, windowname, width, height, 20, 20, 'no', 'no', 'yes', 'no', 'no', 'no' );
}

function popup1( mylink, windowname, width, height, top, left, resizeable, scrollbars, status, toolbar, menubar, location )
{
	var href;
	var sFeatures;

	if ( !window.focus) return true;

	if ( typeof( mylink ) == 'string' )
	{
		href=mylink;
	}
	else
	{
		href=mylink.href;
	}

	sFeatures = "width=" + width + 
			",height=" + height + 
			",top=" + top + 
			",left=" + left + 
			",resizeable=" + resizeable +
			",scrollbars=" + scrollbars + 
			",status=" + status + 
			",toolbar=" + toolbar + 
			",menubar=" + menubar + 
			",location=" + location;

	window.open( href, windowname, sFeatures );
	
	return false;
}

function createXMLHttp( url, callback )
{
	var ret = null;

	try
	{
		ret = new ActiveXObject( 'Msxml2.XMLHTTP' );
	}
	catch (e)
	{
		try
		{
			ret = new ActiveXObject( 'Microsoft.XMLHTTP' );
		}
		catch (e2)
		{
			ret = null;
		}
	}

	if ( ( ret == null ) && ( typeof( XMLHttpRequest ) != 'undefined' ) )
	{
		ret = new XMLHttpRequest();
	}

	if ( ret != null )
	{
		try
		{
			ret.open( 'GET', url, true );
	
			ret.onreadystatechange = callback;
		}
		catch ( e )
		{
			ret = null;
		}
	}

	return ret;
}

function sendXMLHttp( xmlhttp )
{
	if ( xmlhttp != null )
	{
		try
		{
			xmlhttp.send( null );

			return true;
		}
		catch ( e )
		{
		}
	}
	return false;
}

function getXMLChildText( node, ns, tag )
{
	var child;
	var i;

	if ( ( ns != null ) && ( typeof( node.getElementsByTagNameNS ) == 'function' ) )
	{
		child = node.getElementsByTagNameNS( ns, new String( tag ).split( ':' )[ 1 ] );
	}
	else
	{
		child = node.getElementsByTagName( tag );
	}

	if ( child.length > 0 )
	{
		for ( i = 0, child = child[ 0 ].childNodes; i < child.length; i++ )
		{
			if ( child[ i ].nodeType == 3 )
			{
				return child[ i ].nodeValue;
			}
		}
	}
	return '';
}

function formatDate( date )
{
	date = date.split( '-' );

	var day = parseInt( date[ 2 ], 10 );
	var month = parseInt( date[ 1 ], 10 );
	var year = parseInt( date[ 0 ], 10 );

	switch ( day )
	{
	case 1:
	case 21:
	case 31:	day = day + 'st'; break;
	case 2:	
	case 22:	day = day + 'nd'; break;
	case 3:	
	case 23:	day = day + 'rd'; break;
	default:	day = day + 'th'; break;
	}

	switch ( month )
	{
	case 1:	month = 'Jan'; break;
	case 2:	month = 'Feb'; break;
	case 3:	month = 'Mar'; break;
	case 4:	month = 'Apr'; break;
	case 5:	month = 'May'; break;
	case 6:	month = 'Jun'; break;
	case 7:	month = 'Jul'; break;
	case 8:	month = 'Aug'; break;
	case 9:	month = 'Sep'; break;
	case 10:	month = 'Oct'; break;
	case 11:	month = 'Nov'; break;
	case 12:	month = 'Dec'; break;
	}

	return day + ' ' + month + ' ' + year;
}

function setRssResults( xmlhttp, div, limit, showSubTitle )
{
	var items;
	var htm;
	var title;
	var text;
	var i, j;

	try
	{
		if ( xmlhttp.readyState == 4 )
		{
			htm = 'No news currently available.';

			if ( xmlhttp.status == 200 )
			{
				items = xmlhttp.responseXML.getElementsByTagName( 'item' );

				if ( items.length > 0 )
				{
					htm = '<ul>';

					for ( i = 0; ( i < items.length ) && ( i < limit ); i++ )
					{
						if ( showSubTitle ) {
							htm += '<li><a href="' + getXMLChildText( items[ i ], null, 'link' ) + '" target="_blank">' + getXMLChildText( items[ i ], null, 'title' ) + '</a><br/>' + getXMLChildText( items[ i ], null, 'description') + '</li>'; //'<br/>' + formatDate( new String( getXMLChildText( items[ i ], 'http://purl.org/dc/elements/1.1/', 'dc:date' ) ) ) + '</li>';
						} else {
							htm += '<li><a href="' + getXMLChildText( items[ i ], null, 'link' ) + '" target="_blank">' + getXMLChildText( items[ i ], null, 'title' ) + '</a><br/>' + formatDate( new String( getXMLChildText( items[ i ], 'http://purl.org/dc/elements/1.1/', 'dc:date' ) ) ) + '</li>';
						}
					}

					htm += '</ul>';
				}
			}
		
			div.innerHTML = htm;
		}
	}
	catch ( e )
	{
		window.alert( e );
	}
}
