/*
---------------------
** REQUIRES jQuery **
---------------------
	
includes scripts to:
+ add functionality to allow text boxes a default value that will be cleared on focus (ie. 'Search...')
+ equalize the heights of elements matching the given selector rules

*/

var hsrg = {
    searchDefault: 'Search...', // default value for search boxes if initialized

    documentExtensions: [".doc", ".docx", ".pdf", ".xls", ".xlsx"],

    initSearchText: function (selector, defValue) {
        // example selectors to pass in: .searchText, .sf_searchText
        if (selector === '') return;
        defValue = defValue || hsrg.searchDefault;

        $(selector)
            .focus(function () {
                $(this).attr({ value: '' });
            })
		    .blur(function () {
		        if ($(this).attr('value') == '') {
		            $(this).attr({ value: defValue });
		        }
		    })
		    .attr({ value: defValue });
    },

    initTrackingLinks: function (selectors) {
        $(selectors).each(function () {
            var href = $(this).attr("href");
            if (href.indexOf(window.location.hostname) !== -1 || href.match("^/") || !href.match("^http\://")) {
                var oThis = $(this);

                $(hsrg.documentExtensions).each(function () {
                    if (href.indexOf(this) !== -1) {
                        oThis.click(function () {
                            pageTracker._trackPageview(href);
                        });
                    }
                });
            }
        });
    }
};

function equalizeColumnSizes(c) {
    var o = $(c);
    
    var maxH = 0;

    o.each(function () {
        var panelH = $(this).height();
        maxH = panelH > maxH ? panelH : maxH;
    });

    o.each(function () {
        //$(this).height(maxH);
        $(this).css("min-height", maxH);
    });
}

function revisePagingLinks() {
    $('div.sf_pagerNumeric a').each(function () {
        var rootUrl = document.location.href;
        if (rootUrl.indexOf('?') > 0) {
            rootUrl = rootUrl.substring(0, rootUrl.indexOf('?'));
        }
        if (!rootUrl.match('/$')) {
            rootUrl = rootUrl + '/';
        }

        var href = $(this).attr('href');

        var queryString = href.substring(href.indexOf('?'));

        $(this).attr('href', rootUrl + queryString);
    });
}

// Notify the page ScriptManager that we're done loading
if (typeof (Sys) !== 'undefined') {
    Sys.Application.notifyScriptLoaded();
}
