
Event.observe( window, 'load', onload_news );

function onload_news()
{
	var aEls = $$('div.news-results-item div.headline a');
//alert( 'aEls: ' + aEls );
	for ( var i=0; i < aEls.length; i++ )
	{
		aEls[i].onclick = newswire_result_onclick;
	}

	$$('#news-results div.timeline-label').each(
		function(el)
		{
			el.onmouseover = timeline_onmouseover;
			el.onmouseout = timeline_onmouseout;
		});

	if ( $('newswire-timeline-icon') )
	{
		var hHook = { target: 'topRight', tip: 'topLeft' };
		new Tip( $('newswire-timeline-icon'), "h = hours<br/>d = days<br/>w = weeks<br/>m = months<br/>y = years", { title: "Timeline", hook: hHook } );
	}

	$$('#news-results div.news-results-item div.timeline-label').each(
		function(el)
		{
			var tiptext = el.up().getElementsByClassName('data-tip-text')[0].value;
//alert( 'tiptext = ' + tiptext );

			var hHook = { target: 'topRight', tip: 'topLeft' };
			new Tip( el, tiptext, { hook: hHook } );
		});


}

function timeline_onmouseover()
{
	this.addClassName( 'timeline-label-highlight' );
	var oInputs = this.getElementsByClassName('data-within');

	if ( oInputs.length == 0 )
		return;
//alert( 'within = ' + within );
	var within = $F(oInputs[0]);


	$$('#news-results div.timeline-'+within).each(
		function(el)
		{
			el.addClassName('highlight');
		});
}

function timeline_onmouseout()
{
	this.removeClassName( 'timeline-label-highlight' );
	var oInputs = this.getElementsByClassName('data-within');

	if ( oInputs.length == 0 )
		return;
//alert( 'within = ' + within );
	var within = $F(oInputs[0]);

	$$('#news-results div.timeline-'+within).each(
		function(el)
		{
//			el.style.backgroundColor = '#ffffff';
			el.removeClassName('highlight');
		});
}

function newswire_result_onclick()
{
	var QID = window.QID ? window.QID : 0;

	var args = 'url=' + this.href + '&qid=' + QID + '&t=n';
//alert( 'args = ' + args );
	send_request( '/click.php', args, cb_newswire_result_onclick );
}

function cb_newswire_result_onclick()
{
}


