// JavaScript Document

function applyToElements()
{
	$('.newsribbon_newsItem').mouseover(function()
						
	{
		var cItem = $(this).find('.popup');
		if(cItem.length > 0)
		{
			//cItem.show();
			$('#popup').html(cItem.html()).show();
		}
		$(this).mousemove();
	}).mousemove(function(e)
	{
		 var IE = document.all?true:false;

		var popup = $('#popup');
		if (IE) { // grab the x-y pos.s if browser is IE
		  tempX = event.clientX + document.body.scrollLeft;
		  tempY = event.clientY + document.documentElement.scrollTop;
		}
		else {  // grab the x-y pos.s if browser is NS
		  tempX = e.pageX;
		  tempY = e.pageY;
		} 
		var contentEdge = $("body").width() - (($("body").width()-$("#content").width())/2);
		if((tempX+popup.width()) > (contentEdge - 50)){
			popup.addClass("flip").css({'left':(tempX-266),'top':(tempY-(popup.height()-10))});
		} else {
			popup.removeClass("flip").css({'left':(tempX+20),'top':(tempY-(popup.height()-10))});
		}
	}).mouseout(function()
	{
		$('#popup').hide().empty();
	});
}

function applyToElementsClass(className)
{
	$('.' + className).mouseover(function()
						
	{
		var cItem = $(this).find('.popup');
		if(cItem.length > 0)
		{
			//cItem.show();
			$('#popup').html(cItem.html()).show();
		}
		$(this).mousemove();
	}).mousemove(function(e)
	{
		 var IE = document.all?true:false;

		var popup = $('#popup');
		if (IE) { // grab the x-y pos.s if browser is IE
		  tempX = event.clientX + document.body.scrollLeft;
		  tempY = event.clientY + document.documentElement.scrollTop;
		}
		else {  // grab the x-y pos.s if browser is NS
		  tempX = e.pageX;
		  tempY = e.pageY;
		} 
		var contentEdge = $("body").width() - (($("body").width()-$("#content").width())/2);
		if((tempX+popup.width()) > (contentEdge - 50)){
			popup.addClass("flip").css({'left':(tempX-266),'top':(tempY-(popup.height()-10))});
		} else {
			popup.removeClass("flip").css({'left':(tempX+20),'top':(tempY-(popup.height()-10))});
		}
	}).mouseout(function()
	{
		$('#popup').hide().empty();
	});
}
