function tabSwitch(active, number, tab_prefix, content_prefix) {
	for (var i=1; i < number+1; i++) {
	  $('#'+content_prefix+i).hide('fast');
	  $('#'+tab_prefix+i).removeClass('active');
	}
	$('#'+content_prefix+active).show('fast');
	$('#'+tab_prefix+active).addClass('active');
}

function enforceFullView(){
	if(window.location.href!=window.parent.location.href)
		window.parent.location.href=window.location.href;	
}

function getLatestContentForWord(number){
		tabSwitch(number,4,"tab_","content_");	
}

function getLatestContent(){
	var url=window.location.href;	
	
	if(url.indexOf("#why")>0){
		getLatestContentForWord(2);
	}
	
	if(url.indexOf("#who")>0){
		getLatestContentForWord(3);
	}
	
	if(url.indexOf("#where")>0){
		getLatestContentForWord(4);
	}
}
 
function getInternalLinks(){
	$('a[href^="#"]').click(function(){
		if($(this).attr('href')=='#what'){
			getLatestContentForWord(1);
		}
		
		if($(this).attr('href')=='#why'){
			getLatestContentForWord(2);
		}
		
		if($(this).attr('href')=='#who'){
			getLatestContentForWord(3);
		}
		
		if($(this).attr('href')=='#where'){
			getLatestContentForWord(4);
		}
								   
	});	
	
}

$(document).ready(function(){
	
	getInternalLinks();
	
	getLatestContent();
	
});