/* Sitewide - Open External Links in a New Window */
function initExternalLinks() {
	$('a[rel="external"]').click( function() {
	        window.open( $(this).attr('href') );
	        return false;
    });
}

/* Homepage Brand Connector Cycle */
function initHomeBcCycle() {
	var timeoutCallback = function() {return Math.floor(1000 + Math.random()*10000)}  // randomize timeout
	$('#homeBCs ul li a').cycle({
		fx: 'fade',
		timeoutFn: timeoutCallback
	});
}

/* What We Do Content Cycle */
function initWhatWeDoCycle() {
	$('#contentSlider').cycle({
		fx: 'fade',
		timeout: 10000,
		speed: 1000,
		prev: '#prev a',
		next: '#next a'
	});
    $('#play a').click(function () {
        $(this).addClass('on').parent('li').siblings('li').children('a.on').removeClass('on');
		$('#contentSlider').cycle('resume');
    });
    $('#pause a').toggle(function () {
        $(this).addClass('on').parent('li').siblings('li').children('a.on').removeClass('on');
		$('#contentSlider').cycle('pause');
		}, function () {
        $(this).removeClass('on');
		$('#contentSlider').cycle('resume');
    });
}

/* Document Ready */
$(document).ready(function(){

	initExternalLinks();
	initHomeBcCycle();
	initWhatWeDoCycle();
	
	/* Cufon for Agenda */
	Cufon.replace('h2', { fontFamily: 'Agenda', color: '#fff' });
	Cufon.replace('h3, #connectivePg p.agenda', { fontFamily: 'Agenda', color: '#d51b38' });
	Cufon.replace('#contactPg p.agenda, #contentSlider p', { fontFamily: 'Agenda', color: '#555453' });
	Cufon.replace('#contentSlider p span', { fontFamily: 'Agenda', color: '#0095d7' });

});
