/* Calculate for youself how many days there's left before the site launches. You can also check the counter after you set the date in the below code. Just write the startDays only once! Example: If you know your site will launch in exactly 1 year, you should write 365 days in the startDays. This way we can calculate the percentage done. */
var startDays = 85;

$(document).ready(function(){
	
	/* Change the time to count down to */
	$("#time").countdown({
		date: "february 29, 2012", /* Counting to a date */
		offset: 1,
		hoursOnly: false,
		onComplete: function( event ) {
		
			$(this).html("<span class='complete'>The site will launch today!</span>");
			$("#progressbar").css("display", "none"); /* When the countdown reaches above 100%, there's no use in displaying the progressbar */
			$(".tool").css("display", "none");
		},
		leadingZero: true
		
	});
	
	/* The percentage of the progressbar */
	$("#progressbar").progressbar({
		value: percent
	});
	
	/* The position of the tooltip, where the percentage number is in */
	$("#percentage .tool").css({
		marginLeft: percent +"%"
	}).append(percent+"%");
	
	/* The "notify" form validation */
	$('#btn-submit').click(function() {  
				
		$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var emailblockReg =  /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)(?!aol.com)([\w-]+\.)+[\w-]{2,4})?$/; 

		var emailaddressVal = $("#notify_by_mail").val();
		if(emailaddressVal == '') {
			$("#notify_by_mail").after('<span class="error">Please enter your email address.</span>');
			hasError = true;
		} else if(!emailReg.test(emailaddressVal)) {	
			$("#notify_by_mail").after('<span class="error">Enter a valid email address.</span>');
			hasError = true;
		} 

		if(hasError == true) { return false; }
		
	});	
	
	$(".email").val("Get notified by leaving your e-mailaddress");
	
	$('.email').click(
		function() {
			if (this.value == 'Get notified by leaving your e-mailaddress') {
				this.value = '';
			}
		}
	);
	
	$('.email').blur(
		function() {
			if (this.value == '') {
				this.value = 'Get notified by leaving your e-mailaddress';
			}
		}
	);
});
