jQuery(document).ready(function() {

  jQuery("#calendar_tabs").tabs();
  
    if ( jQuery('.bodycontent .help, .bodycontent a[title], .bodycontent img[title]').qtip ) {

        jQuery('.bodycontent .help, .bodycontent a[title], .bodycontent img[title]').qtip({
            position: {
                corner: {
                    target: 'topMiddle',
                    tooltip: 'bottomMiddle'
                }
            },
            style: { 
                name: 'blue',
                tip: 'bottomMiddle'
            }
        });
    }

	/* hide the standard submit button, show the pretty button */
	/* jQuery('form input:submit').hide(); */
	/* jQuery('.submit.button').show(); */
	
	/* submit the form when the pretty button is clicked */
	/* jQuery('.submit.button').click(function(){ jQuery(this).parents('form:first').submit(); }); */

  if (jQuery('input[title]').example) {

      jQuery('input[title]').example(function() {
          return jQuery(this).attr('title')}, 
          {className: 'gray'}
      );
  }

  jQuery('.subcontent').hide();
  jQuery('#f_contact .toggle').toggle(function()
  {
    jQuery(this).next('.subcontent').slideDown(400);
    jQuery(this).html('<img class="icon" src="/icons/silk/bullet_toggle_minus.png" /> Hide additional recipients');
  }, function() {
    jQuery(this).next('.subcontent').slideUp(400);
    jQuery(this).html('<img class="icon" src="/icons/silk/bullet_toggle_plus.png" /> Show additional recipients');
  });

  jQuery('#training .toggle').toggle(function()
  {
    jQuery(this).next('.subcontent').slideDown(400);
    jQuery(this).children('img').attr('src', '/icons/silk/bullet_toggle_minus.png' );
  }, function() {
    jQuery(this).next('.subcontent').slideUp(400);
    jQuery(this).children('img').attr('src', '/icons/silk/bullet_toggle_plus.png' );
  });
  
  var fadeColor = "#ffffff"; 

  jQuery('.thanks').hide();
  jQuery('.design_your_march').hide();

  jQuery('.signup_button').click(function() {
    jQuery('.signup').slideUp();
    jQuery('.thanks').slideDown();
    jQuery('.who_is_signed_up').slideUp();
    jQuery('.design_your_march').slideDown();
  });

  jQuery('.from_fax').click(function() {
    jQuery('h3#fax').html('<img class="icon" src="/icons/silk/tick.png"/> <a href="#">Bank Faxes</a> <strong>You banked 3 free faxes. That makes us smile!</strong> <img class="icon" src="/icons/silk/emoticon_smile.png"/> ');
    jQuery('h3#fax strong').animate({backgroundColor:fadeColor}, 30000);
  });

  jQuery('.no_fax').click(function() {
    jQuery('h3#fax').html('<img class="icon" src="/icons/silk/bullet_go.png"/> <a href="#">Bank Faxes</a> <strong>No problem, you can still fax on the day of the march.</strong>');
    jQuery('h3#fax strong').animate({backgroundColor:fadeColor}, 30000);
  });

  jQuery('.from_call').click(function() {
    jQuery('h3#call').html('<img class="icon" src="/icons/silk/tick.png"/> <a href="#">Make Calls</a> <strong>You signed up to call from 1 &ndash; 3. Thumbs up!</strong> <img class="icon" src="/icons/silk/thumb_up.png"/> ');
    jQuery('h3#call strong').animate({backgroundColor:fadeColor}, 30000);
  });

  jQuery('.no_call').click(function() {
    jQuery('h3#call').html('<img class="icon" src="/icons/silk/bullet_go.png"/> <a href="#">Make Calls</a> <strong>Busy schedule? You can still call on the day of the march.</strong>');
    jQuery('h3#fax strong').animate({backgroundColor:fadeColor}, 30000);
  });

  jQuery('.from_remind').click(function() {
    jQuery('h3#remind').html('<img class="icon" src="/icons/silk/tick.png"/> <a href="#">Get Reminders</a> <strong>We&rsquo;ll remind you on the day of the march.</strong> <img class="icon" src="/icons/silk/heart.png"/>');
    jQuery('h3#remind strong').animate({backgroundColor:fadeColor}, 30000);
  });

  jQuery('.no_remind').click(function() {
    jQuery('h3#remind').html('<img class="icon" src="/icons/silk/bullet_go.png"/> <a href="#">Get Reminders</a> <strong>See you on the day of the march!</strong>');
    jQuery('h3#fax strong').animate({backgroundColor:fadeColor}, 30000);
  });

  jQuery('.to_call').click(function() {
    jQuery('#accordion').accordion('activate', '#call' );
  });

  jQuery('.to_remind').click(function() {
    jQuery('#accordion').accordion('activate', '#remind' );
  });

  jQuery('.to_share').click(function() {
    jQuery('#accordion').accordion('activate', '#share' );
  });

/* Make all pdfs open in a new window */
jQuery("a[href*=.pdf]").click(function(){
	window.open(this.href);
	return false;
});

/* Jquery slideshow */
if (jQuery('.slideshow').cycle) {
    jQuery('.slideshow').cycle({
        fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    });
}

function ResizeImage(image, maxwidth, maxheight)
{
    if (image.className == "Thumbnail")
    {
        w = image.width;
        h = image.height;
                
        if( w == 0 || h == 0 )
        {
            image.width = maxwidth;
            image.height = maxheight;
        }
        else if (w > h)
        {
            if (w > maxwidth) image.width = maxwidth;
        }
        else
        {
            if (h > maxheight) image.height = maxheight;
        }
                
        image.className = "ScaledThumbnail";
    }
}

if ( jQuery("img[src*=.png]").pngfix ) {
    jQuery("img[src*=.png]").pngfix( { repeatMethod: "crop" } );
}

jQuery("table.sortable").tablesorter({widthFixed: true, widgets: ['zebra']});

});

