var litium = {};

litium.templates = {
    include: (function() {
        var self = {};
        var defaults = { iframeHeight: '600px' };

        self.resize = function(iframe, iframeHeight) {
            try {
                iframe.style.height = iframe.contentWindow.document.body.scrollHeight + 'px';
            } catch (e) {
                iframe.style.height = iframeHeight;
            }
        };

        self.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 self;
    })(),

    framework: (function() {
        var self = {};

        self.init = function(options) {
            ///<summary>
            /// Initialises the links to order details.
            ///</summary>
            $(document).ready(function() {
                

                if ($.browser.msie) {
                    v = jQuery.browser.version.substr(0, 1);
                    if (v == "7" || v == "8") {
                        $(".box p:last-child").addClass('last-child');
                        $(".textholder p:last-child").addClass('last-child');
                    }
                    else if (v == "6") {
                        $(".box h2:first-child").addClass('first-child');
                        $(".box p:last-child").addClass('last-child');
                        $(".textholder h2:first-child").addClass('first-child');
                        $(".textholder p:last-child").addClass('last-child');
                    }
                };
                
                $("#footer .first, #footer .second, #footer .third").equalizeCols();

		(function initExternalLinks () {

                             var internalHostname = location.hostname.replace('www.', '');

                             $("a[href^=http]").each(function () {
                             	if (this.href.indexOf(internalHostname) === -1) { 
                                	$(this).click(function () {
                                        window.open(this.href);
                                        return false;
                                        });
                                }
                             });
}());


            });
        };

        return self;
    })()
};

