﻿Sys.Application.add_load(function() {




$(".tablesorter").tablesorter({ sortList: [[0, 0]] });
$('table.tablesorter tbody tr:odd').addClass('odd');
$('table.tablesorter tbody tr:even').addClass('even');

    var $form = $('#searchbox');


    $form.keypress(function(e) {
        if (e.which == 13 && e.target.type != 'textarea') {
            window.location = $form.attr('title') + "#&&q=" + URLEncode($form.val().toLowerCase(), 'æøå');
            return false;

        }
    });


    var $form404 = $('#searchbox404');


    $form404.keypress(function(e) {
        if (e.which == 13 && e.target.type != 'textarea') {
            window.location = $form404.attr('title') + "#&&q=" + URLEncode($form404.val().toLowerCase(), 'æøå');
            return false;

        }
    });    

    $(".autocomplete_theme").autocomplete("/ajax/autocomplete_theme.aspx");
    $(".autocomplete_headline").autocomplete("/ajax/autocomplete_headlines.aspx");



    if (window.location.href.indexOf("/en/") > 0) {
        $(".epostadresse").Watermark("Your e-mail");
        $("#searchbox").Watermark("Your query, then click enter");
    }
    else {
        $(".epostadresse").Watermark("Din e-postadresse");
        $("#searchbox").Watermark("Skriv søkeord og klikk enter");    
    }
    
    


    /*var max = 0;
    $(".xForm label").each(function() {
    if ($(this).width() > max)
    max = $(this).width();
    });
    $(".xForm label").width(max);*/

    $('input[type="text"]').addClass("txt");
    $('input[type="submit"]').addClass("button");

    /*var maxinput = 0;
    $(".xForm input[type='text'], .xForm textarea").each(function() {
    if ($(this).width() > maxinput)
    maxinput = $(this).width();
    });
    $(".xForm input[type='text'], .xForm textarea").width(maxinput);*/



});
