/**
 * 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/templates/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 file and external link tracking
 * @author Colm McBarron <colm.mcbarron@iqcontent.com>
 */
var hrefs = document.getElementsByTagName("a");
var link_path = "";
for (var l = 0; l < hrefs.length; l++) {
		try {
			var link_path = hrefs[l].pathname;
			if (location.host == hrefs[l].hostname) {
				if (link_path.match(/\.(doc|pdf|xls|ppt|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3)$/)) {
					addtrackerlistener(hrefs[l]);
				}
			} else {
				addtrackerlistener(hrefs[l]);
			}
		}
		catch(err) { }
}
function addtrackerlistener(obj) {
	if (obj.addEventListener) {
		obj.addEventListener('click', trackfiles, true);
	} else if (obj.attachEvent) {
		obj.attachEvent("on" + 'click', trackfiles);
	}
}
function trackfiles(array_element) {
	file_path = "";
	if (location.host != this.hostname) {
		file_path = "/exlinks/" + ((array_element.srcElement) ? "/" + array_element.srcElement.hostname : this.hostname);
	}
	file_path = file_path + ((array_element.srcElement) ? "/" + array_element.srcElement.pathname : this.pathname);
	urchinTracker(file_path);
}