function playVideo() {
	
}

var Quotator = {
	quotes: '',
	active: 0,
	
	rotate: function() {
		var next = Quotator.getNext();
		$(Quotator.quotes[next]).fadeIn(600,function() {
			Quotator.updateActive(next)});
		$(Quotator.quotes[Quotator.active]).fadeOut(200);
		
	},
	
	updateActive: function(index) {
		$(Quotator.quotes[Quotator.active]).removeClass('active');
		Quotator.active = index;
	},
	
	getNext: function() {
		var next = Quotator.active + 1;
		if (next >= Quotator.quotes.length) {
			next = 0;
		}
		return next;
	},
	
	setBackgroundPositons: function() {
		$('#callout q').each(function(index) {
			var bgPosY = 0 - (index*114);
			$(this).css('background-position','0 ' + bgPosY + 'px')
		})
	},
	
	init: function() {
		Quotator.setBackgroundPositons();
		Quotator.quotes = $('#callout li');
		setInterval(Quotator.rotate,8000);
	}
	
}

var Player = {
	hasFlash: !!swfobject.getFlashPlayerVersion().major,
	embedPlayer: function(){
		$("#movie").html('<iframe src="http://player.vimeo.com/video/36520637?title=0&amp;byline=0&amp;autoplay=1" width="640" height="480" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>');	
		/*if(Player.hasFlash){
			var attributes = {}
			var flashVars = {
				flvPath: "/_ui/video/cloudtix_demo.mov",
				imgPath: "",
				flvWidth: 640,
				flvHeight: 480,
				autoPlayBool: "true",
				showActualSize: "true",
				loopBool: "false",
				hideControlsBool: "false",
				imgPath: "/_ui/img/video-poster.jpg",
				controlSetup: "PlayPause,ProgressBar,FlyoutVolumeControl",
				controlPadding: "0"		
			}
		    var params = {
		    	allowfullscreen: "true",
		    	salign: "tl",
				wmode: "window",
				allowScriptAccess: "always"
		    }
		    swfobject.embedSWF("_ui/swf/VideoPlayer.swf", "movie", "640", "510", "9.0.0", null, flashVars, params, attributes);
		} else {
			$("#movie").replaceWith("<video id='movie' src='_ui/video/cloudtix_demo.mp4' width='640' height='480' controls autoplay></video>");	
		}*/
	},
	unembedPlayer: function() {
		$("#movie").html('<div id="placeholder"></div>');
	}
}

function subscribeToList(e) {
	e.preventDefault();
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var address = $('#emailSignUp').val();
	if(reg.test(address) == false) {
	   $("#contact form span").html("Oops! Please make sure to enter a valid email address.");
	} else {
	var iframe = frames['iframeSignUp'].document;
	iframe.getElementById('email').value = $('#emailSignUp').val();
	iframe.getElementById('signUpForm').submit();
	pageTracker._trackPageview('/newsletter-signup/');
	$('#contact form').html("<p><strong>Thanks for your interest in CloudTix!</strong></p><br><p>Over the coming weeks and months we’ll be sharing updates about the launch of CloudTix, discuss the results clients are seeing and highlight new features we’re exploring. Glad you’ll be along for an exciting ride!</p>");
	}
}

var homeInit = function() {
	// clear out value on load if there is one
	$('#emailSignUp').val("");
	
	$('#contact button').click(subscribeToList);
	$('#watch_video').overlay({
		effect: 'apple',
		onLoad: Player.embedPlayer,
		onBeforeClose: Player.unembedPlayer,
		expose: {
			color: '#52b9e3',
			loadSpeed: 200,
			opacity: 0.5
		}
	});
	Quotator.init();
};

$(document).ready(homeInit);
