jQuery(function($)
{
  if ($('div#flashContent').length == 1)
  {
  	toggleDetails();
  }
  
  gaTracking();
});

function toggleDetails()
{
	var benefits = $('#flashContent dl');
	var term = $('#flashContent dt'); //array of all definition titles
	var desc = $('#flashContent dd'); //array of all definition descriptions
		
		
	term.hover(
	function()
	{
		$(this).next().addClass('visible');
	},
	function()
	{
		$(this).next().removeClass('visible');
	});
}

//*********************
// TRACKING FUNCTIONS
//*********************
function googleTrack(tag) {
	tag = "/earthquake/" + tag;
	pageTracker._trackPageview(tag);
}

function gaTracking()
{	 
	 $('#logo_chase').click(function()
	 {
	 	googleTrack('chase_logo');
		openExtLink(this.href);
		return false;
	 });
	 
	 $('#card').click(function()
	 {
	 	googleTrack('banner/apply_cardart');
		openExtLink(this.href);
		return false;
	 });
	 
	 $('#btn_apply_top').click(function()
	 {
	 	googleTrack('banner/apply_button');
		openExtLink(this.href);
		return false;
	 });
	 
	 $('#btn_apply_btm').click(function()
	 {
	 	googleTrack('apply_bottom');
		openExtLink(this.href);
		return false;
	 });

	 $('#pricingTerms,#pricingTermsFoot').click(function()
	 {
	 	googleTrack('footer/pricing');
		openExtLink(this.href);
		return false;
	 });
	 
	 $('#privacy').click(function()
	 {
	 	googleTrack('footer/privacy');
		openExtLink(this.href);
		return false;
	 });
	 
	 $('#creditTools').click(function()
	 {
	 	googleTrack('footer/credit_tools');
		openExtLink(this.href);
		return false;
	 });
	 
	 $('#termsCond').click(function()
	 {
	 	googleTrack('footer/terms');
		openExtLink(this.href);
		return false;
	 });
	 
	 //hover example
/*
	 $('.cta').hover(function()
	 {	 	
		googleTrack('#');
	 },
	 function()
	 {
	 	
	 });
*/
}
function pageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;}
function pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}
function openExtLink(url)
{
	var nH = pageHeight() - 200;
	var nW = pageWidth() - 200;	
	wExtLink=window.open(url,'externalLink','width=' + nW + ',height=' + nH + ',location=1,toolbar=1,menubar=1,directories=1,status=1,resizable=1,scrollbars=1');
	wExtLink.focus();
}