/**
 *	Category-level customisations
 *	Viknesk, 2009-01-03
 */

// Object handling customisations at category level. Most of these arise due to WCMS generate-time limitations as well as use of SSI

//		'corporate': 'telekurs_financial_logo.gif',

var Customisations = {
	pageSelector: '#page',
	welcomeImgSrcs: {
		'global': 'UOB_group.gif',
		'personal': 'UOB_sg.gif',
		'corporate': 'UOB_sg.gif',
		'investor': 'UOB_group.gif',
		'about': 'UOB_group.gif',
		'privilege': 'UOB_privilege.gif',
		'private': 'UOB_private.gif'
	},
	flashHeaderClips: {
		'global': 'birds',
		'personal': 'kite',
		'corporate': 'clouds',
		'investor': 'birds',
		'about': 'hotairballoon',
		'privilege': 'clouds',
		'private': 'plane'
	},
	flashHeaderClipsHoliday: {
		'global': 'birds',
		'personal': 'kite',
		'corporate': 'clouds',
		'investor': 'birds',
		'about': 'hotairballoon',
		'privilege': 'clouds',
		'private': 'plane'
	},
	getLanguage: function () { return 'en'; /* Overload in scripts.html within the respective language folders */ },
	getHoliday: function () {
		// CNY hack, please comment off this line below after holiday period
		//return true;

		// Return immediately if defined
		if ($holiday) return $holiday;

		// Deduce from page classes
		return ($(Customisations.pageSelector).hasClass('holiday'));
	},
	getCategory: function () {
		// Return immediately if defined
		if ($category) return $category;

		// Deduce from page classes
		var page = $(Customisations.pageSelector);
		var category = 'global';
		if (page.hasClass('personal')) category = 'personal';
		else if (page.hasClass('corporate')) category = 'corporate';
		else if (page.hasClass('investor')) category = 'investor';
		else if (page.hasClass('about')) category = 'about';
		else if (page.hasClass('privilege')) category = 'privilege';
		else if (page.hasClass('private')) category = 'private';
		return category;
	},
	getSubCategory: function () {
		// Return immediately if defined
		if ($subcategory) return $subcategory;

		// Deduce from page classes
		var page = $(Customisations.pageSelector);
		var category = Customisations.getCategory();
		var subcategory = category;
		var match = false;
		if (match = page.attr('class').match(category+'-[a-z]+')) subcategory = match[0];
		return subcategory;
	},
	initFlashHeader: function () {
		var category = Customisations.getCategory();
		var holiday = Customisations.getHoliday();
		var src = 'cny';
		if (holiday) { src = Customisations.flashHeaderClipsHoliday[category]; }
		else { src = Customisations.flashHeaderClips[category]; }

		// insert flash
		$('#site-flash')
			.empty ()
			.flash
			(
				{
					src:'/assets/flash/'+src+'.swf',
					height: 59,
					width: 280,
					wmode: 'transparent'
				},
				{ update:false },
				function (htmlOptions) { $(this).append($.fn.flash.transform(htmlOptions)); }
			);
	},
	initWelcomeImg: function () {
		var category = Customisations.getCategory();
		var prefix = (Customisations.getLanguage() == 'en')? '': Customisations.getLanguage()+'/';
		var path = '/assets/images/' + prefix + 'common/' + Customisations.welcomeImgSrcs[category];
		
		$('#site-welcome-text').attr('src', path);
	}
}

