// link glow

var e, currentSelection;

function fadeIn(index) {

	$(e).each(function(index) {
		if ($(this).attr('class') !== currentSelection) {
			$(this).delay(index * 300).fadeTo(600, 0.600);
		}
	});

	setTimeout('fadeOut()', 1200);
}

function fadeOut(index) {

	$(e).each(function(index) {
		if ($(this).attr('class') !== currentSelection) {
			$(this).delay(index * 300).fadeTo(600, 0.001);
		}
	});
	
	setTimeout('fadeIn()', 1200);
}

// email

var email = Base64.decode('Y2hyaXNAY2hyaXN3aGFsZW4uY2E=');

function printMail() {
	document.write('<a href="mailto:'+ email +'">'+ email +'</a>');
}

// tabs

function tabMain() {
	window.location.hash = '';
}

function tabPortfolio() {
	window.location.hash = '#portfolio';
}

function tabStandards() {
	window.location.hash = '#standards';
}

function tabContact() {
	window.location.hash = '#contact';
}

$(function() {
	$('div#contentStandards').css('visibility', 'visible');
	$('div#contentContact').css('visibility', 'visible');
	$('#content').tabs({fx: { opacity: 'toggle', speed: 'slow' } });

	e = $('.bgGlow');
	
	$(e).each(function(index) {
		$(this).css('visibility', 'visible').fadeTo(0, 0.001);
		$(this).hover( function() { $(this).clearQueue().stop().fadeTo(200, 0.999); currentSelection = $(this).attr('class'); },
					   function() { currentSelection = 0; $(this).clearQueue().stop().fadeTo(200, 0.001); }
					 );
	});
	
	$(window).bind( 'hashchange', function() {
		switch(window.location.hash) {
			case '#portfolio': $("#tabPortfolio").click(); break;
			case '#standards': $("#tabStandards").click(); break;
			case '#contact': $("#tabContact").click(); break;
			default: $("#tabMain").click(); break;;
		}		
	});
	
	$(window).trigger( 'hashchange' );
	
	fadeOut();
});
