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

function onload_home()
{
	/* START Newswire */
	$$('#home-latest-news div.timeline-label').each(
		function(el)
		{
			el.onmouseover = newswire_timeline_onmouseover;
			el.onmouseout = newswire_timeline_onmouseout;
		});


	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 } );

	$$('#home-latest-news 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 } );
		});

	var aEls = $$('div.news-results-item div.headline a');
	for ( var i=0; i < aEls.length; i++ )
	{
		aEls[i].onclick =
			function()
			{
				var QID = window.QID ? window.QID : 0;

				var args = 'url=' + this.href + '&qid=' + QID + '&t=n';
				send_request( '/click.php', args, function() {} );
			};
	}
	/* END Newswire */


	/* START Videowire */
	$$('#home-videowire div.timeline-label').each(
		function(el)
		{
			el.onmouseover = videowire_timeline_onmouseover;
			el.onmouseout = videowire_timeline_onmouseout;
		});


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

	$$('#home-videowire div.videowire-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 } );
		});

	var aEls = $$('div.videowire-results-item div.headline a', 'div.videowire-results-item div.thumb a');
	for ( var i=0; i < aEls.length; i++ )
	{
		aEls[i].onclick = videowire_result_onclick;
	}

/*
	$$('#home-videowire div.videowire-results-item div.thumb img').each(
		function(el)
		{
//			el.onmouseover = function() { this.width = 130; this.height = 97; this.style.position = 'absolute'; this.style.left = '-65px'; };

//alert( 'id = ' + el.id );
//			var hHook = { target: 'topRight', tip: 'topRight' };
//			new Tip( el.id, "h = hours<br/>d = days<br/>w = weeks<br/>m = months<br/>y = years", { title: "Timeline", hook: hHook } );

		} );
*/


	/* END Videowire */
}

function videowire_result_onclick()
{
	var args = 'url=' + this.href + '&qid=0&t=vw';
	send_request( '/click.php', args, function() {} );
}


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

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


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

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

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

	$$('#home-latest-news div.timeline-'+within).each(
		function(el)
		{
			el.removeClassName('highlight');
		});
}

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

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


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

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

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

	$$('#home-videowire div.timeline-'+within).each(
		function(el)
		{
			el.removeClassName('highlight');
		});
}


