//document ready
$(document).ready(function(){

	//PNG FIX for IE6
	if($.browser.msie && $.browser.version.substr(0,1) == 6 ){
	DD_belatedPNG.fix('h1#logo a, a.login-btn, #social, #social a, .steps-box h2, .orange-form, .orange-form .field1, .orange-form .field2, .orange-form .submit-button');
	}

	$('.header-list ul li:last').css('background', 'transparent')

	$('.blink').focus(function(){
		$(this).parent().addClass('focused');
  		var defVal = $(this)[0].defaultValue;
	  	if ($(this).val() == defVal) {
		$(this).val("");
		}
	})
	
	$('.blink').blur(function(){
		$(this).parent().removeClass('focused');
	  	if ($(this).val() == "") {
		var defVal = $(this)[0].defaultValue;
		$(this).val(defVal);
		}
	})

	$('a.info-btn').hover(function() {
		$(this).parent().find('p').show();
		}, function(){
		$(this).parent().find('p').hide();
	})

	$('#orange-form').submit(function() {
		if ($(this).data('invalid')) {
			//alert('false');
			return false;
		}

		$(this).submit();
		
		/* $.ajax('home.php', {
			type: 'POST',
			data: $(this).serializeArray(),
			success: function() {
				alert('Thank you!');
				window.location=window.location.href + '?success=1';
			} 

		}); */
		return false;
	});

	$('#orange-form .field1 input').keyup(function() {
		the_length = $(this).val().length;
		if ((the_length == 3) || (the_length == 7)) {
			the_val = $(this).val();
			the_val = the_val + '-';
			$(this).val(the_val);
		}
		if (the_length == 12) {
			setTimeout(second, 500);
		}
	});
	
	function second() {
		$('#orange-form .second input').focus();
	}

	$('#orange-form .second input').keyup(function() {
		the_length = $(this).val().length;
		if (the_length == 5) {
			setTimeout(third, 500);
		}
	});

	function third() {
		$('#orange-form .third input').focus();
	}
});
