//change this to true to enable troubleshooting mode
var myfont_webfont_test = false;
// change this to false if you're having trouble with WOFFs
var woffEnabled = true;
// to place your webfonts in a custom directory, uncomment this and set it to where your webfonts are.
var customPath = "/themes/";




$(document).ready(function() {
						   

  $('#reason').change(function() {
  
  var r = $('option:selected',this).attr('reveal');
    // hide all
    $.each($('.hidden'), function() { $(this).slideUp(); });
    // show current
		$('#'+r).slideDown();
  });



  $('#start_something').click(function() {
 var $righty = $('#xxx');
 $righty.animate({
   width: parseInt($righty.css('width'),10) == 75 ?  600 :  75 
   });  $(this).attr('id') == 'start_something' ? $(this).attr('id','start_somethingOn') : $(this).attr('id','start_something')

  });
});



  function checkEmail(email) { 
    var pattern = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    var emailVal = $("#" + email).val();
    return pattern.test(emailVal);
  }


  $(function() {
    $("#subForm input:submit").click(function() { 
      
      // First, disable the form from submitting
      $('form#subForm').submit(function() { return false; });
      
      // Grab form action
      var formAction = $("form#subForm").attr("action");
      
      // Hacking together id for email field
      // Replace the xxxxx below:
      // If your form action were http://mysiteaddress.createsend.com/t/r/s/abcde/, then you'd enter "abcde" below
      var id = "xutidj";
      var emailId = id + "-" + id;
      
      // Validate email address with regex
      if (!checkEmail(emailId)) {
        alert("Please enter a valid email address");
        return;
      }
      
      // Serialize form values to be submitted with POST
      var str = $("form#subForm").serialize();
      
      // Add form action to end of serialized data
      // CDATA is used to avoid validation errors
      //<![CDATA[
      var serialized = str + "&action=" + formAction;
      // ]]>
      
      // Submit the form via ajax
      $.ajax({
        url: "bin/proxy.php",
        type: "POST",
        data: serialized,
        success: function(data){
          // Server-side validation
          if (data.search(/invalid/i) != -1) {
            alert('The email address you supplied is invalid and needs to be fixed before you we can update you.');
          }
          else
          {
            $("#subForm").hide(); // If successfully submitted hides the form
            $("#notice").fadeIn();  // Shows "Thanks for subscribing" div
            // Fire off Google Analytics fake pageview
            //var pageTracker = _gat._getTracker("UA-XXXXX-X");
            //pageTracker._trackPageview("/newsletter_signup");
          }
        }
      });
    });
  });

