// Main JS file
// Kevin McGill | Elephant Head Productions | 25 June 2010

$(document).ready(function(){
	$(".carousel").jCarouselLite({
	    visible: 1,
		circular: true,
	    start: 0,
	    auto: 10000,
	    speed: 600,
	    btnGo: [
			".control .lc_1", 
			".control .lc_2", 
			".control .lc_3", 
			".control .lc_4" 
		],
		beforeStart: function(a) {
			var slide_id = $(a).attr("class");
			$(".control ." + slide_id).removeClass("current");
	    },
	    afterEnd: function(a) {
	        var slide_id = $(a).attr("class");
			$(".control ." + slide_id).addClass("current");
	    }
	});

	$('textarea.limited').maxlength({
		events: ['blur', 'focus'], // Array of events to be triggerd
		maxCharacters: 2500, // Characters limit
		status: true, // True to show status indicator bewlow the element
		statusClass: "status", // The class on the status div
		statusText: "more characters allowed", // The status text
		notificationClass: "notification",	// Will be added when maxlength is reached
		showAlert: false, // True to show a regular alert message
		alertText: "You have typed too many characters.", // Text in alert message
		slider: true // True Use counter slider
	});

	$('ul#year_tabs li a[class!=add]').click(function() {
		if (!($(this).hasClass('current'))) {
			var year_div = $(this).attr('href');
			year_div = year_div.replace('#', '');
			$("div[class*='year']").hide();
			$('ul#year_tabs li a').removeClass('current');
			$('div.' + year_div).fadeIn();
			$(this).addClass('current');
		};
		return false;
	});

	//On load 
	$('input:radio:checked[name*=attended_]').each(function() {
		var thisID = $(this).attr("id");

		if (thisID.indexOf("other") > 0) {
			$(this).parent().siblings(".uni").hide();
			$(this).parent().siblings(".other").show();
		} else if (thisID.indexOf("university") > 0) {
			$(this).parent().siblings(".other").hide();
			$(this).parent().siblings(".uni").show();
		}

	});
	
	$('input:radio[name*=attended_]').click(function() {
		var thisID = $(this).attr("id");

		if (thisID.indexOf("other") > 0) {
			$(this).parent().siblings(".uni").hide();
			$(this).parent().siblings(".other").show();
		} else if (thisID.indexOf("university") > 0) {
			$(this).parent().siblings(".other").hide();
			$(this).parent().siblings(".uni").show();
		}

	});

	$("a.openInstructions").click(function() {
		var toShow = $(this).attr("href");
		$(toShow).removeClass("hide");
		$(this).hide();
	});
});

