

$(document).ready(function() {
	hoverOpacity.init(); 
	
	revealDiv.init("a#arihest", "div#arihest_div");
	revealDiv.init("a#G_love", "div#G_love_div");
	revealDiv.init("a#arihest", "div#ari_h_div"); 
	revealDiv.init("a#katie_H", "div#katie_H_div");
	revealDiv.init("a#aidan_h", "div#aidan_h_div");
	revealDiv.init("a#rosie_t", "div#rosie_t_div");
	revealDiv.init("a#sambatekes", "div#sambatekes_div");
	revealDiv.init("a#garett_b", "div#garett_b_div");
	revealDiv.init("a#winterpills", "div#winterpills_div");
	revealDiv.init("a#brandi_c", "div#brandi_c_div");
	revealDiv.init("a#alternate_routes", "div#alternate_routes_div");
	revealDiv.init("a#slow_runner", "div#slow_runner_div");
	revealDiv.init("a#submarines", "div#submarines_div");
	revealDiv.init("a#madi_diaz", "div#madi_diaz_div");
    revealDiv.init("a#alexa_w", "div#alexa_w_div");
    revealDiv.init("a#amber_r", "div#amber_r_div");
    revealDiv.init("a#chris_v", "div#chris_v_div");
    revealDiv.init("a#mason_j", "div#mason_j_div");
    revealDiv.init("a#david_m", "div#david_m_div");        
    revealDiv.init("a#william_f", "div#william_f_div");        
    revealDiv.init("a#megan_s", "div#megan_s_div");  
    revealDiv.init("a#kaiser_c", "div#kaiser_c_div");  
    revealDiv.init("a#josh_r", "div#josh_r_div");  
    revealDiv.init("a#jack_j", "div#jack_j_div");  
    revealDiv.init("a#paula_f", "div#paula_f_div");  
    revealDiv.init("a#grace_p", "div#grace_p_div");   
    revealDiv.init("a#erica_w", "div#erica_w_div");   
    revealDiv.init("a#angelique_k", "div#angelique_k_div");  
    revealDiv.init("a#josh_rouse", "div#josh_rouse_div");   
    revealDiv.init("a#jackson_b", "div#jackson_b_div");   
    revealDiv.init("a#paper_r", "div#paper_r_div");   
    revealDiv.init("a#mojave", "div#mojave_div");   
    revealDiv.init("a#alo", "div#alo_div");   
    revealDiv.init("a#keegan", "div#keegan_div");   
    revealDiv.init("a#spring_s", "div#spring_s_div");   
    revealDiv.init("a#dw_brandt", "div#dw_brandt_div");   
    revealDiv.init("a#birdmonster", "div#birdmonster_div");   
    revealDiv.init("a#mark_e", "div#mark_e_div");   
    revealDiv.init("a#lori_m", "div#lori_m_div");   
    revealDiv.init("a#joseph_a", "div#joseph_a_div");   
    revealDiv.init("a#ks_rhoads", "div#ks_rhoads_div");   
    revealDiv.init("a#greg_c", "div#greg_c_div"); 
    revealDiv.init("a#mikel_r", "div#mikel_r_div"); 
    revealDiv.init("a#sons_of_william", "div#sons_of_william_div");      

     
});

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

hoverOpacity = {
	init : function(){
		$('a.linkFader').css({
			position:"absolute",
			backgroundPosition:"0px 0px",
			cursor:"pointer"
		}) 
		

		$('a.linkFader').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:"bottom right",
				position:"absolute",
				display:"block",
				cursor:"pointer",
				top:"0px",
				left:"0px",
				width:spanWidth,
				height:spanHeight,
				opacity:0,
				visibility:"visible"
			})
		}) 
		
		$("a.linkFader").mouseover(function(){
			$(this).find("span").stop()
			$(this).find("span:not(:animated)").animate({opacity: 1}, 300);
	    }).mouseout(function(){
			if ($(this).is(".active") || $(this).is(".on") ){ 
				
			}  
   
		 	else{  
				$(this).find("span").animate({opacity: 0},250);
			}
	    });
	     
		  
		$("a.linkFader").click(function () {  
			
			
			 // find any links with class active and remove
				$("div#artists_body").find("a.active").each( function(){  
					$(this).removeClass('active'); 
					$(this).addClass('shaded');
					$("a.shaded").find("span").animate({opacity: 0},250);					
					}); 
					
				
				
				$(this).addClass('active');
				$(this).removeClass('shaded'); 				
				 
				$(this).find("span").css({opacity: 1});
				
		}) 
		
		//custom function for nav items 
		
		$('a.on').css({
			position:"absolute",
			backgroundPosition:"0px 0px",
			cursor:"pointer"	  
		   })
		
		$('a.on').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:"bottom right",
				position:"absolute",
				display:"block",
				cursor:"pointer",
				top:"0px",
				left:"0px",
				width:spanWidth,
				height:spanHeight,
				opacity:1,
				visibility:"visible"
			})
		}) 
		

	}
}       

/*******    
// Reveal Div - Core Industries - core-industries.com  
*******/     

revealDiv = {   
	
	//pass the link and div variables
	init : function(link, div){   
		
		//if hovering over the artist name container div, fade out instructional text. 
		$("div#artist_map").mouseover(
			function(){      
				
			   	$("div#to_learn_more").fadeOut('fast');
			 
			},
			 	function () { 
				          
						 //if an artist div is selected, dont fade in instructional text on hover out
						 if ( $("div").hasClass('active') ) {

							}
							
							else{  
								
					   			$("div#to_learn_more").fadeIn('fast');   
							}  
							
						}
		); 
		
		
				//hover in
				function fadeInDiv() {   

					//if there is already an active div, dont do anything on hover
					if ( $("div").hasClass('active') ) {

					}  

					//if there is no active div fade in div
					else{ 
						// 	$(this).find("span:not(:animated)").animate({opacity: 1}, 300)
						$(div).fadeIn('fast');


				   }

				}

				//hover out
				function fadeOutDiv() {  


					//if the image is clicked don't do anything one hover out
					if ( $("div").hasClass('active')) {

					} 

					// if the image is not clicked, fade out on hover out
					else {

						$(div).fadeOut('fast');

					}


				}

			var config = {    
			     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
			     interval: 200, // number = milliseconds for onMouseOver polling interval    
			     over: fadeInDiv, // function = onMouseOver callback (REQUIRED)    
			     timeout: 500, // number = milliseconds delay before onMouseOut    
			     out: fadeOutDiv // function = onMouseOut callback (REQUIRED)    
			};     


		     $(link).hoverIntent(config)
		
   		
		 //if image is clicked, give it the class active
		$(link).click(
			function () { 
				
	 			if ( $("div").hasClass('active') ) { 
		            
					// in the container div, fina any divs with class active and remove and add class hidden (this will display none)
					$("div#artists_body").find("div.active").each( function(){  
						$(this).fadeOut('slow');
						$(this).removeClass('active'); 
						$(this).addClass('hidden'); 
						}); 
				 

					$(div).addClass('active');
					$(div).removeClass('hidden');
					$(div).fadeIn('slow');  
					
				   
					}   
					
				   	else{
						$(div).addClass('active');
						// $(link).addClass('active');
					}

			}

		 );      
		
	  
		
		
		   

	}    // init
}    // revealDiv