/**
 * Odgers Berndtson
 *
 * @filename    activate.js
 * @author      Oliver Rowlands
 * @date        2007-01-01
 * @copyright   Liquid Light Digital Ltd.
 * @url         http://www.liquidlight.co.uk
 */

/**
 * Define font
 */
var fcm = {src: '/fileadmin/assets/group/swf/fcm.swf', wmode: 'transparent'};

/**
 * Define common font settings
 */
var common = ['.sIFR-root { color: #264E85; }',
			  'a { color: #264E85; text-decoration: none; }',
			  'a:hover { color: #264E85; text-decoration: underline; }'];

/**
 * Initialize sIFR
 */
sIFR.activate(fcm);

/**
 * Two column inverted layout settings
 */
sIFR.replace(fcm, {
	selector: '#twoColumnInvertedLayout div.columnTwo h2, #twoColumnLayout div.columnOne h2, #ffWrapper div.leftColumn h2',
	css: ['.sIFR-root { color: #264e85; background-color: #F0F0F0;}']
});

/**
 * Boxes
 */
sIFR.replace(fcm, {
	selector: 'div.boxGrey h2, div.boxGrey h3',
	css: ['.sIFR-root { color: #264e85; background-color: #F0F0F0; }']
});
sIFR.replace(fcm, {
	selector: 'div.boxBlue h2, div.boxBlue h3',
	css: ['.sIFR-root { color: #264e85; background-color: #EEF3F9; }']
});
sIFR.replace(fcm, {
	selector: 'div.notification h2, div.notification h3',
	css: ['.sIFR-root { color: #006600; background-color: #e2f9e3; }']
});
sIFR.replace(fcm, {
	selector: 'div.notificationError h2, div.notificationError h3',
	css: ['.sIFR-root { color: #B60000; background-color: #FEDBDB; }']
});

/**
 * Inline two column layout settings
 */
sIFR.replace(fcm, {
	selector: 'div.twoColumnWrapper h2, div.twoColumnWrapper h3',
	css: common
});

/**
 * Global homepage layout settings
 */
sIFR.replace(fcm, {
	selector: '#globalHomePageLayout div.columnOne h2, #localHomePageLayout div.columnOne h2',
	css: ['.sIFR-root { color: #264e85; background-color: #F0F0F0; }',
		  'a { color: #264e85; text-decoration: none; }',
		  'a:hover { color: #264e85; text-decoration: underline; }']
});
sIFR.replace(fcm, {
	selector: '#globalHomePageLayout div.columnThree h2, #localHomePageLayout div.columnThree h2, #localHomePageLayout div.columnThree h3',
	css: ['.sIFR-root { color: #264e85; background-color: #D7DEF1; }',
		  'a { color: #264e85; text-decoration: none; }',
		  'a:hover { color: #264e85; text-decoration: underline; }']
});

/**
 * Three column layout settings
 */
sIFR.replace(fcm, {
	selector: '#threeColumnLayout div.columnOne h2, #threeColumnLayout div.columnThree h2',
	css: ['.sIFR-root { color: #264e85; background-color: #F0F0F0; }',
		  'a { color: #264e85; text-decoration: none; }',
		  'a:hover { color: #264e85; text-decoration: underline; }']
});

/**
 * Default configuration
 */
sIFR.replace(fcm, {
	selector: 'h1, h2, h3',
	css: common
});

/**
 * Google Analytics link tracking
 *
 * Based on the Google Analytics Drupal module by:
 * @author Colm McBarron <colm.mcbarron@iqcontent.com>
 */
$('a').click(function() {
	var isInternal = new RegExp('^(https?):\/\/' + window.location.host, 'i');
	var isDownload = new RegExp('\\.(7z|aac|avi|csv|doc|exe|flv|gif|gz|jpe?g|js|mp(3|4|e?g)|mov|pdf|phps|png|ppt|rar|sit|tar|torrent|txt|wma|wmv|xls|xml|zip)$', 'i');
	try {
		if(isInternal.test(this.href)) {
			if(isDownload.test(this.href)) {
				var extension = isDownload.exec(this.href);
         		pageTracker._trackEvent('Download', extension[1].toUpperCase(), this.href.replace(isInternal, ''));
			}
		} else {
			if($(this).is('a[href^=mailto:]')) {
				pageTracker._trackEvent('Email', 'Click', this.href.substring(7));
	        } else {
				pageTracker._trackEvent('External', 'Click', this.href);
	        }
		}
	} catch(err) {}
});