$(function() {
	$("p#powered a,a[href$=\\.pdf],#main-content a[href$=privacy\\.html],#footerLinks a,a[href^=gesture],#community a,#main-content a[href^=community],#main-content a[href$=feedback\\.php]").attr("target", "_blank");
	if (typeof(flashembed) != 'undefined' && flashembed.isSupported([6, 65])) {
		$('body').addClass('flashenabled');
		$('.flv').empty();
	}
	if($('body').is('.learn')) {
		var videoPath = [
			'swfs/overview.flv',
			'swfs/roomba.flv',
			'swfs/entertainment.flv',
			'swfs/amelia.flv'
		];
	} else if ($('body').is('.use')) {
		var videoPath = [
			'swfs/Launch_Scrybe_three_fingers_down.flv',
			'swfs/Launch_Scrybe_three_finger_press.flv',
			'swfs/Open_Control_Panel_taskbar.flv',
			'swfs/Open_Control_Panel_touchpad.flv',
			'swfs/Gesture_List.flv',
			'swfs/Practice_Drawing.flv',
			'swfs/Edit_Gesture.flv',
			'swfs/Add_Gesture.flv',
			'swfs/Accessing_Preferences.flv',
			'swfs/Accessing_Help.flv',
			'swfs/Launch_Scrybe_CTRL_SHIFT.flv'
		];
	}
	if (typeof(videoPath) != 'undefined') {
		$.each(videoPath,function(i) {
		  if (flashembed.isSupported([6, 65])) {			  
				flowplayer('player'+(i+1), {src: "swfs/flowplayer.commercial-3.2.2.swf",wmode: 'opaque'}, {
					clip: { url: videoPath[i], autoPlay: false },
					key: '#@61e7598886b5224c198'
				});
		  }
		});
	}
	$('.use #main-content .flv').each(function() {
		$(this).prevUntil('h3').wrapAll('<div class="videowrap" />');
		$(this).insertBefore($(this).prev('.videowrap').children());
	});
	$('.use .videowrap:first-child ~ div').css('display','none');
	$('.use #video_container').append('<div id="selection" /><div class="inner"><div /></div>').find('h2,h3').appendTo('#selection');
	$('.use #video_container').children().not('.inner').appendTo('.use #video_container .inner > div');
	$('.use #selection').height($('.use .videowrap:first-child').height());
	$('.use #selection h2').each(function() {
		$(this).nextUntil('h2').wrapAll('<div><div /></div>');
	});
	$('.use #selection h3:first').addClass('current').append('<img src="img/bg_video_select_current.png" alt="" />').children('img').height($('.use #selection h3:first').outerHeight());
	$('.use #selection h3').click(function() {
		$(this).closest('#selection').find('.current').removeClass('current').find('img').remove();
		$(this).addClass('current').append('<img src="img/bg_video_select_current.png" alt="" />');
		var i = $(this).index('.use #selection h3');
		$('.use .videowrap').hide().eq(i).show();
		$('.use #selection').height($('.use #video_container .inner > div').height());
		$(this).children('img').height($(this).outerHeight());
	});
	if(typeof document.body.style.maxHeight === "undefined") {
		$('.use .videowrap:first').addClass('first');
		$('.use #video_container #selection h2 + div').addClass('wrap_bottom');
		$('.use #video_container #selection h2 + div > div').addClass('wrap_right');
	}
});

function showMenu(){
	document.getElementById("menu").style.display="block";
	}
function hideMenu(){
		document.getElementById("menu").style.display="none";		
	}

