$(function(){

	// FAQs
	/*
	if ($('#faq')) {
		var faqmenus = $('#faq nav li a')
		var faqboxes = $('#faq section');
	
		faqmenus.each(function(i, el){
			$(el).click(function(e){
				e.preventDefault();
			
				// Show the right content
				faqboxes.addClass('hide');
				faqboxes.eq(i).removeClass('hide');
				
				// Change menu appearance
				faqmenus.each(function(i, el){
					$(el).parent().removeClass('active');
				})
				$(this).parent().addClass('active');
				
			})
		});
	}
	*/
	
	// Screencasts
	if ($('#screencasts')) {
		var scmenus = $('#screencasts nav li a')
		var scbox = $('#screencasts-video');
	
		scmenus.each(function(i, el){
			$(el).click(function(e){
				e.preventDefault();
				
				// Build the video url
				var videoid = el.href.substr(el.href.indexOf('v=')+2, el.href.length);
				var videourl = 'http://www.youtube.com/v/' + videoid;
				
				// Create the new content
				scbox.empty();
				$(scbox).flash({
					swf: videourl,
					width: 640,
					height: 385,
					params: {
						allowFullScreen: true,
						allowScriptAccess: 'always'
					},
					flashvars: {
						allowfullscreen: true,
						allowscriptaccess: 'always'
					}
				});
				
				// Change menu appearance
				scmenus.each(function(i, el){
					$(el).parent().removeClass('active');
				})
				$(this).parent().addClass('active');
				
			})
		});
	}
});
