$(document).ready( function() {
     $('.trigger').bind( 'click', function() {
          form_display();
     } );
     
     $('#btn_submit').bind( 'click', function() {
          $('#get_started').html('');
          $.ajax( {
               type: 'POST',
               url: 'apply.php',
               data: $('form').serialize(),
               success: function(r) {
                    $('p.trigger').html( r );
                    form_display();
               }
          } );
          return false;
     } );
     
     $('#why').bind( 'focus', function() {
          if( $('#why').val() == 'Why you’d be good for your city.' ) {
               $('#why').val('');
               $('#why').css('color', 'black' );
          }
     } );
     
     $('#why').bind( 'blur', function() {
          if( $('#why').val() == '' ) {
               $('#why').val('Why you’d be good for your city.');
               $('#why').css('color', '#a9a9a9' );
          }
     } );
     
} );


function form_display() {
     if( $('#features ul li').css( 'opacity' ) == 1 ) {
          $('#features ul li').animate( { 'opacity' : 0 }, 'fast' );
          $('form').fadeIn( 'fast' );
     }
     else {
          $('#features ul li').animate( { 'opacity' : 1 }, 'fast' );
          $('form').fadeOut( 'fast' );
     }
}







function activatePlaceholders() {
     $('input.text').each( function() { $(this).css( 'color', '#a9a9a9' ); } );
     var detect = navigator.userAgent.toLowerCase(); 
     if (detect.indexOf("safari") > 0) return false;
     var inputs = document.getElementsByTagName("input");
     for (var i=0;i<inputs.length;i++) {
          if (inputs[i].getAttribute("type") == "text") {
               if (inputs[i].getAttribute("placeholder") && inputs[i].getAttribute("placeholder").length > 0) {
                    inputs[i].value = inputs[i].getAttribute("placeholder");
                    inputs[i].onclick = function() {
                         if (this.value == this.getAttribute("placeholder")) {
                              $(this).css('color', 'black' );
                              this.value = "";
                         }
                         return false;
                         }
                         inputs[i].onblur = function() {
                         if (this.value.length < 1) {
                              this.value = this.getAttribute("placeholder");
                              $(this).css('color', '#a9a9a9' );
                         }
                    }
               }
          }
     }
}

