function showNav(mainSection, subSection, thirdSection){
	var mainSectionInitCaps = (mainSection.substring(0,1)).toUpperCase() + mainSection.substring(1, mainSection.length);
	$('div#navigation li#nav' + mainSectionInitCaps + ' ul[class!=third]').show();
	if (subSection){
		if (thirdSection == null){
			$('div#navigation li.' + subSection).addClass('on');
		}
		$('div#navigation li.' + subSection).children('ul').show();
	}
	else{
		$('div#navigation ul li#nav' + mainSectionInitCaps).addClass('on');
	}
	
	if (thirdSection){
		$('div#navigation li.' + thirdSection).addClass('on');
	}
}

function subsectionNav(){
	$('div.contentSection h4 a').click(function(){
		if ($(this).parent('h4').siblings('div.contentSectionText').css('display') == 'none'){
			$(this).addClass('on');
			$(this).parent('h4').siblings('div.contentSectionText').slideDown('fast');
		}
		else{
			$(this).removeClass('on');
			$(this).parent('h4').siblings('div.contentSectionText').slideUp('fast');
		}
		return false;
	});
	
	$('p.showAll a').toggle(
		function(){
			$('div.contentSectionText').slideDown('fast');
			$('div.contentSection h4 a').addClass('on');
			$(this).html('Hide All Sections');
			//$('div.contentSection h4 a').trigger('click');
		},
		function(){
			$('div.contentSectionText').slideUp('fast');
			$('div.contentSection h4 a').removeClass('on');
			$(this).html('Show All Sections');
			//$('div.contentSection h4 a').trigger('click');
		}
	);
}

function showErrorFields(errorFieldsJson){
	var errorFieldsLength = errorFieldsJson[0].errorFields.length;
	for (var i=0; i<errorFieldsLength; i++){
		$('#' + errorFieldsJson[0].errorFields[i]).addClass('error');
	}
}

function sampleWorkshops(initialShown){
	$('div#sampleWorkshopsTabs a[rel=' + initialShown + ']').parent('li').addClass('on');
	$('div#' + initialShown + '').show();
	
	$('div#sampleWorkshopsTabs a').click(function(){
		$('div#sampleWorkshopsTabs ul li').removeClass('on');
		$('div.sampleWorkshopsContentSection').hide();
		
		$(this).parent('li').addClass('on');
		$('div#' + $(this).attr('rel') + '').show();
	});
}


//external links
$(function(){
	$('a[rel=external]').click(function(){
		this.target = '_blank';
	});
	
	$('a.video').click(function(){
		var videoWindow = window.open	($(this).attr('rel'), 'video', 'scrollbars=yes,resizable=yes,width=535,height=450');
	})
	
	$('input[type=radio], input[type=checkbox], input[type=image], input[type=submit]').addClass('nontext');
});
