/* Author: ivant

*/

$(function(){
  
  // Bind an event to window.onhashchange that, when the hash changes, gets the
  // hash and adds the class "selected" to any matching nav link.
  $(window).hashchange( function(){
    var hash = location.hash;

    // Set the page title based on the hash.
    document.title = 'Studio Legale Imperiali | ' + ( hash.replace( /^#!\//, '' ) || '' ) + '.';
    
    // Iterate over all nav links, setting the "selected" class as-appropriate.
    $('#menu li a').each(function(){
      var that = $(this);
      that[ that.attr( 'href' ) === hash ? 'addClass' : 'removeClass' ]( 'selected' );
    });
    $('#main').empty();
    $('#backstretch').empty();
	if (!hash || hash == "#!/" || hash == "#!") {
	$('#enter').show();
	$('#menu').hide();
	$.backstretch("img/bg-intro.jpg");
	}
	if (hash == "#!/home") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-home.jpg");
	$.getJSON('./content/content.json', function(data) {
		var main = data.section['home'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/profilo") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['profilo'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/servizi") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-servizi.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['servizi'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/direzione") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-direzione.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['direzione'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/gruppo") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-gruppo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['gruppo'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/compliance") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-servizi.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['compliance'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/tutela-giudiziale") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-servizi.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['tutela-giudiziale'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/gestione-credito") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-servizi.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['gestione-credito'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/manutenzione") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-servizi.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['manutenzione'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/contatti") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-contatti.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['contatti'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/riccardo-imperiali") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['riccardo-imperiali'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/rosario-imperiali") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['rosario-imperiali'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/ania-distasio") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['ania-distasio'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/anna-dimezza") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['anna-dimezza'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/daniela-cirillo") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['daniela-cirillo'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/daria-langosco") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['daria-langosco'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/delio-quinzii") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['delio-quinzii'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/diego-cordua") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['diego-cordua'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/diego-fulco") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['diego-fulco'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/ernesto-ceci") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['ernesto-ceci'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/francesco-avola") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['francesco-avola'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/giovanni-spinelli") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['giovanni-spinelli'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/giulia-cafiero") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['giulia-cafiero'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/luca-bolognini") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['luca-bolognini'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/maurizio-ruschetta") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['maurizio-ruschetta'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/sandro-vacca") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['sandro-vacca'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/sergio-formichella") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['sergio-formichella'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/simonetta-gazerro") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['simonetta-gazerro'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/umberto-pandolfi") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['umberto-pandolfi'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/vincenzo-albano") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['vincenzo-albano'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/anna-irace") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['anna-irace'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
	if (hash == "#!/emma-farina") {
	$('#menu').show();
	$('#enter').hide();
	$.backstretch("img/bg-profilo.jpg");
	$.getJSON('content/content.json', function(data) {
		var main = data.section['emma-farina'];
		$('#main').append(main);		
	    $('#main').fadeIn('slow');
	});	
	}
  });
  
  // Since the event is only triggered when the hash changes, we need to trigger
  // the event now, to handle the hash the page may have loaded with.
  $(window).hashchange();
  
});
