// Custom JS used across the site
//var $j = jQuery.noConflict();

jQuery(document).ready(function(){
    jQuery("#site-index .down").click(function () {
      jQuery("#pulldownfull").slideDown("slow");
	  jQuery("#site-index .down").hide();
	  jQuery("#site-index .up").show();
    }); 
    
    jQuery("#pulldownfull *, #site-index .up").click(function () {
      jQuery("#pulldownfull").slideUp("slow");
	  jQuery("#site-index .down").show();
	  jQuery("#site-index .up").hide();
    });    

	jQuery(".facebook, .twitter, .rss").bind("mouseenter",function(){
		jQuery(".popup", this).fadeIn("slow");
	  }).bind("mouseleave",function(){
	  	jQuery(".popup", this).fadeOut("slow");
	});
	
	jQuery('#tertiary-graphics li:first').addClass('first');
	jQuery('#tertiary-graphics li:last').addClass('last');
	jQuery('#main div.info-holder ul.articlelist ul.byline li:last').addClass('last');
	
});

/*
 * Email Defuscator - jQuery plugin 1.0-beta2
 *
 * Copyright (c) 2007 Joakim Stai
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id$
 *
 */

/**
 * Converts obfuscated email addresses into normal, working email addresses.
 *
 * @name defuscate
 * @param Boolean link If true, all defuscated email addresses will be turned into links, defaults to true (optional)
 * @param String find The regular expression used to search for obfuscated email addresses (optional)
 * @param String replace Replacement text for defuscating email addresses (optional)
 * @descr Converts obfuscated email addresses into normal, working email addresses
 */

jQuery.fn.defuscate = function( settings ) {
    settings = jQuery.extend({
        link: true,
        find: /\b([A-Z0-9._%-]+)\([^)]+\)((?:[A-Z0-9-]+\.)+[A-Z]{2,6})\b/gi,
        replace: '$1@$2'
    }, settings);
    return this.each(function() {
        if ( jQuery(this).is('a[@href]') ) {
            jQuery(this).attr('href', jQuery(this).attr('href').replace(settings.find, settings.replace));
            var is_link = true;
        }
        jQuery(this).html(jQuery(this).html().replace(settings.find, (settings.link && !is_link ? '<a href="mailto:' + settings.replace + '">' + settings.replace + '</a>' : settings.replace)));
    });
};