function AllCards() {
	
	this.init = function() {
		this.initJumpList();
		showcase.initFisheye();
		showcase.initCardOverflowButtons();
		showcase.finderFilterInit();
		showcase.initCardHover();
		this.initClickSubFilters();
		this.doSIFR();
	}
	
	this.unInit = function() {
		showcase.unInitFisheye();
	}
	
	this.initJumpList = function() {
		$('.btn-getcard a').click(function() {
			document.getElementById('f-choose-a-card').method="post";
			document.getElementById('f-choose-a-card').action=document.getElementById('card-select').value;
			document.getElementById('f-choose-a-card').submit();
		});
	}
	
	/**
	* Initialises the extra functionality when the sub filters are clicked
	*
	*/
	this.initClickSubFilters = function () {
		$('.allcardsFilter').click(function() {
			allcards.subFilterClick($(this));
		});
	}
	
	/**
	* This function is called when the subfilters are clicked
	*
	*/
	this.subFilterClick = function(object) {
		$('.allcardsFilter').css('background-position','100% 0px');
		$('.allcardsFilter').children().css('background-position','0px 0px');
		object.css('background-position','100% -28px');
		object.children().css('background-position','0px -28px');
	}
	
	
	this.doSIFR = function()  {
		if (GlobalHeaders.isJapanese() == true) return;
		if (GlobalHeaders.isCantanese() == true) return;
		if (typeof sIFR == "function") {
			
			// check for noSIFR flag
			if ($('#content').hasClass('noSIFR') == 1) return;
			
			// sIFR wMode causes strange layout issues, so read current color styles to apply to sIFR
			// define templates
			var strapline1 = named({
				sFlashSrc:	"https://secure.cmax.americanexpress.com/Internet/International/sharedDotCom/flash/AgendaLt.swf",
				sColor:		rgb2hex($('#strapline1 h2').css('color')),
				sBgColor:	rgb2hex($('#strapline1 h2').css('background-color')),
				sCase:		"upper",
				sFlashVars:	"textalign=center"
			});
			var strapline2 = named({
				sFlashSrc:	"https://secure.cmax.americanexpress.com/Internet/International/sharedDotCom/flash/AgendaLt.swf",
				sColor:		rgb2hex($('#strapline2 h2').css('color')),
				sBgColor:	rgb2hex($('#strapline2 h2').css('background-color')),
				sCase:		"upper",
				sFlashVars:	"textalign=center"
			});
			
			var applyHeading = named({
				sFlashSrc:	"https://secure.cmax.americanexpress.com/Internet/International/sharedDotCom/flash/AgendaLt.swf",
				sColor:		rgb2hex($('.leftColumn h3').css('color')),
				sWmode: "transparent",
				sFlashVars:	"textalign=left"
			});

			var helpHeading = named({
				sFlashSrc:	"https://secure.cmax.americanexpress.com/Internet/International/sharedDotCom/flash/AgendaLt.swf",
				sColor:		rgb2hex($('.rightColumn h3').css('color')),
				sWmode: "transparent",
				sFlashVars:	"textalign=left"
			});

			var filterBy = named({
				sFlashSrc:	"https://secure.cmax.americanexpress.com/Internet/International/sharedDotCom/flash/AgendaLt.swf",
				sColor:		rgb2hex($('#filterBy h3').css('color')),
				sBgColor:	rgb2hex($('#filterBy h3').css('background-color')),
				sFlashVars:	"textalign=left"
			});
			//textalign=center in FlashVars is causing problems with 'low graphic' stylesheet (css/light/light.css)
	
			// replace elements
			sIFR.replaceElement('#strapline1 h2', strapline1);
			sIFR.replaceElement('#strapline2 h2', strapline2);
			sIFR.replaceElement('.leftColumn h3', applyHeading);
			sIFR.replaceElement('.rightColumn h3', helpHeading);
			sIFR.replaceElement('#filterBy h3', filterBy);
		};
	}
}

//Function to fix the characters truncating issue in Cantanese pages
var changeLineHeightforCn = 
{
	init: function () { 
		if (GlobalHeaders.isCantanese() == false) return;
		$('.showcaseFisheyeItem span.cardName').css('line-height','1.4');
		$('#h-page-tools a').css('line-height','1.4');
		
	}

}

$(document).ready(function(){
	showcase = new Showcase();
	allcards = new AllCards(showcase);
	allcards.init();
	changeLineHeightforCn.init();
});

