/* Author: Finn Media Company

*/

$(document).ready(function() {

  $("ul li:first-child").addClass('first');
  $("ul li:nth-child(3n)").addClass('third');
  $("ul li:last-child").addClass('last');

  // Handle mailing list onfocus/blur
  $(".wpcf7-subscribe .user-email input").focus(function() {
    if ($(this).val() == "Subscribe to our Mailing List...") $(this).val("");
  });

  $(".wpcf7-subscribe .user-email input").blur(function() {
    if ($(this).val() == "") $(this).val("Subscribe to our Mailing List...");
  });
  
  // Subscribe form validation
  $(".wpcf7-subscribe form.wpcf7-form").submit(function() {
    
    email = $(this).find(".user-email input");
    
     if (email.val() == '') {
       alert('Please fill in your email address.')
     } else if (!(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/).test(email.val())) {
       alert('Please enter a valid email address.')
     } else { return true; }
     
     return false;
    
  });
  
  $("a.spammy").nospam({ replaceText: true });

});

function fbs_click(u,t) {if (!u)u=location.href;if (!t)t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}
function tws_click(u,t) {if (!u)u=location.href;if (!t)t=document.title;window.open('http://twitter.com/share?url='+encodeURIComponent(u)+'&text='+encodeURIComponent(t)+'&via=doggreenproductions','sharer','toolbar=0,status=0,width=626,height=436');return false;}
function dgs_click(u,t) {if (!u)u=location.href;if (!t)t=document.title;window.open('http://digg.com/submit?url='+encodeURIComponent(u)+'&title='+encodeURIComponent(t),'sharer');return false;}
function ems_click(u,t) {if (!u)u=location.href;if (!t)t=document.title;document.location = 'mailto:\?subject\=' + encodeURIComponent(t) + '&body=' + encodeURIComponent(u); return false;}
