// JavaScript Document
/**
* Preload and swap out images on roll-over in the news section on the home page
*/

$(document).ready(function(){
						   
	
	if($('#homeNewsLinks').length > 0){
		
		/**
		* Preload images
		*/
		var imgArr = new Array('news_img1.jpg',
								'news_img2.jpg',
								'news_img3.jpg');
		
		for (var x = 0; x < imgArr.length; x++) {
				
			//create image
			$("<img />").attr({
				id: 'preload'+x,
				src: 'images/news/thumb/'+imgArr[x]
			});

		}
		
		
		/**
		* Set initial link val
		*/
		//var tempHref = $('.highlighted a').attr('href');
		
	
	
		/**
		* Rollover function
		*/
		$('#homeNewsLinks li').each(function(index){
			$(this).find('a').mouseenter(function(){
				var SRC = 'images/news/thumb/'+imgArr[index];
				var theHref = $(this).attr('href');
				var theHtml = '<a href="'+theHref+'"><img src="'+SRC+'" alt="" /></a>';
				$('#homeNewsImage').html(theHtml);
				//
				$('.highlighted').removeClass('highlighted');
				$(this).parent().addClass('highlighted');
			});
		});
	
	}
	
});
