$(function() {
	$( 'ul.services a' ).click( function( e ) {
		e.preventDefault();
		
		var id = 'services-' + e.currentTarget.href.match( /\/([a-z0-9\-]+?)$/ )[1];
		
		if ( $( '#' + id + ' p.back' ).length < 1 ) {
			$( '#' + id ).append( "<p class=\"back\">Click <a href=\"/services\" tabindex=\"14\">here</a> to go back to the services page.</p>" );
			$( '#' + id + ' p.back' ).click( function( e ) { e.preventDefault(); if ( jQuery.browser.msie ) { $( 'div#services-text div:visible' ).hide(); $( '#services-default' ).show(); } else { $( 'div#services-text div:visible' ).fadeOut( 'fast', function() { $( '#services-default' ).fadeIn(); } ) } });
		}		
		
		if ( jQuery.browser.msie ) {
			$( 'div#services-text div:visible' ).hide();
			$( '#' + id ).show();		
		} else {
			$( 'div#services-text div:visible' ).fadeOut( 'fast', function() { $( '#' + id ).fadeIn(); } );		
		}
	});
	
	$( 'p.bio a' ).click( function( e ) {
		e.preventDefault();
		
		var id = 'about-' + e.currentTarget.href.match( /\/([a-z0-9\-]+?)$/ )[1];
		
		if ( $( '#' + id + ' p.back' ).length < 1 ) {
			$( '#' + id ).append( "<p class=\"back\">Click <a href=\"/about\" tabindex=\"11\">here</a> to go back to the about page.</p>" );
			$( '#' + id + ' p.back' ).click( function( e ) { e.preventDefault(); if ( jQuery.browser.msie ) { $( 'div#about-text div:visible' ).hide(); $( '#about-default' ).show(); } else { $( 'div#about-text div:visible' ).fadeOut( 'fast', function() { $( '#about-default' ).fadeIn(); } ) } });
		}		
		
		if ( jQuery.browser.msie ) {
			$( 'div#about-text div:visible' ).hide();
			$( '#' + id ).show();		
		} else {
			$( 'div#about-text div:visible' ).fadeOut( 'fast', function() { $( '#' + id ).fadeIn(); } );		
		}
	});
	
	$( 'a.email' ).each( function() {
		var i, sc, ix, email;
		email = '';

		switch( this.href.match( /\/([a-z0-9\-]+?)$/ )[1] ) {
			case 'info' :
				sc = 'k.saorltcv@niefy';
				ix = '<;>4:20?6<;=85=37<9=1;=7';
				break;
			case 'jobs' :
				sc = 'i@a.jvosctnrlkeby';
				ix = '46?717=@<0:>8;>2905>3:>9';
				break;
			case 'sebastian' :
				sc = 'kiylratcbevsn.@';
				ix = ';985;615<>;0231<9749561:9=<96';
				break;
			case 'istvan' :
				sc = '.yltinrsekcv@a';
				ix = '473;=5<7912458:68=34;80583';
				break;
			case 'erik' :
				sc = 'l.@iyvkrtnasec';
				ix = '<7362;64039<=7<:835<19<8';
				break;
			case 'liam' :
				sc = 'ti@ac.smklvenyr';
				ix = '9137268=91<;4>;301:;5<;0';
				break;
		}
		
		for( i = 0; i < ix.length; i++ ) {
			email += sc.charAt( ix.charCodeAt( i ) - 48 );
		}
		
		this.href = 'mailto:' + email;
		this.innerHTML = email;
	});
	
	$( 'p.showcase' ).scGallery();
});