﻿function OxSearch(path) {
    var searchtext = $j("#searchtext").val();
    if (searchtext != "") {
        var redirectLocation = path + "?s=" + searchtext;
        window.location.href = redirectLocation;
    }
    return false;
}

// function to onload bind the searchtext input field to make a search on enter key
$j(function() {
    $j("#searchtext").keypress(function(e) {
        if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
            $j("#btnSearch").click();
            return false;
        } else {
            return true;
        }
    });
});

$j(document).ready(function () {
    $j('a.scbleml').each(function () {
        e = this.rel.replace('/', '@');
        this.href = 'mailto:' + e;
    });
    if ($j.getURLParam("s") != null) {
        $j('#container').highlight($j.getURLParam("s"));
    }
    var heightstSpot = 0;
    $j('.info-list-item strong').each(function () {
        if ($j(this).height() > heightstSpot)
            heightstSpot = $j(this).height();
    }
    );
    $j('.info-list-item strong').each(function () {
        $j(this).height(heightstSpot);
    }
    );
    if ($j('#webforms-success-message').text() != '') {
        $j('.column').html("<h1 class='title'>Tak for din henvendelse</h1><strong>" + $j('#webforms-success-message').text() + "</strong>");
        $j('#webforms-success-message').css("display", "none");
    }
    TopMenuPadding();

});

// iframe onload script
function iframonload(){
if($j("#iframe")) {
    $j("#iframe").attr('height', 600);
    }
}

function OnClientItemsRequesting(sender, eventArgs) {
    if (sender.get_text().length <= 2) {
        eventArgs.set_cancel(true);
    } else {
        var context = eventArgs.get_context();
        context["FilterString"] = eventArgs.get_text();
    }
}

function TopMenuPadding() {
    var contentArea = $j('#nav');
    $j('li strong', contentArea).each(function () {
        if ($j(this).height() < 43) {
            $j(this).css('paddingTop', (((43 - $j(this).height()) / 2))+"px" );
        }
        else { 
            $j(this).css('paddingTop', "0px");
        }
    })
}
