var images = new Array('images/followme-over.png', 'images/ud-button2.png', 'images/send-but-on.png', 'images/send-but.png', 'images/bubble-bg.png');
var imageObjs = new Array();
for (var i in images) {
  imageObjs[i] = new Image();
  imageObjs[i].src = images[i];
}

$(document).ready(function() {
    $('#update-button').click(function() {
        var $formBubbleElement = $('#form-bubble');
        if ($formBubbleElement.is(':animated')) {
            return false;
        }
        if ($formBubbleElement.is(':visible')) {
            $formBubbleElement.fadeOut();
        } else {
            $formBubbleElement.fadeIn();
        }
    });
    
    setUpAjaxForm();
});

function setUpAjaxForm()
{
	$('#email-element').click(function() {
		if ($(this).val() == 'Email address...') {
			$(this).val('');
		}
	});
	$('#register-form').ajaxForm({
        target: '#form-bubble-inner',
		success: function(responseText) {
            if (responseText.search(/id="register-success"/i) != -1) {
              var $formBubbleElement = $('#form-bubble');
              setTimeout(function() { $formBubbleElement.fadeOut(); }, 3000);
            } else {
              setUpAjaxForm();
            }
        }
	});
}

$(window).load(function() {
    var progressBarWrap = $('#progress-bar-wrap');
    var progressAmount = $('#progress-amount');    
    var targetWidth = $('#progress-wrap').width() * (progress / 100);
    progressBarWrap.animate({
        width: targetWidth
    }, animationSpeed, null, function() {
		$('#moving-arrow').animate({height: '35'}, 'slow', 'easeOutBack', function() {
			progressAmount.text(progress + '%').fadeIn('slow');													   
		});		
    }).css('overflow', 'visible');
	$('#progress-indicator').fadeIn('slow');
});

