// used to warn the user about possible XSS problems
// don't worry, we're checking on the server as well (using the build-in ASP.NET validate request), but this helps the user experience
$(document).ready(function () {
    $("form").submit(function () {
        var result = true;
        var control;

        $("input").each(function (i, val) {
            var m = mayContainXss($(val).val());
            if (m)
                control = $(val);
            result = result && !m;
        });
        $("textarea").each(function (i, val) {
            var m = mayContainXss($(val).val());
            if (m)
                control = $(val);
            result = result && !m;
        });

        if (!result) {
            control.addClass("epunkt-error").focus();
            $("<div>Please check your input in the marked control and remove special characters like < or >.</div>")
                .dialog({
                    modal: true,
                    autoOpen: true,
                    width: 400,
                    resizable: false,
                    buttons: {
                        "OK": function () {
                            $(this).dialog("close").dialog("destroy");
                        }
                    }
                });
        }

        return result;
    });
});

function mayContainXss(text) {
    var r = new RegExp("<[a-zA-Z]", "i");
    return r.test(text);
}  


function Dialog(control, width, height, okCallback) {
    HideDropDowns();
    $(control)
        .show()
        .dialog({
            modal: true,
            width: width,
            height: height,
            resizable: false,
            close: function() {
                $(this).dialog("destroy");
                ShowDropDowns()
            },
            buttons: {
                "Save": function() {
                    ShowDropDowns();
                    okCallback();
                    $(this).dialog("close");
                }
            }
        });
}

function DialogWithoutButtons(control, width, height) {
    HideDropDowns();
    $(control)
        .show()
        .dialog({
            modal: true,
            width: width,
            height: height,
            resizable: false,
            close: function() {
                $(this).dialog("destroy");
                ShowDropDowns()
            }
        });
}

function Message(message, redirectUrl) {
    HideDropDowns();
    $("<div title='&nbsp;'>" + message + "</div>")
        .appendTo("body")
        .dialog({
            modal: true,
            overlay: {
                opacity: 0.9,
                background: "white"
            },
            width: 770,
            height: 130,
            resizable: false,
            close: function() {
                $(this).dialog("destroy");
                ShowDropDowns()
            },         
            buttons: {
                "Next": function() {
                    $(this).dialog("close");
                    if (redirectUrl)
                        location = redirectUrl;
                }
            }
        });
}

function ConfirmMessage(okCallback) {
    HideDropDowns();
    $("<div title='&nbsp;'>Are you sure you want to proceed?</div>")
        .appendTo("body")
        .dialog({
            modal: true,
            height: 115,
            resizable: false,
            close: function() {
                $(this).dialog("destroy");
                ShowDropDowns()
            },
            buttons: {
                "Yes, proceed": function() {
                    $(this).dialog("close");
                    okCallback();
                },
                "No": function() {
                    $(this).dialog("close");
                }
            }
        });
}

function DatePicker(control) {
    var culture = "en";
    culture = culture == "en" ? "" : culture;
    $.datepicker.setDefaults($.datepicker.regional[culture]);
    
    $(control).datepicker({
        dateFormat: "yy-mm-dd",
        yearRange: "c-100:c+0",
        changeMonth: true,
		changeYear: true
    });

    //this is a fix for the jquery datepicker, because the proper class won't be added otherwise 
    $("#ui-datepicker-div").addClass("ui-datepicker-div");
}

function ReplaceBreaksWithCrlf(text) {
    if (!text)
        return "";
    while (text.indexOf("<br />", 0) >= 0)
        text = text.replace("<br />", "\r\n");
    return text;
}

function HideDropDowns() {
    if ($.browser.msie && $.browser.version < 7)
        $(".hide-dropdown").hide();
}

function ShowDropDowns() {
    if ($.browser.msie && $.browser.version < 7)
        $(".hide-dropdown").show();
}

function MaxLength(textarea, maxLength) {
    var divId = "___MaxLength";

    $(textarea).blur(function() {
        $("#" + divId).remove();
    });
    
    $(textarea).focus(function() {
        var left = $(textarea).offset().left;
        var top = $(textarea).offset().top;        
                
        $("<div>")
            .attr("id", divId)
            .addClass("epunkt-grid-item")
		    .css({
			    position: "absolute",
			    left: left,
			    top: top,
			    width: 150,
			    zIndex: 99999
		    })
		    .hide()
		    .html($(textarea).val().length + "/" + maxLength + " Characters.")
		    .appendTo("body")
		    .show()
		    .css({
		        top: top - $("#" + divId).height()
		    });
    });

    $(textarea).keyup(function() {
        $("#" + divId)
            .html($(textarea).val().length + "/" + maxLength + " Characters.");
    });
    
    $(textarea).keydown(function(evnt) {
        if (evnt.keyCode == 8 || evnt.keyCode == 46 || evnt.keyCode == 37 || evnt.keyCode == 39 || evnt.keyCode == 38 || evnt.keyCode == 40) //we still allow Backspace, Del and the Cursors.
            return true;
        if ($(textarea).val().length >= maxLength)
            return false;
    });    
}


(function($) {
    $.fn.maxLen = function(maxLength) {

        $(this).each(function() {
            var divId = "___maxLength";

            $(this).attr("maxlength", maxLength);

            $(this).blur(function() {
                $("#" + divId).remove();
            });

            $(this).focus(function() {
                var left = $(this).offset().left;
                var top = $(this).offset().top - 14;

                $("<div>")
                    .attr("id", divId)
                    .addClass("epunkt-grid-item")
                    .css({
                            position: "absolute",
                            left: left,
                            top: top,
                            width: 100,
                            zIndex: 99999
                        })
                    .hide()
                    .appendTo("body")
                    .show();

                $(this).keyup();
            });

            $(this).keyup(function() {
                $("#" + divId).html($(this).val().length + "/" + maxLength + " Characters.");
            });
        });
    };
})(jQuery);


(function ($) {
    $.fn.bubble = function(text, width) {
        if (!text)
            text = "nbsp;";
        if (!width)
            width = 200;

        $(this).css("cursor", "help");

        $(this).hover(function() {
            var left = $(this).offset().left;
            var top = $(this).offset().top + 25;

            if (left + 10 + width > $(document).width())
                left = $(document).width() - 10 - width;

            $("#_____bubble").remove();
            $("<div>")
                .attr("id", "_____bubble")
                .addClass("epunkt-hover-box")
                .css({
                        position: "absolute",
                        left: left,
                        top: top,
                        width: width,
                        zIndex: 99999
                    })
                .html(text)
                .hide()
                .appendTo("body")
                .fadeIn(100);
        }, function() {
            $("#_____bubble")
                .fadeOut(100);
        });

        return $(this);
    };
})(jQuery);


(function ($) {
    $.fn.watermark = function(text) {

        var textbox = $(this);

        textbox.blur(function() {
            if (textbox.val() == "")
                textbox.val(text).addClass("epunkt-watermark");
        });

        textbox.click(function() {
            if (textbox.val() == text)
                textbox.val("").removeClass("epunkt-watermark");
        });

        $(document).ready(function() {
            if (textbox.val() == "")
                textbox.val(text).addClass("epunkt-watermark");
        });

        return textbox;
    };
})(jQuery);

(function($) {
    $.fn.autoComplete = function(options) {
        var defaults = {
            seperator: null,
            cssClassItems: "epunkt-autocomplete-items",
            cssClassItem: "epunkt-autocomplete-item",
            cssClassItemHover: "epunkt-autocomplete-item-hover",
            triggerEnterOnClick: false
        };
        options = $.extend(defaults, options);
        if (options.method == null)
            return $(this);

        var cache = null;
        var cacheIsBeeingFilled = false;
        var selectedIndex = -1;
        var lastTextbox = null; //we use these variables or the ajax-callback-method would need a lot more parameters
        var lastText = null;

        function GetId() {
            return "___autoComplete";
        }

        function GetItemId(index) {
            return "___autoComplete_" + index;
        }

        function Remove() {
            $("#" + GetId()).remove();
            selectedIndex = -1;
        }

        function RenderItems(textbox, text) {
            var html = "";

            var filtered = new Array();
            $.each(cache, function(i, tag) {
                if (i <= 20 && tag.toLowerCase().indexOf(text.toLowerCase(), 0) >= 0)
                    filtered.push(tag);
            });

            $.each(filtered, function(i, tag) {
                var highlightedText = tag.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + text.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<b>$1</b>");
                html += "<div title='" + tag + "' class='" + options.cssClassItem + "' id='" + GetItemId(i) + "'>" + highlightedText + "</div>";
            });

            if (html == "")
                Remove();
            else
                $("#" + GetId())
                            .html(html)
                            .css({
                                top: (textbox.offset().top + textbox.height() + 3) + "px",
                                left: (textbox.offset().left) + "px",
                                width: (textbox.width() + 4) + "px"
                            })
                            .show();

            $.each(filtered, function(i, tag) {
                $("#" + GetItemId(i)).click(function(evnt) {
                    AddText(textbox, tag, options.triggerEnterOnClick);
                });
            });
        }

        function AddText(textbox, tag, triggerEnter) {
            var existingText = textbox.val();

            if (options.seperator != null && options.seperator != "" && existingText.lastIndexOf(options.seperator) >= 0)
                existingText = existingText.substring(0, existingText.lastIndexOf(options.seperator)) + options.seperator + " ";
            else
                existingText = "";
            textbox.val(existingText + tag);
            textbox.focus();

            if (triggerEnter)
                textbox.trigger("keyup", [{
                    preventDefault: function() { },
                    keyCode: 13
}]);
        }

        function SelectItem(textbox) {
            $("." + options.cssClassItemHover).removeClass(options.cssClassItemHover);
            var selectedItem = $("#" + GetItemId(selectedIndex));
            selectedItem.addClass(options.cssClassItemHover);
            AddText(textbox, selectedItem.attr("title"), false);
        }

        function SetCache(items) {
            cache = new Array();
            $.each(items, function(i, val) {
                cache.push(val);
            });
            cacheIsBeeingFilled = false;
            RenderItems(lastTextbox, lastText);
        }

        return this.each(function() {
            var textbox = $(this);
            textbox.attr("autocomplete", "off");

            textbox.keydown(function(event) {
                if (event.which == 13 || event.which == 9) { //ENTER, TAB
                    if ($("#" + GetId(selectedIndex)).length > 0) {
                        textbox.val(textbox.val() + options.seperator + " ");
                        setTimeout("$('#" + textbox.attr("id") + "').focus();", 50);
                    }
                    Remove();
                }
            });

            textbox.keyup(function(event) {
                var text = textbox.val();
                if (options.seperator != null && options.seperator != "")
                    if (text.lastIndexOf(options.seperator) >= 0)
                    text = text.substring(text.lastIndexOf(options.seperator) + 1);
                text = $.trim(text);

                if (event.which == 8) //backspace clears the cache
                    cache = null;

                if (text.length > 1) {
                    if ($("#" + GetId()).length <= 0) {
                        $("<div />")
                                    .attr("id", GetId())
                                    .addClass(options.cssClassItems)
                                    .hide()
                                    .css({
                                        top: (textbox.offset().top + textbox.height() + 3) + "px",
                                        left: (textbox.offset().left) + "px",
                                        width: (textbox.width() + 4) + "px",
                                        position: "absolute",
                                        zIndex: 9999
                                    })
                                    .insertAfter(textbox)
                    }


                    $(document).click(function() {
                        Remove();
                    });
                    $(window).resize(function() {
                        $(document).click();
                    });

                    if (event.which == 40 || event.which == 38) {
                        if (event.which == 38) //KEYUP
                            selectedIndex--;
                        else if (event.which == 40) //KEYDOWN
                            selectedIndex++;

                        if (selectedIndex < 0 || $("#" + GetId(selectedIndex)).length <= 0)
                            selectedIndex = 0;

                        SelectItem(textbox);
                    }
                    else if (event.which == 37 || event.wich == 39) { //KEYLEFT, KEYRIGHT
                        //do nothing here
                    }
                    else {
                        if (cache==null && !cacheIsBeeingFilled) {
                            cacheIsBeeingFilled = true;
                            lastTextbox = textbox;
                            lastText = text;
                            var textToSuggestFor = text;
                            while (textToSuggestFor.indexOf("/") >= 0)
                                textToSuggestFor = textToSuggestFor.replace("/", "");
                            options.method(textToSuggestFor, SetCache);
                        }
                        else if (cache)
                            RenderItems(textbox, text);
                    }
                }
                else {
                    Remove();
                }
            });

        });
    }
})(jQuery);
(function ($) {
    $.fn.feedbackDialog = function () {
        var link = $(this);

        var dialog = $("#feedbackDialog");
        var confirmationDialog = $("#feedbackConfirmationDialog");

        var confirmationButtons = {};
        confirmationButtons[confirmationDialog.data("buttontext")] = function () {
            confirmationDialog.dialog("close");
        };

        var buttons = {};
        buttons[dialog.data("buttontext")] = function () {
            var text = dialog.find("#feedback").val();
            var email = dialog.find("#email").val();
            var url = window.location.href;

            dialog.next().hide(); //hide the button

            $.ajax({
                url: dialog.data("posturl"),
                type: "POST",
                data: { url: url, feedback: text, email: email, calledViaJavaScript: true },
                success: function () {
                    dialog.next().show();
                    dialog.dialog("close");
                    confirmationDialog.dialog("open");
                }
            });
        };

        dialog.dialog({
            autoOpen: false,
            modal: true,
            resizable: false,
            width: 600,
            buttons: buttons
        });

        confirmationDialog.dialog({
            autoOpen: false,
            modal: true,
            resizable: false,
            width: 600,
            buttons: confirmationButtons
        });

        link.attr("href", "javascript:void(0);").click(function () {
            dialog.dialog("open");
        });

        return link;
    };
})(jQuery);
var hasFlash = function() { var a = 6; if (navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.indexOf("Windows") > -1) { document.write('<script language="VBScript"\> \non error resume next \nhasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & ' + a + '))) \n</script\> \n'); if (window.hasFlash != null) return window.hasFlash } if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) { var b = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description; return parseInt(b.charAt(b.indexOf(".") - 1)) >= a } return false } (); String.prototype.normalize = function() { return this.replace(/\s+/g, " ") }; if (Array.prototype.push == null) { Array.prototype.push = function() { var i = 0, a = this.length, b = arguments.length; while (i < b) { this[a++] = arguments[i++] } return this.length } } if (!Function.prototype.apply) { Function.prototype.apply = function(a, b) { var c = []; var d, e; if (!a) a = window; if (!b) b = []; for (var i = 0; i < b.length; i++) { c[i] = "b[" + i + "]" } e = "a.__applyTemp__(" + c.join(",") + ");"; a.__applyTemp__ = this; d = eval(e); a.__applyTemp__ = null; return d } } function named(a) { return new named.Arguments(a) } named.Arguments = function(a) { this.oArgs = a }; named.Arguments.prototype.constructor = named.Arguments; named.extract = function(a, b) { var c, d; var i = a.length; while (i--) { d = a[i]; if (d != null && d.constructor != null && d.constructor == named.Arguments) { c = a[i].oArgs; break } } if (c == null) return; for (e in c) if (b[e] != null) b[e](c[e]); return }; var parseSelector = function() { var a = /^([^#.>`]*)(#|\.|\>|\`)(.+)$/; function r(s, t) { var u = s.split(/\s*\,\s*/); var v = []; for (var i = 0; i < u.length; i++) v = v.concat(b(u[i], t)); return v } function b(c, d, e) { c = c.normalize().replace(" ", "`"); var f = c.match(a); var g, h, i, j, k, n; var l = []; if (f == null) f = [c, c]; if (f[1] == "") f[1] = "*"; if (e == null) e = "`"; if (d == null) d = document; switch (f[2]) { case "#": k = f[3].match(a); if (k == null) k = [null, f[3]]; g = document.getElementById(k[1]); if (g == null || (f[1] != "*" && !o(g, f[1]))) return l; if (k.length == 2) { l.push(g); return l } return b(k[3], g, k[2]); case ".": if (e != ">") h = m(d, f[1]); else h = d.childNodes; for (i = 0, n = h.length; i < n; i++) { g = h[i]; if (g.nodeType != 1) continue; k = f[3].match(a); if (k != null) { if (g.className == null || g.className.match("\\b" + k[1] + "\\b") == null) continue; j = b(k[3], g, k[2]); l = l.concat(j) } else if (g.className != null && g.className.match("\\b" + f[3] + "\\b") != null) l.push(g) } return l; case ">": if (e != ">") h = m(d, f[1]); else h = d.childNodes; for (i = 0, n = h.length; i < n; i++) { g = h[i]; if (g.nodeType != 1) continue; if (!o(g, f[1])) continue; j = b(f[3], g, ">"); l = l.concat(j) } return l; case "`": h = m(d, f[1]); for (i = 0, n = h.length; i < n; i++) { g = h[i]; j = b(f[3], g, "`"); l = l.concat(j) } return l; default: if (e != ">") h = m(d, f[1]); else h = d.childNodes; for (i = 0, n = h.length; i < n; i++) { g = h[i]; if (g.nodeType != 1) continue; if (!o(g, f[1])) continue; l.push(g) } return l } } function m(d, o) { if (o == "*" && d.all != null) return d.all; return d.getElementsByTagName(o) } function o(p, q) { return q == "*" ? true : p.nodeName.toLowerCase().replace("html:", "") == q.toLowerCase() } return r } (); var sIFR = function() { var a = "http://www.w3.org/1999/xhtml"; var b = false; var c = false; var d; var ah = []; var al = document; var ak = al.documentElement; var am = window; var au = al.addEventListener; var av = am.addEventListener; var f = function() { var g = navigator.userAgent.toLowerCase(); var f = { a: g.indexOf("applewebkit") > -1, b: g.indexOf("safari") > -1, c: navigator.product != null && navigator.product.toLowerCase().indexOf("konqueror") > -1, d: g.indexOf("opera") > -1, e: al.contentType != null && al.contentType.indexOf("xml") > -1, f: true, g: true, h: null, i: null, j: null, k: null }; f.l = f.a || f.c; f.m = !f.a && navigator.product != null && navigator.product.toLowerCase() == "gecko"; if (f.m) f.j = new Number(g.match(/.*gecko\/(\d{8}).*/)[1]); f.n = g.indexOf("msie") > -1 && !f.d && !f.l && !f.m; f.o = f.n && g.match(/.*mac.*/) != null; if (f.d) f.i = new Number(g.match(/.*opera(\s|\/)(\d+\.\d+)/)[2]); if (f.n || (f.d && f.i < 7.6)) f.g = false; if (f.a) f.k = new Number(g.match(/.*applewebkit\/(\d+).*/)[1]); if (am.hasFlash && (!f.n || f.o)) { var aj = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description; f.h = parseInt(aj.charAt(aj.indexOf(".") - 1)) } if (g.match(/.*(windows|mac).*/) == null || f.o || f.c || (f.d && (g.match(/.*mac.*/) != null || f.i < 7.6)) || (f.b && f.h < 7) || (!f.b && f.a && f.k < 124) || (f.m && f.j < 20020523)) f.f = false; if (!f.o && !f.m && al.createElementNS) try { al.createElementNS(a, "i").innerHTML = "" } catch (e) { f.e = true } f.p = f.c || (f.a && f.k < 312) || f.n; return f } (); function at() { return { bIsWebKit: f.a, bIsSafari: f.b, bIsKonq: f.c, bIsOpera: f.d, bIsXML: f.e, bHasTransparencySupport: f.f, bUseDOM: f.g, nFlashVersion: f.h, nOperaVersion: f.i, nGeckoBuildDate: f.j, nWebKitVersion: f.k, bIsKHTML: f.l, bIsGecko: f.m, bIsIE: f.n, bIsIEMac: f.o, bUseInnerHTMLHack: f.p} } if (am.hasFlash == false || !al.getElementsByTagName || !al.getElementById || (f.e && f.p)) return { UA: at() }; function af(e) { if ((!k.bAutoInit && (am.event || e) != null) || !l(e)) return; b = true; for (var i = 0, h = ah.length; i < h; i++) j.apply(null, ah[i]); ah = [] } var k = af; function l(e) { if (c == false || k.bIsDisabled == true || ((f.e && f.m || f.l) && e == null && b == false) || (al.body == null || al.getElementsByTagName("body").length == 0)) return false; return true } function m(n) { if (f.n) return n.replace(new RegExp("%\d{0}", "g"), "%25"); return n.replace(new RegExp("%(?!\d)", "g"), "%25") } function as(p, q) { return q == "*" ? true : p.nodeName.toLowerCase().replace("html:", "") == q.toLowerCase() } function o(p, q, r, s, t) { var u = ""; var v = p.firstChild; var w, x, y, z; if (s == null) s = 0; if (t == null) t = ""; while (v) { if (v.nodeType == 3) { z = v.nodeValue.replace("<", "&lt;"); switch (r) { case "lower": u += z.toLowerCase(); break; case "upper": u += z.toUpperCase(); break; default: u += z } } else if (v.nodeType == 1) { if (as(v, "a") && !v.getAttribute("href") == false) { if (v.getAttribute("target")) t += "&sifr_url_" + s + "_target=" + v.getAttribute("target"); t += "&sifr_url_" + s + "=" + m(v.getAttribute("href")).replace(/&/g, "%26"); u += '<a href="asfunction:_root.launchURL,' + s + '">'; s++ } else if (as(v, "br")) u += "<br/>"; if (v.hasChildNodes()) { y = o(v, null, r, s, t); u += y.u; s = y.s; t = y.t } if (as(v, "a")) u += "</a>" } w = v; v = v.nextSibling; if (q != null) { x = w.parentNode.removeChild(w); q.appendChild(x) } } return { "u": u, "s": s, "t": t} } function A(B) { if (al.createElementNS && f.g) return al.createElementNS(a, B); return al.createElement(B) } function C(D, E, z) { var p = A("param"); p.setAttribute("name", E); p.setAttribute("value", z); D.appendChild(p) } function F(p, G) { var H = p.className; if (H == null) H = G; else H = H.normalize() + (H == "" ? "" : " ") + G; p.className = H } function aq(ar) { var a = ak; if (k.bHideBrowserText == false) a = al.getElementsByTagName("body")[0]; if ((k.bHideBrowserText == false || ar) && a) if (a.className == null || a.className.match(/\bsIFR\-hasFlash\b/) == null) F(a, "sIFR-hasFlash") } function j(I, J, K, L, M, N, O, P, Q, R, S, r, T) { if (!l()) return ah.push(arguments); aq(); named.extract(arguments, { sSelector: function(ap) { I = ap }, sFlashSrc: function(ap) { J = ap }, sColor: function(ap) { K = ap }, sLinkColor: function(ap) { L = ap }, sHoverColor: function(ap) { M = ap }, sBgColor: function(ap) { N = ap }, nPaddingTop: function(ap) { O = ap }, nPaddingRight: function(ap) { P = ap }, nPaddingBottom: function(ap) { Q = ap }, nPaddingLeft: function(ap) { R = ap }, sFlashVars: function(ap) { S = ap }, sCase: function(ap) { r = ap }, sWmode: function(ap) { T = ap } }); var U = parseSelector(I); if (U.length == 0) return false; if (S != null) S = "&" + S.normalize(); else S = ""; if (K != null) S += "&textcolor=" + K; if (M != null) S += "&hovercolor=" + M; if (M != null || L != null) S += "&linkcolor=" + (L || K); if (O == null) O = 0; if (P == null) P = 0; if (Q == null) Q = 0; if (R == null) R = 0; if (N == null) N = "#FFFFFF"; if (T == "transparent") if (!f.f) T = "opaque"; else N = "transparent"; if (T == null) T = ""; var p, V, W, X, Y, Z, aa, ab, ac; var ad = null; for (var i = 0, h = U.length; i < h; i++) { p = U[i]; if (p.className != null && p.className.match(/\bsIFR\-replaced\b/) != null) continue; V = p.offsetWidth - R - P; W = p.offsetHeight - O - Q; aa = A("span"); aa.className = "sIFR-alternate"; ac = o(p, aa, r); Z = "txt=" + m(ac.u).replace(/\+/g, "%2B").replace(/&/g, "%26").replace(/\"/g, "%22").normalize() + S + "&w=" + V + "&h=" + W + ac.t; F(p, "sIFR-replaced"); if (ad == null || !f.g) { if (!f.g) p.innerHTML = ['<embed class="sIFR-flash" type="application/x-shockwave-flash" src="', J, '" quality="best" wmode="', T, '" bgcolor="', N, '" flashvars="', Z, '" width="', V, '" height="', W, '" sifr="true"></embed>'].join(""); else { if (f.d) { ab = A("object"); ab.setAttribute("data", J); C(ab, "quality", "best"); C(ab, "wmode", T); C(ab, "bgcolor", N) } else { ab = A("embed"); ab.setAttribute("src", J); ab.setAttribute("quality", "best"); ab.setAttribute("flashvars", Z); ab.setAttribute("wmode", T); ab.setAttribute("bgcolor", N) } ab.setAttribute("sifr", "true"); ab.setAttribute("type", "application/x-shockwave-flash"); ab.className = "sIFR-flash"; if (!f.l || !f.e) ad = ab.cloneNode(true) } } else ab = ad.cloneNode(true); if (f.g) { if (f.d) C(ab, "flashvars", Z); else ab.setAttribute("flashvars", Z); ab.setAttribute("width", V); ab.setAttribute("height", W); ab.style.width = V + "px"; ab.style.height = W + "px"; p.appendChild(ab) } p.appendChild(aa); if (f.p) p.innerHTML += "" } if (f.n && k.bFixFragIdBug) setTimeout(function() { al.title = d }, 0) } function ai() { d = al.title } function ae() { if (k.bIsDisabled == true) return; c = true; if (k.bHideBrowserText) aq(true); if (am.attachEvent) am.attachEvent("onload", af); else if (!f.c && (al.addEventListener || am.addEventListener)) { if (f.a && f.k >= 132 && am.addEventListener) am.addEventListener("load", function() { setTimeout("sIFR({})", 1) }, false); else { if (al.addEventListener) al.addEventListener("load", af, false); if (am.addEventListener) am.addEventListener("load", af, false) } } else if (typeof am.onload == "function") { var ag = am.onload; am.onload = function() { ag(); af() } } else am.onload = af; if (!f.n || am.location.hash == "") k.bFixFragIdBug = false; else ai() } k.UA = at(); k.bAutoInit = true; k.bFixFragIdBug = true; k.replaceElement = j; k.updateDocumentTitle = ai; k.appendToClassName = F; k.setup = ae; k.debug = function() { aq(true) }; k.debug.replaceNow = function() { ae(); k() }; k.bIsDisabled = false; k.bHideBrowserText = true; return k } ();
function getArgs() {
    var args = new Object();
    var query = location.search.substring(1);
    var pairs = query.split("&");

    for (var i = 0; i < pairs.length; i++) {
        var pos = pairs[i].indexOf('=');
        if (pos == -1) continue;
        var argname = pairs[i].substring(0, pos);
        var value = pairs[i].substring(pos + 1);
        args[argname] = unescape(value);
    }

    return args;
} //end function getArgs()
function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    } else {
        expires = "";
    } //end if
    document.cookie = name + "=" + value + expires + "; path=/";
} //end function createCookie()
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) {
            return c.substring(nameEQ.length, c.length);
        } //end if
    } //end for
    return null;
} //function readCookie()
function dw(str) {
    document.write(str);
} //end function dw()
function writeDiv(div, html) {
    var evaldiv;
    if (DomExp) {
        evaldiv = eval(div);
        evaldiv.innerHTML = html;
    }
    else if (DomNav)
        (document.getElementById(div)).innerHTML = html;
}
function menuMark(lev1, lev2, lev3, lev4, lev5) {
    menu_mark_1 = lev1;
    menu_mark_2 = lev1 + "_" + lev2;
    menu_mark_3 = lev1 + "_" + lev2 + "_" + lev3;
    menu_mark_4 = lev1 + "_" + lev2 + "_" + lev3 + "_" + lev4;
    menu_mark_5 = lev1 + "_" + lev2 + "_" + lev3 + "_" + lev4 + "_" + lev5;
}
function validateString(what) {
    //check if string empty
    if (what != "")
        return false;
    else
        return true;
}
function compareString(what1, what2) {
    //compare 2 strings
    if (what1 == what2)
        return false;
    else
        return true;
}
function stringLength(tString, tLength1, tLength2) {
    //check if string length is in range
    if ((tString.length >= tLength1) && (tString.length <= tLength2))
        return false;
    else
        return true;
}
function validateEmail(what) {
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(what))
        return false;
    else
        return true;
}
function popUp(url, name, width, height) {
    if (name == "") name = "myPopUpWindow";
    if (width == 0 || width == "") width = 300;
    if (height == 0 || width == "") height = 300;
    if (url != "") window.open(url, name, "width=" + width + ",height=" + height + ",resizable=no,menubar=no,locationbar=no,scrollbars=yes,status=no");
}
function replaceIt(sString, sReplaceThis, sWithThis) {
    if (sReplaceThis != "" && sReplaceThis != sWithThis) {
        var counter = 0;
        var start = 0;
        var before = "";
        var after = "";

        while (counter < sString.length) {
            start = sString.indexOf(sReplaceThis, counter);
            if (start == -1) {
                break;
            } else {
                before = sString.substr(0, start);
                after = sString.substr(start + sReplaceThis.length, sString.length);
                sString = before + sWithThis + after;
                counter = before.length + sWithThis.length;
            } //end if
        } //end while
    } //end if
    return sString;
} //end function replaceIt()

function startMarquee(str) {
    document.write('<marquee scrollamount="4" scrolldelay="8">' + str + '</marquee>');
} //end function startMarquee()

sfHover = function() {
    if (document.getElementById("sf-nav")) {
        var sfEls = document.getElementById("sf-nav").getElementsByTagName("LI");
        //only for IE
        if (sIFR.UA.bIsIE) {
            for (var i = 0; i < sfEls.length; i++) {
                sfEls[i].onmouseover = function() {
                    this.className += " sfhover";
                }
                sfEls[i].onmouseout = function() {
                    this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
                }
            }
        }
    }
}
//if (window.attachEvent) window.attachEvent("onload", sfHover);
window.onload = function() {
    sfHover();
}
/*chage 2nd level navi:Hover class*/
function changeHover(id) {
    if (id == 1) {
        document.getElementById("m_1").className = "navi-2-unternehmen-on";
    }
    else if (id == 2) {
        document.getElementById("m_2").className = "navi-2-produkte-on";
    }
    else if (id == 3) {
        document.getElementById("m_3").className = "navi-2-branchen-on";
    }
    else if (id == 4) {
        document.getElementById("m_4").className = "navi-2-service-on";
    }
    else if (id == 5) {
        document.getElementById("m_5").className = "navi-2-aktuell-on";
    }

}
function clearHover(id) {
    if (id == 1) {
        document.getElementById("m_1").className = "navi-2-unternehmen";
    }
    else if (id == 2) {
        document.getElementById("m_2").className = "navi-2-produkte";
    }
    else if (id == 3) {
        document.getElementById("m_3").className = "navi-2-branchen";
    }
    else if (id == 4) {
        document.getElementById("m_4").className = "navi-2-service";
    }
    else if (id == 5) {
        document.getElementById("m_5").className = "navi-2-aktuell";
    }
}

function validateKontakt() {
    var f = document.kontakt_form;
    var error_flag = false;


    if (validateString(f.vorname.value)) {
        document.getElementById("vorname_txt").style.display = "block";
        document.getElementById("vorname").style.borderColor = "#E22E1E";
        error_flag = true;
    } else {
        document.getElementById("vorname_txt").style.display = "none";
        document.getElementById("vorname").style.borderColor = "#183D86";
    }

    //nachname
    if (validateString(f.nachname.value)) {
        document.getElementById("nachname_txt").style.display = "block";
        document.getElementById("nachname").style.borderColor = "#E22E1E";
        error_flag = true;
    } else {
        document.getElementById("nachname_txt").style.display = "none";
        document.getElementById("nachname").style.borderColor = "#183D86";
    }
    if (validateString(f.email.value) || (validateEmail(f.email.value))) {
        document.getElementById("email_txt").style.display = "block";
        document.getElementById("email").style.borderColor = "#E22E1E";
        error_flag = true;
    } else {
        document.getElementById("email_txt").style.display = "none";
        document.getElementById("email").style.borderColor = "#183D86";
    }
    if (error_flag === true) {
        return false;
    }
    else {
        document.kontakt_form.submit();
    }
}
function detectIE55() {
    version = 0
    if (navigator.appVersion.indexOf("MSIE") != -1) {
        temp = navigator.appVersion.split("MSIE")
        version = parseFloat(temp[1])
    }
    if (version == 5.5) {
        document.write('<style type="text/css">');
        document.write('div.clear { margin: 0 0 -5px 0;}');
        document.write('* html #header div.logo { bottom: -36px;}');
        document.write('#navi-wrap div.engel-global {height: 21px; margin: 0 49px 0 38px;}');
        document.write('#header div.suchen input {margin: 3px 8px 0 0;}');
        document.write('#navi-2 a.navi-2-unternehmen, #navi-2 a.navi-2-unternehmen-on {width: 115px; height: 19px;}');
        document.write('#navi-2 a.navi-2-produkte, #navi-2 a.navi-2-produkte-on {width: 111px; height: 19px;}');
        document.write('#navi-2 a.navi-2-branchen, #navi-2 a.navi-2-branchen-on {width: 111px; height: 19px;}');
        document.write('#navi-2 a.navi-2-service, #navi-2 a.navi-2-service-on {width: 111px; height: 19px;}');
        document.write('#navi-2 a.navi-2-aktuell, #navi-2 a.navi-2-aktuell-on {width: 112px; height: 19px;}');
        document.write('#sf-nav li ul li { border-top: 1px solid #B2BDD3; }');
        document.write('#sf-nav ul.navi-3-first {width: 116px;}');
        document.write('#sf-nav ul.navi-3 {width: 112px;}');
        document.write('#sf-nav ul.navi-3-first li {width: 113px;}');
        document.write('#sf-nav ul.navi-3 li {width: 110px;}');
        document.write('#sf-nav ul.navi-3-first li a {width: 114px;}');
        document.write('#sf-nav ul.navi-3 li a {width: 110px;}');
        document.write('</style>');
    }
}
