//<![CDATA[
// load handler
$(document).ready(function () {
	TemplateK.init();
	changeLineHeightforJP.init();
	changeLineHeightforCn.init();
});

/**
 * Class for managing template-specific scripts
 */
var TemplateK =
{
	init: function () {
		this.initToggle();
		this.doSIFR();
	}
	,
	doSIFR: function () {
		if (StyleSwitcher.isCantanese() == true) return;
		if (typeof sIFR == "function")
		{
			// sIFR wMode causes strange layout issues, so read current color styles to apply to sIFR
			// define templates
			if(document.getElementById('strapline1')){
			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')),
        sWmode:		"opaque",
				sFlashVars:	"textalign=center"
			});
			}
			if(document.getElementById('strapline2')){
			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')),
        sWmode:		"opaque",
				sFlashVars:	"textalign=center"
			});
			}
			var blueHeader = named({
				sFlashSrc:	"https://secure.cmax.americanexpress.com/Internet/International/sharedDotCom/flash/AgendaLt.swf",
				sColor:		"#005598",
				sWmode:		"transparent",
				sFlashVars:	""
			});
			
			// replace elements
			if(document.getElementById('strapline1') && StyleSwitcher.isJapanese() == false ){
				sIFR.replaceElement('#strapline1 h2', strapline1);
			}
			if(document.getElementById('strapline2')  && StyleSwitcher.isJapanese() == false ){
				sIFR.replaceElement('#strapline2 h2', strapline2);
			}
			if(StyleSwitcher.isJapanese() == false){
				sIFR.replaceElement('#content-footer h3', blueHeader);
			}
		};
	}
	,
	initToggle: function() {
		$('ul.tab-headers li a').click(function(e) {
			$('ul.tab-headers li a').removeClass('active');
			$(this).addClass('active');
			var tab = $(this).attr("href").substring(1,5);
			$("#tabsheet .tab-content div.tab dl").removeClass('active');
			$("#tabsheet .tab-content div[@id=" + tab + "] dl").addClass('active');
			$("#tabsheet .tab-content div.tab").hide();
			$("#tabsheet .tab-content div[@id=" + tab + "]").show();
			e.preventDefault();	
		});
		$('ul.tab-headers li a[@href="#tab1"]').addClass('active');
		$("#tabsheet .tab-content div.tab").hide();	
		$("#tabsheet .tab-content div#tab1").show();
	}
}

var changeLineHeightforJP = 
{
	init: function () { 
		if (StyleSwitcher.isJapanese() == false) return;
		$('.panel600').css('line-height','1.4');
		$('.tab UL').css('line-height','1.4');
	}

}

//Function to fix the characters truncating issue in Cantanese pages
var changeLineHeightforCn = 
{
	init: function () { 
		if (StyleSwitcher.isCantanese() == false) return;
		$('#h-page-tools a').css('line-height','1.4');
		$('.panel600').css('line-height','1.4');
		$('.tab UL').css('line-height','1.4');
		
	}

}
//]]>
