var tradegothicbold = { src: '/thinking/wp-content/themes/thinking/js/trade-gothic-bold.swf' };
sIFR.useStyleCheck = true;

sIFR.activate(tradegothicbold);



sIFR.replace(tradegothicbold, {
  selector: '.page h1',
  wmode: 'transparent',
  css: [
		'.sIFR-root {color:#939598;margin-left:5px;font-size:28px;text-transform:uppercase;}'
		]
});

sIFR.replace(tradegothicbold, {
  selector: '.box h1',
  wmode: 'transparent',
  css: [
		'.sIFR-root {color:#ffffff;font-size:20px;text-transform:uppercase;}'
		]
});


	$(document).ready(function() {
							   
	  $('#right h3').click(function() {

			$(this).next(".expando-content").slideDownToggle("slow");
			$(this).toggleClass("closed"); return false;
	  });

						   
	
	$('.category-item h3').click(function() {
			$(this).next(".expando-content").slideDownToggle("slow");
			$(this).toggleClass("closed"); return false;					  
	});

    $("#subForm input:image").click(function() { 
      
      // First, disable the form from submitting
      $('form#subForm').submit(function() { return false; });
      
      var formAction = $("form#subForm").attr("action");
      
      var id = "ttwju";
      var emailId = id + "-" + id;
      
      if (!checkEmail(emailId)) {
        alert("Please enter a valid email address");
        return;
      }
	  
	  $("#confirmation").html('<img src="/thinking/wp-content/themes/thinking/img/loader.gif">');
	  $("#confirmation").show();
      

      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: "/thinking/wp-content/themes/thinking/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 can subscribe to this list.');
          }
          else
          {
            //$("#theForm").hide(); // If successfully submitted hides the form
            $("#confirmation").html("Thank You").delay(3000).fadeOut();

            $("#confirmation").tabIndex = -1;
            $("#confirmation").focus(); // For screen reader accessibility
            // Fire off Google Analytics fake pageview
            //var pageTracker = _gat._getTracker("UA-XXXXX-X");
            //pageTracker._trackPageview("/newsletter_signup");
			$("#interaction").delay(3000).animate({height:'76'});
			$("#interaction input:text").val("");
          }
        }
      });
    });					   
						   
	$('.author-list .expando-content').hide();
	$('.about .expando-content').hide();
	$('.category-item .expando-content').hide();
	$('#subscribe').toggle(function() {
		$("#interaction").animate({height:'200'});
		$('#subscribe').toggleClass("open"); 
	},
	function() {
		$("#interaction").animate({height:'76'});
		$('#subscribe').toggleClass("open"); 
	}
   );


	jQuery.fn.slideDownToggle = function(speed, easing, callback) {
		return this.animate({height: 'toggle'}, speed, easing, callback);
	};
	
	if ((navigator.appName == "Microsoft Internet Explorer" &&
    navigator.appVersion.indexOf("Mac") == -1 &&   navigator.appVersion.indexOf("3.1") == -1) ||

    (navigator.plugins && navigator.plugins["Shockwave Flash"])
                       || navigator.plugins["Shockwave Flash 2.0"]){

	} else {
		
   //Load a pre-defined HTML page with Flash Player in it into the browser window.
    $('.expando-box h3').click(function() {
		$(this).next(".expando-content").slideDownToggle("slow");
		$(this).toggleClass("closed"); return false;									
	});
	}



jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
	    phone_number = phone_number.replace(/\s+/g, ""); 
		return this.optional(element) || phone_number.length > 9 &&
		phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
		}, "Please specify a valid phone number");

	$(".wpcf7-form #state").children().each(function() {
		if ($(this).val()=="NE") {
			$(this).attr("selected","selected");
		}
	});


	$(".wpcf7-form").validate({
		errorLabelContainer: $("div.error-container"),
		wrapper: 'li',
		rules: {
			zip: {
				required:true,
				digits:true
			},
			phone: {
				required: true,
				phoneUS: true
			}
		},
		messages: {
			zip: {
				required: "Please enter your zip code.",
				digits: "Please enter only numbers in the zip code field."
			},
			phone: {
				required: "Please enter your phone number.",
				phoneUS: "Please enter a valid phone number.  Example: 402-555-1212."
			}
		}
	});

						   
	$('.author-name span').click(function() {
		$('.bio').toggleClass('bio-on');
		$('#content').toggleClass('content-transparency');
	});
	
	$('.author-name h3.author-name').click(function() {
		$('.bio').toggleClass('bio-on');
		$('#content').toggleClass('content-transparency');
	});
	

});


