﻿
$(document).ready(function() {
    $(".textboxwrapper input").focus(function() { $(this).parents(".textboxwrapper").addClass("infocus"); });
    $(".textboxwrapper input").blur(function() { $(this).parents(".textboxwrapper").removeClass("infocus"); });
    $(".dropdownwrapper select").focus(function() { $(this).parents(".dropdownwrapper").addClass("infocus"); });
    $(".dropdownwrapper select").blur(function() { $(this).parents(".dropdownwrapper").removeClass("infocus"); });

    //Help(helparr);
    $("a[rel*=facebox]").facebox();
    PlusMinus();
    $("table.coltoggle").coltoggle();
    //Unique colorize
    var last = 0; var sec = 0;
    $(".unique-colorize tr:not(:first)").each(function(index) {
        var v = $($(this).find("td:first")).text();
        if (last != v) { last = v; if (sec == 0) { sec = 1; } else { sec = 0 } }; //Alt
        if (sec == 0) { $(this).css("background", "#DFDFDF"); } else { } //Colorize
    });

    //Marginal
    $(".pMar").keyup(function() {
        var buy = parseFloat($(".pIn").attr("value").replace(",", "."));
        var mar = parseFloat($(this).attr("value").replace(",", ".")) / 100;
        var p = (buy / (1 - mar)).toFixed(2) + "";
        p = p.replace(".", ",");
        $(".pOut").attr("value", p);
    });

    $(".datepicker").datepicker($.datepicker.regional['sv']);
    $('input[type="text"]').each(function(i, selected) {
        IterPopup(selected, i);
    });
    $('.checkbox').each(function(i, selected) {
        IterPopupCheckbox(selected, i);
    });
    $(".ActiveHelp-Button").click(function() {
        $(this).toggleClass("ActiveHelp-Button-On");
        $("form").toggleClass("helpactive");
    });
    //    if ($.browser.mozilla) {
    //        $(".articlegroupcomplete, .articlecomplete, .articlesapcomplete, .sapositioncomplete, .saarticlecomplete, .sareceivercomplete").keypress(AutoCompletePress);
    //    } else {
    //        $(".articlegroupcomplete, .articlecomplete, .articlesapcomplete, .sapositioncomplete, .saarticlecomplete, .sareceivercomplete").keydown(AutoCompletePress);
    //    };
    //    $(".articlegroupcomplete, .articlecomplete, .articlesapcomplete, .sapositioncomplete, .saarticlecomplete, .sareceivercomplete").after("<div style=\"clear:both\"></div><span class=\"completevalue\" style=\"display:none;\"></span><div class=\"completewrapper\"><div class=\"completeholder\" style=\"display:none;\"></div></div>")
    //    $(".articlegroupcomplete, .articlecomplete, .articlesapcomplete, .sapositioncomplete, .saarticlecomplete, .sareceivercomplete").attr("autocomplete", "off");
    //    $(".completeholder li").live("click", function() {
    //        SelectItem(this);
    //    });

    //    $(".completeholder li").live("mouseover", function() { $(".completeholder li").removeClass("active"); $(this).addClass("active"); });
    //    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(PostAjaxResponseHandler);
    //    Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(preCommitAutoGen);
    InitTextboxes();
    $(".saarticlecomplete").autocomplete({ url: function(q) {
        return "/bpo/misc/TypeComplete.ashx?TypeID=5&q=" + q;
    }
    });
    $(".sareceivercomplete").autocomplete({ url: function(q) {
        return "/bpo/misc/TypeComplete.ashx?TypeID=6&q=" + q;
    }
    });
    $(".sapositioncomplete").autocomplete({ url: function(q) {
        return "/bpo/misc/TypeComplete.ashx?TypeID=4&q=" + q;
    }
    });
    $(".articlecomplete").autocomplete({ url: function(q) {
        return "/bpo/misc/TypeComplete.ashx?TypeID=1&q=" + q;
    }
    });
    $(".articlesapcomplete").autocomplete({ url: function(q) {
        return "/bpo/misc/TypeComplete.ashx?TypeID=2&q=" + q;
    }
    });
    $(".articlegroupcomplete").autocomplete({ url: function(q) {
        return "/bpo/misc/TypeComplete.ashx?TypeID=3&q=" + q;
    }
    });
    $(".customercomplete").autocomplete({ url: function(q) {
        return "/bpo/misc/TypeComplete.ashx?TypeID=8&q=" + q;
    }
    });
    $(".autocompletepartner").autocomplete({ url: function(q) {
        return "/bpo/misc/TypeComplete.ashx?TypeID=9&q=" + q;
    }
    });
    $(".autocompletestorageuser").autocomplete({ url: function(q) {
        return "/bpo/misc/TypeComplete.ashx?TypeID=12&q=" + q;
    }
});
$(".autocompletetrsuser").autocomplete({ url: function(q) {
    return "/bpo/misc/TypeComplete.ashx?TypeID=13&q=" + q;
}
});
$(".autocompletetrsproj").autocomplete({ url: function(q) {
    return "/bpo/misc/TypeComplete.ashx?TypeID=14&q=" + q;
}
});

    $("ul.first-lvl li").click(function() {

        var $el = $("div#megamenu" + $(this).index());
        $el.siblings("div.megamenu").hide();
        $(this).siblings("li").removeClass("megamenu-arrow-marker");
        if ($el.is(":visible")) {
            $el.hide();
            $(this).removeClass("megamenu-arrow-marker");
            $("#MegaMenuClose").hide();
        } else {
            $el.show();
            $(this).addClass("megamenu-arrow-marker");
            $("#MegaMenuClose").show();
        }
    });

    $("ul.first-lvl li").mouseover(function() {
        $(this).addClass("topmenuhover");
    });

    $("ul.first-lvl li").mouseout(function() {
        $(this).removeClass("topmenuhover");
    });

    $("body").keypress(function(e) {
        if (e.keyCode == 27) {
            $("#navigation ul.first-lvl li").removeClass("megamenu-arrow-marker");
            $("div.megamenu").hide();
            $("#MegaMenuClose").hide();
        }
    });

    $("#MegaMenuClose").click(function() {
        $(this).hide();
        $("#navigation ul.first-lvl li").removeClass("megamenu-arrow-marker");
        $("div.megamenu").hide();
    });

    if (ie67()) {
        $('div.megamenu-footer').append('<span class="megamenu-ieold-close"><a href="javascript:;">X</a></span>');
        $('span.megamenu-ieold-close a').live("click", function() {
            $("div.megamenu").hide();
            $("#navigation ul.first-lvl li").removeClass("megamenu-arrow-marker");
        });
    }

    $('#extra .box_title .plusminus').live("click", function() {

        $(this).parents(".box").before('<div class="righttoggle"></div>');
        $(this).parents("#extra_padder").find(".box").hide();
    });

    $('#extra .righttoggle').live("click", function() {
        $(this).siblings('.box').show();
        $(this).remove();
    });

    if ($(".sales-support input.seacotxt").val() != '') {
        $(".sales-support .seacolbl").hide();
    }

    var seacoClicked = false;
    $(".sales-support .seacotxt, .sales-support .seacolbl").live("click", function() {
        $(".sales-support .seacolbl").hide();
        seacoClicked = true;
    });

    $("body").click(function() {
        if ($(".sales-support input.seacotxt").val() != undefined && $(".sales-support input.seacotxt").val().length == 0 && !seacoClicked) {
            $(".sales-support .seacolbl").show();
        }
        seacoClicked = false;
    });

    if (!ie67()) {
        $(".sales-support .tablesorter").tablesorter();
    }

    $(".sales-support .view-toggle .h").click(function() {
        if ($(this).next(".tggl").is(":visible")) {
            $($(this).next(".tggl")).hide();
            $(this).removeClass("vis").addClass("hid");

        } else {
            $($(this).next(".tggl")).slideDown();
            $(this).removeClass("hid").addClass("vis");
        }
    });

    $(".sales-support .company-classification .classification-add").live("click", function() {
        $(this).parents(".add").siblings(".toggle").show();
        $(this).hide();

        if ($(this).parents(".add").siblings(".toggle").prev().hasClass("alt") == false) {
            $(this).parents(".add").siblings(".toggle").addClass("alt");
        }
    });

    $(".sales-support .tabs .tab").click(function() {
        if (!$(this).hasClass("active")) {
            var tab = $(this).attr("class");
            tab = tab.replace("tab", "");
            tab = tab.replace(" ", "");
            $(this).parent().find(".tab").removeClass("active");
            $(".sales-support .tab-content .content").hide();
            $(".sales-support .tab-content ." + tab).show();
            $(this).addClass("active");
        }
    });

    $(".sales-support .tab-content .create-new").live("click", function() {

        var tab = $(this).parents(".content").attr("class").match(/tab(\d+)/)[1];

        if ($(this).parents(".sales-support").find(".tab-edit .edit").is(":visible")) {
            $(this).parents(".sales-support").find(".tab-edit .edit").hide();
            $(this).parents(".sales-support").find(".tab-edit .tab" + tab).show();
        }
        else {
            $(this).parents(".sales-support").find(".tab-edit .tab" + tab).slideDown();
        }

        $(this).parents(".sales-support").find(".tab-edit .tab" + tab).find("input[type=text]").val("");
        $(this).parents(".sales-support").find(".tab-edit .tab" + tab).find("textarea").val("");

    });

    $(".sales-support .tab-edit .close").live("click", function() {
        $(this).parents(".edit").slideUp();
    });

    $(".sales-support .table a.show").live("click", function() {
        $(this).siblings("span.show").show();
        $(this).hide();
    });

    $(".sales-support .table a.hide").live("click", function() {
        $(this).parents("span.show").hide();
        $(this).parents("td").find("a.show").show();
    });

    $(".sales-support .tab-edit .product-packages-show div input").live("click", function() {
        setTimeout(function() {
            $(this).attr("disabled", "disabled");
        }, 50);
    });

    $(".sales-support .company-list .close").live("click", function() {
        $(this).parents(".create").slideUp();
    });

    //    $(".sales-support .product-list-aspx .products .group span").click(function() {

    //        var group = $(this).parent().attr("class");
    //        group = group.replace("group", "");
    //        group = group.replace("active", "");
    //        group = group.replace(/^\s+|\s+$/g, "");

    //        $(this).parent().toggleClass("active");

    //        var $products = $(this).parent().siblings("." + group);

    //        if ($products.is(":visible")) {
    //            $products.hide();
    //        } else {
    //            $products.show();
    //        }

    //    });

    $(".sales-support .tab-content .prosp .expand").live("click", function() {
        $(this).parent().toggleClass("active");
        $(this).siblings(".unable-to-gain").toggle();
        var $toggleEl = $(this).parent().siblings(".item");
        if ($toggleEl.is(":visible")) {
            $toggleEl.hide();
        } else {
            $toggleEl.slideDown();
        }
    });

    $(".sales-support .tab-content .prosp .unable-to-gain .checkboxwrapper .chkUnableToGain input").live("click", function() {
        $(this).parents(".checkboxwrapper").siblings("div.save-button").toggle();
    });

    $(".sales-support .tab-edit .product-packages-show input.show").live("click", function() {
        $(this).hide();
        $(this).siblings("div").show();
    });



    $("div.sales-support div.tab-edit div.content a.DeletePrdPck").live("click", function() {
        if (confirm('Vill du ta bort produktpaketet?')) {
            $(this).siblings("input.btnDeleteProductPackage").click();
        }
    });




});

//Help msg
function IterPopup(selected, i) {

    var helpmsg = $(selected).attr("Title");
    if (!(helpmsg === undefined || helpmsg == "")) {
        $(selected).wrapAll("<div class=\"helpbox\">");
        $(selected).after("<div class=\"helpmsg\" id=\"helpmsg-" + i + "\" style=\"display:none\">" + helpmsg + "</div>");
        $(selected).focus(function() {
            if ($("form").hasClass("helpactive"))
                $("#helpmsg-" + i).fadeIn("fast", done);
        });

        $(selected).blur(function() {
            if ($("form").hasClass("helpactive"))
                $("#helpmsg-" + i).fadeOut("fast", done);
        });
    }
}
function IterPopupCheckbox(selected, i) {
    var helpmsg = $(selected).attr("Title");
    if (!(helpmsg === undefined || helpmsg == "")) {
        $(selected).wrapAll("<div class=\"helpbox\">");
        $(selected).after("<div class=\"helpmsg\" id=\"helpmsg-" + i + "\" style=\"display:none\">" + helpmsg + "</div>");
        $(selected).mouseenter(function() {
            if ($("form").hasClass("helpactive"))
                $("#helpmsg-" + i).fadeIn("fast", done);
        });

        $(selected).mouseleave(function() {
            if ($("form").hasClass("helpactive"))
                $("#helpmsg-" + i).fadeOut("fast", done);
        });
    }
}



function Help(arr) {
    $(".box .box_title span").each(function(i, selected) {
        var title = $(selected).text();

        for (var x = 0; x < arr.length; x++) {
            if (title == arr[x][0]) {
                var helptext = arr[x][1];
                var cssclass = "help" + (i + 1);
                $(selected).after('<span class="help" id="' + cssclass + '">?</span>');
                $("#" + cssclass).click(function() { jQuery.facebox('<h4>' + title + '</h4>' + helptext + '<br />'); });
            }
        }
    });
}

function prev(a) {
    var html = $(a).val();
    jQuery.facebox(html);
}



function PlusMinus(arr) {
    $(".box .box_title").append('<span class="plusminus ui-icon ui-icon-plusthick"></span>');

    $("#content .box .box_title").click(function() {
        $(this).find(".plusminus").toggleClass("ui-icon-minusthick");
        $(this).parents(".box:first").find(".box_content").toggle();
    });
    $(".defaulthidden .box_content").toggle();

}
var __defaultFired = false;

function WebForm_FireDefaultButton(event, target) {
    var element = event.target || event.srcElement;

    if (!__defaultFired && event.keyCode == 13 && !(element && (element.tagName.toLowerCase() == "textarea"))) {
        var defaultButton;

        if (__nonMSDOMBrowser)
            defaultButton = document.getElementById(target);
        else
            defaultButton = document.all[target];

        if (defaultButton) {
            if (typeof (defaultButton.click) != "undefined")
                defaultButton.click();
            else
                eval(unescape(defaultButton.href.replace("javascript:", "")));

            event.cancelBubble = true;

            if (event.stopPropagation) event.stopPropagation();
            return false;
        }
    }
    return true;
}


function preCommitAutoGen() {
    $('input[type="text"].autogen').each(function() {
    if (this.value == $(this).attr('Message') || $(this).hasClass("text-label-grey")) {
            this.value = '';
        }
    });
}

// Mark fields with autogen
function InitTextboxes() {
    $('input[type="text"].autogen').each(function() {

        if (this.value == '' || this.value == $(this).attr('Message')) {
            this.value = $(this).attr('Message');
            $(this).addClass('text-label-grey');
        }
        $(this).focus(function() {
            if (this.value == $(this).attr('Message')) {
                this.value = '';
                $(this).removeClass('text-label-grey');
            }
        });

        $(this).blur(function() {
            if (this.value == '') {
                this.value = $(this).attr('Message');
                $(this).addClass('text-label-grey');
            }
        });
    });
    $('input[type="text"].textbox').each(function() {

        //        if ($(this).attr('title') != '')
        //            $(this).after('<div class="helpmessage" style="display:none">' + $(this).attr('title') + '</div>');
        //        
        //        $(this).focus(function() {
        //            $(this).parent().find('div.helpmessage').slideDown("fast", done);
        //        });

        //        $(this).blur(function() {
        //            $(this).parent().find('div.helpmessage').slideUp("fast", done);
        //        });

});
    
    

}
function preCommitAutoComplete() {
}
//    $(".completevalue").each(function() {
//        if ($(this).text() != "")
//            $(this).siblings("input").val($(this).html());
//    });
//}
//function PostAjaxResponseHandler(sender, args) {
//    $(".articlegroupcomplete, .articlecomplete, .articlesapcomplete, .sapositioncomplete, .saarticlecomplete, .sareceivercomplete").val('').removeClass('correct');
//    $(".articlegroupcomplete, .articlecomplete, .articlesapcomplete, .sapositioncomplete, .saarticlecomplete, .sareceivercomplete").siblings(".completevalue").remove();
//    $(".articlegroupcomplete, .articlecomplete, .articlesapcomplete, .sapositioncomplete, .saarticlecomplete, .sareceivercomplete").siblings(".completewrapper").remove();
//    $(".articlegroupcomplete, .articlecomplete, .articlesapcomplete, .sapositioncomplete, .saarticlecomplete, .sareceivercomplete").after("<span class=\"completevalue\" style=\"display:none;\"></span><div class=\"completewrapper\"><div class=\"completeholder\" style=\"display:none;\"></div></div>");
//    if ($.browser.mozilla) {
//        $(".articlegroupcomplete, .articlecomplete, .articlesapcomplete, .sapositioncomplete, .saarticlecomplete, .sareceivercomplete").keypress(AutoCompletePress);
//    } else {
//        $(".articlegroupcomplete, .articlecomplete, .articlesapcomplete, .sapositioncomplete, .saarticlecomplete, .sareceivercomplete").keydown(AutoCompletePress);
//    };
//    $(".iframe iframe", parent.document.body).height($(document.body).height());

//}
function preCustomCommitScript() {

}

function ie67() {
    if (!$.browser.msie) { return false;}
    else if ($.browser.version.slice(0, 2) != "7." && $.browser.version.slice(0, 3) != "6.") { return false; }
    return true;
}


function CancelPostBack() {

    var objMan = Sys.WebForms.PageRequestManager.getInstance();

    if (objMan.get_isInAsyncPostBack())

        objMan.abortPostBack();
}

(function($) {
    $.fn.autocomplete = function(acOptions) {
        // support mutltiple elements
        if (this.length > 1) {
            this.each(function() { $(this).autocomplete(acOptions) });
            return this;
        }

        // SETUP private variabls;
        var actxt = this;
        var a = -1;
        var cwrapper = null;
        var btndd = null;
        var selected = false;
        // setup options
        var defaultOptions = {
            debug: false
        };
        var onchange = function() { };
        var options = $.extend({}, defaultOptions, acOptions);

        // SETUP private functions;
        var intialize = function() {
            if ($.browser.mozilla) {
                actxt.keypress(keydownaction);
            } else {
                actxt.keydown(keydownaction);
            };
            actxt.keyup(keyupaction);
            actxt.wrap("<div class=\"completewrapper\"/>");
            cwrapper = actxt.parent();
            actxt.after("<div style=\"clear:both\"></div><span class=\"completevalue\" style=\"display:none;\"></span>");
            $("<div class=\"completeholder\" style=\"display:none;\"></div>").insertAfter(actxt);
            btndd = $("<div class=\"list\"><div class=\"innerlist\"></div></div>").insertBefore(actxt).find(".innerlist");
            btndd.click(defaultlist);

            actxt.attr("autocomplete", "off");
            if (typeof (actxt.attr("onchange")) != "undefined") {
                onchange = actxt.attr("onchange");
                actxt.attr("onchange", "");
            }
            return actxt;
        };


        var SelectItem = function(it) {
            var tb = $(it).parents("div.completewrapper").children("input[type=text]");
            var display = $(it).children("span.display").text();
            var compval = $(it).children("span.value").html();
            if (compval === undefined) {
                tb.val(display);
                compval = $(it).children("span.display").html();
            } else {
                tb.val("<" + compval + "> " + display);
            }
            tb.focus();
            $(it).parents("div.completewrapper").children(".completevalue").html(compval);
            tb.addClass("correct");
            $(".completeholder").html('');
            $(".completeholder").hide();
        };

        var keydownaction = function(e) {
            switch (e.keyCode) {
                case 40:
                    e.preventDefault();
                    a++;
                    if (a >= cwrapper.find(".completeholder li").size())
                        a = 0;
                    cwrapper.find(".completeholder li").removeClass("active");
                    cwrapper.find(".completeholder li:eq(" + a + ")").addClass("active");
                    return false;
                case 38:
                    e.preventDefault();
                    a--;
                    if (a < 0)
                        a = cwrapper.find(".completeholder li").size() - 1;
                    cwrapper.find(".completeholder li").removeClass("active");
                    cwrapper.find(".completeholder li:eq(" + a + ")").addClass("active");
                    return false;
                case 13:
                    e.preventDefault();
                    var it = cwrapper.find(".completeholder li.active");
                    if (it.size() != 0) {
                        SelectItem(it);
                         eval(onchange);
                    }
                    return false;
                default:
            }
            return true;
        }
        var keyupaction = function(e) {
            switch (e.keyCode) {
                case 40:
                case 38:
                case 13:
                    break;
                default:
                    var q = $(this).val();
                    q = q.replace(/<[\d\w\-\.]+>/, "");
                    var h = cwrapper.children(".completeholder");
                    if (q.length > 2) {
                        doquery(q);
                    } else {
                        h.html('');
                        h.hide();
                    }
            }
            return true;
        }

        var defaultlist = function(e) {
            var h = cwrapper.children(".completeholder");
            if (h.is(":visible"))
                h.hide();
            else
                doquery("");
        }

        var doquery = function(q) {
            actxt.removeClass("correct");
            var h = cwrapper.children(".completeholder");

            $.get(options.url.call(actxt, encodeURI(q)), null,
    function(html) {
        a = -1;
        if (html == "") {
            h.html("<ul><li class=\"noresult\">0 träffar<li></ul>");
        } else {
            h.html(html);
            h.find("li")
          .click(function() { SelectItem(this); eval(onchange); })
          .mouseover(function() { $(this).siblings().removeClass("active"); $(this).addClass("active"); });

            //var e = new Object(); e.keyCode = 13; e.target = actxt;e.srcElement = actxt; actxt.attr("onkeypress")(e);
        }
        //console.log($(window).height() - actxt.offset().top);
        h.show();
        if ($(window).height() - actxt.offset().top < 350) {
            h.addClass("acbottomup");
            h.children("ul").position({ of: actxt, my: "left bottom", at: "left top" });
        }
    }, "html");

        }
        // PUBLIC functions
        //  this.keydownaction = function() {
        //    // change Tab
        //  };

        return intialize();
    }
})(jQuery);

(function($) {

    $.fn.coltoggle = function(options) {

        var settings = {
            'createTdClassIfMissing': false
        };

        return this.each(function() {

            if ($(this).data("coltoggle")) {
                return;
            }

            $(this).data("coltoggle", true);

            if (options) {
                $.extend(settings, options);
            }

            var $me = $(this);
            var html = '<div class="coltoggle">';

            if (settings.createTdClassIfMissing && !$me.find("td:first").hasClass("ct0")) {
                $me.find("tbody tr").each(function() {
                    $(this).children("td").each(function(i) {
                        $(this).addClass("ct" + i);
                    });
                });
            }

            if ($me.find("thead th").length != $me.find("tbody tr:first").children().length || !$me.find("td:first").hasClass("ct0")) {
                $me.before(html);
                return;
            }

            $me.find("th").each(function(i) {
                if (!$(this).hasClass("coltoggle-exclude")) { // Sätt klass 'coltoggle-exclude' på <th> som inte ska vara valbar.
                    if ($(this).hasClass("coltoggle-unchecked")) { // Sätt klass 'coltoggle-unchecked' på <th> för kolumner som inte ska visas från start.
                        html += '<span><input type="checkbox" id="coltoggle-cb' + i + '" /><label for="coltoggle-cb' + i + '">' + $(this).text() + '</label></span>';
                        $(this).hide();
                        $me.find("td.ct" + i).hide();
                    } else {
                        html += '<span><input type="checkbox" id="coltoggle-cb' + i + '" checked="checked" /><label for="coltoggle-cb' + i + '">' + $(this).text() + '</label></span>';
                    }
                }
            });

            $(this).before(html + '</div>');

            $me.siblings("div.coltoggle").find("input[type=checkbox]").click(function() {
                var th = null;
                var thIndex = null;
                var checkboxText = $(this).parent().text();
                $me.find("th").each(function(i) {
                    if ($(this).text() == checkboxText) {
                        th = $(this);
                        thIndex = i;
                    }
                });

                if ($(this).is(":checked")) {
                    $(th).show();
                    $me.find("td.ct" + thIndex).show();
                } else {
                    $(th).hide();
                    $me.find("td.ct" + thIndex).hide();
                }

            });


        });

    };
})(jQuery);

(function($) {

    $.fn.cphSearch = function(options) {

        var settings = {
            'searchText': 'Sök'
        };

        return this.each(function() {

            if ($(this).data("cphSearch")) {
                return;
            }

            $(this).data("cphSearch", true);

            if (options) {
                $.extend(settings, options);
            }

            var m = $(this);

            if (isDefault()) {
                m.val(settings.searchText);
                m.addClass("cphSearch-st");
            }

            m.focus(function() { if (isDefault()) { m.val(""); m.removeClass("cphSearch-st"); } });
            m.blur(function() {
                if (isDefault()) {
                    m.val(settings.searchText);
                    m.addClass("cphSearch-st");
                }
            });

            function isDefault() {
                return (m.val() == '' || m.val() == settings.searchText);
            }
        });

    };
})(jQuery);
