﻿var ir = {};
var path = "";
ir.init = function (options) {
    var settings = { page: null, level: 0 };
    $.extend(settings, options);
    if (settings.level > 0) {path = "../";}
    $.ajax({
        success: function (html) {
            $("#toolbar .pageCenter").html(html);
            $("form").submit(function () { ir.search($("#searchTerm").val()); return false; });
            $("#search a").click(function () { ir.search($("#searchTerm").val()); });
            if (settings.page != null) {
                $("." + settings.page).addClass(settings.page + "Selected").removeClass(settings.page);
            }
        },
        url: path + "toolbar_a01.htm"
    });
    $.ajax({
        success: function (html) {
            $("#footer .pageCenter").html(html);
            $("#footer").after('<div class="dev">Web development by <a href="http://innovationroad.com">Innovation Road</a></div>');
        },
        url: path + "footer_a01.htm"
    });
};

ir.search = function () {
    window.location = path + "searchResults.htm?q=" + $("#searchTerm").val();
};

ir.displayFeed = function (data, container, showDescription, descriptionLength, maxEntries) {
    var d = $(data);
    var i = 0;
    splitDesc = function (d) {
        if (d.length > descriptionLength) {
            d = d.substring(0, descriptionLength + 1);
            d = d.substring(0, d.lastIndexOf(" "));
        }
        return d;
    };
    $(data).find("item").each(function () {
        if (i++ > maxEntries) {
            return;
        }
        var d = $(this);
        var html = '<li><a href="' + d.find("link").text() + '" >' +
            d.find("title").text() + '</a>' +
            (showDescription ? '<br/>' + splitDesc(d.find("description").text()) + '...' : '') +
            '<p>' + d.find("pubDate").text().substring(0, 16) + '</p></li>';
        container.append(html);
    });
};

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-16813255-1']);
_gaq.push(['_trackPageview']);

(function () {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})(); 




