(function($) {
	
	var
		imagePath = 'img/chartbox_new/';
	
	/*
	 * preload images
	 * done in header section of document
	 */
	$.imgpreload(['img/chartbox_new/splash1_07.gif',
	              'img/chartbox_new/splash1_10.gif',
	              'img/chartbox_new/splash1_11.gif',
	              'img/chartbox_new/splash1_12.gif',
	              'img/chartbox_new/splash1_15.gif',
	              'img/chartbox_new/splash1_16.gif',
	              'img/chartbox_new/splash1_08.jpg',
	              'img/chartbox_new/splash1_09.jpg',
	              'img/chartbox_new/splash1_13.jpg',
	              'img/chartbox_new/splash1_14.jpg',
	              'img/chartbox_new/splash1_19.jpg',
	              'img/chartbox_new/splash1_17.jpg'], {
	
		
	});
	
	
	
	var switchImages = function(img, highlight) {
		
		var
			filename,
			newFilename,
			imgNumberExtensionPair = [],
			boundImg;
		/*
		 * one we hover
		 */
		filename = img.src.split('/').pop();
		imgNumberExtensionPair = filename.split('_').pop().split('.');
		imgNumber = imgNumberExtensionPair[0];
		img.src = imagePath + (highlight ? 'splash1_' : 'splash_') + imgNumber + '.' + imgNumberExtensionPair[1];
		/*
		 * another one bound to this
		 */
		boundImg = $(img).attr('data-bound-elem');
		boundImg = $('#'+boundImg).get(0);
		filename = boundImg.src.split('/').pop();
		imgNumberExtensionPair = filename.split('_').pop().split('.');
		imgNumber = imgNumberExtensionPair[0];
		boundImg.src = imagePath + (highlight ? 'splash1_' : 'splash_') + imgNumber + '.' + imgNumberExtensionPair[1];
	};
	
	/*
	 * wait until DOM is loaded
	 */
	$(document).ready(function() {
		
		$('img.preloadable-image[data-bound-elem]').hover(function(e) {
			/*
			 * highlight images
			 */
			switchImages(this, true);
			
		}, function(e) {
			/*
			 * restore images
			 */
			switchImages(this, false);
		});
		
				
			
		$('#buttonLogo').hover(
			function()
			{
				$('#boxText').addClass('selected');
			},
			function()
			{
				$('#boxText').removeClass('selected');
			}
		);
	});
	
})(jQuery);

