//JQuery is special
$(document).ready(function(){


	////////////////////////////////////////////
	//		Client Hover Scripting		//
	////////////////////////////////////////////

	/* Generate thumbnails and throw them into dataset			*/
	var data_set = [
		
			
				
					"#clients1", "/images/made/uploads/client-logos/CollegeBoard-Logo_200_58_neg_gra_col-83-103-0-0_bri-50.png",
				
				
					"/images/made/uploads/client-logos/CollegeBoard-Logo_200_58_gra_col-94-120-13-0_bri--75.png",
				
			
		
			
				
					"#clients2", "/images/made/uploads/client-logos/tandem-training-logo_165_88_neg_gra_col-83-103-0-0_bri-50.png",
				
				
					"/images/made/uploads/client-logos/tandem-training-logo_165_88_gra_col-94-120-13-0_bri--75.png",
				
			
		
			
				
					"#clients3", "/images/made/uploads/client-logos/ViaIdentity-Logo_200_88_neg_gra_col-83-103-0-0_bri-50.png",
				
				
					"/images/made/uploads/client-logos/ViaIdentity-Logo_200_88_gra_col-94-120-13-0_bri--75.png",
				
			
		
		""
	];

	/* Split  data set into separate arrays					*/
	var i = 0;
	var next = 0;
	var image_ids = [];
	var first_image_urls = [];
	var second_image_urls = [];
	$.each( data_set, function(key, value){
		if (key == next && value != "")
		{
			image_ids[i] = value;
			second_image_urls[i] = data_set[key + 1];
			first_image_urls[i] = data_set[key + 2];
			next+=3;
			i++;
		}
	});

	/* Loop through each image and...						*/
	$.each( image_ids, function(key, value){
		//Style original div
		$(value).css("background","transparent url('" + first_image_urls[key] + "') center center no-repeat");

		//Style hover div
		$(value + "-hover").css("background","#859932 url('" + second_image_urls[key] + "') center center no-repeat").css('opacity','0').css('display','block');

		//Set up hover animation
		$(value + "-hover").hover(
			function () {
				$(this).stop().animate({
					opacity: 1
				}, {
					duration: 300, queue: true
				});
			},
			function () {
				$(this).stop().animate({
					opacity: 0
				}, {
					duration: 150, queue: true
				});
			}
		);
	});

	/* Preload hover images with Javascript						*/
	preLoadArrayOfImages(second_image_urls);

	////////////////////////////////////////////
	//		Work Section Hover		//
	////////////////////////////////////////////

	$.each(setupStandardHoverItems(".featurebox.work"), function(key, itemId){
		setHoverActions(itemId, 300, 150);
	});

	////////////////////////////////////////////
	//		Blog Section Hover		//
	////////////////////////////////////////////

	$.each(setupStandardHoverItems(".featurebox.blog"), function(key, itemId){
		setHoverActions(itemId, 300, 150);
	});

});

