	
	//Homepage Funtions
	$(document).ready(function() {

		//Image preloader
		function preload(arrayOfImages) {
			$(arrayOfImages).each(function(){
				$('<img/>')[0].src = this;
				// Alternatively you could use:
				// (new Image()).src = this;
			});
		}
		
		// Usage:
		var img1 = $("#feat-element1").attr('url');
		var img2 = $("#feat-element2").attr('url');
		var img3 = $("#feat-element3").attr('url');
		var img4 = $("#feat-element4").attr('url');
		var img5 = $("#feat-element5").attr('url');
		var img6 = $("#feat-element6").attr('url');
		preload([
			img1,
			img2,
			img3,
			img4,
			img5,
			img6
		]);

		
		//Set Default Image
		var defimg = $("#feat-element1").attr('url');
		$("#feat-transimg").html('<img src="'+defimg+'" />');

		//Initial Element Pop up
		  setTimeout(function(){
			  $('#feat-element1').css('zIndex','99').animate({
				  height: '200px', 
				  marginTop: '240px', 
				  borderTopColor: 'white', 
				  borderRightColor: 'white', 
				  borderLeftColor: 'white', 
				  borderBottomColor: 'white'
			  },800);
			  $("#feat-element1 #feat-thb_prev #feat-prevwind").css('display','block');
			},1000);

		  setTimeout(function(){
			  $('#feat-element1').css('zIndex','99').animate({
				  height: '80px', 
				  marginTop: '300px', 
				  borderTopColor: 'black', 
				  borderRightColor: 'black', 
				  borderLeftColor: 'black', 
				  borderBottomColor: 'black'
			  },800);
			  $("#feat-element1 #feat-thb_prev #feat-prevwind").css('display','none');
			},3000);

		
		//Element Hover Function		
		$('[id^="feat-element"]').hover(function() {
			var urls = $(this).attr('url');
			var txt = $(this).attr('text');
			var lbl = $(this).attr('label');
			var curst = $(this);
			
			
			$("#feat-box2").html(lbl);
			$("#feat-box2").stop().css('zIndex','9').animate({ opacity: "1" }, 1000);
			$("#feat-box1").html(txt);
			$("#feat-box1").stop().css('zIndex','9').animate({ opacity: "1", marginTop: "110px" }, 1000);
			$(this).css('zIndex','99').animate( { height: '200px', marginTop: '240px', borderTopColor: 'white', borderRightColor: 'white', borderLeftColor: 'white', borderBottomColor: 'white' }, 800);
			$("#feat-transimg").html('<img src="'+urls+'" />');
			$("#feat-transimg").stop().css('zIndex','-1').animate({ opacity: "1" }, 1000);
			$("#feat-transimg2").stop().css('zIndex','-2').animate({ opacity: "0" }, 1000);
			$("#" + this.id + " #feat-thb_prev #feat-prevwind").css('display','block');
			


		},function(){
			var defimg = $("#feat-element1").attr('url');
		    $("#feat-box2").stop().css('zIndex','9').animate({ opacity: "0" }, 500);
		    $("#feat-box1").stop().css('zIndex','9').animate({ opacity: "0", marginTop: "500px" }, 500);
			$("#feat-transimg").stop().css('zIndex','-1').animate({ opacity: "0" }, 500);
			$("#feat-transimg2").html('<img src="'+defimg+'" />');
			$("#feat-transimg2").stop().css('zIndex','-2').animate({ opacity: "1" }, 500);
			$(this).css('zIndex','99').animate( { height: '80px', marginTop: '300px', borderTopColor: 'black', borderRightColor: 'black', borderLeftColor: 'black', borderBottomColor: 'black'}, 500);
			$(this).css('border-color','black');
			$("#" + this.id + " #feat-thb_prev #feat-prevwind").css('display','none');
			
			
		});

		// DIrectional scrolls
		
		//Hide initial elements
		$("#feat-element5").stop().css('display','none');
		$("#feat-element6").stop().css('display','none');
		
		$("#feat-leftarrow2").click(function() {
			
			$("#feat-element1").stop().css('display','block');
			$("#feat-element5").stop().css('display','none');
			$("#feat-element6").stop().css('display','none');
			$("#feat-leftarrow").stop().css('display','block');
			$("#feat-leftarrow2").stop().css('display','none');
			$("#feat-rightarrow").stop().css('display','block');
			$("#feat-rightarrow2").stop().css('display','none');
			$("#feat-rightarrow3").stop().css('display','none');
			
		});

		$("#feat-leftarrow3").click(function() {
			
			$("#feat-element2").stop().css('display','block');
			$("#feat-element5").stop().css('display','block');
			$("#feat-element6").stop().css('display','none');
			$("#feat-leftarrow").stop().css('display','none');
			$("#feat-leftarrow3").stop().css('display','none');
			$("#feat-leftarrow2").stop().css('display','block');
			$("#feat-rightarrow").stop().css('display','none');
			$("#feat-rightarrow2").stop().css('display','block');
			$("#feat-rightarrow3").stop().css('display','none');
			
		});

		
		$("#feat-rightarrow").click(function() {
			
			$("#feat-element1").stop().css('display','none');
			$("#feat-element5").stop().css('display','block');
			$("#feat-element6").stop().css('display','none');
			$("#feat-rightarrow").stop().css('display','none');
			$("#feat-rightarrow2").stop().css('display','block');
			$("#feat-rightarrow3").stop().css('display','none');
			$("#feat-leftarrow").stop().css('display','none');
			$("#feat-leftarrow2").stop().css('display','block');
			$("#feat-leftarrow3").stop().css('display','none');
			
		});


		$("#feat-rightarrow2").click(function() {
			
			$("#feat-element1").stop().css('display','none');
			$("#feat-element2").stop().css('display','none');
			$("#feat-element5").stop().css('display','block');
			$("#feat-element6").stop().css('display','block');
			$("#feat-rightarrow").stop().css('display','none');
			$("#feat-rightarrow2").stop().css('display','none');
			$("#feat-rightarrow3").stop().css('display','block');
			$("#feat-leftarrow").stop().css('display','none');
			$("#feat-leftarrow3").stop().css('display','block');
			$("#feat-leftarrow2").stop().css('display','none');
			
		});



	});
