$('document').ready(function() {

	$('#open_gallery').click(function() {
	  if ($('#video_gallery').is(':visible')) {
		$('#video_gallery').slideUp();
		$('#open_gallery').val('Open Video Gallery');
		$('#video_flowplayer').hide();
		$f().mute();
		$('.slider-wrap').show();
	
	  } else {
	
		$('#video_gallery').slideDown();
		$('#open_gallery').val('X Close Video Gallery');
	  }
	});

	$('.playvideo').click(function() {

		$('#video_gallery').slideDown('slow');
		$('.slider-wrap').hide();
		$('#video_flowplayer').show();
		$('#open_gallery').val('X Close Video Gallery');
		$f().unmute();
			
		$f().play(this.getAttribute("href", 2));
				
		return false;
	});
		

// For use within normal web clients 
	var isiPad = navigator.userAgent.match(/iPad/i) != null;
	
	// For use within iPad developer UIWebView
	// Thanks to Andrew Hedges!
	var ua = navigator.userAgent;
	var isiPad = /iPad/i.test(ua) || /iPhone OS 3_1_2/i.test(ua) || /iPhone OS 3_2_2/i.test(ua);
	
	if (isiPad) {
		$f("ipad", "http://assets.erau.edu/flowplayer/flowplayer.unlimited-3.2.7.swf").ipad();
		$('#player').remove();
	
	}
	
	else {
	
	// setup player from "Flow player Demo 
		$f("player", "http://assets.erau.edu/flowplayer/flowplayer.unlimited-3.2.7.swf");
		$('#ipad').remove();
	}		
	
});	 

