$j(function () {

    //Søkefelt på søkeside (enter)
    $j('#googlesokeord').keyup(function (event) {
        if (event.keyCode == '13') {
            event.preventDefault();
            location.href = "/sok.aspx?q=" + this.value; // $j("#googlesokeord").attr("value");
            return false;
        }
    })

    //Søkeknapp på søkeside
    $j("#googlesubmit").click(function () {
        location.href = "/sok.aspx?q=" + $j("#googlesokeord").attr("value");
        return false;
    });

    //Søkefelt på søkeside (enter)
    $j('#searchboxmain').keyup(function (event) {
        if (this.value != this.defaultValue) {
            if (event.keyCode == '13') {
                event.preventDefault();
                location.href = "/sok.aspx?q=" + this.value; //$j("#searchboxmain").attr("value");
                return false;
            }
        }
    })
    //Søkefelt på toppmeny
    $j("#searchboxmain").click(function () {
        if (this.value == this.defaultValue) {
            this.select();
        }
    });

    //Søkeknapp på toppmeny
    $j("#searchbuttonmain").click(function () {
        location.href = "/sok.aspx?q=" + $j("#searchboxmain").attr("value");
        return false;
    });

    //Søkefelt på forhandlere
    $j("#sokeordDealers").click(function () {
        if (this.value == this.defaultValue) {
            this.select();
        }
    });

    //Søkefelt på forhandlere (enter)
    $j('#sokeordDealers').keyup(function (event) {
        if (event.keyCode == '13') {
            event.preventDefault();
            if (location.search.indexOf('p=1') != -1) {
                location.href = "/Toppmeny/Om Network Norway/Forhandlere.aspx?p=1&sokeord=" + this.value;
            }
            else {
                location.href = "/Toppmeny/Om Network Norway/Forhandlere.aspx?sokeord=" + this.value;
            }
            return false;
        }
    })

    //Søkeknapp på forhandlere
    $j("#sokeordsubmitDealers").click(function () {
        if (location.search.indexOf('p=1') != -1) {
            location.href = "/Toppmeny/Om Network Norway/Forhandlere.aspx?p=1&sokeord=" + $j("#sokeordDealers").attr("value");
        }
        else {
            location.href = "/Toppmeny/Om Network Norway/Forhandlere.aspx?sokeord=" + $j("#sokeordDealers").attr("value");
        }
        return false;
    });

    //Søkefelt på kundeservice (enter)
    $j('#sokeordQandA').keyup(function (event) {
        if (event.keyCode == '13') {
            event.preventDefault();
            location.href = "/Kundeservice/Sporsmal og svar.aspx?sokeord=" + this.value; //$j("#sokeordQandA").attr("value");
            return false;
        }
    })

    //Søkeknapp på kundeservice
    $j("#sokeordQandA").click(function () {
        //$j("#sokeordQandA").val("");
        if (this.value == this.defaultValue) {
            this.select();
        }
    });

    $j("#sokeordsubmitQandA").click(function () {
        location.href = "/Kundeservice/Sporsmal og svar.aspx?sokeord=" + $j("#sokeordQandA").attr("value");
        return false;
    });


    $j("#country-picker").change(function () {
        var pos = (location.href).indexOf('?', 0);
        var url = (location.href).substring(0, pos);
        var href = url + "?country=" + this.value;
        //alert(href);
        location.href = href;
        //location.href = $(this).val();
        return false;
    });

    $j("#mainServiceDL").each(function () {
        $j("#mainServiceDL dt a").click(function () {
            if ($j('#mainServiceDL').is('.detail-information-expanded')) {

                $j("#mainServiceDL").removeClass("detail-information-expanded");
                $j("#mainServiceDL").addClass("detail-information-collapsed");
            }
            else {
                $j("#mainServiceDL").removeClass("detail-information-collapsed");
                $j("#mainServiceDL").addClass("detail-information-expanded");

            }
            //$j("#mainServiceDD").toggle();
            return false;
        })
    });

    $j(function () {
        $j(".effect-button").each(function () { $j(this).etpButtonHover("effect-button-hover"); });
    });

    //    $j('#searchbox').keyup(function(event) {
    //        if (event.keyCode == '13') {
    //            event.preventDefault();
    //            location.href = "/sok.aspx?q=" + $j("#searchbox").attr("value");
    //            return false;
    //        }
    //    })
    //    
    //    $j("#searchboxfront").click(function() {
    //        if (this.value == this.defaultValue) {
    //            this.select();
    //        }
    //    });

    //    $j("#searchbutton").click(function() {
    //        location.href = "/sok.aspx?q=" + $j("#searchbox").attr("value");
    //        return false;
    //    });
    //    $j("#searchbuttonfront").click(function() {
    //        location.href = "/sok.aspx?q=" + $j("#searchboxfront").attr("value");
    //        return false;
    //    });

});


(function($) {

    var classToToggle = "c_bluebuttonhover";

    // Visitnorway, button - hover
    $.fn.etpButtonHover = function(className) {
        if (className) { classToToggle = className; }

        $(this)
      .mouseover(function() { $(this).etpToogleClass(classToToggle); })
      .mouseout(function() { $(this).etpToogleClass(classToToggle); });
    }

    $.fn.etpToogleClass = function(className) {
        if (className) { classToToggle = className; }
        $(this).toggleClass(classToToggle);
    }

    // IE6 - dropdown
    $.fn.etpIE6DropDownMenu = function() {
        $("ul > li", $(this)).each(function() {
            $(this)
      .mouseover(function() { $(this).addClass("sfhover"); })
      .mouseout(function() { $(this).removeClass("sfhover"); });
        });
    }

    $.fn.test = function() { alert("testfunc"); }

})(jQuery);


