var mouseX,mouseY,blogto = new Array();

function showLargeBlogImg(src)
{
	var img = '<img src="'+src+'" />';
	$('#blog_limg').html(img).fadeIn();
}
function hideLargeBlogImg()
{
	$('#blog_limg').html('&nbsp;').fadeOut();
}

$(document).ready(function () {
	
	//Track mouse position
	$().mousemove(function(e)
	{ 
		mouseX = e.pageX;
		mouseY = e.pageY; 
	}); 

	//Headline slides
	if($('#headline_slides').length > 0) 
	{
		$("#header_menu").jFlow({
			slides: "#headline_slides",
			controller: ".header_menu_item",
			width: "900px",
			height: "310px",
			duration: 400,
			easing: "swing",
			prev: ".headline_prev",
			next: ".headline_next"
		});
		$('#headline_loading').fadeOut();
		$('#headline_slides').fadeIn('slow');
	}
	
	//Blog image popups
	$('.older_blogs').mouseover(function()
	{
		var img = '<img src="'+$(this).attr('name')+'" />';
		if($('#blog_img').html() != img)
		{
			clearTimeout(blogto);
			$('#blog_img').html(img).css('top',mouseY-75).fadeIn();	
		}
			
	});
	$('.older_blogs').mouseout(function()
	{
		blogto = setTimeout("$('#blog_img').html('&nbsp;').fadeOut();",750);	
			
	});
	
	//Blog large image popups
	$('.blog_limg').click(function()
	{
		var img = '<img src="'+$(this).attr('name')+'" />';
		$('#blog_limg').html(img).fadeIn();	
	});
	$('.blog_limg_hide').click(function()
	{
		$('#blog_limg').html('&nbsp;').fadeOut();	
	});
	
	//Home gallery
	var lastimg;
	$('img.home_gallery').mouseover(function()
	{
		lastimg = $(this).attr('src');
		var swap = $(this).attr('swap');
		$(this).attr('src',swap);
	})
	.mouseout(function()
	{
		$(this).attr('src',lastimg);
	});
});