/*    Main settings   */
progress = 79; /* Site complete percentage */
launchDate = new Date(2012, 2 - 1, 28);  /* Your launch date in format (Year, Month - 1, Day) */
twitter_username = "twitter"; /* Your twitter username */
monthNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];

$(document).ready(function() {
	if (window.PIE) {
        $('.round5').each(function() {
            PIE.attach(this);
        });
		$('.round3').each(function() {
            PIE.attach(this);
        });
		$('.round8').each(function() {
            PIE.attach(this);
        });
    }
	
	//insert placeholders
	$('#email-field').attr('placeholder', 'Enter your Email to sign up');
	$('#contact-form input[name*="name"]').attr('placeholder', 'Name');
	$('#contact-form input[name*="email"]').attr('placeholder', 'Email');
	$('#contact-form textarea[name*="message"]').attr('placeholder', 'Message');
	
	$('input[placeholder], textarea[placeholder]').placeholder();
	
	$('#contact-form').validate();
	$('#subscribe-form').validate();
	$('#contact-form').ajaxForm(function() { 
		alert("Thank you for your comment! We will try to answer your question as quickly as possible."); 
	});
	$('#subscribe-form').ajaxForm(function() { 
		alert("Thank you for your subscribtion!"); 
	});
	
	$("#tweets").tweet({
		avatar_size: 32,
		count: 3,
		username: twitter_username,
		template: "<div class='birdy'></div>{user} {text} <br /> {time}",
		loading_text: "loading tweets..."
	});
	$("a.twitter-link").attr("href", "http://twitter.com/"+twitter_username);
	
	$('#defaultCountdown').countdown({until: launchDate, layout:'<span class="countdown_row countdown_show4"><span class="countdown_section"><span class="countdown_amount highlight">{dn}</span>{dl}</span><span class="countdown_sep"></span><span class="countdown_section"><span class="countdown_amount highlight">{hn}</span>{hl}</span><span class="countdown_sep"></span><span class="countdown_section"><span class="countdown_amount highlight">{mn}</span>{ml}</span><span class="countdown_sep"></span><span class="countdown_section"><span class="countdown_amount highlight">{sn}</span>{sl}</span></span>'});
	
	if(progress>100){
		progress=100;
	}else if(progress<0){
		progress=0;
	}
	
	$('#progress-popup #progress-num').html(progress+'%');
	$('#progress-done').css('width','0').animate({
		width:progress+'%'
	},1000);
	
	$('#progress').hover(function () {
		$('#progress-popup').fadeIn(300);
	  }, 
	  function () {
		$('#progress-popup').fadeOut(100);
	});

	$('#coming-soon').toggle(function(){
		$(this)
		.animate({
			top: '+=10'
		}, 300)
		.animate({
			top: '-=85'
		}, 500, function() {
			// Animation complete.
		});
	}, function(){
		$(this)
		.animate({
			top: '+=75'
		}, 500, function() {
			// Animation complete.
		});
	});
	
	$("#launch-date-num").html(monthNames[launchDate.getMonth()]+' '+launchDate.getDate());
});

