').attr({id: 'dither'});
if(index == 0){
if(refer.indexOf('espn') == -1){
sharefile = teams[teams_sort[index]['team_id']].slug + '_s_1.html';
} else {
sharefile = teams[teams_sort[index]['team_id']].slug + '_e_1.html';
}
twtext = encodeURIComponent("I now support " + teams[teams_sort[index]['team_id']].handle + ". Find your #MLS Club now. " + teams[teams_sort[index]['team_id']].hashtag);
} else {
if(refer.indexOf('espn') == -1){
sharefile = teams[teams_sort[index]['team_id']].slug + '_s_2.html';
} else {
sharefile = teams[teams_sort[index]['team_id']].slug + '_e_2.html';
}
twtext = encodeURIComponent("Check out what it takes to be a " + teams[teams_sort[index]['team_id']].handle + " fan and find your #MLS Club! " + teams[teams_sort[index]['team_id']].hashtag);
}
$o = $('
').attr({id: 'shareoverlay'}).html('
close x
Share The Journey!
Now that you\'ve found a club to rep, help your friends find theirs.

Or
Download your personal player card and then share it on Facebook or Twitter.');
$('body').append($d).append($o);
$('#dither').fadeTo(500,0.8,function(){
$('#shareoverlay').fadeIn(500,function(){
$('#dither, #close').unbind('click').click(function(){
$('#shareoverlay').fadeOut(500,function(){
$('#dither').fadeOut(500,function(){
$('#dither').remove();
$('#shareoverlay').remove();
});
});
});
});
});
}
function appendCharacter(index){
$('#content').append('
');
//$('.character').width($('body').width());
}
function prependCharacter(index){
$('#content').append('
');
//$('.character').width($('body').width());
}
function updateInfo(index){
if(index != 0 && teams_sort[index]['percent'] == 100){
$('#result').html('
' + teams[teams_sort[index]['team_id']].name + '
Match Score:98%');
} else if(teams_sort[index]['percent'] == 100){
$('#result').html('
club Found!' + teams[teams_sort[index]['team_id']].name + '
Match Score:' + teams_sort[index]['percent'] + '%');
} else {
$('#result').html('
' + teams[teams_sort[index]['team_id']].name + '
Match Score:' + teams_sort[index]['percent'] + '%');
}
$('#logo').attr({src: "img/logo_" + teams_sort[index]['team_id'] + ".png"});
$('#description').html('

<Play Again
' + teams[teams_sort[index]['team_id']].character + '
' + teams[teams_sort[index]['team_id']].description + '
');
$('#links').html('
');
setTimeout("$('#result,#logo,#description,#links').fadeIn(200)",1);
setTimeout("$('#desctext').css({marginTop: Math.round((210 - $('#desctext').height()) / 2) + 'px'})",50);
$('#links #social a').each(function(){
if($(this).attr('href') == ''){
$(this).hide();
} else {
$(this).show();
}
});
$('#playagain').unbind('click').click(function(){
playAgain();
});
$('#sharetab').unbind('click').click(function(){
sharePop(index);
});
setTimeout('arrow_press = false;', 400);
}
function showBubble(){
$('#content').append('

');
setTimeout('$("#resultsbubble").remove();',5000);
$("#rightarrow").hover(function(){$('#content').append('

');},function(){$("#resultsbubble").remove();});
}
function showIntro(){
_gaq.push(['_trackPageview', '/instructions']);
_gaq.push([ '_trackEvent', 'Entry', 'Kick-Off', '' ]);
window.scrollTo(0, 0);
if(window.top != window.self){
parent.postMessage('100','*');
}
$('#content').html('
');
$(document).unbind('keydown').keydown(function(event){
if(event.keyCode == 13 || event.keyCode == 32){ //enter key_presses
finish_animation = true;
}
});
speechChar(0);
}
function speechChar(position){
if(position < speech.length && !finish_animation){
if(speech[position] == "\n"){
$('#bigspeech').append('
');
} else {
$('#bigspeech').append(speech[position]);
}
setTimeout('speechChar(' + (position + 1) + ');',40);
} else {
if(position < speech.length){
finish_animation = false;
app = speech.substr(position).replace(/\n/gi,"
");
$('#bigspeech').append(app);
}
$('#bigspeech').append('

');
$('#continue').click(function(){
showNextQuestion();
});
$(document).unbind('keydown').keydown(function(event){
if(event.keyCode == 65){
showNextQuestion();
}
});
}
}
function playAgain(){
_gaq.push([ '_trackEvent', 'Entry', 'Play Again Entry', '' ]);
window.location.reload();
}
function show20thTeam(){
_gaq.push([ '_trackEvent', 'Entry', 'Contra Code', '' ]);
window.scrollTo(0, 0);
if(window.top != window.self){
parent.postMessage('100','*');
}
$('#content').html('
');
$(document).unbind('keydown').keydown(function(event){
if(event.keyCode == 13 || event.keyCode == 32){ //enter key_presses
finish_animation = true;
}
});
cheatChar(0);
}
function cheatChar(position){
if(position < smallspeech.length && !finish_animation){
if(smallspeech[position] == "\n"){
$('#bigspeech').append('
');
} else {
$('#bigspeech').append(smallspeech[position]);
}
setTimeout('cheatChar(' + (position + 1) + ');',40);
} else {
if(position < speech.length){
finish_animation = false;
app = smallspeech.substr(position);
$('#bigspeech').append(app);
}
$('#bigspeech').append('

');
$('#continue').click(function(){
showCheatTeam();
});
$(document).unbind('keydown').keydown(function(event){
if(event.keyCode == 65){
showCheatTeam();
}
});
}
}
function showCheatTeam(){
final_html = '
Club Found!
NYC FC
';
final_html += '

';
final_html += '

<Play Again
Name: Unknown
A new army of supporters has risen. We stand together, a wall of fans, to usher in a new age of prosperity.
Expect us on your shores in 2015.
A new New York is coming.
';
final_html += '
';
$('#content').html(final_html);
$('#desctext').css({marginTop: Math.round((210 - $('#desctext').height()) / 2) + 'px'});
$('#playagain').unbind('click').click(function(){
playAgain();
});
$('#sharetab').unbind('click').click(function(){
$d = $('
').attr({id: 'dither'});
if(refer.indexOf('espn') == -1){
sharefile = '20_s_1.html';
} else {
sharefile = '20_e_1.html';
}
twtext = encodeURIComponent("I found the newest MLS team, NYC FC. Find out what MLS club you were born to support!");
$o = $('
').attr({id: 'shareoverlay'}).html('
close x
Share The Journey!
Now that you\'ve found a club to rep, help your friends find theirs.

Or
Download your personal player cardand then share it on Facebook or Twitter.');
$('body').append($d).append($o);
$('#dither').fadeTo(500,0.8,function(){
$('#shareoverlay').fadeIn(500,function(){
$('#dither, #close').unbind('click').click(function(){
$('#shareoverlay').fadeOut(500,function(){
$('#dither').fadeOut(500,function(){
$('#dither').remove();
$('#shareoverlay').remove();
});
});
});
});
});
});
}
function closePopovers(){
if($('#dither').length > 0){
$('#overlay, #shareoverlay').fadeOut(500,function(){
$('#dither').fadeOut(500,function(){
$('#dither').remove();
$('#overlay').remove();
$('#shareoverlay').remove();
});
});
}
}