 $(function() {
	// Colored ordered lists
	$('#contentMain ol').addClass('orderedList').children('li').wrapInner('<span></span>'); 
	$('#contentMain ul').addClass('unorderedList').children('li').wrapInner('<span></span>');
	
	// Automatically call out linked PDF documents so we don't surprise users
	$('a').each(function(){
		var href = $(this).attr('href');
		var useNewWindow = false;
		var parentLi = $(this).parent('li');
		
		if(href.indexOf('.pdf') != -1){
			$(this).addClass('pdf');
			$(this).append(' (pdf)');
			parentLi.addClass('file_pdf');
			useNewWindow = true;
		}
		
		if( useNewWindow ) {
			$(this).click(function(){
				window.open(this.href);
				return false;
			});
		}
	});
	
	//FAQ Section
	var faqSection = $("#faqSection");
	var questions = faqSection.children("h2");
	
	faqSection.children(".answer").hide();
	questions.css("cursor", "pointer");
	
	questions.toggle(
		function(){
			$(this).next(".answer").slideDown();
		}, function(){
			$(this).next(".answer").hide();
		}
	);
	
	// Make the whole region clickable while keeping the HTML valid
	
	$('ul.selectItemList li').each(function(){
		var href = $(this).find('a').attr('href');
		$(this).addClass('clickable').click(function(){
			window.location = href;
		});
	});
	
	$('a.popup').click(function(){
		var rel = $(this).attr('rel');
		var href = $(this).attr('href');
		if(!rel){
			window.open(href,'newWindow');
		} else {
			var rel_split = rel.split('|');
			var w = rel_split[0];
			var h = rel_split[1];
			var scrollbars = rel_split[2];
			var leftPos=(screen.width-w)/2;
			var topPos=(screen.height-h)/2;
			window.open(href,'newWindow','width='+w+',height='+h+',left='+leftPos+',top='+topPos+',scrollbars='+scrollbars+',resizable=no,statusbar=no,menubar=no,toolbar=no');
		}
		return false;		
	});	
});

