/**
* @author Den Markin <denmarkin@gmail.com>, http://dmarkin.name
* @version $Id$
* @package MashIt
*/

$(document).ready(function(){
	// slideshow
	startPos = 0
	// set width of content
	listWidth	= 0;
	liWidth	= parseInt($('#screenshotsList li:first').width());
	listWidth	= $('#screenshotsList li').length * liWidth;
	$('#screenshotsList').width(listWidth);
	
	var f = function () {
		if ((parseInt($('#screenshotsList').css('left')) + listWidth + startPos) > $('#screenshots').width() ) {
			$('#screenshotsList').stop().animate({"left": "-="+liWidth+"px"}, 'fast', 'linear', function () {
				t = setTimeout(f, 5000);
			});
		}
	};
	var t = setTimeout(f, 5000);
	
	// unlock btn interaction
	$('#unlockBtn').click( function () {
		$('#infoContainer').hide();
		$('#unlockFormContainer').show();
	});
	
	// unlock form validation
		$('#unlockForm').validate({
/*			messages: {
				myEmail: {
					email: "Not valid email."
				},
				"fEmail[1]": {
					email: "Not valid email."
				},
				"fEmail[2]": {
					email: "Not valid email."
				},
				"fEmail[3]": {
					email: "Not valid email."
				},
				"fEmail[4]": {
					email: "Not valid email."
				},
				"fEmail[5]": {
					email: "Not valid email."
				}
			},*/
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					// target: "#msg-result",
					success: function () {
						$('#unlockFormContainer').html('<h2>An email was sent to you with your personal unlock code.<br />Thank you!</h2>');
					},
					timeout: 3000,
					resetForm: true
				});
			}
		});
		$('#sendBtn').click( function () {
			$('#unlockForm').submit();
		});
});
