/*******

	***	Link Fader by Cedric Dugas   ***
	*** Http://www.position-absolute.com ***
	Cutomized by Core Industries - http://core-industries.com/
	
*****/

$(document).ready(function() {
	hoverOpacity.init()
});

hoverOpacity = {
	init : function(){
		$('a.linkFader').css({
			position:"relative",
			backgroundPosition:"0px 0px",
			cursor:"pointer"
		}) 
		
		
		$('a.linkFader').each(function(){
			
			h = $(this).height();
			
			spanFader = document.createElement('span');
			myBG = $(this).css("background-image")
			
			$(this).append(spanFader);
		
			myBG = $(this).css("background-image")
			spanWidth =  $(this).css("width")
			spanHeight =  $(this).css("height")
				
			$(this).find("span").css({
				backgroundImage:myBG,
				backgroundPosition:"0px -"+h+"px",
				position:"absolute",
				display:"block",
				cursor:"pointer",
				top:"0px",
				left:"0px",
				width:spanWidth,
				height:spanHeight,
				opacity:0,
				visibility:"visible"
			})
		})
		
		
		$("a.linkFader").hover(function () {
			$(this).find("span").stop()
			$(this).find("span:not(:animated)").animate({opacity: 1}, 200)
		},
		function () {
			$(this).find("span").animate({opacity: 0},200)
		}); 
		
		
		
		$('p.linkFader_era').css({
			position:"relative",
			backgroundPosition:"0px 0px",
			cursor:"pointer"
		}) 
	

		
		$('p.linkFader_era').each(function(){
			
			spanFader = document.createElement('span');
			myBG = $(this).css("background-image")
			
			$(this).append(spanFader);
		
			myBG = $(this).css("background-image")
			spanWidth =  $(this).css("width")
			spanHeight =  $(this).css("height")
				
			$(this).find("span").css({
				backgroundImage:myBG,
				backgroundPosition:"0px -42px",
				position:"absolute",
				display:"block",
				cursor:"pointer",
				top:"0px",
				left:"0px",
				width:spanWidth,
				height:spanHeight,
				opacity:0,
				visibility:"visible"
			})
		});
		
		
		$(".single_era p.active").each(function(){
			$(this).find("span").stop()
			$(this).find("span:not(:animated)").animate({opacity: 1}, 10)
		});
		
		$("p.linkFader_era").hover(function () { 
			
			$(this).find("span").stop()
			$(this).find("span:not(:animated)").animate({opacity: 1}, 200)
		},
		function () { 
			
			if($(this).hasClass('active')){
				$(this).find("span").animate({opacity: 1},200)
			}else{
				$(this).find("span").animate({opacity: 0},200)
			}     
			
		});    
             

 

 
	$('#scrubber').mousemove(function (event){ 
			
			$(".single_era a").each(function(){ 
				$(this).find("span").stop()
				$(this).find("span:not(:animated)").animate({opacity: 0}, 100)
			});
			
			$(".single_era a.active").each(function(){
				$(this).find("span").stop()
				$(this).find("span:not(:animated)").animate({opacity: 1}, 10)
			});   
	}); 

		
		// custom for on versus hover states of theme navigation
		
		$("#theme_titles a.linkFader").click(function () {  
			 	
				$(this).addClass('on');
				$(this).removeClass('off');
				//$(this).removeClass('shaded'); 				
				//$(this).find("span").css({opacity: 0}); 
				$('a.on').find("span").css({backgroundPosition:"0px -62px"});					
				$('a.off').find("span").css({backgroundPosition:"0px -31px"}); 
				
		});
	}
}
