/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);

/****** end hoverIntent plugin ********************/


/************ Subnavigation slide open/slide close on hover ***************/
function subNav() {
	jQuery('#subnav').children('li').each(function() {
		var thisli = jQuery(this);	
		var thislinkbg = thisli.children('a').css('backgroundColor');
		if((thisli.children('ul').length > 0) && ((thislinkbg == 'rgb(52, 69, 79)') || (thislinkbg == '#34454f')) ) {
			thisli.addClass('expandnav');
		}

	});
	
	if(jQuery('.expandnav').length > 0 ) {
      jQuery('.expandnav ul').slideUp();
  	  /* jQuery('#subnav').delegate('.expandnav', 'hover', function() { */
	jQuery('.expandnav').hoverIntent(function() {
	      var li = jQuery(this);
		  li.find('ul').slideDown();
	  }, function() {
		  var li = jQuery(this);
		  li.find('ul').slideUp();
	  });
	}
}

/* $('.expandnav ul').slideUp();

$('#subnav').delegate('.expandnav','mouseover mouseout',function() {
	var li = $(this);
	
	if(event.type == 'mouseover') {
		li.find('ul').slideDown();	
	} else if(event.type == 'mouseout') {
		li.find('ul').slideUp();	
	}
	
	return false;
});		 */	

/************ rotating features ***************************/
function featureChange() {

   var active = jQuery('#feature').find('h1.active');
   
   /* if it is the last feature, then start over, otherwise go on to the next */
   if(active.next('h1').length > 0) {
	  var nextfeature = active.next('h1');
   }
   else {
	  var nextfeature = jQuery('#feature').find('h1:first-child');
   }

   active.removeClass('active');
   nextfeature.addClass('active');

   /* if(navigator.appName=='Microsoft Internet Explorer') {
	    // internet explorer glitches on alpha background and fading in and out
	  active.html(next);
   } else { */
	  /* current quote will fade out and new one will fade in */
   active.fadeOut('fast', function() {
		nextfeature.fadeIn('fast');
	});
   /* } */
}




/************ carousel ***********************************/

/* Store the quotes in an array, with the quote separated from the author by the vertical bar symbol | */
var quotes = new Array(
	"It is possible that because merchants will reject more expensive cards from smaller institutions or because networks will not be willing to differentiate the interchange fee for issuers of different sizes, it is possible that that exemption will not be effective in the marketplace. | Chairman Bernanke",
	"JOHANNS: You wouldn't suggest that it would be good economic policy that we pass a law that the price of a porterhouse steak or the price of a gallon of milk could only go so high, would you?<br />BERNANKE: No. | Senator Mike Johanns (R-NE) &amp; Chairman Bernanke ",
	"The likelihood of this hurting community banks and requiring them to increase the fees they charge for accounts is much greater than any tiny benefit retail customers maybe get. | Chairman Bair",
	/* "The statute limits the &mdash; the interchange fee to the incremental cost associated with an individual transaction, which does not cover the full cost, if you include some fixed costs associated with setting up a debit card program, for example.  So it's certainly possible that some of those costs would get passed on to consumers in some &mdash; in some way, for example, a charge for a debit card or something like that. | Chairman Bernanke", */
	"If they are forced down to the 12 cent level, that is going to &mdash; to reduce the income that they get for debit cards, so I think they're going to have to make that up somewhere, probably by raising the fees that they have on transaction accounts &hellip; That would not be helpful for consumers and that might be an unintended consequence. | Chairman Bair",
	"I think the full policy ramifications, who's paying for what, who's going to pay more, and who's going to pay less under this is something that maybe wasn't dealt with as thoroughly as it might have been. | Chairman Bair",
	"We agree with you. This -- this really needs to be fixed. | Chairman Bair",
	"If there's one thing that I hope you will take from this hearing this morning, it is that a delay in the implementation of this rule is definitely in order. ... I think we owe it to the American people, to these institutions, to be able to delay and make sure that we get this rule right. | Representative David Scott (D-GA)",
	"I would like for you to take more time, I would like for you to consider the impact that this is going to have on small to medium sized banks and on their ability to add capital to their banks. | Representative Kenny Marchant (R-TX)",
	"[T]here is at a minimum some confusion about the provision in this rule and if done incorrectly, this could be the final nail in the coffin for many of the smaller financial institutions, I think, that have been decimated by a weak economy and piles of new regulations from Washington. | Representative Ed Royce (D-CA)",
	"In relation to the comment period, some organizations, some constituents have suggested that the process was not as thorough as it should be, that the Federal Reserve should have had more time to study the issue and to survey a wider set of financial institutions and retail establishments. | Representative Carolyn Maloney (D-NY)",
	"I think there are a lot of costs that were talked about, but really are not being evaluated. And we need to get them all. If we're going to do this, we need to do it right. | Representative Jim Renacci (R-OH)",
	"I haven't been able to see how we assure that the ultimate beneficiary that we were advocating for, that we all should be advocating for, consumers, really get the benefit of this. | Representative Mel Watt (D-NC)",
	"I feel that the current timetable for implementing [these] interchange rules is not sufficient for those who are affected &mdash; whether you're the consumer or the retailer or the bank ... it's going to be very difficult for them to adjust. | Representative Francisco Canseco (R-TX)",
	"Your job was to figure the impact on the consumer, and on the retail industry, and on the banking industry. And just because they were exempted it does not mean that they were impacted. So, I think that your survey and your studies and flawed and you should admit that. | Representative Don Manzullo (R-IL)",
	"I wish we would have the time before we passed the bill to have this kind of an intensive kind of debate and conversation and it might have cleared it up. | Representative Gregory Meeks (D-NY)",
	"In the rush to comply with the unrealistic deadlines set in Dodd- Frank, the regulators have had to focus on speed rather than deliberation. And while our regulators will do their best to comply with the deadlines, Congress, I believe, should seriously examine whether the speed of the process is undermining its integrity. There are early indications that it is. | Senator Richard Shelby (R-AL)",
	"But there's no question that our smaller institutions are going to be impacted in a big way. And I think we all know that and I hope that we will endeavor somehow to fix that here in Congress. | Senator Bob Corker (R-TN)",
	"You're starting to hear feedback that there may actually be some practical problems with implementing [the exemption for small financial institutions with assets of less than $10 billion]. | Senator Michael Bennet (D-CO)",
	"[I]t seems to me that it's an impossibility that if a rate is set for the larger institutions, it is not going to impact the smaller institutions as it relates to interchange rules. | Senator Bob Corker (R-TN)",
	"It would seem to me that there's going to be undue harm done to smaller banks when the retailer looks at this and says, 'You know what? I'm going with the smallest interchange possible, because it's going to help my bottom line.' | Senator Jon Tester (D-MT)",
	"But there's the problem with price-fixing. We can't guarantee that, can we? We can't guarantee that a single consumer will get any benefit from that legislation. | Senator Mike Johanns (R-NE)",
	"The fairness of us price-setting at some rate that only as a transmission cost seems to me to be incredibly in error. We also are going to be forcing people into credit cards over time. I mean, people that don't have credit are going to be forced into credit cards ... It just seems like to me the whole issue is very perverse in something that was very short-sighted on our part. | Senator Bob Corker (R-TN)",
	"Dodd-Frank may not raise taxes directly, but consumers will soon feel its cost with a pie -- pay higher regulatory fees, higher compliance costs and higher prices for financial services. | Senator Richard Shelby (R-AL)",
	"Not only national firms are multinational players, they're some of the biggest economic players in the world. This isn't Joe's Hardware in somewhere in Nebraska. ... Really, what you're doing is moving money from here to here, and it's the big players that are going to see the benefit of that, the big retailers. | Senator Mike Johanns (R-NE)"

);

/* get the total number of quotes */
var num = quotes.length;

/* function to actually change the quote */
function quotesChange() {
   var active = jQuery('#carousel').find('a');
   var id = active.attr('class').split('q')[1];
   
   /* if it is the last quote in the array, then start over, otherwise go on to the next quote */
   if((parseInt(id) + 1) == num) {
	  var nextid = 0;
   }
   else {
	  var nextid = parseInt(id) + 1;
   }

   var nextquote = quotes[nextid].split('|');
   var next = '"' + nextquote[0] + '" <cite class="textright">&mdash; ' + nextquote[1] + '</cite><div id="click">CLICK TO LEARN MORE</div>';
   
   active.removeClass('q'+id).addClass('q'+nextid);
   
   if(navigator.appName=='Microsoft Internet Explorer') {
	    // internet explorer glitches on alpha background and fading in and out
	  active.html(next);
   } else {
	  /* current quote will fade out and new one will fade in */
   active.fadeOut('fast', function() {
		active.html(next).fadeIn('fast');
	});
   }
}

/**************** IMPLEMENTATION *************************************/

jQuery(document).ready(function() {
	
	if(jQuery('#carousel').length > 0) {
		jQuery('#carousel').find('a').addClass('q0');
		var int = setInterval(quotesChange, 7000);
	}
	
	if(jQuery('#feature').length > 0) {
		jQuery('#feature').find('h1:last-child').addClass('active');
	    jQuery('#feature').find('h1:not(.active)').hide();	
		var int = setInterval(featureChange, 7000);
	}
	
    subNav();
	
});
