/// <reference path="jquery-vsdoc2.js" />
var litium = {};

litium.framework = {
	siteMenu: (function() {
		var that = {};
		var timer = null;
		var timeoutDelay = 1000;
		
		that.init = function() {
			$('#oursites').click(function() {
				$('#sites,#oursites').mouseenter(function() {
					if (timer !== null) {
						window.clearTimeout(timer);
					}
				}).mouseleave(function() {
					window.clearTimeout(timer);
					timer = window.setTimeout(function() {
						$('#sites').hide().unbind('mouseenter mouseleave');
						$('#oursites').unbind('mouseenter mouseleave');
					}, timeoutDelay);
				}).show();
				return false;
			});
		};

		return that;
	})()
};

litium.templates = {
	faqcategory: (function(litium) {
		var that = {};

		that.init = function(options) {
			$(document).ready(function() {
				$('ul.faqs h2 a').click(
				function() {
					var $this = $(this);
					$this.toggleClass('selected');
					$this.parents('.faqcontainer').find('.answer').slideToggle(200);
					return false;
				}
				);
			});
		};

		return that;
	})(),

	include: (function(litium) {
		var that = {};
		var defaults = { iframeHeight: '600px' };

		that.resize = function(iframe, iframeHeight) {
			try {
				iframe.style.height = iframe.contentWindow.document.body.scrollHeight + 'px';
			} catch (e) {
				iframe.style.height = iframeHeight;
			}
		};

		that.init = function(options) {
			///<summary>
			/// Initialises the resizing of iframes in the document.
			/// Parameters: options: { iframeHeight: height declaration, e.g. '600px' }
			///</summary>
			var i;
			var iframe;
			var iframes = document.getElementsByTagName('iframe');
			var settings = jQuery.extend({}, defaults, options);
			var onloadValue = 'litium.templates.include.resize(this, \'' + settings.iframeHeight + '\');'

			for (i = 0; iframe = iframes[i]; i++) {
				iframe.setAttribute('onload', onloadValue);
			}
		};

		return that;
	})()
};

