$(document).ready(function(){	
	/*
		Info
		
		Each Main Logo block within the image is 155px high
		Each Sub Logo block within the image is 119px high
	
	*/
	
	if ($.browser.msie&& $.browser.version.substr(0,1) < 8 ) 
	{
		$('#atass-hex .text, #atass-hex .link').hide();
		$('#atass-hex img.engaged').removeClass('engaged');
		
	}
	else {
		$engagedCompany = "atassGroup";
		$('#atass-hex .group[rel="'+$engagedCompany+'"]').fadeIn(); /* displays engaged companies subs + allows jqueries is(visible) to pick them up */
		
		startdescription = $('#atass-hex #data .'+$engagedCompany+' .description').html()
		$('#content-right-home').html(startdescription).show('fast');
	
		// MAIN LOGO HOVERS
		$('#atass-hex area.logo').mouseover(function(event){
			event.stopPropagation();
			
			// get data
			company = $(this).attr('rel');
			text = $('#atass-hex #data .'+company+' .text').html();
			link = $('#atass-hex #data .'+company+' .link').html();										 
			thedescription = $('#atass-hex #data .'+company+' .description').html();										 
			
			//console.log('logo hover - ' + company);
			
			$('#atass-hex img.logo, #atass-hex img.subLogo ').css({'z-index':5});
			$('#atass-hex img#'+company).css({'z-index':10});
			
			if ( $('#atass-hex #'+company).hasClass('engaged') )
			{
			}else{
				// style logo
				$('#atass-hex .logo.hover').removeClass('hover');
				$('#atass-hex #'+company+'.logo').addClass('hover');
				
				// text setup
				$('#atass-hex .text .base').hide().html('');
				$('#atass-hex .text .hover').hide().html('').html(text).fadeIn();
				
				// link setup
				$('#atass-hex .link .base').hide().html('');
				$('#atass-hex .link .hover').html('').html(link).show('fast');
				
				// description setup
				$('#content-right-home').html(thedescription).show('fast');
			}
			
		}).mouseout(function(){
			//console.log('mouseout logo')
			// makes sure last hovered item does not intefere with the new one
			company = $(this).attr('rel');
			$('#atass-hex img#'+company).css({'z-index':4});
		});
		
		
		// MAIN LOGO CLICKS
		$('#atass-hex area.logo').click(function(event){
			event.stopPropagation();									 
												 
			// get data
			$engagedCompany = $(this).attr('rel');
			text = $('#atass-hex #data .'+$engagedCompany+' .text').html();
			link = $('#atass-hex #data .'+$engagedCompany+' .link').html();
			thedescription = $('#atass-hex #data .'+$engagedCompany+' .description').html();
			
			// logo styling
			$('.logo').removeClass('engaged');		
			$('#'+$engagedCompany+'.logo').addClass('engaged');
			
			// text setup
			/*$('#atass-hex .text .hover').hide();*/
			$('#atass-hex .text .base').html(text).fadeIn();
			
			// link setup
			$('#atass-hex .link .base').html(link).show();
			
			// description setup
			$('#content-right-home').html(thedescription).show();
			
			// sub companies
			
			if ( $('#atass-hex .group[rel="'+$engagedCompany+'"]').is(":visible") == false )
			{
				$('#atass-hex .group').hide().children().removeClass('engaged'); /* remove any previous selected classes + fade */
			
				$('#atass-hex .group[rel="'+$engagedCompany+'"]').fadeIn();
			}else{
				// if we are selecting the same group then just remove the engaged classes so we dont flash
				$('#atass-hex .group .engaged').removeClass('engaged');
			}
			return false; 
		});
		
	
		
		// SUB LOGO HOVERS
		$('#atass-hex area.subLogo').mouseover(function(event){
			event.stopPropagation();
			//console.log('mouseover sub logo')
			
			// get data
			company = $(this).attr('rel');
			text = $('#atass-hex #data .'+company+' .text').html();
			link = $('#atass-hex #data .'+company+' .link').html();
			thedescription = $('#atass-hex #data .'+company+' .description').html();
			
			// this sorts out the corners of the squares messing things up
			$('#atass-hex img.logo, #atass-hex img.subLogo ').css({'z-index':5});
			$('#atass-hex img#'+company).css({'z-index':10});
			
			// style logo
			$('#atass-hex .subLogo.hover').removeClass('hover');
			$('#atass-hex #'+company+'.subLogo').addClass('hover');
			
			// text setup
			$('#atass-hex .text .base').hide().html('');
			$('#atass-hex .text .hover').hide().html('').html(text).fadeIn('fast');
			
			// link setup
			$('#atass-hex .link .base').hide().html('');
			$('#atass-hex .link .hover').html('').html(link).show();
			
			// description setup
			$('#content-right-home').html(thedescription).show('fast');
			
		}).mouseout(function(){	
			//console.log('mouseout sub logo')
			// makes sure last hovered item does not intefere with the new one
			$('#atass-hex img#'+company).css({'z-index':4});
		 });
		
		
		// SUB LOGO CLICKS
		$('#atass-hex area.subLogo').click(function(event){
			event.stopPropagation();
	
			// get data
			$engagedCompany = $(this).attr('rel');
			text = $('#atass-hex #data .'+$engagedCompany+' .text').html();
			link = $('#atass-hex #data .'+$engagedCompany+' .link').html();
			thedescription = $('#atass-hex #data .'+$engagedCompany+' .description').html();
			
			// logo styling
			$('#atass-hex .subLogo').removeClass('engaged');
			$('#atass-hex #'+$engagedCompany+'.subLogo').addClass('engaged');
			
			// text setup
			$('#atass-hex .text .base').hide().html(text).fadeIn('fast');
			
			// link setup
			$('#atass-hex .link .base').html(link).show();
			
			// description setup
			$('#content-right-home').html(thedescription).show();
			
			return false; 
		});
		$('#atass-hex area#main-logo-shape, #atass-hex img.logo, #atass-hex img.subLogo').mouseenter(function(event){	
			if ( $('#atass-hex .text .base').is(':hidden') == true )
			{
				// enagedCompany is set beforehand
				text = $('#atass-hex #data .'+$engagedCompany+' .text').html();
				link = $('#atass-hex #data .'+$engagedCompany+' .link').html();
				thedescription = $('#atass-hex #data .'+$engagedCompany+' .description').html();
			
				$('#atass-hex .subLogo, #atass-hex .logo').removeClass('hover');
				
				// text
				 $('#atass-hex .text .hover').html('').hide();
				 $('#atass-hex .text .base').html(text).hide().fadeIn('fast');
				
				// link 
				 $('#atass-hex .link .hover').html('').hide();
				 $('#atass-hex .link .base').html(link).show();		
				
				// description 
				$('#content-right-home').html(thedescription).show();
			}else {
				//console.log('outside no action');
			}
			
		});
	}
});
