// JavaScript Document
$(function(){

var lastclicked = ''
var that = this;
		$(window).load(function(){
	
	$("#sports-articles-icon-padding img:first").trigger("click");
	
	
	
	});	

	$.preload( 'img[@src*=-off]', {
				find:'-ImageOut',
			    replace:'-ImageSelect'
			});
			
	
	
	
	$("#sports-articles-images").find("img:not(:first)").hide();
	$("#sports-related-articles-block").find("div:not(:first)").hide();
	$("#sports-articles-icon-highlight").css({ "left": "14px" });
	$("#sports-articles-images-content").find("div:not(:first)").hide();
	
	
	
	$("#sports-articles-icon-padding img").click (function() {
        var iconindex =$("#sports-articles-icon-padding img").index(this);  
		if (that.lastclicked){
		that.lastclicked.src = that.lastclicked.src.replace('-ImageSelect','-ImageOut');
			this.src = this.src.replace('-ImageOver','-ImageSelect');
		
		
		move(this , iconindex);
		}
		else{
		this.src = this.src.replace('-ImageOut','-ImageSelect');	
		
		
		}
	
        
		that.lastclicked = this;
		});
		
		function move(el,icon){
	
		$("#sports-related-articles-block div").hide();
		$("#sports-related-articles-block div").eq(icon).show();
		$("#sports-articles-images img").hide();
		$("#sports-articles-images img").eq(icon).fadeIn(300);
		$("#sports-articles-images-content div").slideUp(200);
		$("#sports-articles-images-content div").eq(icon).slideDown(300);
		$("#sports-articles-icon-highlight").animate({ 
        left: el.offsetLeft
      }, 300 );
	  }


	
});
