// Create Georgia Nicolson name space
var gn = function () {
	// Make archive lists expandable
	var prepArchive = function () {
		// Helper function to toggle hide class
		var toggle = function (elm) {
			elm.toggleClass('hide');
		};

		// Get archive elements
		var elms = $$('.archive');

		// Loop through archive elements
		elms.each(function (elm) {
			var o = elm.getElements('h3, h4'); // Get our openers

			o.each(function (o) {
				var oE = o.getParent();

				if (o.get('tag') === 'h4') {
					toggle(oE);
				}

				// Event Click: Call toggle helper passing the openers parent
				o.addEvent('click', toggle.pass(oE));
			});
		});
	};

	// Adds odd row striping
	var prepTable = function () {
		var tables = $$('table');

		tables.each(function (tbl) {
			tbl.getElements('tbody tr:nth-child(odd)').addClass('odd');
		});
	};

	// Prepare cufon fonts
	var prepCufon = function () {
		var elm = $$('h2',
			'.cta a',
			'#twitter p',
			'.galNav li a',
			'.extract h3',
			'.col.two .block.style2.media .item h3',
			'.meetChars .item h3',
			'.glossary .item h3',
			'#userBar ul li a',
			'#treatNav ul li a',
			'#content.treats #gallery h3',
			'.block.treatGallery .item h3'
		);
		elm.addClass('cufon');

		Cufon.replace(elm, {lineHeight: 1});
	};

	// Inject flash into cont
	var addFlash = function (cont, path, opt) {
		// Check to see if the user has flash
		if (Browser.Plugins.Flash.version > 6) {
			var swf = new Swiff(path, opt);

			cont.empty();

			swf.inject(cont);
		}
	};

	// Return public methods
	return {
		pA: prepArchive,
		pT: prepTable,
		pC: prepCufon,
		addFlash: addFlash
	}
}();

window.addEvent('domready', function() {
	gn.pA(); // Prepare Archive list
	gn.pT(); // Prepare tables
	gn.pC(); // Prepare cufon

	new LightBox();
});
