// bind 'myForm' and provide a simple callback function 
$(document).ready(function() { 
  $('#ipr-taf-form').ajaxForm(function() { 
    alert('Thank you for spreading the word!');
  }); 
});

// Attach Jquery Tabs if they exist
$(document).ready(function() {
  $('#tab-container').tabs();
});

// Set the video quiz question to display by default on each issue page
$(document).ready(function() {
  $('.issue-bucket-quiz-link').click( function() {
    startQuizQuestion = $(this).attr('start');
  });
});

// Attach Jquery Tabs if they exist
$(document).ready(function() {
  $('#slideshow').cycle({
    fx:      'fade',
    speed:   1500,
    timeout: 5000
  });
});

$(document).ready(function () {
  $('#friends-email-submitted').bind('blur', function() {
    $('#friends-email').val( $('#friends-email-submitted').val() );
  });
});

// Make all the inputs use the default text if available
$(document).ready(function() {
  $(':input').inputdefault();
});

// Make the homepage latest news slide down widget
$(document).ready(function() {
  $('a#more-news-link')
  .toggle(
    function() { $(this).html('Hide...') },
    function() { $(this).html('More news...') })
  .click(function() {
    $('#more-news').slideToggle(1000);
    return false;
  });
});


$(document).ready(function() { 
  // bind 'ipr-signup' and provide a simple callback function 
  $('#ipr-signup').ajaxForm( {
    /* clearForm:     true, */
    beforeSubmit:  function() { return checkmail( $('#mailing-list-email')); },
    /* success:       function() { $('#hidden-message').hide().show('slow'); $(':input').inputdefault(); } */
    success:       function() { $('#sign-up-area').html('<img id="success-image" src="/img/pledge-your-vote-success-message.gif" width="219" height="15" alt="" border="0" style="display: none">'); $('#success-image').hide().show('slow'); $('#sign-up-area').css('text-align', 'center').css('margin-top', '30px'); }
  });
}); 

// Email validation script
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
function checkmail($e) {
  var returnval = emailfilter.test($e.val());
  if (returnval != true) {
    alert('Please enter a valid email');
    $e[0].select();
  }
  return returnval;
}