$(document).ready(function() {
	
	var hints = [
		"So, what is this?",
		"Well, it's not a car commercial.",
		"It's a Mac app announcement.",
		"But not for a theming app.",
		"And it's not a color picker either.",
		"It certainly isn't a tube of mirrors containing various loose, small, colored objects...",
		"Actually, we're not gonna tell you just yet."
	];
	
	var hintState = 0;
	var isIphone = (navigator.userAgent.toLowerCase().indexOf('iphone')!=-1);
	
	function startMovie() {
		
		if (isIphone) {
			$("#movie").media({
				width: 1000, 
				height: 500, 
				autoplay: true, 
				src: 'http://d38sv94p198wrl.cloudfront.net/kaleidoscope_iphone2.mp4', 
				params: {controller: 'false'},
				caption: false
			});
			
		} else {
			$("#movie").media({
				width: 1000, 
				height: 500, 
				autoplay: true, 
				src: 'http://d38sv94p198wrl.cloudfront.net/kaleidoscope.mp4', 
				params: {controller: 'false'},
				caption: false
			});	
		}
	}
	
	startMovie();
	
	$("#refresh_button").click(function() {
		startMovie();
		hintState = 0;
		$("#text").html(hints[hintState] + "<div id=\"next_button\"></div>");
	})
	
	$("#text").html(hints[hintState] + "<div id=\"next_button\"></div>");
	$("#subscribe").hide()
	
	$("#text").click(function() {
		hintState += 1;
		
		if (hintState == hints.length) {
			$(this).hide()
			$("#subscribe").show()
		} else {
			$(this).html(hints[hintState] + "<div id=\"next_button\"></div>")
		}

	});

	$("#next_button.submit").click(function() {
		$("form").submit();
	});

	/* 
	Descriptive text for forms 
	==========================================================================
	*/
	
	if (isIphone == false) {
	
		$('input[type=text]').addClass('placeholder');
	
		$('input[type=text]').focus(function() {
			if ($(this).attr('value') == $(this).attr('defaultValue')) {
				$(this).removeClass('placeholder');
				$(this).attr('value','');
			}
		});
  
		$('input[type=text]').blur(function() {
			if ($(this).attr('value') == '') {
				$(this).addClass('placeholder');
				$(this).attr('value', $(this).attr('defaultValue'));
			}
		});
	}
});

