var site_url = root_uri = window.location.href;

if (root_uri.indexOf('.html')) {
  root_uri = root_uri.split('/');
  root_uri.pop();
  root_uri = root_uri.join('/') + '/';
}

var msie7 = $.browser.msie && $.browser.version == '7.0';
$(document).ready(function() {
	$('.fb-plugin').html('<iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fplatform&amp;width=220&amp;colorscheme=light&amp;show_faces=true&amp;stream=false&amp;header=false&amp;height=270" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:220px; height:270px;"></iframe>');
	$('.twitter-share-button').attr('data-count', 'horizontal').attr('data-via', 'SemanadaCriacao').attr('data-url', site_url).attr('data-text', '24ª Semana Internacional da Criação Publicitária #24semanacriacao');
	$(document).append('<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>');
	
	$('#timeline').twitterSearch({
        term:   'SemanadaCriacao',
        animOut: { opacity: 0 },
        avatar:  true,
        anchors: false,
        bird:    false,
        colorExterior: 'transparent',
        colorInterior: 'transparent',
        pause:   true,
        time:    false,
        timeout: 2000
	});

	$('.madrinhas h4 a').click(function () {
		pageTracker._trackEvent('links externos', $(this).parent().attr('class').replace('-', ' '));
		setTimeout('window.open("'+ $(this).attr('href') +'")', 100);
		return false;
	});

	$('.compre-ingresso a').click(function () {
		pageTracker._trackEvent('links externos', 'compre seu ingresso online');
		setTimeout('window.open("'+ $(this).attr('href') +'")', 100);
		return false;
	});

	$('.datadrome a').click(function () {
		pageTracker._trackEvent('links externos', 'datadrome');
		setTimeout('window.open("'+ $(this).attr('href') +'")', 100);
		return false;
	});
	
	$('.televendas-ingresso-rapido a, .televendas-editora a').click(function () {
		pageTracker._trackEvent('links externos', 'televendas');
		setTimeout('window.open("'+ $(this).attr('href') +'")', 100);
		return false;
	});

	$('.rede-social-twitter a, .follow').click(function () {
		pageTracker._trackEvent('redes sociais', 'twitter');
		setTimeout('window.open("'+ $(this).attr('href') +'")', 100);
		return false;
	});

	$('.twitterSearchUser a').live('click', function () {
		pageTracker._trackEvent('redes sociais', 'twitter streaming');
		setTimeout('window.open("'+ $(this).attr('href') +'")', 100);
		return false;
	});
});
