/**
 * @author plarson
 */

 function toggleDiv(id) {
	var divOne = document.getElementById(id);
	if ( divOne.style.display != 'none' ) {
		divOne.style.display = 'none';
	}
	else {
		divOne.style.display = '';
	}
	return false;
} 

/**
 * Google Analytics Event Tracking
 * @author Ryan Christie
 */

function analyticsEventTrack(action, label){
	//console.log(action + ' ' + label );
	_gaq.push(['_trackEvent', 'Calendar', action, label]);
}

$(document).ready(function () {
	$('#mastNavContainer, #mastLogo').find('a').each(function () {
		$(this).click(function () {
			analyticsEventTrack('Mast Nav',$(this).text().trim()+'-'+this.href);
			setTimeout('document.location = "' + this.href + '"', 200);
			return false;
		});
	});
	
	$('#wrapSiteLink').find('a').each(function () {
		$(this).click(function () {
			analyticsEventTrack('Left Nav',$(this).text().trim()+'-'+this.href);
			setTimeout('document.location = "' + this.href + '"', 200);
			return false;
		});
	});
	
	var nextprevdate = $('#nextprevdate h1').text().trim();

	$('#columnText').find('a').each(function () {
		$(this).click(function () {
			analyticsEventTrack('Event List',$(this).text().trim()+'-'+nextprevdate);
			setTimeout('document.location = "' + this.href + '"', 200);
			return false;
		});
	});

	$('#wrapMediumBox').find('a').each(function () {
		$(this).click(function () {
			analyticsEventTrack('Links Right',$(this).text().trim()+'-'+nextprevdate);
			setTimeout('document.location = "' + this.href + '"', 200);
			return false;
		});
	});

	$('#nextViewPeriod').click(function () {
		analyticsEventTrack('Header Next',nextprevdate);
		setTimeout('document.location = "' + this.href + '"', 200);
		return false;
	});
	$('#prevViewPeriod').click(function () {
		analyticsEventTrack('Header Previous',nextprevdate);
		setTimeout('document.location = "' + this.href + '"', 200);
		return false;
	});
});

function analyticsOngoing() {
	var nextprevdate = $('#nextprevdate h1').text().trim();

	$('#ongoingeventsdiv').find('a').each(function () {
		console.log($(this).text().trim()+'-'+nextprevdate);
		$(this).click(function () {
			analyticsEventTrack('Ongoing',$(this).text().trim()+'-'+nextprevdate);
			setTimeout('document.location = "' + this.href + '"', 200);
			return false;
		});
	});

}


