
function getUrlParameter(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
}


$(document).ready(function() {
    // custom sorter
    // add parser through the tablesorter addParser method
    $.tablesorter.addParser({
        id: "money",
        is: function(s) {
            return false;
        },
        format: function(s) {
            // clean away HTML
            return $.tablesorter.formatFloat(s.replace(new RegExp(/USD|GBP|NOK|SEK|,/g), ""));
        },
        type: "numeric"
    });

    $(".sortable").addClass("tablesorter");
    $('th:contains(ownership)').addClass("{sorter: 'percent'}");
    $('th:contains(mill)').addClass("{sorter: 'money'}");
    $(".sortable").tablesorter();

    // shown before?
    showjulekort = $.cookie("julekort") == null || getUrlParameter("julekort") == "2009";

    if (showjulekort) {
        var options = { path: '/', expires: 340 };
        $.cookie("julekort", "julekort", options);
        if ($.browser.msie) {
            $(".julekort").colorbox({ width: "842px", height: "516px", iframe: true, open: true, scrolling: false, opacity: 0.8,
                onClosed: function() {

                    window.location = "http://www.argentum.no";
                }
            });
        }
        else {
            $(".julekort").colorbox({ width: "842px", height: "490px", iframe: true, open: true, scrolling: false, opacity: 0.8 });
        }
    }

    // quick fix for investor portal to remove "Main Page" from listing text
    $(".NewsListingItemText:contains(Main page)").each(function() {
        $(this).html($(this).html().replace(/Main page/ig, ""));
    });

//    var comment_title = "Test 123";

//    //debugger;
//    // Disqus:
//    $('#disqus_thread').disqus({
//        domain: 'argentum',
//        title: comment_title,
//        message: 'Comment Short description.',
//        developer: 1 // 0 if production.
//    });

});

