﻿/* menu */

var activemn;
activemn = "";

function hidd() {
    if (activemn != "") {
        var currTabElem = document.getElementById(activemn);
        currTabElem.setAttribute("class", "lnk");
        currTabElem.setAttribute("className", "lnk");
    }
}

function expand(s, aa) {
    var td = s;
    var d = td.getElementsByTagName("div").item(0);
    d.className = "menuHover";
    activemn = aa
    var currTabElem = document.getElementById(activemn);
    currTabElem.setAttribute("class", "mainleve2");
    currTabElem.setAttribute("className", "mainleve2");
}

function collapse(s, aa) {
    var td = s;
    var d = td.getElementsByTagName("div").item(0);
    d.className = "menuNormal";
    var currTabElem = document.getElementById(activemn);
    currTabElem.setAttribute("class", "lnk");
    currTabElem.setAttribute("className", "lnk");
}


/* Textbox focus change */

function areaOnFocus(element, inputText) {
    if (element.value == inputText) {
        element.value = '';
    }
}


function areaOnBlur(element, inputText) {
    if (element.value == '') {
        element.value = inputText;
    }
}


/* Button submit */
function clickButton(e, buttonid) {

    var evt = e ? e : window.event;

    var bt = document.getElementById(buttonid);

    if (bt) {

        if (evt.keyCode == 13) {
            bt.click();

            return false;

        }

    }

}



//show hide div
function toggleDiv(id, flagit) {
    if (flagit == "1") {
        if (document.layers) document.layers['' + id + ''].visibility = "show"
        else if (document.all) document.all['' + id + ''].style.visibility = "visible"
        else if (document.getElementById) document.getElementById('' + id + '').style.visibility = "visible"
    }
    else
        if (flagit == "0") {
        if (document.layers) document.layers['' + id + ''].visibility = "hide"
        else if (document.all) document.all['' + id + ''].style.visibility = "hidden"
        else if (document.getElementById) document.getElementById('' + id + '').style.visibility = "hidden"
    }
}

function waittoggleDiv(msecs, id, flagit) {
    var start = new Date().getTime();
    var cur = start
    while (cur - start < msecs) {
        cur = new Date().getTime();
        toggleDiv(id, flagit)
    }
} 


//trim textbox value
function trimAll(sString) {
    //This function used to trim data
    while (sString.substring(0, 1) == ' ') {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length - 1, sString.length) == ' ') {
        sString = sString.substring(0, sString.length - 1);
    }
    return sString;
}


/*
This methods for tool tips or pupup box
*/
(function(f) {
    function p(a, b, c) { var h = c.relative ? a.position().top : a.offset().top, d = c.relative ? a.position().left : a.offset().left, i = c.position[0]; h -= b.outerHeight() - c.offset[0]; d += a.outerWidth() + c.offset[1]; if (/iPad/i.test(navigator.userAgent)) h -= f(window).scrollTop(); var j = b.outerHeight() + a.outerHeight(); if (i == "center") h += j / 2; if (i == "bottom") h += j; i = c.position[1]; a = b.outerWidth() + a.outerWidth(); if (i == "center") d -= a / 2; if (i == "left") d -= a; return { top: h, left: d} } function u(a, b) {
        var c = this, h = a.add(c), d, i = 0, j =
0, m = a.attr("title"), q = a.attr("data-tooltip"), r = o[b.effect], l, s = a.is(":input"), v = s && a.is(":checkbox, :radio, select, :button, :submit"), t = a.attr("type"), k = b.events[t] || b.events[s ? v ? "widget" : "input" : "def"]; if (!r) throw 'Nonexistent effect "' + b.effect + '"'; k = k.split(/,\s*/); if (k.length != 2) throw "Tooltip: bad events configuration for " + t; a.bind(k[0], function(e) { clearTimeout(i); if (b.predelay) j = setTimeout(function() { c.show(e) }, b.predelay); else c.show(e) }).bind(k[1], function(e) {
    clearTimeout(j); if (b.delay) i =
setTimeout(function() { c.hide(e) }, b.delay); else c.hide(e)
}); if (m && b.cancelDefault) { a.removeAttr("title"); a.data("title", m) } f.extend(c, { show: function(e) {
    if (!d) { if (q) d = f(q); else if (b.tip) d = f(b.tip).eq(0); else if (m) d = f(b.layout).addClass(b.tipClass).appendTo(document.body).hide().append(m); else { d = a.next(); d.length || (d = a.parent().next()) } if (!d.length) throw "Cannot find tooltip for " + a; } if (c.isShown()) return c; d.stop(true, true); var g = p(a, d, b); b.tip && d.html(a.data("title")); e = e || f.Event(); e.type = "onBeforeShow";
    h.trigger(e, [g]); if (e.isDefaultPrevented()) return c; g = p(a, d, b); d.css({ position: "absolute", top: g.top, left: g.left }); l = true; r[0].call(c, function() { e.type = "onShow"; l = "full"; h.trigger(e) }); g = b.events.tooltip.split(/,\s*/); if (!d.data("__set")) { d.bind(g[0], function() { clearTimeout(i); clearTimeout(j) }); g[1] && !a.is("input:not(:checkbox, :radio), textarea") && d.bind(g[1], function(n) { n.relatedTarget != a[0] && a.trigger(k[1].split(" ")[0]) }); d.data("__set", true) } return c
}, hide: function(e) {
    if (!d || !c.isShown()) return c;
    e = e || f.Event(); e.type = "onBeforeHide"; h.trigger(e); if (!e.isDefaultPrevented()) { l = false; o[b.effect][1].call(c, function() { e.type = "onHide"; h.trigger(e) }); return c }
}, isShown: function(e) { return e ? l == "full" : l }, getConf: function() { return b }, getTip: function() { return d }, getTrigger: function() { return a }
}); f.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","), function(e, g) { f.isFunction(b[g]) && f(c).bind(g, b[g]); c[g] = function(n) { n && f(c).bind(g, n); return c } })
    } f.tools = f.tools || { version: "1.2.5" }; f.tools.tooltip =
{ conf: { effect: "toggle", fadeOutSpeed: "fast", predelay: 0, delay: 30, opacity: 1, tip: 0, position: ["top", "center"], offset: [0, 0], relative: false, cancelDefault: true, events: { def: "mouseenter,mouseleave", input: "focus,blur", widget: "focus mouseenter,blur mouseleave", tooltip: "mouseenter,mouseleave" }, layout: "<div/>", tipClass: "tooltip" }, addEffect: function(a, b, c) { o[a] = [b, c] } }; var o = { toggle: [function(a) { var b = this.getConf(), c = this.getTip(); b = b.opacity; b < 1 && c.css({ opacity: b }); c.show(); a.call() }, function(a) {
    this.getTip().hide();
    a.call()
} ], fade: [function(a) { var b = this.getConf(); this.getTip().fadeTo(b.fadeInSpeed, b.opacity, a) }, function(a) { this.getTip().fadeOut(this.getConf().fadeOutSpeed, a) } ]
}; f.fn.tooltip = function(a) { var b = this.data("tooltip"); if (b) return b; a = f.extend(true, {}, f.tools.tooltip.conf, a); if (typeof a.position == "string") a.position = a.position.split(/,?\s/); this.each(function() { b = new u(f(this), a); f(this).data("tooltip", b) }); return a.api ? b : this }
})(jQuery);
(function(d) {
    var i = d.tools.tooltip; d.extend(i.conf, { direction: "up", bounce: false, slideOffset: 10, slideInSpeed: 200, slideOutSpeed: 200, slideFade: !d.browser.msie }); var e = { up: ["-", "top"], down: ["+", "top"], left: ["-", "left"], right: ["+", "left"] }; i.addEffect("slide", function(g) { var a = this.getConf(), f = this.getTip(), b = a.slideFade ? { opacity: a.opacity} : {}, c = e[a.direction] || e.up; b[c[1]] = c[0] + "=" + a.slideOffset; a.slideFade && f.css({ opacity: 0 }); f.show().animate(b, a.slideInSpeed, g) }, function(g) {
        var a = this.getConf(), f = a.slideOffset,
b = a.slideFade ? { opacity: 0} : {}, c = e[a.direction] || e.up, h = "" + c[0]; if (a.bounce) h = h == "+" ? "-" : "+"; b[c[1]] = h + "=" + f; this.getTip().animate(b, a.slideOutSpeed, function() { d(this).hide(); g.call() })
    })
})(jQuery);
(function(g) {
    function j(a) { var c = g(window), d = c.width() + c.scrollLeft(), h = c.height() + c.scrollTop(); return [a.offset().top <= c.scrollTop(), d <= a.offset().left + a.width(), h <= a.offset().top + a.height(), c.scrollLeft() >= a.offset().left] } function k(a) { for (var c = a.length; c--; ) if (a[c]) return false; return true } var i = g.tools.tooltip; i.dynamic = { conf: { classNames: "top right bottom left"} }; g.fn.dynamic = function(a) {
        if (typeof a == "number") a = { speed: a }; a = g.extend({}, i.dynamic.conf, a); var c = a.classNames.split(/\s/), d; this.each(function() {
            var h =
g(this).tooltip().onBeforeShow(function(e, f) {
    e = this.getTip(); var b = this.getConf(); d || (d = [b.position[0], b.position[1], b.offset[0], b.offset[1], g.extend({}, b)]); g.extend(b, d[4]); b.position = [d[0], d[1]]; b.offset = [d[2], d[3]]; e.css({ visibility: "hidden", position: "absolute", top: f.top, left: f.left }).show(); f = j(e); if (!k(f)) {
        if (f[2]) { g.extend(b, a.top); b.position[0] = "top"; e.addClass(c[0]) } if (f[3]) { g.extend(b, a.right); b.position[1] = "right"; e.addClass(c[1]) } if (f[0]) { g.extend(b, a.bottom); b.position[0] = "bottom"; e.addClass(c[2]) } if (f[1]) {
            g.extend(b,
a.left); b.position[1] = "left"; e.addClass(c[3])
        } if (f[0] || f[2]) b.offset[0] *= -1; if (f[1] || f[3]) b.offset[1] *= -1
    } e.css({ visibility: "visible" }).hide()
}); h.onBeforeShow(function() { var e = this.getConf(); this.getTip(); setTimeout(function() { e.position = [d[0], d[1]]; e.offset = [d[2], d[3]] }, 0) }); h.onHide(function() { var e = this.getTip(); e.removeClass(a.classNames) }); ret = h
        }); return a.api ? ret : this
    }
})(jQuery);



