var userDetails = new Array();
var globalLogout = false;
var globalUsess = false;
var globalCompanyName = "";
var globalCompanySymbol = "";
var watchlist_id_toaddstock = 0;
var watchlistName_toredirect = "";
var watchListDetails = "";
var global_flag_select = false;
var globalPredict = new Array(5500, 5400, 5300, 5400, 4000, 5600, 5700, 5800);
var userglobalPredict = new Array();
var userPredict = new Array();
var tTime = 0;

function homeAdvDec() {
    $('#adv-grp-bar').height(($('#adv-grp b').html()) * 4);
    $('#dec-grp-bar').height(($('#dec-grp b').html()) * 4);
}
function showPrediction() {
    if (getCookie("usess").length > 0) {
        PredictionProcess("", "fetch");
        if (userPredict.length <= 2) {
            if (userPredict[1] == "1") {
                document.getElementById("fgraph").showUserPredictionUI();
                $("#addPrediction").val("Save your prediction");
                $("#userPredication").attr("unchecked", "unchecked")
            } else {
                $("#addPrediction").attr("disabled", "disabled")
            }
        } else {
            if (userPredict[8] == "1") {
                for (var a = 0; a < 8; a++) {
                    userglobalPredict[a] = userPredict[a]
                }
                $("#addPrediction").attr("disabled", "disabled");
                $("#userPredication").attr("checked", "checked");
                setUserPredictGraph()
            } else {
                $("#addPrediction").attr("disabled", "disabled")
            }
        }
    }
}
function getUserPrediction() {
    if (getCookie("usess").length > 0) {
        if (userDetails.length > 0) {
            if (userDetails[6].length > 0 && userDetails[5] == "PREDICT") {
                if (userDetails[14] == "1") {
                    for (a = 0; a < 8; a++) {
                        userglobalPredict[a] = userDetails[a + 6]
                    }
                    $("#addPrediction").attr("disabled", "disabled");
                    $("#userPredication").attr("checked", "checked");
                    setUserPredictGraph()
                } else {
                    $("#addPrediction").attr("disabled", "disabled")
                }
            } else {
                document.getElementById("fgraph").showUserPredictionUI();
                $("#addPrediction").val("Save your prediction");
                $("#userPredication").attr("unchecked", "unchecked")
            }
        } else {
            PredictionProcess("", "fetch");
            if (userPredict.length <= 2) {
                if (userPredict[1] == "1") {
                    document.getElementById("fgraph").showUserPredictionUI();
                    $("#addPrediction").val("Save your prediction");
                    $("#userPredication").attr("unchecked", "unchecked")
                } else {
                    $("#addPrediction").attr("disabled", "disabled")
                }
            } else {
                if (userPredict[8] == "1") {
                    for (var a = 0; a < 8; a++) {
                        userglobalPredict[a] = userPredict[a]
                    }
                    $("#addPrediction").attr("disabled", "disabled");
                    $("#userPredication").attr("checked", "checked");
                    setUserPredictGraph()
                } else {
                    $("#addPrediction").attr("disabled", "disabled")
                }
            }
        }
    } else {
        validateUserLogin("addPrediction")
    }
}
function getPrediction() {
    showPrediction();
    getCommunityPrediction();
    return globalPredict
}
function getCommunityPrediction() {
    $.ajax({
        type: "GET",
        url: siteURL + "getCommunityPrediction.php",
        data: "",
        dataType: "html",
        async: false,
        success: function (b) {
            if (b.indexOf("|") > -1) {
                var a = b.split("|");
                for (i = 0; i < a.length; i++) {
                    if (a[i] == 0) {
                        a[i] = 5000
                    }
                    globalPredict[i] = parseInt(a[i])
                }
            } else {
                return b
            }
        }
    })
}
function getTradeTime() {
    $.ajax({
        type: "POST",
        url: siteURL + "getTradeTime.php",
        data: "",
        dataType: "html",
        async: false,
        success: function (a) {
            tTime = a
        }
    })
}
function setPrediction() {
    getUserPrediction();
    $("#addPrediction").click(function () {
        if ($(this).val() == "Save your prediction") {
            $("#addPrediction").attr("disabled", "disabled");
            closeUserPredictMode()
        }
    })
}
function setChkPrediction() {
    if ($("#userPredication").is(":checked")) {
        getUserPrediction()
    }
}
function closeUserPredictMode() {
    userPredict = document.getElementById("fgraph").saveUserPrediction();
    $("#userPredication").attr("checked", "checked");
    var a = "";
    for (i = 0; i < 8; i++) {
        userglobalPredict[i] = userPredict[i];
        if (a == "") {
            if (userPredict[i] == 0) {
                userPredict[i] = "0"
            }
            a = userPredict[i]
        } else {
            if (userPredict[i] == 0) {
                userPredict[i] = "0"
            }
            a = a + "," + userPredict[i]
        }
    }
    PredictionProcess(a, "add");
    setUserPredictGraph()
}
function setUserPredictGraph() {
    if (document.getElementById("fgraph")) {
        document.getElementById("fgraph").setUserPrediction(userglobalPredict);
        delete userPredict;
        delete userglobalPredict
    }
}
function unsetUserPredictGraph() {
    document.getElementByName("fgraph").setUserPrediction(unglobalPredict)
}
function PredictionProcess(b, a) {
    $.ajax({
        type: "POST",
        url: siteURL + "PredictionProcess.php",
        data: "action=" + a + "&dataPoints=" + b + "&rand=" + Math.random(),
        dataType: "html",
        async: false,
        success: function (d) {
            if (d.indexOf("|") > -1) {
                var c = d.split("|");
                for (i = 0; i < c.length; i++) {
                    userPredict[i] = c[i]
                }
            } else {
                return d
            }
        }
    })
}
function initAutocomplete() {
    searchUrl = callURL + "getSearchList.php";
    if(menu1 == 'mutual-funds'){
        searchUrl = callURL + "getSearchList.php?pg=mutual-funds";
    }
    $("#search-keywords").autocomplete(searchUrl, {
        max: 15,
        minChars: 2,
        width: 467
    });
    $("#search-keywords").result(function (data) {
        var cname = $("#search-keywords").val();
        if (cname.indexOf("<i>MF ") > -1) {
            $("#search-keywords").val(cname.replace("<i>MF </i>", "MF "));
        } else if (cname.indexOf("<i>CO ") > -1) {
            $("#search-keywords").val(cname.replace("<i>CO </i>", "CO "));
        } else if (cname.indexOf("<font") > -1) {
            var str = cname.replace("<font color='blue'>", "");
            str = str.replace("</font>", "");
            $("#search-keywords").val(str);
        }
        return getQuoteTips();
    });
    $("#submit-tip-company").autocomplete(siteURL + "getTipSearchList.php", {
        minChars: 2,
        width: 400
    });
    $("#submit-tip-company").result(function (data) {
        if (data) {
            global_flag_select = true;
        }
    }); /*$("#submit-tip-company").change(function(){if(global_flag_select==true){global_flag_select=false;}})*/
}
function addCoToWatchlist() {
    globalCompanyName = $("#companyNameId").val();
    globalCompanySymbol = $("#companySymbolId").val();
    if (globalUsess) {
        getWatchlist()
    } else {
        url = "addtowatchlist";
        validateUserLogin(url)
    }
}
function checkTipCompanyforFNO(b) {
    $.ajax({
        type: "GET",
        url: siteURL + "checkTipCompanyforFNO.php",
        data: "code=" + b  + "&rand=" + Math.random(),
        dataType: "html",
        async: false,
        success: function (d) {
			if(d == 0){
				$("#tip-instrument2").attr("disabled", "disabled");
				$("#submit-tip-instrument label[for=tip-action]").hide();
			}else {
				$("#tip-instrument2").attr("disabled", "");
				$("#submit-tip-instrument label[for=tip-action]").show();
			}        
        }
    })
}
function addTips() {
    if (getEl("errorMsg")) {
        getEl("errorMsg").className = "errorMsgRed";
        getEl("errorMsg").innerHTML = ""
    }
    if ($("#submit-tip-button-1").parent().parent().parent().find("#submit-tip-company").val() != "") {
        symbol = initAutocomplete();
        var a = "";
        if ($("#submit-tip-button-1").parent().parent().parent().find("#page-name").val() != "") {
            a = $("#submit-tip-button-1").parent().parent().parent().find("#page-name").val()
        }
        if (global_flag_select == false && (a == "home" || a == "best-tipper")) {
            $("#errorMsg").html("Please select the name from suggestion");
            $("#submit-tip-company").focus();
            return false
        }else{			
			var tipCompanyCode = getCompanySymbol('submit-tip-company');
			checkTipCompanyforFNO(tipCompanyCode);			
		}
        $("#submit-tips-process").modal({
            onClose: function (b) {
                $(".submit-tip-row2").hide();
                $(".submit-tip-row3-stock").hide();
                $(".submit-tip-row3-derivative").hide();
                $.modal.close();
                if ($("#page-name").val() == 'home' || $("#page-name").val() == 'best-tipper') {
                    $("#submit-tip-company").val("");
                }
                $("div").remove(".ac_results");
                initAutocomplete()
            },
            opacity: 90,
            overlayId: "mangoPeopleModalOverlay",
            closeClass: "cancelButton",
            closeHTML: '<a class="cancelButton" title="Close">Cancel</a>',
            overlayClose: true,
            persist: false,
            minWidth: 490,
            position: ["1%"]
        });
        $("#submit-tips-process").css({
            border: "1px solid #808080",
            "-moz-box-shadow": "0 0 10px rgba(0, 0, 0, 0.3)",
            "-webkit-box-shadow": "0 0 10px rgba(0, 0, 0, 0.3)",
            "box-shadow": "0 0 10px rgba(0, 0, 0, 0.3)"
        });
        $("#submit-tip-button-1").parent().parent().parent().find("#submit-tip-company").attr("disabled", "disabled").css({
            color: "#000",
            "text-transform": "capitalize",
            background: "transparent",
            border: 0,
            width: "290px"
        });
        $("#submit-tip-button-1").parent().parent().parent().find("#submit-tip-button-1").hide("fast").parent().hide();
        $("#submit-tip-button-1").parent().parent().parent().find(".submit-tip-row2").slideDown("fast");
        $("#submit-tip-button-1").parent().parent().parent().find(".submit-tip-row2-fld").show("fast");
        $("#submit-tip-instrument label").click(function (b) {
            if ($("input", $(this)).val() == "Stock") {
                $("input", $(this)).attr("checked", "checked");
                $("#submit-tips-process").find(".submit-tip-row3-derivative").hide("fast");
                $("#submit-tips-process").find(".submit-tip-row3-derivative-fld").hide("fast");
                $("#submit-tips-process").find(".submit-tip-row3-stock").slideDown("fast");
                $("#submit-tips-process").find(".submit-tip-row3-stock-fld").show("fast");
                getLTP(0);
            } else {
                if ($("input", $(this)).val() == "Derivative") {
                    $("input", $(this)).attr("checked", "checked");
                    $("#submit-tips-process").find(".submit-tip-row3-stock").hide("fast");
                    $("#submit-tips-process").find(".submit-tip-row3-stock-fld").hide("fast");
                    $("#submit-tips-process").find(".submit-tip-row3-derivative").slideDown("fast");
                    $("#submit-tips-process").find(".submit-tip-row3-derivative-fld").show("fast");
                    showDerivative();
                }
            }
        })
    } else {
        if (getEl("errorMsg")) {
            getEl("errorMsg").className = "errorMsgRed";
            getEl("errorMsg").innerHTML = msg5
        }
    }
}
function getWatchlist() {
    var tmpUrl = siteURL + "ajax_process_watchlist.php";
    var param = "action=getuserwatchlist&r=" + Math.random();
    $.ajax({
        type: "GET",
        url: tmpUrl,
        data: param,
        dataType: "html",
        success: function (txtdata) {
            var data = eval(txtdata);
            if (typeof(data) != "undefined") {
                watchListDetails = data.watchlists;
                var objWlCnt = watchListDetails.length;
                var watchlistExists = false;
                var multipleWatchlists = false;
                if (objWlCnt > 0) {
                    watchlistExists = true;
                    if (objWlCnt > 1) {
                        multipleWatchlists = true
                    }
                }
                $companyID = globalCompanySymbol;
                $companyName = globalCompanyName;
                if ($companyID) {
                    if (watchlistExists == false) {
                        if (confirm("You do not have a Watchlist. Would you like to create one now?")) {
                            globalURL = "watchlist"
                        }
                    } else {
                        if (multipleWatchlists == true && watchlistExists == true) {
                            $coAddToWatchlistHTML = '<div id="co-add-stock-process" class="wl-modal-dialog"><input type="button" class="sm-submit-button mangoPeopleModalClose" value="X" onclick="$.modal.close();" title="Cancel" /><h2>Add <b>' + $companyName + '</b> to Watchlist</h2><div class="form-area"><fieldset><legend>Select Watchlist:</legend><label><select id="wl-watchlists-list">';
                            for (i = 0; i < objWlCnt; i++) {
                                wlId = watchListDetails[i].w_id;
                                wlName = watchListDetails[i].display_name;
                                $coAddToWatchlistHTML += '<option id="wl-watchlist-target" value="' + wlId + '">' + wlName + "</option>"
                            }
                            $coAddToWatchlistHTML += '</select></label><p id="wl-move-stocks-message"></p></fieldset><fieldset><label><input type="button" class="medium-submit-button" value="Add Stock" id="co-add-stock-submit" /></label></fieldset></div></div>';
                            $.modal.close();
                            $.modal($coAddToWatchlistHTML, {
                                opacity: 90,
                                focus: false,
                                overlayId: "mangoPeopleModalOverlay",
                                containerId: "mangoPeopleModalContainer",
                                closeClass: "mangoPeopleModalClose",
                                persist: false
                            });
                            $("#co-add-stock-submit").click(function () {
                                watchlist_id_toaddstock = $("#wl-watchlists-list option:selected").val();
                                watchlistName_toredirect = $("#wl-watchlists-list option:selected").text();
                                if (confirm("Add " + $companyName + " to " + $("#wl-watchlists-list option:selected").text() + "?")) {
                                    $.modal.close();
                                    addComopanyStockToWatchlist()
                                }
                            })
                        } else {
                            if (confirm("Add " + $companyName + " to your Watchlist?")) {
                                watchlist_id_toaddstock = watchListDetails[0].w_id;
                                watchlistName_toredirect = watchListDetails[0].display_name;
                                $.modal.close();
                                addComopanyStockToWatchlist()
                            }
                        }
                    }
                }
            }
        }
    })
}
function pageOverlay(a) {
    if (a == 1) {
        $("body").append('<div id="mangoPeopleModalOverlay"></div>');
        $("#mangoPeopleModalOverlay").width($(document).width()).height($(document).height()).css({
            position: "absolute",
            top: "0",
            left: "0"
        }).fadeTo("slow", 0.9)
    } else {
        if (a == 0) {
            $("#mangoPeopleModalOverlay").fadeOut("slow", function () {
                $("#mangoPeopleModalOverlay").remove()
            })
        }
    }
}
document.createElement("canvas").getContext || (function () {
    var K = Math,
        ac = K.round,
        E = K.sin,
        w = K.cos,
        e = K.abs,
        d = K.sqrt,
        ab = 10,
        z = ab / 2;

    function c() {
        return this.context_ || (this.context_ = new u(this))
    }
    var q = Array.prototype.slice;

    function b(j, s) {
        var v = q.call(arguments, 2);
        return function () {
            return j.apply(s, v.concat(q.call(arguments)))
        }
    }
    var p = {
        init: function (j) {
            if (/MSIE/.test(navigator.userAgent) && !window.opera) {
                var s = j || document;
                s.createElement("canvas");
                s.attachEvent("onreadystatechange", b(this.init_, this, s))
            }
        },
        init_: function (j) {
            j.namespaces.g_vml_ || j.namespaces.add("g_vml_", "urn:schemas-microsoft-com:vml", "#default#VML");
            j.namespaces.g_o_ || j.namespaces.add("g_o_", "urn:schemas-microsoft-com:office:office", "#default#VML");
            if (!j.styleSheets.ex_canvas_) {
                var s = j.createStyleSheet();
                s.owningElement.id = "ex_canvas_";
                s.cssText = "canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}g_vml_\\:*{behavior:url(#default#VML)}g_o_\\:*{behavior:url(#default#VML)}"
            }
            var y = j.getElementsByTagName("canvas"),
                v = 0;
            for (; v < y.length; v++) {
                this.initElement(y[v])
            }
        },
        initElement: function (j) {
            if (!j.getContext) {
                j.getContext = c;
                j.innerHTML = "";
                j.attachEvent("onpropertychange", a);
                j.attachEvent("onresize", g);
                var s = j.attributes;
                if (s.width && s.width.specified) {
                    j.style.width = s.width.nodeValue + "px"
                } else {
                    j.width = j.clientWidth
                }
                if (s.height && s.height.specified) {
                    j.style.height = s.height.nodeValue + "px"
                } else {
                    j.height = j.clientHeight
                }
            }
            return j
        }
    };

    function a(j) {
        var s = j.srcElement;
        switch (j.propertyName) {
        case "width":
            s.style.width = s.attributes.width.nodeValue + "px";
            s.getContext().clearRect();
            break;
        case "height":
            s.style.height = s.attributes.height.nodeValue + "px";
            s.getContext().clearRect();
            break
        }
    }
    function g(j) {
        var s = j.srcElement;
        if (s.firstChild) {
            s.firstChild.style.width = s.clientWidth + "px";
            s.firstChild.style.height = s.clientHeight + "px"
        }
    }
    p.init();
    var o = [],
        S = 0;
    for (; S < 16; S++) {
        var R = 0;
        for (; R < 16; R++) {
            o[S * 16 + R] = S.toString(16) + R.toString(16)
        }
    }
    function t() {
        return [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
    }
    function r(j, s) {
        var C = t(),
            B = 0;
        for (; B < 3; B++) {
            var A = 0;
            for (; A < 3; A++) {
                var v = 0,
                    y = 0;
                for (; y < 3; y++) {
                    v += j[B][y] * s[y][A]
                }
                C[B][A] = v
            }
        }
        return C
    }
    function m(j, s) {
        s.fillStyle = j.fillStyle;
        s.lineCap = j.lineCap;
        s.lineJoin = j.lineJoin;
        s.lineWidth = j.lineWidth;
        s.miterLimit = j.miterLimit;
        s.shadowBlur = j.shadowBlur;
        s.shadowColor = j.shadowColor;
        s.shadowOffsetX = j.shadowOffsetX;
        s.shadowOffsetY = j.shadowOffsetY;
        s.strokeStyle = j.strokeStyle;
        s.globalAlpha = j.globalAlpha;
        s.arcScaleX_ = j.arcScaleX_;
        s.arcScaleY_ = j.arcScaleY_;
        s.lineScale_ = j.lineScale_
    }
    function l(j) {
        var s, C = 1;
        j = String(j);
        if (j.substring(0, 3) == "rgb") {
            var B = j.indexOf("(", 3),
                A = j.indexOf(")", B + 1),
                v = j.substring(B + 1, A).split(",");
            s = "#";
            var y = 0;
            for (; y < 3; y++) {
                s += o[Number(v[y])]
            }
            if (v.length == 4 && j.substr(3, 1) == "a") {
                C = v[3]
            }
        } else {
            s = j
        }
        return {
            color: s,
            alpha: C
        }
    }
    function ae(j) {
        switch (j) {
        case "butt":
            return "flat";
        case "round":
            return "round";
        case "square":
        default:
            return "square"
        }
    }
    function u(j) {
        this.m_ = t();
        this.mStack_ = [];
        this.aStack_ = [];
        this.currentPath_ = [];
        this.fillStyle = this.strokeStyle = "#000";
        this.lineWidth = 1;
        this.lineJoin = "miter";
        this.lineCap = "butt";
        this.miterLimit = ab * 1;
        this.globalAlpha = 1;
        this.canvas = j;
        var s = j.ownerDocument.createElement("div");
        s.style.width = j.clientWidth + "px";
        s.style.height = j.clientHeight + "px";
        s.style.overflow = "hidden";
        s.style.position = "absolute";
        j.appendChild(s);
        this.element_ = s;
        this.lineScale_ = this.arcScaleY_ = this.arcScaleX_ = 1
    }
    var ad = u.prototype;
    ad.clearRect = function () {
        this.element_.innerHTML = ""
    };
    ad.beginPath = function () {
        this.currentPath_ = []
    };
    ad.moveTo = function (j, s) {
        var v = this.getCoords_(j, s);
        this.currentPath_.push({
            type: "moveTo",
            x: v.x,
            y: v.y
        });
        this.currentX_ = v.x;
        this.currentY_ = v.y
    };
    ad.lineTo = function (j, s) {
        var v = this.getCoords_(j, s);
        this.currentPath_.push({
            type: "lineTo",
            x: v.x,
            y: v.y
        });
        this.currentX_ = v.x;
        this.currentY_ = v.y
    };
    ad.bezierCurveTo = function (D, F, C, B, y, s) {
        var v = this.getCoords_(y, s),
            j = this.getCoords_(D, F),
            A = this.getCoords_(C, B);
        h(this, j, A, v)
    };

    function h(j, s, y, v) {
        j.currentPath_.push({
            type: "bezierCurveTo",
            cp1x: s.x,
            cp1y: s.y,
            cp2x: y.x,
            cp2y: y.y,
            x: v.x,
            y: v.y
        });
        j.currentX_ = v.x;
        j.currentY_ = v.y
    }
    ad.quadraticCurveTo = function (j, s, C, B) {
        var A = this.getCoords_(j, s),
            v = this.getCoords_(C, B),
            y = {
                x: this.currentX_ + 0.6666666666666666 * (A.x - this.currentX_),
                y: this.currentY_ + 0.6666666666666666 * (A.y - this.currentY_)
            };
        h(this, y, {
            x: y.x + (v.x - this.currentX_) / 3,
            y: y.y + (v.y - this.currentY_) / 3
        }, v)
    };
    ad.arc = function (L, M, I, H, F, C) {
        I *= ab;
        var D = C ? "at" : "wa",
            B = L + w(H) * I - z,
            G = M + E(H) * I - z,
            A = L + w(F) * I - z,
            j = M + E(F) * I - z;
        if (B == A && !C) {
            B += 0.125
        }
        var y = this.getCoords_(L, M),
            v = this.getCoords_(B, G),
            s = this.getCoords_(A, j);
        this.currentPath_.push({
            type: D,
            x: y.x,
            y: y.y,
            radius: I,
            xStart: v.x,
            yStart: v.y,
            xEnd: s.x,
            yEnd: s.y
        })
    };
    ad.rect = function (j, s, y, v) {
        this.moveTo(j, s);
        this.lineTo(j + y, s);
        this.lineTo(j + y, s + v);
        this.lineTo(j, s + v);
        this.closePath()
    };
    ad.strokeRect = function (j, s, A, y) {
        var v = this.currentPath_;
        this.beginPath();
        this.moveTo(j, s);
        this.lineTo(j + A, s);
        this.lineTo(j + A, s + y);
        this.lineTo(j, s + y);
        this.closePath();
        this.stroke();
        this.currentPath_ = v
    };
    ad.fillRect = function (j, s, A, y) {
        var v = this.currentPath_;
        this.beginPath();
        this.moveTo(j, s);
        this.lineTo(j + A, s);
        this.lineTo(j + A, s + y);
        this.lineTo(j, s + y);
        this.closePath();
        this.fill();
        this.currentPath_ = v
    };
    ad.createLinearGradient = function (j, s, A, y) {
        var v = new J("gradient");
        v.x0_ = j;
        v.y0_ = s;
        v.x1_ = A;
        v.y1_ = y;
        return v
    };
    ad.createRadialGradient = function (j, s, C, B, A, v) {
        var y = new J("gradientradial");
        y.x0_ = j;
        y.y0_ = s;
        y.r0_ = C;
        y.x1_ = B;
        y.y1_ = A;
        y.r1_ = v;
        return y
    };
    ad.drawImage = function (U) {
        var V, Q, P, N, L, M, I, O, H = U.runtimeStyle.width,
            B = U.runtimeStyle.height;
        U.runtimeStyle.width = "auto";
        U.runtimeStyle.height = "auto";
        var G = U.width,
            F = U.height;
        U.runtimeStyle.width = H;
        U.runtimeStyle.height = B;
        if (arguments.length == 3) {
            V = arguments[1];
            Q = arguments[2];
            L = M = 0;
            I = P = G;
            O = N = F
        } else {
            if (arguments.length == 5) {
                V = arguments[1];
                Q = arguments[2];
                P = arguments[3];
                N = arguments[4];
                L = M = 0;
                I = G;
                O = F
            } else {
                if (arguments.length == 9) {
                    L = arguments[1];
                    M = arguments[2];
                    I = arguments[3];
                    O = arguments[4];
                    V = arguments[5];
                    Q = arguments[6];
                    P = arguments[7];
                    N = arguments[8]
                } else {
                    throw Error("Invalid number of arguments")
                }
            }
        }
        var C = this.getCoords_(V, Q),
            A = [];
        A.push(" <g_vml_:group", ' coordsize="', ab * 10, ",", ab * 10, '"', ' coordorigin="0,0"', ' style="width:', 10, "px;height:", 10, "px;position:absolute;");
        if (this.m_[0][0] != 1 || this.m_[0][1]) {
            var y = [];
            y.push("M11=", this.m_[0][0], ",", "M12=", this.m_[1][0], ",", "M21=", this.m_[0][1], ",", "M22=", this.m_[1][1], ",", "Dx=", ac(C.x / ab), ",", "Dy=", ac(C.y / ab), "");
            var D = C,
                j = this.getCoords_(V + P, Q),
                v = this.getCoords_(V, Q + N),
                s = this.getCoords_(V + P, Q + N);
            D.x = K.max(D.x, j.x, v.x, s.x);
            D.y = K.max(D.y, j.y, v.y, s.y);
            A.push("padding:0 ", ac(D.x / ab), "px ", ac(D.y / ab), "px 0;filter:progid:DXImageTransform.Microsoft.Matrix(", y.join(""), ", sizingmethod='clip');")
        } else {
            A.push("top:", ac(C.y / ab), "px;left:", ac(C.x / ab), "px;")
        }
        A.push(' ">', '<g_vml_:image src="', U.src, '"', ' style="width:', ab * P, "px;", " height:", ab * N, 'px;"', ' cropleft="', L / G, '"', ' croptop="', M / F, '"', ' cropright="', (G - L - I) / G, '"', ' cropbottom="', (F - M - O) / F, '"', " />", "</g_vml_:group>");
        this.element_.insertAdjacentHTML("BeforeEnd", A.join(""))
    };
    ad.stroke = function (ag) {
        var ah = [],
            af = l(ag ? this.fillStyle : this.strokeStyle),
            aa = af.color,
            Y = af.alpha * this.globalAlpha;
        ah.push("<g_vml_:shape", ' filled="', !! ag, '"', ' style="position:absolute;width:', 10, "px;height:", 10, 'px;"', ' coordorigin="0 0" coordsize="', ab * 10, " ", ab * 10, '"', ' stroked="', !ag, '"', ' path="');
        var W = {
            x: null,
            y: null
        },
            X = {
                x: null,
                y: null
            },
            V = 0;
        for (; V < this.currentPath_.length; V++) {
            var Z = this.currentPath_[V];
            switch (Z.type) {
            case "moveTo":
                ah.push(" m ", ac(Z.x), ",", ac(Z.y));
                break;
            case "lineTo":
                ah.push(" l ", ac(Z.x), ",", ac(Z.y));
                break;
            case "close":
                ah.push(" x ");
                Z = null;
                break;
            case "bezierCurveTo":
                ah.push(" c ", ac(Z.cp1x), ",", ac(Z.cp1y), ",", ac(Z.cp2x), ",", ac(Z.cp2y), ",", ac(Z.x), ",", ac(Z.y));
                break;
            case "at":
            case "wa":
                ah.push(" ", Z.type, " ", ac(Z.x - this.arcScaleX_ * Z.radius), ",", ac(Z.y - this.arcScaleY_ * Z.radius), " ", ac(Z.x + this.arcScaleX_ * Z.radius), ",", ac(Z.y + this.arcScaleY_ * Z.radius), " ", ac(Z.xStart), ",", ac(Z.yStart), " ", ac(Z.xEnd), ",", ac(Z.yEnd));
                break
            }
            if (Z) {
                if (W.x == null || Z.x < W.x) {
                    W.x = Z.x
                }
                if (X.x == null || Z.x > X.x) {
                    X.x = Z.x
                }
                if (W.y == null || Z.y < W.y) {
                    W.y = Z.y
                }
                if (X.y == null || Z.y > X.y) {
                    X.y = Z.y
                }
            }
        }
        ah.push(' ">');
        if (ag) {
            if (typeof this.fillStyle == "object") {
                var U = this.fillStyle,
                    L = 0,
                    Q = {
                        x: 0,
                        y: 0
                    },
                    O = 0,
                    M = 1;
                if (U.type_ == "gradient") {
                    var I = U.x1_ / this.arcScaleX_,
                        H = U.y1_ / this.arcScaleY_,
                        N = this.getCoords_(U.x0_ / this.arcScaleX_, U.y0_ / this.arcScaleY_),
                        B = this.getCoords_(I, H);
                    L = Math.atan2(B.x - N.x, B.y - N.y) * 180 / Math.PI;
                    if (L < 0) {
                        L += 360
                    }
                    if (L < 0.000001) {
                        L = 0
                    }
                } else {
                    var N = this.getCoords_(U.x0_, U.y0_),
                        F = X.x - W.x,
                        D = X.y - W.y;
                    Q = {
                        x: (N.x - W.x) / F,
                        y: (N.y - W.y) / D
                    };
                    F /= this.arcScaleX_ * ab;
                    D /= this.arcScaleY_ * ab;
                    var v = K.max(F, D);
                    O = 2 * U.r0_ / v;
                    M = 2 * U.r1_ / v - O
                }
                var G = U.colors_;
                G.sort(function (al, ak) {
                    return al.offset - ak.offset
                });
                var C = G.length,
                    ai = G[0].color,
                    y = G[C - 1].color,
                    P = G[0].alpha * this.globalAlpha,
                    aj = G[C - 1].alpha * this.globalAlpha,
                    s = [],
                    V = 0;
                for (; V < C; V++) {
                    var j = G[V];
                    s.push(j.offset * M + O + " " + j.color)
                }
                ah.push('<g_vml_:fill type="', U.type_, '"', ' method="none" focus="100%"', ' color="', ai, '"', ' color2="', y, '"', ' colors="', s.join(","), '"', ' opacity="', aj, '"', ' g_o_:opacity2="', P, '"', ' angle="', L, '"', ' focusposition="', Q.x, ",", Q.y, '" />')
            } else {
                ah.push('<g_vml_:fill color="', aa, '" opacity="', Y, '" />')
            }
        } else {
            var A = this.lineScale_ * this.lineWidth;
            if (A < 1) {
                Y *= A
            }
            ah.push("<g_vml_:stroke", ' opacity="', Y, '"', ' joinstyle="', this.lineJoin, '"', ' miterlimit="', this.miterLimit, '"', ' endcap="', ae(this.lineCap), '"', ' weight="', A, 'px"', ' color="', aa, '" />')
        }
        ah.push("</g_vml_:shape>");
        this.element_.insertAdjacentHTML("beforeEnd", ah.join(""))
    };
    ad.fill = function () {
        this.stroke(true)
    };
    ad.closePath = function () {
        this.currentPath_.push({
            type: "close"
        })
    };
    ad.getCoords_ = function (j, s) {
        var v = this.m_;
        return {
            x: ab * (j * v[0][0] + s * v[1][0] + v[2][0]) - z,
            y: ab * (j * v[0][1] + s * v[1][1] + v[2][1]) - z
        }
    };
    ad.save = function () {
        var j = {};
        m(this, j);
        this.aStack_.push(j);
        this.mStack_.push(this.m_);
        this.m_ = r(t(), this.m_)
    };
    ad.restore = function () {
        m(this.aStack_.pop(), this);
        this.m_ = this.mStack_.pop()
    };

    function n(j) {
        var s = 0;
        for (; s < 3; s++) {
            var v = 0;
            for (; v < 2; v++) {
                if (!isFinite(j[s][v]) || isNaN(j[s][v])) {
                    return false
                }
            }
        }
        return true
    }
    function T(j, s, v) {
        if ( !! n(s)) {
            j.m_ = s;
            if (v) {
                j.lineScale_ = d(e(s[0][0] * s[1][1] - s[0][1] * s[1][0]))
            }
        }
    }
    ad.translate = function (j, s) {
        T(this, r([
            [1, 0, 0],
            [0, 1, 0],
            [j, s, 1]
        ], this.m_), false)
    };
    ad.rotate = function (j) {
        var s = w(j),
            v = E(j);
        T(this, r([
            [s, v, 0],
            [-v, s, 0],
            [0, 0, 1]
        ], this.m_), false)
    };
    ad.scale = function (j, s) {
        this.arcScaleX_ *= j;
        this.arcScaleY_ *= s;
        T(this, r([
            [j, 0, 0],
            [0, s, 0],
            [0, 0, 1]
        ], this.m_), true)
    };
    ad.transform = function (j, s, B, A, y, v) {
        T(this, r([
            [j, s, 0],
            [B, A, 0],
            [y, v, 1]
        ], this.m_), true)
    };
    ad.setTransform = function (j, s, B, A, y, v) {
        T(this, [
            [j, s, 0],
            [B, A, 0],
            [y, v, 1]
        ], true)
    };
    ad.clip = function () {};
    ad.arcTo = function () {};
    ad.createPattern = function () {
        return new f
    };

    function J(j) {
        this.type_ = j;
        this.r1_ = this.y1_ = this.x1_ = this.r0_ = this.y0_ = this.x0_ = 0;
        this.colors_ = []
    }
    J.prototype.addColorStop = function (j, s) {
        s = l(s);
        this.colors_.push({
            offset: j,
            color: s.color,
            alpha: s.alpha
        })
    };

    function f() {}
    G_vmlCanvasManager = p;
    CanvasRenderingContext2D = u;
    CanvasGradient = J;
    CanvasPattern = f
})();
(function (a) {
    a.fn.hoverIntent = function (m, l) {
        var n = {
            sensitivity: 7,
            interval: 100,
            timeout: 0
        };
        n = a.extend(n, l ? {
            over: m,
            out: l
        } : m);
        var p, o, h, d;
        var e = function (f) {
            p = f.pageX;
            o = f.pageY
        };
        var c = function (g, f) {
            f.hoverIntent_t = clearTimeout(f.hoverIntent_t);
            if ((Math.abs(h - p) + Math.abs(d - o)) < n.sensitivity) {
                a(f).unbind("mousemove", e);
                f.hoverIntent_s = 1;
                return n.over.apply(f, [g])
            } else {
                h = p;
                d = o;
                f.hoverIntent_t = setTimeout(function () {
                    c(g, f)
                }, n.interval)
            }
        };
        var j = function (g, f) {
            f.hoverIntent_t = clearTimeout(f.hoverIntent_t);
            f.hoverIntent_s = 0;
            return n.out.apply(f, [g])
        };
        var b = function (r) {
            var q = (r.type == "mouseover" ? r.fromElement : r.toElement) || r.relatedTarget;
            while (q && q != this) {
                try {
                    q = q.parentNode
                } catch (r) {
                    q = this
                }
            }
            if (q == this) {
                return false
            }
            var g = jQuery.extend({}, r);
            var f = this;
            if (f.hoverIntent_t) {
                f.hoverIntent_t = clearTimeout(f.hoverIntent_t)
            }
            if (r.type == "mouseover") {
                h = g.pageX;
                d = g.pageY;
                a(f).bind("mousemove", e);
                if (f.hoverIntent_s != 1) {
                    f.hoverIntent_t = setTimeout(function () {
                        c(g, f)
                    }, n.interval)
                }
            } else {
                a(f).unbind("mousemove", e);
                if (f.hoverIntent_s == 1) {
                    f.hoverIntent_t = setTimeout(function () {
                        j(g, f)
                    }, n.timeout)
                }
            }
        };
        return this.mouseover(b).mouseout(b)
    }
})(jQuery);
(function (c) {
    var b = c.browser.msie && parseInt(c.browser.version) == 6 && typeof window.XMLHttpRequest != "object",
        d = null,
        a = [];
    c.modal = function (f, e) {
        return c.modal.impl.init(f, e)
    };
    c.modal.close = function () {
        c.modal.impl.close()
    };
    c.fn.modal = function (e) {
        return c.modal.impl.init(this, e)
    };
    c.modal.defaults = {
        appendTo: "body",
        focus: true,
        opacity: 50,
        overlayId: "simplemodal-overlay",
        overlayCss: {},
        containerId: "simplemodal-container",
        containerCss: {},
        dataId: "simplemodal-data",
        dataCss: {},
        minHeight: null,
        minWidth: null,
        maxHeight: null,
        maxWidth: null,
        autoResize: false,
        autoPosition: true,
        zIndex: 1000,
        close: true,
        closeHTML: '<a class="modalCloseImg" title="Close"></a>',
        closeClass: "simplemodal-close",
        escClose: true,
        overlayClose: false,
        position: null,
        persist: false,
        modal: true,
        onOpen: null,
        onShow: null,
        onClose: null
    };
    c.modal.impl = {
        o: null,
        d: {},
        init: function (g, e) {
            var f = this;
            if (f.d.data) {
                return false
            }
            d = c.browser.msie && !c.boxModel;
            f.o = c.extend({}, c.modal.defaults, e);
            f.zIndex = f.o.zIndex;
            f.occb = false;
            if (typeof g == "object") {
                g = g instanceof jQuery ? g : c(g);
                f.d.placeholder = false;
                if (g.parent().parent().size() > 0) {
                    g.before(c("<span></span>").attr("id", "simplemodal-placeholder").css({
                        display: "none"
                    }));
                    f.d.placeholder = true;
                    f.display = g.css("display");
                    if (!f.o.persist) {
                        f.d.orig = g.clone(true)
                    }
                }
            } else {
                if (typeof g == "string" || typeof g == "number") {
                    g = c("<div></div>").html(g)
                } else {
                    alert("SimpleModal Error: Unsupported data type: " + typeof g);
                    return f
                }
            }
            f.create(g);
            g = null;
            f.open();
            if (c.isFunction(f.o.onShow)) {
                f.o.onShow.apply(f, [f.d])
            }
            return f
        },
        create: function (f) {
            var e = this;
            a = e.getDimensions();
            if (e.o.modal && b) {
                e.d.iframe = c('<iframe src="javascript:false;"></iframe>').css(c.extend(e.o.iframeCss, {
                    display: "none",
                    opacity: 0,
                    position: "fixed",
                    height: a[0],
                    width: a[1],
                    zIndex: e.o.zIndex,
                    top: 0,
                    left: 0
                })).appendTo(e.o.appendTo)
            }
            e.d.overlay = c("<div></div>").attr("id", e.o.overlayId).addClass("simplemodal-overlay").css(c.extend(e.o.overlayCss, {
                display: "none",
                opacity: e.o.opacity / 100,
                height: e.o.modal ? a[0] : 0,
                width: e.o.modal ? a[1] : 0,
                position: "fixed",
                left: 0,
                top: 0,
                zIndex: e.o.zIndex + 1
            })).appendTo(e.o.appendTo);
            e.d.container = c("<div></div>").attr("id", e.o.containerId).addClass("simplemodal-container").css(c.extend(e.o.containerCss, {
                display: "none",
                position: "fixed",
                zIndex: e.o.zIndex + 2
            })).append(e.o.close && e.o.closeHTML ? c(e.o.closeHTML).addClass(e.o.closeClass) : "").appendTo(e.o.appendTo);
            e.d.wrap = c("<div></div>").attr("tabIndex", -1).addClass("simplemodal-wrap").css({
                height: "100%",
                outline: 0,
                width: "100%"
            }).appendTo(e.d.container);
            e.d.data = f.attr("id", f.attr("id") || e.o.dataId).addClass("simplemodal-data").css(c.extend(e.o.dataCss, {
                display: "none"
            })).appendTo("body");
            f = null;
            e.setContainerDimensions();
            e.d.data.appendTo(e.d.wrap);
            if (b || d) {
                e.fixIE()
            }
        },
        bindEvents: function () {
            var e = this;
            c("." + e.o.closeClass).bind("click.simplemodal", function (f) {
                f.preventDefault();
                e.close()
            });
            if (e.o.modal && e.o.close && e.o.overlayClose) {
                e.d.overlay.bind("click.simplemodal", function (f) {
                    f.preventDefault();
                    e.close()
                })
            }
            c(document).bind("keydown.simplemodal", function (f) {
                if (e.o.modal && e.o.focus && f.keyCode == 9) {
                    e.watchTab(f)
                } else {
                    if ((e.o.close && e.o.escClose) && f.keyCode == 27) {
                        f.preventDefault();
                        e.close()
                    }
                }
            });
            c(window).bind("resize.simplemodal", function () {
                a = e.getDimensions();
                e.setContainerDimensions(true);
                if (b || d) {
                    e.fixIE()
                } else {
                    if (e.o.modal) {
                        e.d.iframe && e.d.iframe.css({
                            height: a[0],
                            width: a[1]
                        });
                        e.d.overlay.css({
                            height: a[0],
                            width: a[1]
                        })
                    }
                }
            })
        },
        unbindEvents: function () {
            c("." + this.o.closeClass).unbind("click.simplemodal");
            c(document).unbind("keydown.simplemodal");
            c(window).unbind("resize.simplemodal");
            this.d.overlay.unbind("click.simplemodal")
        },
        fixIE: function () {
            var e = this,
                f = e.o.position;
            c.each([e.d.iframe || null, !e.o.modal ? null : e.d.overlay, e.d.container], function (t, l) {
                if (l) {
                    var q = "document.body.clientHeight",
                        v = "document.body.clientWidth",
                        y = "document.body.scrollHeight",
                        u = "document.body.scrollLeft",
                        o = "document.body.scrollTop",
                        j = "document.body.scrollWidth",
                        h = "document.documentElement.clientHeight",
                        r = "document.documentElement.clientWidth",
                        p = "document.documentElement.scrollLeft",
                        z = "document.documentElement.scrollTop",
                        A = l[0].style;
                    A.position = "absolute";
                    if (t < 2) {
                        A.removeExpression("height");
                        A.removeExpression("width");
                        A.setExpression("height", "" + y + " > " + q + " ? " + y + " : " + q + ' + "px"');
                        A.setExpression("width", "" + j + " > " + v + " ? " + j + " : " + v + ' + "px"')
                    } else {
                        var n, g;
                        if (f && f.constructor == Array) {
                            var w = f[0] ? typeof f[0] == "number" ? f[0].toString() : f[0].replace(/px/, "") : l.css("top").replace(/px/, "");
                            n = w.indexOf("%") == -1 ? w + " + (t = " + z + " ? " + z + " : " + o + ') + "px"' : parseInt(w.replace(/%/, "")) + " * ((" + h + " || " + q + ") / 100) + (t = " + z + " ? " + z + " : " + o + ') + "px"';
                            if (f[1]) {
                                var m = typeof f[1] == "number" ? f[1].toString() : f[1].replace(/px/, "");
                                g = m.indexOf("%") == -1 ? m + " + (t = " + p + " ? " + p + " : " + u + ') + "px"' : parseInt(m.replace(/%/, "")) + " * ((" + r + " || " + v + ") / 100) + (t = " + p + " ? " + p + " : " + u + ') + "px"'
                            }
                        } else {
                            n = "(" + h + " || " + q + ") / 2 - (this.offsetHeight / 2) + (t = " + z + " ? " + z + " : " + o + ') + "px"';
                            g = "(" + r + " || " + v + ") / 2 - (this.offsetWidth / 2) + (t = " + p + " ? " + p + " : " + u + ') + "px"'
                        }
                        A.removeExpression("top");
                        A.removeExpression("left");
                        A.setExpression("top", n);
                        A.setExpression("left", g)
                    }
                }
            })
        },
        focus: function (h) {
            var f = this,
                g = h || "first";
            var e = c(":input:enabled:visible:" + g, f.d.wrap);
            e.length > 0 ? e.focus() : f.d.wrap.focus()
        },
        getDimensions: function () {
            var f = c(window);
            var e = c.browser.opera && c.browser.version > "9.5" && c.fn.jquery <= "1.2.6" ? document.documentElement.clientHeight : c.browser.opera && c.browser.version < "9.5" && c.fn.jquery > "1.2.6" ? window.innerHeight : f.height();
            return [e, f.width()]
        },
        getVal: function (e) {
            return e == "auto" ? 0 : e.indexOf("%") > 0 ? e : parseInt(e.replace(/px/, ""))
        },
        setContainerDimensions: function (h) {
            var l = this;
            if (!h || (h && l.o.autoResize)) {
                var j = c.browser.opera ? l.d.container.height() : l.getVal(l.d.container.css("height")),
                    e = c.browser.opera ? l.d.container.width() : l.getVal(l.d.container.css("width")),
                    m = l.d.data.outerHeight(true),
                    g = l.d.data.outerWidth(true);
                var f = l.o.maxHeight && l.o.maxHeight < a[0] ? l.o.maxHeight : a[0],
                    n = l.o.maxWidth && l.o.maxWidth < a[1] ? l.o.maxWidth : a[1];
                if (!j) {
                    if (!m) {
                        j = l.o.minHeight
                    } else {
                        if (m > f) {
                            j = f
                        } else {
                            if (m < l.o.minHeight) {
                                j = l.o.minHeight
                            } else {
                                j = m
                            }
                        }
                    }
                } else {
                    j = j > f ? f : j
                }
                if (!e) {
                    if (!g) {
                        e = l.o.minWidth
                    } else {
                        if (g > n) {
                            e = n
                        } else {
                            if (g < l.o.minWidth) {
                                e = l.o.minWidth
                            } else {
                                e = g
                            }
                        }
                    }
                } else {
                    e = e > n ? n : e
                }
                l.d.container.css({
                    height: j,
                    width: e
                });
                if (m > j || g > e) {
                    l.d.wrap.css({
                        overflow: "auto"
                    })
                }
            }
            if (l.o.autoPosition) {
                l.setPosition()
            }
        },
        setPosition: function () {
            var f = this,
                h, g, j = (a[0] / 2) - (f.d.container.outerHeight(true) / 2),
                e = (a[1] / 2) - (f.d.container.outerWidth(true) / 2);
            if (f.o.position && Object.prototype.toString.call(f.o.position) === "[object Array]") {
                h = f.o.position[0] || j;
                g = f.o.position[1] || e
            } else {
                h = j;
                g = e
            }
            f.d.container.css({
                left: g,
                top: h
            })
        },
        watchTab: function (g) {
            var f = this;
            if (c(g.target).parents(".simplemodal-container").length > 0) {
                f.inputs = c(":input:enabled:visible:first, :input:enabled:visible:last", f.d.data[0]);
                if ((!g.shiftKey && g.target == f.inputs[f.inputs.length - 1]) || (g.shiftKey && g.target == f.inputs[0]) || f.inputs.length == 0) {
                    g.preventDefault();
                    var h = g.shiftKey ? "last" : "first";
                    setTimeout(function () {
                        f.focus(h)
                    }, 10)
                }
            } else {
                g.preventDefault();
                setTimeout(function () {
                    f.focus()
                }, 10)
            }
        },
        open: function () {
            var e = this;
            e.d.iframe && e.d.iframe.show();
            if (c.isFunction(e.o.onOpen)) {
                e.o.onOpen.apply(e, [e.d])
            } else {
                e.d.overlay.show();
                e.d.container.show();
                e.d.data.show()
            }
            e.focus();
            e.bindEvents()
        },
        close: function () {
            var e = this;
            if (!e.d.data) {
                return false
            }
            e.unbindEvents();
            if (c.isFunction(e.o.onClose) && !e.occb) {
                e.occb = true;
                e.o.onClose.apply(e, [e.d])
            } else {
                if (e.d.placeholder) {
                    var f = c("#simplemodal-placeholder");
                    if (e.o.persist) {
                        f.replaceWith(e.d.data.removeClass("simplemodal-data").css("display", e.display))
                    } else {
                        e.d.data.hide().remove();
                        f.replaceWith(e.d.orig)
                    }
                } else {
                    e.d.data.hide().remove()
                }
                e.d.container.hide().remove();
                e.d.overlay.hide().remove();
                e.d.iframe && e.d.iframe.hide().remove();
                e.d = {}
            }
        }
    }
})(jQuery);
(function (a) {
    a.fn.autoSuggest = function (f, c) {
        var j = {
            asHtmlID: false,
            startText: "",
            emptyText: "No Companies Found",
            preFill: {},
            limitText: "No More Selections Are Allowed",
            selectedItemProp: "value",
            selectedValuesProp: "value",
            searchObjProps: "value",
            queryParam: "q",
            retrieveLimit: false,
            extraParams: "",
            matchCase: false,
            minChars: 1,
            keyDelay: 400,
            resultsHighlight: true,
            neverSubmit: false,
            selectionLimit: false,
            showResultList: true,
            start: function () {},
            selectionClick: function (l) {},
            selectionAdded: function (l) {},
            selectionRemoved: function (l) {
                l.remove()
            },
            formatList: false,
            beforeRetrieve: function (l) {
                return l
            },
            retrieveComplete: function (l) {
                return l
            },
            resultClick: function (l) {},
            resultsComplete: function () {}
        };
        var e = a.extend(j, c);
        var d = "object";
        var h = 0;
        if (typeof f == "string") {
            d = "string";
            var b = f
        } else {
            var g = f;
            for (k in f) {
                if (f.hasOwnProperty(k)) {
                    h++
                }
            }
        }
        if ((d == "object" && h > 0) || d == "string") {
            return this.each(function (z) {
                if (!e.asHtmlID) {
                    z = z + "" + Math.floor(Math.random() * 100);
                    var m = "as-input-" + z
                } else {
                    z = e.asHtmlID;
                    var m = z
                }
                e.start.call(this);
                var B = a(this);
                B.attr("autocomplete", "off").addClass("as-input").attr("id", m).val(e.startText);
                var F = false;
                B.wrap('<ul class="as-selections" id="as-selections-' + z + '"></ul>').wrap('<li class="as-original" id="as-original-' + z + '"></li>');
                var G = a("#as-selections-" + z);
                var v = a("#as-original-" + z);
                var o = a('<div class="as-results" id="as-results-' + z + '"></div>').hide();
                var p = a('<ul class="as-list"></ul>');
                var J = a('<input type="hidden" class="as-values" name="as_values_' + z + '" id="as-values-' + z + '" />');
                var u = "";
                if (typeof e.preFill == "string") {
                    var C = e.preFill.split(",");
                    for (var H = 0; H < C.length; H++) {
                        var n = {};
                        n[e.selectedValuesProp] = C[H];
                        if (C[H] != "") {
                            I(n, "000" + H)
                        }
                    }
                    u = e.preFill
                } else {
                    u = "";
                    var K = 0;
                    for (k in e.preFill) {
                        if (e.preFill.hasOwnProperty(k)) {
                            K++
                        }
                    }
                    if (K > 0) {
                        for (var H = 0; H < K; H++) {
                            var D = e.preFill[H][e.selectedValuesProp];
                            if (D == undefined) {
                                D = ""
                            }
                            u = u + D + ",";
                            if (D != "") {
                                I(e.preFill[H], "000" + H)
                            }
                        }
                    }
                }
                if (u != "") {
                    B.val("");
                    var A = u.substring(u.length - 1);
                    if (A != ",") {
                        u = u + ","
                    }
                    J.val("," + u);
                    a("li.as-selection-item", G).addClass("blur").removeClass("selected")
                }
                B.after(J);
                G.click(function () {
                    F = true;
                    B.focus()
                }).mousedown(function () {
                    F = false
                }).after(o);
                var y = null;
                var E = "";
                var q = 0;
                var r = false;
                B.focus(function () {
                    if (a(this).val() == e.startText && J.val() == "") {
                        a(this).val("")
                    } else {
                        if (F) {
                            a("li.as-selection-item", G).removeClass("blur");
                            if (a(this).val() != "") {
                                p.css("width", G.outerWidth());
                                o.show()
                            }
                        }
                    }
                    F = true;
                    return true
                }).blur(function () {
                    if (a(this).val() == "" && J.val() == "" && u == "") {
                        a(this).val(e.startText)
                    } else {
                        if (F) {
                            a("li.as-selection-item", G).addClass("blur").removeClass("selected");
                            o.hide()
                        }
                    }
                }).keydown(function (Q) {
                    lastKeyPressCode = Q.keyCode;
                    first_focus = false;
                    switch (Q.keyCode) {
                    case 38:
                        Q.preventDefault();
                        w("up");
                        break;
                    case 40:
                        Q.preventDefault();
                        w("down");
                        break;
                    case 8:
                        if (B.val() == "") {
                            var M = J.val().split(",");
                            M = M[M.length - 2];
                            G.children().not(v.prev()).removeClass("selected");
                            if (v.prev().hasClass("selected")) {
                                J.val(J.val().replace("," + M + ",", ","));
                                e.selectionRemoved.call(this, v.prev())
                            } else {
                                e.selectionClick.call(this, v.prev());
                                v.prev().addClass("selected")
                            }
                        }
                        if (B.val().length == 1) {
                            o.hide();
                            E = ""
                        }
                        if (a(":visible", o).length > 0) {
                            if (y) {
                                clearTimeout(y)
                            }
                            y = setTimeout(function () {
                                l()
                            }, e.keyDelay)
                        }
                        break;
                    case 9:
                    case 188:
                        r = true;
                        var O = B.val().replace(/(,)/g, "");
                        if (O != "" && J.val().search("," + O + ",") < 0 && O.length >= e.minChars) {
                            Q.preventDefault();
                            var N = {};
                            N[e.selectedItemProp] = O;
                            N[e.selectedValuesProp] = O;
                            var L = a("li", G).length;
                            I(N, "00" + (L + 1));
                            B.val("")
                        }
                    case 13:
                        r = false;
                        var P = a("li.active:first", o);
                        if (P.length > 0) {
                            P.click();
                            o.hide()
                        }
                        if (e.neverSubmit || P.length > 0) {
                            Q.preventDefault()
                        }
                        break;
                    default:
                        if (e.showResultList) {
                            if (e.selectionLimit && a("li.as-selection-item", G).length >= e.selectionLimit) {
                                p.html('<li class="as-message">' + e.limitText + "</li>");
                                o.show()
                            } else {
                                if (y) {
                                    clearTimeout(y)
                                }
                                y = setTimeout(function () {
                                    l()
                                }, e.keyDelay)
                            }
                        }
                        break
                    }
                });

                function l() {
                    if (lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32)) {
                        return o.hide()
                    }
                    var M = B.val().replace(/[\\]+|[\/]+/g, "");
                    if (M == E) {
                        return
                    }
                    E = M;
                    if (M.length >= e.minChars) {
                        G.addClass("loading");
                        if (d == "string") {
                            var L = "";
                            if (e.retrieveLimit) {
                                L = "&limit=" + encodeURIComponent(e.retrieveLimit)
                            }
                            if (e.beforeRetrieve) {
                                M = e.beforeRetrieve.call(this, M)
                            }
                            a.getJSON(b + "?" + e.queryParam + "=" + encodeURIComponent(M) + L + e.extraParams, function (O) {
                                h = 0;
                                var N = e.retrieveComplete.call(this, O);
                                for (k in N) {
                                    if (N.hasOwnProperty(k)) {
                                        h++
                                    }
                                }
                                s(N, M)
                            })
                        } else {
                            if (e.beforeRetrieve) {
                                M = e.beforeRetrieve.call(this, M)
                            }
                            s(g, M)
                        }
                    } else {
                        G.removeClass("loading");
                        o.hide()
                    }
                }
                var t = 0;

                function s(O, U) {
                    if (!e.matchCase) {
                        U = U.toLowerCase()
                    }
                    var W = 0;
                    o.html(p.html("")).hide();
                    for (var P = 0; P < h; P++) {
                        var Q = P;
                        t++;
                        var R = false;
                        if (e.searchObjProps == "value") {
                            var S = O[Q].value
                        } else {
                            var S = "";
                            var T = e.searchObjProps.split(",");
                            for (var V = 0; V < T.length; V++) {
                                var L = a.trim(T[V]);
                                S = S + O[Q][L] + " "
                            }
                        }
                        if (S) {
                            if (!e.matchCase) {
                                S = S.toLowerCase()
                            }
                            if (S.search(U) != -1 && J.val().search("," + O[Q][e.selectedValuesProp] + ",") == -1) {
                                R = true
                            }
                        }
                        if (R) {
                            var N = a('<li class="as-result-item" id="as-result-item-' + Q + '"></li>').click(function () {
                                var aa = a(this).data("data");
                                var Y = aa.num;
                                if (a("#as-selection-" + Y, G).length <= 0 && !r) {
                                    var Z = aa.attributes;
                                    B.val("").focus();
                                    E = "";
                                    I(Z, Y);
                                    e.resultClick.call(this, aa);
                                    o.hide()
                                }
                                r = false
                            }).mousedown(function () {
                                F = false
                            }).mouseover(function () {
                                a("li", p).removeClass("active");
                                a(this).addClass("active")
                            }).data("data", {
                                attributes: O[Q],
                                num: t
                            });
                            var X = a.extend({}, O[Q]);
                            if (!e.matchCase) {
                                var M = new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + U + ")(?![^<>]*>)(?![^&;]+;)", "gi")
                            } else {
                                var M = new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + U + ")(?![^<>]*>)(?![^&;]+;)", "g")
                            }
                            if (e.resultsHighlight) {
                                X[e.selectedItemProp] = X[e.selectedItemProp].replace(M, "<em>$1</em>")
                            }
                            if (!e.formatList) {
                                N = N.html(X[e.selectedItemProp])
                            } else {
                                N = e.formatList.call(this, X, N)
                            }
                            p.append(N);
                            delete X;
                            W++;
                            if (e.retrieveLimit && e.retrieveLimit == W) {
                                break
                            }
                        }
                    }
                    G.removeClass("loading");
                    if (W <= 0) {
                        p.html('<li class="as-message">' + e.emptyText + "</li>")
                    }
                    p.css("width", G.outerWidth());
                    o.show();
                    e.resultsComplete.call(this)
                }
                function I(N, L) {
                    J.val(J.val() + N[e.selectedValuesProp] + ",");
                    var M = a('<li class="as-selection-item" id="as-selection-' + L + '"></li>').click(function () {
                        e.selectionClick.call(this, a(this));
                        G.children().removeClass("selected");
                        a(this).addClass("selected")
                    }).mousedown(function () {
                        F = false
                    });
                    var O = a('<a class="as-close">×</a>').click(function () {
                        J.val(J.val().replace("," + N[e.selectedValuesProp] + ",", ","));
                        e.selectionRemoved.call(this, M);
                        F = true;
                        B.focus();
                        return false
                    });
                    v.before(M.html(N[e.selectedItemProp]).prepend(O));
                    e.selectionAdded.call(this, v.prev())
                }
                function w(N) {
                    if (a(":visible", o).length > 0) {
                        var L = a("li", o);
                        if (N == "down") {
                            var O = L.eq(0)
                        } else {
                            var O = L.filter(":last")
                        }
                        var M = a("li.active:first", o);
                        if (M.length > 0) {
                            if (N == "down") {
                                O = M.next()
                            } else {
                                O = M.prev()
                            }
                        }
                        L.removeClass("active");
                        O.addClass("active")
                    }
                }
            })
        }
    }
})(jQuery);
(function (b) {
    var a = null;
    b.fn.liveUpdate = function (c) {
        return this.each(function () {
            new b.liveUpdate(this, c)
        })
    };
    b.liveUpdate = function (d, c) {
        this.field = b(d);
        this.list = b("#" + c);
        if (this.list.length > 0) {
            this.init()
        }
    };
    b.liveUpdate.prototype = {
        init: function () {
            var c = this;
            this.setupCache();
            this.field.parents("form").submit(function () {
                return false
            });
            this.field.keyup(function () {
                c.filter()
            });
            c.filter()
        },
        filter: function () {
            if (b.trim(this.field.val()) == "") {
                this.list.children("li.tr").show();
                return
            }
            this.displayResults(this.getScores(this.field.val().replace(/<\/?[^>]+>/gi, "").toLowerCase()));
            if (b("#results-filter-menu").length) {
                b("#results-filter-menu").children().removeClass("active-element")
            }
        },
        setupCache: function () {
            var c = this;
            this.cache = [];
            this.rows = [];
            this.list.children("li.tr").each(function () {
                c.cache.push(this.innerHTML.replace(/<\/?[^>]+>/gi, "").toLowerCase());
                c.rows.push(b(this))
            });
            this.cache_length = this.cache.length
        },
        displayResults: function (d) {
            var c = this;
            this.list.children("li.tr").hide();
            b.each(d, function (e, f) {
                c.rows[f[1]].show()
            })
        },
        getScores: function (d) {
            var f = [];
            for (var c = 0; c < this.cache_length; c++) {
                var e = this.cache[c].score(d);
                if (e > 0) {
                    f.push([e, c])
                }
            }
            return f.sort(function (h, g) {
                return g[0] - h[0]
            })
        }
    }
})(jQuery);
(function (f) {
    f.fn.simpledraw = function (j, h, l) {
        if (l && this[0].vcanvas) {
            return this[0].vcanvas
        }
        if (j == undefined) {
            j = f(this).innerWidth()
        }
        if (h == undefined) {
            h = f(this).innerHeight()
        }
        if (f.browser.hasCanvas) {
            return new c(j, h, this)
        } else {
            if (f.browser.msie) {
                return new d(j, h, this)
            } else {
                return false
            }
        }
    };
    var g = [];
    f.fn.sparkline = function (j, h) {
        var h = f.extend({
            type: "line",
            lineColor: "#00f",
            fillColor: "#cdf",
            defaultPixelsPerValue: 3,
            width: "auto",
            height: "auto",
            composite: false
        }, h ? h : {});
        return this.each(function () {
            var l = function () {
                var m = (j == "html" || j == undefined) ? f(this).text().split(",") : j;
                var o = h.width == "auto" ? m.length * h.defaultPixelsPerValue : h.width;
                if (h.height == "auto") {
                    if (!h.composite || !this.vcanvas) {
                        var n = document.createElement("span");
                        n.innerHTML = "a";
                        f(this).html(n);
                        height = f(n).innerHeight();
                        f(n).remove()
                    }
                } else {
                    height = h.height
                }
                f.fn.sparkline[h.type].call(this, m, h, o, height)
            };
            if ((f(this).html() && f(this).is(":hidden")) || (f.fn.jquery < "1.3.0" && f(this).parents().is(":hidden"))) {
                g.push([this, l])
            } else {
                l.call(this)
            }
        })
    };
    f.sparkline_display_visible = function () {
        for (var h = g.length - 1; h >= 0; h--) {
            var j = g[h][0];
            if (f(j).is(":visible") && !f(j).parents().is(":hidden")) {
                g[h][1].call(j);
                g.splice(h, 1)
            }
        }
    };
    f.fn.sparkline.line = function (m, o, L, I) {
        var o = f.extend({
            spotColor: "#f80",
            spotRadius: 1.5,
            minSpotColor: "#f80",
            maxSpotColor: "#f80",
            lineWidth: 1,
            normalRangeMin: undefined,
            normalRangeMax: undefined,
            normalRangeColor: "#ccc",
            chartRangeMin: undefined,
            chartRangeMax: undefined,
            chartRangeMinX: undefined,
            chartRangeMaxX: undefined
        }, o ? o : {});
        var z = [],
            w = [],
            F = [];
        for (O = 0; O < m.length; O++) {
            var G = m[O];
            var J = typeof(m[O]) == "string";
            var s = typeof(m[O]) == "object" && m[O] instanceof Array;
            var P = J && m[O].split(":");
            if (J && P.length == 2) {
                z.push(Number(P[0]));
                w.push(Number(P[1]));
                F.push(Number(P[1]))
            } else {
                if (s) {
                    z.push(m[O][0]);
                    w.push(m[O][1]);
                    F.push(m[O][1])
                } else {
                    z.push(O);
                    if (m[O] === null || m[O] == "null") {
                        w.push(null)
                    } else {
                        w.push(Number(m[O]));
                        F.push(Number(m[O]))
                    }
                }
            }
        }
        if (o.xvalues) {
            z = o.xvalues
        }
        var n = Math.max.apply(Math, F);
        var B = n;
        var p = Math.min.apply(Math, F);
        var t = p;
        var q = Math.max.apply(Math, z);
        var u = q;
        var r = Math.min.apply(Math, z);
        var l = r;
        if (o.normalRangeMin != undefined) {
            if (o.normalRangeMin < p) {
                p = o.normalRangeMin
            }
            if (o.normalRangeMax > n) {
                n = o.normalRangeMax
            }
        }
        if (o.chartRangeMin != undefined && (o.chartRangeClip || o.chartRangeMin < p)) {
            p = o.chartRangeMin
        }
        if (o.chartRangeMax != undefined && (o.chartRangeClip || o.chartRangeMax > n)) {
            n = o.chartRangeMax
        }
        if (o.chartRangeMinX != undefined && (o.chartRangeClipX || o.chartRangeMinX < r)) {
            r = o.chartRangeMinX
        }
        if (o.chartRangeMaxX != undefined && (o.chartRangeClipX || o.chartRangeMaxX > q)) {
            q = o.chartRangeMaxX
        }
        var j = q - r == 0 ? 1 : q - r;
        var h = n - p == 0 ? 1 : n - p;
        var S = w.length - 1;
        if (S < 1) {
            this.innerHTML = "";
            return
        }
        var T = f(this).simpledraw(L, I, o.composite);
        if (T) {
            var R = T.pixel_width;
            var N = T.pixel_height;
            var U = 0;
            var Q = 0;
            if (o.spotRadius && (R < (o.spotRadius * 4) || N < (o.spotRadius * 4))) {
                o.spotRadius = 0
            }
            if (o.spotRadius) {
                if (o.minSpotColor || (o.spotColor && w[S] == p)) {
                    N -= Math.ceil(o.spotRadius)
                }
                if (o.maxSpotColor || (o.spotColor && w[S] == n)) {
                    N -= Math.ceil(o.spotRadius);
                    U += Math.ceil(o.spotRadius)
                }
                if (o.minSpotColor || o.maxSpotColor && (w[0] == p || w[0] == n)) {
                    Q += Math.ceil(o.spotRadius);
                    R -= Math.ceil(o.spotRadius)
                }
                if (o.spotColor || (o.minSpotColor || o.maxSpotColor && (w[S] == p || w[S] == n))) {
                    R -= Math.ceil(o.spotRadius)
                }
            }
            N--;
            if (o.normalRangeMin != undefined) {
                var H = U + Math.round(N - (N * ((o.normalRangeMax - p) / h)));
                var I = Math.round((N * (o.normalRangeMax - o.normalRangeMin)) / h);
                T.drawRect(Q, H, R, I, undefined, o.normalRangeColor)
            }
            var K = [];
            var M = [K];
            for (var O = 0, A = w.length; O < A; O++) {
                var D = z[O],
                    C = w[O];
                if (C === null) {
                    if (O) {
                        if (w[O - 1] !== null) {
                            K = [];
                            M.push(K)
                        }
                    }
                } else {
                    if (C < p) {
                        C = p
                    }
                    if (C > n) {
                        C = n
                    }
                    if (!K.length) {
                        K.push([Q + Math.round((D - r) * (R / j)), U + N])
                    }
                    K.push([Q + Math.round((D - r) * (R / j)), U + Math.round(N - (N * ((C - p) / h)))])
                }
            }
            for (var O = 0, E = M.length; O < E; O++) {
                K = M[O];
                if (!K.length) {
                    continue
                }
                if (o.fillColor) {
                    K.push([K[K.length - 1][0], U + N - 1]);
                    T.drawShape(K, undefined, o.fillColor);
                    K.pop()
                }
                if (K.length > 2) {
                    K[0] = [K[0][0], K[1][1]]
                }
                T.drawShape(K, o.lineColor, undefined, o.lineWidth)
            }
            if (o.spotRadius && o.spotColor) {
                T.drawCircle(Q + Math.round(z[z.length - 1] * (R / j)), U + Math.round(N - (N * ((w[S] - p) / h))), o.spotRadius, undefined, o.spotColor)
            }
            if (n != t) {
                if (o.spotRadius && o.minSpotColor) {
                    var D = z[w.indexOf(t)];
                    T.drawCircle(Q + Math.round((D - r) * (R / j)), U + Math.round(N - (N * ((t - p) / h))), o.spotRadius, undefined, o.minSpotColor)
                }
                if (o.spotRadius && o.maxSpotColor) {
                    var D = z[w.indexOf(B)];
                    T.drawCircle(Q + Math.round((D - r) * (R / j)), U + Math.round(N - (N * ((B - p) / h))), o.spotRadius, undefined, o.maxSpotColor)
                }
            }
        } else {
            this.innerHTML = ""
        }
    };
    f.fn.sparkline.bar = function (h, l, u, s) {
        var l = f.extend({
            type: "bar",
            barColor: "#00f",
            negBarColor: "#f44",
            zeroColor: undefined,
            nullColor: undefined,
            zeroAxis: undefined,
            barWidth: 4,
            barSpacing: 1,
            chartRangeMax: undefined,
            chartRangeMin: undefined,
            chartRangeClip: false,
            colorMap: undefined
        }, l ? l : {});
        var u = (h.length * l.barWidth) + ((h.length - 1) * l.barSpacing);
        var m = [];
        for (var B = 0, o = h.length; B < o; B++) {
            if (h[B] == "null" || h[B] === null) {
                h[B] = null
            } else {
                h[B] = Number(h[B]);
                m.push(Number(h[B]))
            }
        }
        var A = Math.max.apply(Math, m);
        var v = Math.min.apply(Math, m);
        if (l.chartRangeMin != undefined && (l.chartRangeClip || l.chartRangeMin < v)) {
            v = l.chartRangeMin
        }
        if (l.chartRangeMax != undefined && (l.chartRangeClip || l.chartRangeMax > A)) {
            A = l.chartRangeMax
        }
        if (l.zeroAxis == undefined) {
            l.zeroAxis = v < 0
        }
        var r = A - v == 0 ? 1 : A - v;
        if (f.isArray(l.colorMap)) {
            var n = l.colorMap;
            var t = null
        } else {
            var n = null;
            var t = l.colorMap
        }
        var D = f(this).simpledraw(u, s, l.composite);
        if (D) {
            var C = D.pixel_width;
            var z = D.pixel_height;
            var j = v < 0 && l.zeroAxis ? z - Math.round(z * (Math.abs(v) / r)) - 1 : z - 1;
            for (var B = 0, o = h.length; B < o; B++) {
                var q = B * (l.barWidth + l.barSpacing);
                var E = h[B];
                if (E === null) {
                    if (l.nullColor) {
                        w = l.nullColor;
                        E = (l.zeroAxis && v < 0) ? 0 : v;
                        var s = 1;
                        var p = (l.zeroAxis && v < 0) ? j : z - s
                    } else {
                        continue
                    }
                } else {
                    if (E < v) {
                        E = v
                    }
                    if (E > A) {
                        E = A
                    }
                    var w = (E < 0) ? l.negBarColor : l.barColor;
                    if (l.zeroAxis && v < 0) {
                        var s = Math.round(z * ((Math.abs(E) / r))) + 1;
                        var p = (E < 0) ? j : j - s
                    } else {
                        var s = Math.round(z * ((E - v) / r)) + 1;
                        var p = z - s
                    }
                    if (E == 0 && l.zeroColor != undefined) {
                        w = l.zeroColor
                    }
                    if (t && t[E]) {
                        w = t[E]
                    } else {
                        if (n && n.length > B) {
                            w = n[B]
                        }
                    }
                    if (w === null) {
                        continue
                    }
                }
                D.drawRect(q, p, l.barWidth - 1, s - 1, w, w)
            }
        } else {
            this.innerHTML = ""
        }
    };
    f.fn.sparkline.tristate = function (v, z, j, w) {
        v = f.map(v, Number);
        var z = f.extend({
            barWidth: 4,
            barSpacing: 1,
            posBarColor: "#6f6",
            negBarColor: "#f44",
            zeroBarColor: "#999",
            colorMap: {}
        }, z);
        var j = (v.length * z.barWidth) + ((v.length - 1) * z.barSpacing);
        if (f.isArray(z.colorMap)) {
            var o = z.colorMap;
            var u = null
        } else {
            var o = null;
            var u = z.colorMap
        }
        var p = f(this).simpledraw(j, w, z.composite);
        if (p) {
            var q = p.pixel_width;
            var h = p.pixel_height;
            var n = Math.round(h / 2);
            for (var m = 0, t = v.length; m < t; m++) {
                var s = m * (z.barWidth + z.barSpacing);
                if (v[m] < 0) {
                    var r = n;
                    var w = n - 1;
                    var l = z.negBarColor
                } else {
                    if (v[m] > 0) {
                        var r = 0;
                        var w = n - 1;
                        var l = z.posBarColor
                    } else {
                        var r = n - 1;
                        var w = 2;
                        var l = z.zeroBarColor
                    }
                }
                if (u && u[v[m]]) {
                    l = u[v[m]]
                } else {
                    if (o && o.length > m) {
                        l = o[m]
                    }
                }
                if (l === null) {
                    continue
                }
                p.drawRect(s, r, z.barWidth - 1, w - 1, l, l)
            }
        } else {
            this.innerHTML = ""
        }
    };
    f.fn.sparkline.discrete = function (h, j, s, r) {
        h = f.map(h, Number);
        var j = f.extend({
            lineHeight: "auto",
            thresholdColor: undefined,
            thresholdValue: 0,
            chartRangeMax: undefined,
            chartRangeMin: undefined,
            chartRangeClip: false
        }, j);
        s = j.width == "auto" ? h.length * 2 : s;
        var z = Math.floor(s / h.length);
        var A = f(this).simpledraw(s, r, j.composite);
        if (A) {
            var y = A.pixel_width;
            var u = A.pixel_height;
            var o = j.lineHeight == "auto" ? Math.round(u * 0.3) : j.lineHeight;
            var m = u - o;
            var t = Math.min.apply(Math, h);
            var v = Math.max.apply(Math, h);
            if (j.chartRangeMin != undefined && (j.chartRangeClip || j.chartRangeMin < t)) {
                t = j.chartRangeMin
            }
            if (j.chartRangeMax != undefined && (j.chartRangeClip || j.chartRangeMax > v)) {
                v = j.chartRangeMax
            }
            var p = v - t;
            for (var w = 0, l = h.length; w < l; w++) {
                var B = h[w];
                if (B < t) {
                    B = t
                }
                if (B > v) {
                    B = v
                }
                var n = (w * z);
                var q = Math.round(m - m * ((B - t) / p));
                A.drawLine(n, q, n, q + o, (j.thresholdColor && B < j.thresholdValue) ? j.thresholdColor : j.lineColor)
            }
        } else {
            this.innerHTML = ""
        }
    };
    f.fn.sparkline.bullet = function (l, n, u, s) {
        l = f.map(l, Number);
        var n = f.extend({
            targetColor: "red",
            targetWidth: 3,
            performanceColor: "blue",
            rangeColors: ["#D3DAFE", "#A8B6FF", "#7F94FF"],
            base: undefined
        }, n);
        u = n.width == "auto" ? "4.0em" : u;
        var B = f(this).simpledraw(u, s, n.composite);
        if (B && l.length > 1) {
            var A = B.pixel_width - Math.ceil(n.targetWidth / 2);
            var w = B.pixel_height;
            var v = Math.min.apply(Math, l);
            var y = Math.max.apply(Math, l);
            if (n.base == undefined) {
                var v = v < 0 ? v : 0
            } else {
                v = n.base
            }
            var q = y - v;
            for (i = 2, vlen = l.length; i < vlen; i++) {
                var o = parseInt(l[i]);
                var j = Math.round(A * ((o - v) / q));
                B.drawRect(0, 0, j - 1, w - 1, n.rangeColors[i - 2], n.rangeColors[i - 2])
            }
            var t = parseInt(l[1]);
            var h = Math.round(A * ((t - v) / q));
            B.drawRect(0, Math.round(w * 0.3), h - 1, Math.round(w * 0.4) - 1, n.performanceColor, n.performanceColor);
            var r = parseInt(l[0]);
            var p = Math.round(A * ((r - v) / q) - (n.targetWidth / 2));
            var m = Math.round(w * 0.1);
            var z = w - (m * 2);
            B.drawRect(p, m, n.targetWidth - 1, z - 1, n.targetColor, n.targetColor)
        } else {
            this.innerHTML = ""
        }
    };
    f.fn.sparkline.pie = function (v, y, m, w) {
        v = f.map(v, Number);
        var y = f.extend({
            sliceColors: ["#f00", "#0f0", "#00f"]
        }, y);
        m = y.width == "auto" ? w : m;
        var r = f(this).simpledraw(m, w, y.composite);
        if (r && v.length > 1) {
            var s = r.pixel_width;
            var h = r.pixel_height;
            var q = Math.floor(Math.min(s, h) / 2);
            var t = 0;
            for (var o = 0, u = v.length; o < u; o++) {
                t += v[o]
            }
            var p = 0;
            if (y.offset) {
                p += (2 * Math.PI) * (y.offset / 360)
            }
            var j = 2 * Math.PI;
            for (var o = 0, u = v.length; o < u; o++) {
                var l = p;
                var n = p;
                if (t > 0) {
                    n = p + (j * (v[o] / t))
                }
                r.drawPieSlice(q, q, q, l, n, undefined, y.sliceColors[o % y.sliceColors.length]);
                p = n
            }
        }
    };

    function a(j, l) {
        if (l == 2) {
            var h = Math.floor(j.length / 2);
            return j.length % 2 ? j[h] : (j[h] + j[h + 1]) / 2
        } else {
            var m = Math.floor(j.length / 4);
            return j.length % 2 ? (j[m * l] + j[m * l + 1]) / 2 : j[m * l]
        }
    }
    f.fn.sparkline.box = function (j, m, v, u) {
        j = f.map(j, Number);
        var m = f.extend({
            raw: false,
            boxLineColor: "black",
            boxFillColor: "#cdf",
            whiskerColor: "black",
            outlierLineColor: "#333",
            outlierFillColor: "white",
            medianColor: "red",
            showOutliers: true,
            outlierIQR: 1.5,
            spotRadius: 1.5,
            target: undefined,
            targetColor: "#4a2",
            chartRangeMax: undefined,
            chartRangeMin: undefined
        }, m);
        v = m.width == "auto" ? "4.0em" : v;
        minvalue = m.chartRangeMin == undefined ? Math.min.apply(Math, j) : m.chartRangeMin;
        maxvalue = m.chartRangeMax == undefined ? Math.max.apply(Math, j) : m.chartRangeMax;
        var D = f(this).simpledraw(v, u, m.composite);
        if (D && j.length > 1) {
            var A = D.pixel_width;
            var w = D.pixel_height;
            if (m.raw) {
                if (m.showOutliers && j.length > 5) {
                    var B = j[0],
                        s = j[1],
                        r = j[2],
                        q = j[3],
                        p = j[4],
                        h = j[5],
                        n = j[6]
                } else {
                    var s = j[0],
                        r = j[1],
                        q = j[2],
                        p = j[3],
                        h = j[4]
                }
            } else {
                j.sort(function (F, E) {
                    return F - E
                });
                var r = a(j, 1);
                var q = a(j, 2);
                var p = a(j, 3);
                var l = p - r;
                if (m.showOutliers) {
                    var s = undefined,
                        h = undefined;
                    for (var y = 0, o = j.length; y < o; y++) {
                        if (s == undefined && j[y] > r - (l * m.outlierIQR)) {
                            s = j[y]
                        }
                        if (j[y] < p + (l * m.outlierIQR)) {
                            h = j[y]
                        }
                    }
                    var B = j[0];
                    var n = j[j.length - 1]
                } else {
                    var s = j[0];
                    var h = j[j.length - 1]
                }
            }
            var C = A / (maxvalue - minvalue + 1);
            var z = 0;
            if (m.showOutliers) {
                z = Math.ceil(m.spotRadius);
                A -= 2 * Math.ceil(m.spotRadius);
                var C = A / (maxvalue - minvalue + 1);
                if (B < s) {
                    D.drawCircle((B - minvalue) * C + z, w / 2, m.spotRadius, m.outlierLineColor, m.outlierFillColor)
                }
                if (n > h) {
                    D.drawCircle((n - minvalue) * C + z, w / 2, m.spotRadius, m.outlierLineColor, m.outlierFillColor)
                }
            }
            D.drawRect(Math.round((r - minvalue) * C + z), Math.round(w * 0.1), Math.round((p - r) * C), Math.round(w * 0.8), m.boxLineColor, m.boxFillColor);
            D.drawLine(Math.round((s - minvalue) * C + z), Math.round(w / 2), Math.round((r - minvalue) * C + z), Math.round(w / 2), m.lineColor);
            D.drawLine(Math.round((s - minvalue) * C + z), Math.round(w / 4), Math.round((s - minvalue) * C + z), Math.round(w - w / 4), m.whiskerColor);
            D.drawLine(Math.round((h - minvalue) * C + z), Math.round(w / 2), Math.round((p - minvalue) * C + z), Math.round(w / 2), m.lineColor);
            D.drawLine(Math.round((h - minvalue) * C + z), Math.round(w / 4), Math.round((h - minvalue) * C + z), Math.round(w - w / 4), m.whiskerColor);
            D.drawLine(Math.round((q - minvalue) * C + z), Math.round(w * 0.1), Math.round((q - minvalue) * C + z), Math.round(w * 0.9), m.medianColor);
            if (m.target) {
                var t = Math.ceil(m.spotRadius);
                D.drawLine(Math.round((m.target - minvalue) * C + z), Math.round((w / 2) - t), Math.round((m.target - minvalue) * C + z), Math.round((w / 2) + t), m.targetColor);
                D.drawLine(Math.round((m.target - minvalue) * C + z - t), Math.round(w / 2), Math.round((m.target - minvalue) * C + z + t), Math.round(w / 2), m.targetColor)
            }
        } else {
            this.innerHTML = ""
        }
    };
    if (!Array.prototype.indexOf) {
        Array.prototype.indexOf = function (j) {
            for (var h = 0, l = this.length; h < l; h++) {
                if (this[h] == j) {
                    return h
                }
            }
            return -1
        }
    }
    if (f.browser.msie && !document.namespaces.v) {
        document.namespaces.add("v", "urn:schemas-microsoft-com:vml", "#default#VML")
    }
    if (f.browser.hasCanvas == undefined) {
        var b = document.createElement("canvas");
        f.browser.hasCanvas = b.getContext != undefined
    }
    var e = function (j, h, l) {};
    e.prototype = {
        init: function (j, h, l) {
            this.width = j;
            this.height = h;
            this.target = l;
            if (l[0]) {
                l = l[0]
            }
            l.vcanvas = this
        },
        drawShape: function (l, j, m, h) {
            alert("drawShape not implemented")
        },
        drawLine: function (l, n, j, m, o, h) {
            return this.drawShape([
                [l, n],
                [j, m]
            ], o, h)
        },
        drawCircle: function (j, n, h, l, m) {
            alert("drawCircle not implemented")
        },
        drawPieSlice: function (j, p, h, m, l, n, o) {
            alert("drawPieSlice not implemented")
        },
        drawRect: function (j, o, l, h, m, n) {
            alert("drawRect not implemented")
        },
        getElement: function () {
            return this.canvas
        },
        _insert: function (h, j) {
            f(j).html(h)
        }
    };
    var c = function (j, h, l) {
        return this.init(j, h, l)
    };
    c.prototype = f.extend(new e, {
        _super: e.prototype,
        init: function (j, h, l) {
            this._super.init(j, h, l);
            this.canvas = document.createElement("canvas");
            if (l[0]) {
                l = l[0]
            }
            l.vcanvas = this;
            f(this.canvas).css({
                display: "inline-block",
                width: j,
                height: h,
                verticalAlign: "top"
            });
            this._insert(this.canvas, l);
            this.pixel_height = f(this.canvas).height();
            this.pixel_width = f(this.canvas).width();
            this.canvas.width = this.pixel_width;
            this.canvas.height = this.pixel_height;
            f(this.canvas).css({
                width: this.pixel_width,
                height: this.pixel_height
            })
        },
        _getContext: function (l, m, h) {
            var j = this.canvas.getContext("2d");
            if (l != undefined) {
                j.strokeStyle = l
            }
            j.lineWidth = h == undefined ? 1 : h;
            if (m != undefined) {
                j.fillStyle = m
            }
            return j
        },
        drawShape: function (o, n, p, h) {
            var l = this._getContext(n, p, h);
            l.beginPath();
            l.moveTo(o[0][0] + 0.5, o[0][1] + 0.5);
            for (var j = 1, m = o.length; j < m; j++) {
                l.lineTo(o[j][0] + 0.5, o[j][1] + 0.5)
            }
            if (n != undefined) {
                l.stroke()
            }
            if (p != undefined) {
                l.fill()
            }
        },
        drawCircle: function (j, o, h, m, n) {
            var l = this._getContext(m, n);
            l.beginPath();
            l.arc(j, o, h, 0, 2 * Math.PI, false);
            if (m != undefined) {
                l.stroke()
            }
            if (n != undefined) {
                l.fill()
            }
        },
        drawPieSlice: function (j, q, h, n, l, o, p) {
            var m = this._getContext(o, p);
            m.beginPath();
            m.moveTo(j, q);
            m.arc(j, q, h, n, l, false);
            m.lineTo(j, q);
            m.closePath();
            if (o != undefined) {
                m.stroke()
            }
            if (p) {
                m.fill()
            }
        },
        drawRect: function (j, o, l, h, m, n) {
            return this.drawShape([
                [j, o],
                [j + l, o],
                [j + l, o + h],
                [j, o + h],
                [j, o]
            ], m, n)
        }
    });
    var d = function (j, h, l) {
        return this.init(j, h, l)
    };
    d.prototype = f.extend(new e, {
        _super: e.prototype,
        init: function (j, h, m) {
            this._super.init(j, h, m);
            if (m[0]) {
                m = m[0]
            }
            m.vcanvas = this;
            this.canvas = document.createElement("span");
            f(this.canvas).css({
                display: "inline-block",
                position: "relative",
                overflow: "hidden",
                width: j,
                height: h,
                margin: "0px",
                padding: "0px",
                verticalAlign: "top"
            });
            this._insert(this.canvas, m);
            this.pixel_height = f(this.canvas).height();
            this.pixel_width = f(this.canvas).width();
            this.canvas.width = this.pixel_width;
            this.canvas.height = this.pixel_height;
            var l = '<v:group coordorigin="0 0" coordsize="' + this.pixel_width + " " + this.pixel_height + '" style="position:absolute;top:0;left:0;width:' + this.pixel_width + "px;height=" + this.pixel_height + 'px;"></v:group>';
            this.canvas.insertAdjacentHTML("beforeEnd", l);
            this.group = f(this.canvas).children()[0]
        },
        drawShape: function (u, p, h, m) {
            var q = [];
            for (var l = 0, j = u.length; l < j; l++) {
                q[l] = "" + (u[l][0]) + "," + (u[l][1])
            }
            var o = q.splice(0, 1);
            m = m == undefined ? 1 : m;
            var t = p == undefined ? ' stroked="false" ' : ' strokeWeight="' + m + '" strokeColor="' + p + '" ';
            var s = h == undefined ? ' filled="false"' : ' fillColor="' + h + '" filled="true" ';
            var n = q[0] == q[q.length - 1] ? "x " : "";
            var r = '<v:shape coordorigin="0 0" coordsize="' + this.pixel_width + " " + this.pixel_height + '" ' + t + s + ' style="position:absolute;left:0px;top:0px;height:' + this.pixel_height + "px;width:" + this.pixel_width + 'px;padding:0px;margin:0px;"  path="m ' + o + " l " + q.join(", ") + " " + n + 'e"> </v:shape>';
            this.group.insertAdjacentHTML("beforeEnd", r)
        },
        drawCircle: function (j, q, h, o, p) {
            j -= h + 1;
            q -= h + 1;
            var n = o == undefined ? ' stroked="false" ' : ' strokeWeight="1" strokeColor="' + o + '" ';
            var m = p == undefined ? ' filled="false"' : ' fillColor="' + p + '" filled="true" ';
            var l = "<v:oval " + n + m + ' style="position:absolute;top:' + q + "px; left:" + j + "px; width:" + (h * 2) + "px; height:" + (h * 2) + 'px"></v:oval>';
            this.group.insertAdjacentHTML("beforeEnd", l)
        },
        drawPieSlice: function (u, s, p, q, m, t, l) {
            if (q == m) {
                return
            }
            if ((m - q) == (2 * Math.PI)) {
                q = 0;
                m = (2 * Math.PI)
            }
            var j = u + Math.round(Math.cos(q) * p);
            var h = s + Math.round(Math.sin(q) * p);
            var o = u + Math.round(Math.cos(m) * p);
            var n = s + Math.round(Math.sin(m) * p);
            if (j == o && h == n && (m - q) < Math.PI) {
                return
            }
            var r = [u - p, s - p, u + p, s + p, j, h, o, n];
            var z = t == undefined ? ' stroked="false" ' : ' strokeWeight="1" strokeColor="' + t + '" ';
            var w = l == undefined ? ' filled="false"' : ' fillColor="' + l + '" filled="true" ';
            var v = '<v:shape coordorigin="0 0" coordsize="' + this.pixel_width + " " + this.pixel_height + '" ' + z + w + ' style="position:absolute;left:0px;top:0px;height:' + this.pixel_height + "px;width:" + this.pixel_width + 'px;padding:0px;margin:0px;"  path="m ' + u + "," + s + " wa " + r.join(", ") + ' x e"> </v:shape>';
            this.group.insertAdjacentHTML("beforeEnd", v)
        },
        drawRect: function (j, o, l, h, m, n) {
            return this.drawShape([
                [j, o],
                [j, o + h],
                [j + l, o + h],
                [j + l, o],
                [j, o]
            ], m, n)
        }
    })
})(jQuery);

function showNewTip(b, a) {
    if (b) {
        b.parent().height(b.parent().outerHeight());
        if (!a) {
            $tc = b.last().clone()
        } else {
            $tc = $(a)
        }
        $tc.prependTo(b.parent()).hide().slideDown("slow");
        b.last().slideUp("slow", function () {
            b.last().remove()
        })
    }
}
function showOrHide(b, a) {
    if (!a) {
        a = b.prev()
    }
    if (b.html() == "[+] Show me more") {
        a.slideDown();
        b.html("[-] Hide details")
    } else {
        a.slideUp();
        b.html("[+] Show me more")
    }
}
function positionMPbar() {
    $("#mangopeoplebar").css({
        position: "absolute",
        top: ($(window).height() - $("#mangopeoplebar").height()) + "px"
    })
}
function trendChartBar(c, d, b) {
    var a = new Array;
    $(c + " " + d).each(function () {
        var e = $(this).html();
        var f = /^[+-]?\d+(\.\d+)?([eE][+-]?\d+)?$/;
        if (e.indexOf(",") > 0) {
            e = e.replace(",", "")
        }
        if (f.test(e)) {
            a.push(e)
        } else {
            a.push(0)
        }
    });
    $(b).sparkline(a, {
        type: "bar",
        barColor: "#548c00",
        negBarColor: "#c02000",
        barWidth: 5,
        barSpacing: 3,
        width: "5em"
    })
}
function resultsSwitcher(a) {
    $("#filter-names").val("").focus();
    $("ol#companies-list li.tr").each(function () {
        switch (a) {
        case 1:
            $(this).show();
            if ($("div.t-isfno", this).html() != "") {
                $(this).hide()
            }
            break;
        case 2:
            $(this).show();
            if ($("div.t-isfno", this).html() == "") {
                $(this).hide()
            }
            break;
        default:
            $(this).show();
            break
        }
    })
}
function fixPng(b) {
    var a = b.src;
    if (!b.style.width) {
        b.style.width = $(b).width()
    }
    if (!b.style.height) {
        b.style.height = $(b).height()
    }
    b.src = "http://images.mangopeople.com/utvmoney/blank.gif";
    b.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + a + "',sizingMethod='scale')"
}
function toggleGainersLosers(a) {
    $gainersHTML = '<h2>Gainers<small> | <a onclick="toggleGainersLosers($(this));">Losers</a></small></h2><p class="text-menu"><a href="/gainers-and-losers/gainers">View Weekly, Monthly</a></p><span></span>';
    $losersHTML = '<h2>Losers<small> | <a onclick="toggleGainersLosers($(this));">Gainers</a></small></h2><p class="text-menu"><a href="/gainers-and-losers/losers">View Weekly, Monthly</a></p><span></span>';
    if (a.parent().parent().parent().parent().find("#home-losers").css("display") == "none") {
        a.parent().parent().parent().parent().find("#home-gainers").hide("fast", function () {
            a.parent().parent().parent().parent().find("#home-losers").show("fast");
            a.parent().parent().parent().html($losersHTML)
        })
    } else {
        a.parent().parent().parent().parent().find("#home-losers").hide("fast", function () {
            a.parent().parent().parent().parent().find("#home-gainers").show("fast");
            a.parent().parent().parent().html($gainersHTML)
        })
    }
}
function toggleFnOGainersLosers(a) {
    $gainersHTML = '<h2>F&amp;O Gainers<small> | <a onclick="toggleFnOGainersLosers($(this));">Losers</a></small></h2><p class="text-menu"><a href="/gainers-and-losers/gainers/daily/futures-and-options">View Older</a></p><span></span>';
    $losersHTML = '<h2>F&amp;O Losers<small> | <a onclick="toggleFnOGainersLosers($(this));">Gainers</a></small></h2><p class="text-menu"><a href="/gainers-and-losers/losers/daily/futures-and-options">View Older</a></p><span></span>';
    if (a.parent().parent().parent().parent().find("#fno-losers").css("display") == "none") {
        a.parent().parent().parent().parent().find("#fno-gainers").hide("fast", function () {
            a.parent().parent().parent().parent().find("#fno-losers").show("fast");
            a.parent().parent().parent().html($losersHTML)
        })
    } else {
        a.parent().parent().parent().parent().find("#fno-losers").hide("fast", function () {
            a.parent().parent().parent().parent().find("#fno-gainers").show("fast");
            a.parent().parent().parent().html($gainersHTML)
        })
    }
}
function animateNumbers(e, d) {
    var c = $(e).html();
    var b = parseInt(c.replace(/\,/g, ""));
    var a = 1;
    if (b - d > 0) {
        a *= -1
    }
    animateNumbersHelper(e, b, d, a)
}
function animateNumbersHelper(d, c, b, a) {
    c += a;
    $(d).html(c);
    if (c != b) {
        setTimeout("animateNumbersHelper('" + d + "'," + c + "," + b + "," + a + ")", 10)
    }
}
function loadtickerfrom(a) {
    var b = $(a).val();
    loadtickerFX(b)
}
function loadtickerFX(c, f, h) {
    var e = 0;
    h = parseFloat(h);
    $tickerElemName = f.attr("id");
    if ($(".counter-wrap", f).length < 1) {
        e = parseFloat($(f).text());
        $(f).html('<img src="http://images.mangopeople.com/utvmoney/icon-trend-up.png" alt="[Up]" />')
    } else {
        var g = "";
        oldNumberTemp = "";
        $(".counter-number", f).each(function () {
            var j = $(this).attr("value");
            if (!isNaN(j) || j == ".") {
                g += j
            }
        });
        e = parseFloat(g)
    }
    for (i = $(".counter-wrap", f).length; i <= c.toString().length; i++) {
        $(f).append('<span class="counter-wrap"><span class="counter-number">0<br />1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />.</span></span>')
    }
    $(".counter-wrap", f).show();
    $(".counter-number", f).show();
    $(".counter-number", f).each(function (j) {
        $(this).attr("id", $tickerElemName + "-num" + j)
    });
    if (!isNaN(e)) {
        if (e < c) {
            $(f).removeClass().addClass("add-emphasis").addClass("trend-up").delay(3000).queue(function (j) {
                $(this).removeClass();
                j()
            })
        }
        if (e > c) {
            $(f).removeClass().addClass("add-emphasis").addClass("trend-down").delay(3000).queue(function (j) {
                $(this).removeClass();
                j()
            })
        }
        if (e == c) {
            $(f).removeClass().addClass("add-emphasis").addClass("trend-nochange").delay(3000).queue(function (j) {
                $(this).removeClass();
                j()
            })
        }
    }
    if (c > h && e <= h) {
        $("img", f).fadeOut("slow", function () {
            $(this).attr("src", imageURL + "icon-trend-up.png").fadeIn("slow")
        })
    }
    if (c > h && e > h) {
        $("img", f).attr("src", imageURL + "icon-trend-up.png")
    }
    if (c < h && e >= h) {
        $("img", f).fadeOut("slow", function () {
            $(this).attr("src", imageURL + "icon-trend-down.png").fadeIn("slow")
        })
    }
    if (c < h && e < h) {
        $("img", f).attr("src", imageURL + "icon-trend-down.png")
    }
    if (c == h && e != h) {
        $("img", f).fadeOut("slow", function () {
            $(this).attr("src", imageURL + "icon-trend-nochange.png").fadeIn("slow")
        })
    }
    if (c == h && e == h) {
        $("img", f).attr("src", imageURL + "icon-trend-nochange.png")
    }
    var b = ($(".counter-number:first", f).height()) / 12;
    addticker(c, f);
    if (c && c != 0) {
        var d = String(c);
        for (i = d.length; i >= 0; i--) {
            var a = d.charAt(i);
            $("#" + $tickerElemName + "-num" + i).attr("value", a)
        }
        $(".counter-number", f).each(function () {
            var l = $(this).attr("value");
            if (!isNaN(l)) {
                var j = (Number(l) * b * -1);
                $(this).animate({
                    top: j + "px"
                }, {
                    queue: false,
                    duration: 1500
                })
            }
            if (l == ".") {
                $(this).animate({
                    top: "-" + ((b * 11) - (b * 1)) + "px"
                }, {
                    queue: false,
                    duration: 1500
                })
            }
        })
    }
}
function addticker(a, e) {
    var c = $(".counter-number", e).size();
    var b = String(a).length;
    var d = Number(b - Number(c));
    if (d < 0) {
        var f = (Number(b) - 1);
        $(".counter-number:gt(" + f + ")", e).parent().remove()
    }
    for (i = 1; i <= d; i++) {
        $(".counter-wrap", e).parent().append('<span class="counter-wrap"><span class="counter-number" id="num' + (Number(c + i - 1)) + '"> </span></span>')
    }
}
function add_commas(b) {
    b += "";
    x = b.split(".");
    x1 = x[0];
    x2 = x.length > 1 ? "." + x[1] : "";
    var a = /(\d+)(\d{3})/;
    while (a.test(x1)) {
        x1 = x1.replace(a, "$1,$2")
    }
    return x1 + x2
}
function setupAutoSuggest(b) {
    var a = {
        items: [{
            value: 1385,
            name: "Reliance Communications Ltd.  ( RCOM )"
        }, {
            value: 1394,
            name: "Reliance Capital Ltd.  ( RELCAPITAL )"
        }, {
            value: 1395,
            name: "Reliance Industries Ltd.  ( RELIANCE )"
        }, {
            value: 1397,
            name: "Reliance Infrastructure Ltd.  ( RELINFRA )"
        }, {
            value: 1398,
            name: "Reliance MediaWorks Ltd.  ( RELMEDIA )"
        }, {
            value: 1407,
            name: "Reliance Industrial InfraStructure Ltd.  ( RIIL )"
        }, {
            value: 1412,
            name: "Reliance Media World Ltd.  ( RMEDIA )"
        }, {
            value: 1414,
            name: "Reliance Natural Resources Ltd.  ( RNRL )"
        }, {
            value: 1425,
            name: "Reliance Petroleum Ltd.(Merged)  ( RPL )"
        }, {
            value: 1426,
            name: "Reliance Power Ltd.  ( RPOWER )"
        }]
    };
    $(b).autoSuggest(a.items, {
        selectionLimit: 1,
        selectedItemProp: "name",
        searchObjProps: "name"
    })
}
function randomTicker(b, a, c) {
    rndnum = Math.round((1000 + (99999 - 1000) * Math.random()) * 100) / 100;
    alert("New number: " + rndnum + "\nPrev Close: " + c);
    loadtickerFX(rndnum, b, c);
    loadtickerFX(rndnum, a, c)
}
function userAuthTriggerSignup() {
    $.modal.close();
    $.modal($userAuthSignUpHTML, {
        opacity: 90,
        overlayId: "mangoPeopleModalOverlay",
        containerId: "mangoPeopleModalContainer",
        closeClass: "mangoPeopleModalClose",
        closeHTML: '<a class="modalCloseImg" title="Close"></a>',
        overlayClose: true,
        persist: true
    })
}
function mpAccountPassReminder() {
    forgotPassword(mpAccountEmail)
}
var mpUserIsNew = true;
var mpPassElapsed = false;
var mpPasswordIsValid = false;
var mpAccountEmail = "ram_gopal@gmail.com";
var mpSignupSuccess = false;

function isEmail(a) {
    a = a.toLowerCase();
    return (a.search(/^([a-z]+)([a-z0-9\-\_\.]{1,100})([a-z0-9]+)\@([a-z0-9]+)([a-z0-9\-\.]*)([a-z0-9]+)\.([a-z]{2,6})$/) != -1)
}
function isText(a) {
    a = a.toLowerCase();
    return (a.search(/^([a-z\-\'\s]+)$/) != -1)
}
function putLoggedInBox(b, c, d) {
    var f = siteURL + "profiles/" + b;
    var a = profileImageURL + d;
    c = c.replace(/\\/g, "");
    var e = '<div id="mangopeople-account-identity"><img alt="[Photo of ' + c + ' ]" src="' + a + '"><b>' + c + '</b><br><a href="' + f + '">My Tips</a> | <a href="' + siteURL + 'change-password/">Password</a>   </div> <div id="mangopeople-account-actions"> <a href="javascript:void(0);" onclick="logout();" class="link-logout"><b>Log Out</b></a> </div> <div id="mangopeople-account-form"></div>';
    $("#mangopeople-account-badge").html(e)
}
function logout() {
    $.ajax({
        type: "POST",
        url: callURL + "login.php",
        data: "action=logout",
        dataType: "html",
        success: function (a) {
            globalLogout = true;
            globalURL = "";
            redirectUrl()
        }
    })
}
function isExists(a) {
    $.ajax({
        type: "POST",
        url: siteURL + "login.php",
        data: "email=" + a + "&action=chk",
        dataType: "html",
        async: false,
        success: function (b) {
            if (b == 1) {
                mpUserIsNew = false
            } else {
                if (b == 0) {
                    mpUserIsNew = true
                }
            }
            return b
        }
    })
}
function forgotPassword(a) {
    if (confirm('An email has been sent to you.\n Press "OK" to send reminder or "Cancel" to go back')) {
        $.ajax({
            type: "POST",
            url: siteURL + "login.php",
            data: "email=" + a + "&action=resendPassword",
            dataType: "html",
            async: false,
            success: function (b) {
                if (b == 1) {
                    alert("Your password was sent to " + mpAccountEmail + "\n You should receive it in the next 10 minutes, or less");
                    $.modal.close();
                }
            }
        })
    } else {
        $.modal.close();
    }
}
function doLogin(b, a, c) {
    $.ajax({
        type: "POST",
        url: siteURL + "login.php",
        data: "email=" + b + "&passwd=" + a + "&rememberMe=" + c + "&action=login",
        dataType: "html",
        async: false,
        success: function (e) {
            var d = e.split("|");
            if (d[0] == 1) {
                mpPasswordIsValid = true;
                userDetails = d
            } else {
                if (d[0] == 0) {
                    mpPasswordIsValid = false
                }
            }
            return e
        }
    })
}
function doRegister(b, a, c, d, e) {
    $.ajax({
        type: "POST",
        url: siteURL + "login.php",
        data: "email=" + b + "&passwd=" + a + "&fname=" + c + "&lname=" + d + "&rememberMe=" + e + "&action=register",
        dataType: "html",
        async: false,
        success: function (g) {
            var f = g.split("|");
            if (f[0] > 0) {
                userDetails = f;
                mpSignupSuccess = true
            } else {
                if (f[0] == 0) {
                    mpSignupSuccess = -1
                }
            }
            return g
        }
    })
}
function initiateLoginSignupProcess() {
    var c = 0;
    var b = "<b>Sign Up</b> or <b>Log In</b>";
    $userAuthInitHTML = '<input type="button" class="sm-submit-button mangoPeopleModalClose" value="X" onclick="$.modal.close();" title="Cancel" /><h2>' + b + '</h2><form id="frmLogin" name="frmLogin" onsubmit="return false;"><fieldset id="mp-account-username-fieldset"><legend>What is your email address?</legend><label><input id="mp-account-username" name="mp-account-username" type="email" value="" autofocus /></label><p></p></fieldset><fieldset id="mp-account-personal-information"></fieldset><fieldset id="mp-account-password-fieldset"><legend>Enter your password</legend><label><input id="mp-account-password" name="mp-account-password" type="password" /></label><p></p><div id="mp-account-passremind"><a onclick="mpAccountPassReminder();">Forgot your password?</a></div></fieldset><fieldset id="mp-account-submit"><label><input type="button" class="medium-submit-button" value="Continue" id="mp-account-initial-submit" /></label></fieldset><fieldset id="mp-account-remember"><label><input type="checkbox" id="rememberMe"  name="mp-account-remember" value=false" /> Remember my password</label></fieldset></form><hr />';
    $userSignupHTML = '<div id="feedbackErrorMsg" class="mangoPeopleErrorMessageText"></div><label><i>First Name</i> <input id="mp-account-firstname" name="mp-account-firstname" maxlength="15" type="text" value="" autofocus /></label><p id="mp-account-firstname-msg"></p><label><i>Last/Family Name</i> <input id="mp-account-lastname" name="mp-account-lastname" type="text" value="" maxlength="15" /></label><p id="mp-account-lastname-msg"></p>';
    var e = ($("#mangopeople-account-badge").offset().left);
    var d = $("#mangopeople-account-badge").offset().top;

    function a() {
        if (mpPassElapsed) {
            f(1)
        } else {
            $("#mp-account-username").focus()
        }
        $("#mp-account-password").bind("click keypress", function () {
            if ($("#mp-account-password-fieldset p").hasClass("mangoPeopleErrorMessageText") && $("#mp-account-password-fieldset p").html() == "Email address and password do not match") {
                $("#mp-account-password-fieldset p").removeClass().html("")
            }
        });

        function f(g) {
            if (g == 1) {
                $("#mp-account-username").val(mpAccountEmail);
                $("#mangopeople-account-badge h2").html("<b>Welcome back!</b>");
                $("#mp-account-username").attr("disabled", "disabled");
                $("#mp-account-password-fieldset").slideDown("fast");
                $("#mp-account-username-fieldset legend").html('<a onclick="mpPassElapsed=false; initiateLoginSignupProcess();">Change email address</a>');
                $("#mp-account-initial-submit").val("Log In");
                c = 1;
                $("#mp-account-password-fieldset legend").html("Enter your password");
                $("#mp-account-remember").show();
                $("#mp-account-password").focus()
            }
            if (g == 2) {
                $("#mp-account-username").val(mpAccountEmail);
                $("#mangopeople-account-badge h2").html("<b>You must be new!</b><small>You are moments away from creating your account.</small>");
                $("#mp-account-username").attr("disabled", "disabled");
                $("#mp-account-username-fieldset legend").html('<a onclick="initiateLoginSignupProcess();">Change email address</a>');
                $("#mp-account-initial-submit").val("Sign Up");
                c = 2;
                $("#mp-account-password-fieldset legend").html("Choose a password");
                $("#mp-account-remember").show();
                $("#mp-account-personal-information").html($userSignupHTML).slideDown("fast");
                $("#mp-account-firstname").focus();
                $("#mp-account-password-fieldset").slideDown("fast");
                $("#mp-account-passremind").hide()
            }
        }
        $("#mp-account-initial-submit").click(function () {
            if ($(this).val() == "Continue") {
                mpAccountEmail = $("#mp-account-username").val();
                if (isEmail(mpAccountEmail)) {
                    $("#mp-account-username-fieldset p").html("");
                    var h = isExists(mpAccountEmail);
                    if (!mpUserIsNew) {
                        f(1)
                    } else {
                        f(2)
                    }
                } else {
                    $("#mp-account-username-fieldset p").removeClass().addClass("mangoPeopleErrorMessageText").html("Enter Valid Email address.")
                }
            } else {
                if (c == 1 && $("#mp-account-password").val() != "") {
                    mpAccountEmail = $("#mp-account-username").val();
                    mpPasswd = $("#mp-account-password").val();
                    rememberMe = getEl("rememberMe").checked;
                    var h = doLogin(mpAccountEmail, mpPasswd, rememberMe);
                    if (mpPasswordIsValid) {
                        $("#mp-account-password-fieldset p").html("");
                        $.modal.close()
                    } else {
                        $("#mp-account-password-fieldset p").removeClass().addClass("mangoPeopleErrorMessageText").html("Email address and password do not match")
                    }
                } else {
                    if (c == 2) {
                        mpAccountEmail = $("#mp-account-username").val();
                        mpPasswd = trim($("#mp-account-password").val());
                        mpFname = trim($("#mp-account-firstname").val());
                        mpLname = trim($("#mp-account-lastname").val());
                        if (mpFname == "") {
                            $("#feedbackErrorMsg").html("Please enter first name.");
                            $("#mp-account-firstname").val("").focus();
                            return false
                        }
                        var g = new RegExp("^[ _a-zA-Z'-]+$");
                        if (!g.test(mpFname)) {
                            $("#feedbackErrorMsg").html("Please enter alphabetic characters.");
                            $("#mp-account-firstname").val("").focus();
                            return false
                        }
                        if (mpLname == "") {
                            $("#feedbackErrorMsg").html("Please enter last name.");
                            $("#mp-account-lastname").val("").focus();
                            return false
                        }
                        if (!g.test(mpLname)) {
                            $("#feedbackErrorMsg").html("Please enter alphabetic characters.");
                            $("#mp-account-lastname").val("").focus();
                            return false
                        }
                        if (mpPasswd == "") {
                            $("#feedbackErrorMsg").html("Please enter your password.");
                            $("#mp-account-password").val("").focus();
                            return false
                        }
                        rememberMe = getEl("rememberMe").checked;
                        var h = doRegister(mpAccountEmail, mpPasswd, mpFname, mpLname, rememberMe);
                        if (mpSignupSuccess == true) {
                            $("#mp-account-password-fieldset p").html("");
                            $.modal.close()
                        } else {
                            if (mpSignupSuccess == -1) {
                                $("#mp-account-firstname-msg").removeClass().addClass("mangoPeopleErrorMessageText").html("Invalid entry. Cannot contain numbers or special characters.");
                                $("#mp-account-lastname-msg").removeClass().addClass("mangoPeopleErrorMessageText").html("Invalid entry. Cannot contain numbers or special characters.");
                                $("#mp-account-password-fieldset p").removeClass().addClass("mangoPeopleErrorMessageText").html("Your password must be at least 7 characters long and contain both alphabets and numbers.")
                            }
                        }
                    }
                }
            }
        });
        $("#mp-account-username").keypress(function (g) {
            if (g.which == 13) {
                $("#mp-account-initial-submit").click()
            }
        });
        $("#mp-account-password").keypress(function (g) {
            if (g.which == 13) {
                $("#mp-account-initial-submit").click()
            }
        })
    }
    $("#mangopeople-account-badge").modal({
        onOpen: function (f) {
            f.overlay.fadeIn("slow");
            f.container.fadeIn("fast");
            f.data.addClass("mangoPeopleModalContainerClass").slideDown("fast")
        },
        onClose: function (f) {
            f.overlay.fadeOut("fast");
            $("#mangopeople-account-form").slideUp("fast", function () {
                $("#mangopeople-account-form").hide();
                $("#mangopeople-account-form").html("")
            });
            f.container.fadeOut("fast", function () {
                $.modal.close();
                f.data.removeClass("mangoPeopleModalContainerClass");
                if (mpPasswordIsValid || mpSignupSuccess) {
                    putLoggedInBox(userDetails[1], userDetails[2] + " " + userDetails[3], userDetails[4]);
                    redirectUrl()
                }
            })
        },
        opacity: 90,
        overlayId: "mangoPeopleModalOverlay",
        containerId: "mangoPeopleModalContainer",
        close: true,
        overlayClose: false,
        position: ["2px"],
        focus: false,
        persist: false
    });
    $("#mangopeople-account-form").html($userAuthInitHTML).slideDown("fast", function () {
        a()
    }).show()
}
function mailfeedback(n, l, h, g, b, f, d, c, a, o) {
    var j = screen.width + "x" + screen.height;
    var e = navigator.userAgent;
    var m = document.location.href;
    if (menu1 == "watchlist") {
        rURL = web_url
    } else {
        rURL = siteURL
    }
    
    var n = n.replace(/&/g, "@##@");
    
    $.ajax({
        type: "POST",
        url: rURL + "mailfeedback.php",
        data: "comments=" + n + "&username=" + l + "&email=" + h + "&mobile=" + g + "&city=" + b + "&check1=" + f + "&check2=" + d + "&check3=" + c + "&check4=" + a + "&check5=" + o + "&resolution=" + j + "&useragent=" + e + "&url=" + m,
        dataType: "html",
        async: false,
        success: function (p) {
            alert("Thanks for your feedback.")
        }
    })
}
function trim(a) {
    if (a == null) {
        return
    }
    a = a.replace(/^\s\s*/, "").replace(/\s\s*$/, "");
    return a
}
function initiateFeedbackProcess() {
    feedbackHTML = '<div id="site-feedback" class="col-8-span"><div class="col-title"><h2>Your <b>Feedback</b></h2><a class="cancelButton" onclick="$.modal.close();">X</a></div>';
    feedbackHTML += '<form action="" method="post" name="feedback" id="feedback"><div class="col-body"><div class="nl"><div class="col-4-span"><div class="col-body"><h3>Do you find <b>UTV Money</b> useful?</h3><p>Please enter your comments in the box below:</p>';
    feedbackHTML += '<textarea name="feedback-comments" rows="10" id="feedback-comments"></textarea></div></div><div class="col-4-span trim-right"><div class="col-body"><h3>(Optional) Help us serve you better:</h3><table><tbody><tr>';
    feedbackHTML += '<td rowspan="2">Did it take long to locate the information you were looking for?</td><td class="feedback-option"><input type="radio" id="fb1-1" value="1" name="task-time"></td><td class="feedback-option"><input type="radio" id="fb1-2" value="2" name="task-time"></td></tr><tr><td class="feedback-label"><label for="fb1-1">Yes</label></td><td class="feedback-label"><label for="fb1-2">No</label></td></tr><tr><td rowspan="2">Are you satisfied with the available content?</td><td class="feedback-option"><input type="radio" id="fb2-1" value="1" name="content-satisfaction"></td><td class="feedback-option"><input type="radio" id="fb2-2" value="2" name="content-satisfaction"></td></tr><tr><td class="feedback-label"><label for="fb2-1">Yes</label></td><td class="feedback-label"><label for="fb2-2" >No</label></td></tr><tr><td rowspan="2">Did you find any errors on this page?</td><td class="feedback-option"><input type="radio" id="fb3-1" value="1" name="errors-found"></td><td class="feedback-option"><input type="radio" id="fb3-2" value="2" name="errors-found"></td></tr><tr><td class="feedback-label"><label for="fb3-1">Yes</label></td><td class="feedback-label"><label for="fb3-2" >No</label></td></tr><tr><td rowspan="2">Is the quality of design to your satisfaction?</td><td class="feedback-option"><input type="radio" id="fb4-1" value="1" name="design-quality"></td><td class="feedback-option"><input type="radio" id="fb4-2" value="2" name="design-quality"></td></tr><tr><td class="feedback-label"><label for="fb4-1">Yes</label></td><td class="feedback-label"><label for="fb4-2" >No</label></td></tr><tr><td rowspan="2">Would you recommend this site to your friends and family?</td><td class="feedback-option"><input type="radio" id="fb5-1" value="1" name="recommend-site"></td><td class="feedback-option"><input type="radio" id="fb5-2" value="2" name="recommend-site"></td></tr><tr><td class="feedback-label"><label for="fb5-1">Yes</label></td><td class="feedback-label"><label for="fb5-2" >No</label></td></tr></tbody></table></div></div></div><!-- end row--><div id="feedback-personal-details" class="col-8-span trim-right"><div class="col-body"><div class="nl">';
    feedbackHTML += '<label id="feedback-form-name"><span>Your Name:</span><input type="text" name="feedback-sender-name"  id="feedback-sender-name" maxlength="100" /></label></div><div class="nl"><label id="feedback-form-email"><span>Your Email:</span><input type="text" name="feedback-sender-email"  id="feedback-sender-email" maxlength="50" /></label><label id="feedback-form-mobile"><span>Your Mobile No.:</span><input type="text" name="feedback-sender-mobile" maxlength="50" id="feedback-sender-mobile"/></label></div>';
    feedbackHTML += '<div class="nl"><label id="feedback-form-location"><span>City, Country:</span><input type="text" name="feedback-sender-location" id="feedback-sender-location"  maxlength="75" /></label><label id="feedback-form-submit"><span></span><input id="mp-feedback-submit"  name="mp-feedback-submit" type="button" class="medium-submit-button" value="Submit" /></label></div><div id="feedbackErrorMsg"></div></div></div></div></form></div>';
    $.modal(feedbackHTML, {
        onClose: function (a) {
            $.modal.close()
        },
        opacity: 90,
        overlayId: "mangoPeopleModalOverlay",
        containerId: "mangoPeopleModalContainerWhite",
        overlayClose: true,
        persist: false
    });
    $("#feedback-comments").keyup(function () {
        limitChars("feedback-comments", 1000, "commentsErr")
    });
    $("#mp-feedback-submit").click(function () {
        feedbackComments = $("#feedback-comments").val();
        feedbackUname = $("#feedback-sender-name").val();
        feedbackEmail = $("#feedback-sender-email").val();
        feedbackMobile = $("#feedback-sender-mobile").val();
        feedcity = $("#feedback-sender-location").val();
        if (trim(feedbackComments) == "") {
            $("#site-feedback #feedbackErrorMsg").html("Please Enter Your Comments.");
            $("#feedback-comments").focus()
        } else {
            if (!(isText(feedbackUname))) {
                $("#site-feedback #feedbackErrorMsg").html("Please Enter Valid Name.");
                $("#feedback-sender-name").val("").focus()
            } else {
                if (!(isEmail(feedbackEmail))) {
                    $("#feedbackErrorMsg").html("Please Enter Valid Email Address.");
                    $("#feedback-sender-email").val("").focus()
                } else {
                    $("#site-feedback #feedbackErrorMsg").html("");
                    var d = "";
                    var c = "";
                    var b = "";
                    var a = "";
                    var e = "";
                    if ($("#fb1-1:checked").val() == "1") {
                        d = "Yes"
                    }
                    if ($("#fb1-2:checked").val() == "2") {
                        d = "No"
                    }
                    if ($("#fb2-1:checked").val() == "1") {
                        c = "Yes"
                    }
                    if ($("#fb2-2:checked").val() == "2") {
                        c = "No"
                    }
                    if ($("#fb3-1:checked").val() == "1") {
                        b = "Yes"
                    }
                    if ($("#fb3-2:checked").val() == "2") {
                        b = "No"
                    }
                    if ($("#fb4-1:checked").val() == "1") {
                        a = "Yes"
                    }
                    if ($("#fb4-2:checked").val() == "2") {
                        a = "No"
                    }
                    if ($("#fb5-1:checked").val() == "1") {
                        e = "Yes"
                    }
                    if ($("#fb5-2:checked").val() == "2") {
                        e = "No"
                    }
                    $.modal.close();
                    mailfeedback(feedbackComments, feedbackUname, feedbackEmail, feedbackMobile, feedcity, d, c, b, a, e)
                }
            }
        }
    })
}
function limitChars(d, a, b) {
    var e = $("#" + d).val();
    var c = e.length;
    if (c > a) {
        $("#" + b).removeClass().addClass("mangoPeopleErrorMessageText").html("You cannot write more than " + a + " characters!");
        $("#" + d).val(e.substr(0, a));
        return false
    } else {
        $("#" + b).removeClass().addClass("mangoPeopleErrorMessageText").html("You have " + (a - c) + " characters left.");
        return true
    }
}
function initCompanyMiniGraphBse(d, cCode) {
    $("#company-mini-graph-content-bse").html('<p id="co-mini-graph-flash-bse">Loading graph. Please wait2...' + d + "</p>");
    var a = {};
    var c = {
        menu: "false",
        wmode: "transparent",
        bgcolor: "#f7f7f7"
    };
    var b = {
        id: "fgraph",
        name: "fgraph"
    };
    var e = cCode.replace("%26", "~");
    e = e.replace("&", "~");
    e = e.replace("'", "");
    swfobject.embedSWF(siteURL +"/player/fgraph17_A.swf?drawGP=false&drawUP=false&config=" + siteURL + "charts/bse-eq/" + e + "/config.xml&period=" + d, "co-mini-graph-flash-bse", "309", "260", "9.0.0", "/player/expressInstall.swf", a, c, b)
}
function initCompanyMiniGraph(d) {
    $("#company-mini-graph-content").html('<p id="co-mini-graph-flash">Loading graph. Please wait...' + d + "</p>");
    var a = {};
    var c = {
        menu: "false",
        wmode: "transparent",
        bgcolor: "#f7f7f7"
    };
    var b = {
        id: "fgraph",
        name: "fgraph"
    };
	if(SYMBOL != '' && SYMBOL != null){
		var e = SYMBOL.replace("%26", "~");
		e = e.replace("&", "~");
	}
	
    swfobject.embedSWF(siteURL +"/player/fgraph17_A.swf?drawGP=false&drawUP=false&config=" + siteURL + "charts/eq/" + e + "/config.xml&period=" + d, "co-mini-graph-flash", "308", "260", "9.0.0", "/player/expressInstall.swf", a, c, b)
	
}
function initCompanyMFGraph(d) {
    if (d == "day") {
        d = "month";
    }
    $("#company-mini-graph-content").html('<p id="mf-co-graph-flash">Loading graph. Please wait...' + d + "</p>");
    var a = {};
    var c = {
        menu: "false",
        wmode: "transparent",
        bgcolor: "#f7f7f7",
        width: "640",
        height: "225"
    };
    var b = {
        id: "fgraph",
        name: "fgraph"
    };
    var e = securityCode;
    swfobject.embedSWF(siteURL +"/player/fgraph17_A.swf?drawGP=false&drawUP=false&config=" + siteURL + "charts/mf/" + e + "/config.xml&period=" + d, "mf-co-graph-flash", "640", "225", "9.0.0", "/player/expressInstall.swf", a, c, b)
}
function initCompanyFOMiniGraph(e, c) {
    $("#company-mini-graph-content").html('<p id="co-mini-graph-flash">Loading graph. Please wait...' + e + "</p>");
    var a = {};
    var d = {
        menu: "false",
        wmode: "transparent",
        bgcolor: "#f7f7f7"
    };
    var b = {
        id: "fgraph",
        name: "fgraph"
    };
    var f = c.replace("%26", "~");
    f = f.replace("&", "~");
    swfobject.embedSWF(siteURL +"/player/fgraph17_A.swf?drawGP=false&drawUP=false&config=" + siteURL + "charts/fo/" + f + "/config.xml&period=" + e, "co-mini-graph-flash", "308", "260", "9.0.0", "/player/expressInstall.swf", a, d, b)
}
function preparePage() {
    var c = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
    if (c) {
        $("img[src$=.png]").each(function () {
            fixPng(this)
        })
    }
    
    $('#search-keywords').focus();
    
	if(menu1=='budget-home'){
        $adCode='<iframe src="http://c1.zedo.com/jsc/c1/ff2.html?n=1252;c=105/104/91;s=1;d=29;w=500;h=400" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" allowTransparency="true" width="500" height="400"></iframe>';
        $.modal($adCode, {
            opacity: 90,
            overlayId: "mangoPeopleModalOverlay",
            containerCss:{
                      height:430,
                      width:530,
                      padding:0,
                      margin: 0,
                      border: 0
                },
            closeClass: "mangoPeopleModalClose",
            closeHTML: '<a class="modalCloseImg" title="Close"></a>',
            overlayClose: true,
                escClose: true,
            persist: true
        });
        $('#simplemodal-data').delay(15000).queue(function() {
            $.modal.close();
        });
    }
    
    $('#submitpoll').click(function () {

        var rad_val = '';
        for (var i = 0; i < document.frmpoll.poll_ans.length; i++) {
            if (document.frmpoll.poll_ans[i].checked) {
                rad_val = document.frmpoll.poll_ans[i].value;
            }
        }

        if (rad_val == '') {
            alert("Please select your answer")
        } else {
            var pollid = $("#hid_pollid").val();

            $.ajax({
                type: "GET",
                url: siteURL + 'budget2011/poll_submit.php',
                data: 'r=' + Math.random() + '&pollid=' + pollid + '&answer=' + rad_val,
                dataType: "html",
                success: function (data) {

                    if (data == 2) {
                        alert("You have already submitted poll");
                    } else {

                        var dataRes = data;

                        arrData = dataRes.split('@@###@@');

                        if (arrData[0] == 1) {
                            alert("Poll submitted successfully");

                            $(".rightside").html(arrData[1]);
                        } else {
                            alert("Error occured. Please try again");
                        }



                    }

                }
            });
        }

        return false;
    });
    $('#tipper-return-selector input').click(function () {
        var tipRetPeriod = $(this).attr('value');
        var tipPeriod = $(this).attr('id');
        var tipRetPeriodArray = tipRetPeriod.split(";"); /* EXPERT CODING */
        $('#home-top-tippers-expt-returns').html('Rs. ' + tipRetPeriodArray[0]);
        if (parseInt(tipRetPeriodArray[0].replace(",", "")) < 10000) {
            $('#home-top-tippers-expt-returns').removeClass().addClass('trend-down');
        } else {
            $('#home-top-tippers-expt-returns').removeClass().addClass('trend-up');
        } /*Community Coding*/
        $('#home-top-tippers-comm-returns').html('Rs. ' + tipRetPeriodArray[1]);
        if (parseInt(tipRetPeriodArray[1].replace(",", "")) < 10000) {
            $('#home-top-tippers-comm-returns').removeClass().addClass('trend-down');
        } else {
            $('#home-top-tippers-comm-returns').removeClass().addClass('trend-up');
        }
        var Content;
        var ContentArray;
        if (tipPeriod == 'tpr-ret-1') {
            Content = $('#tpr-ret-content-1').attr('value');
            ContentArray = Content.split(";");
        } else if (tipPeriod == 'tpr-ret-2') {
            Content = $('#tpr-ret-content-2').attr('value');
            ContentArray = Content.split(";");
        } else if (tipPeriod == 'tpr-ret-3') {
            Content = $('#tpr-ret-content-3').attr('value');
            ContentArray = Content.split(";");
        } else if (tipPeriod == 'tpr-ret-4') {
            Content = $('#tpr-ret-content-4').attr('value');
            ContentArray = Content.split(";");
        } /* EXPERT CODING */
        var te1 = '<p><small><b>No Followers</b></small></p>';
        var te2 = '<p><small><b>No Followers</b></small></p>';
        var te3 = '<p><small><b>No Followers</b></small></p>';
        var tc1 = '<p><small><b>No Followers</b></small></p>';
        var tc2 = '<p><small><b>No Followers</b></small></p>';
        var tc3 = '<p><small><b>No Followers</b></small></p>';
        if (ContentArray[5] != 'undefined' && ContentArray[5] != '' && ContentArray[5] != 0) {
            te1 = "<p><small><b>" + ContentArray[5] + "</b> followers</small></p>";
        }
        $('#tipper-expt-1').html("<a href='" + siteURL + "profiles/" + ContentArray[0] + "'> <img src='" + profileImageURL + ContentArray[2] + "' class='photo' /></a><b>" + ContentArray[1] + "</b><p class='utvmoney-tipper-rating " + ContentArray[4] + "' title='Tipper return: " + ContentArray[3] + "'><i>Tipper return: " + ContentArray[3] + "</i>" + te1 + "</p>");
        if (ContentArray[11] != 'undefined' && ContentArray[11] != '' && ContentArray[11] != 0) {
            te2 = "<p><small><b>" + ContentArray[11] + "</b> followers</small></p>";
        }
        $('#tipper-expt-2').html("<a href='" + siteURL + "profiles/" + ContentArray[6] + "'> <img src='" + profileImageURL + ContentArray[8] + "' class='photo' /></a><b>" + ContentArray[7] + "</b><p class='utvmoney-tipper-rating " + ContentArray[10] + "' title='Tipper return: " + ContentArray[9] + "'><i>Tipper return: " + ContentArray[9] + "</i>" + te2 + "</p>");
        if (ContentArray[17] != 'undefined' && ContentArray[17] != '' && ContentArray[17] != 0) {
            te3 = "<p><small><b>" + ContentArray[17] + "</b> followers</small></p>";
        }
        $('#tipper-expt-3').html("<a href='" + siteURL + "profiles/" + ContentArray[12] + "'> <img src='" + profileImageURL + ContentArray[14] + "' class='photo' /></a><b>" + ContentArray[13] + "</b><p class='utvmoney-tipper-rating " + ContentArray[16] + "' title='Tipper return: " + ContentArray[15] + "'><i>Tipper return: " + ContentArray[15] + "</i>" + te3 + "</p>"); /* COMMUNITY CODING */
        if (ContentArray[23] != 'undefined' && ContentArray[23] != '' && ContentArray[23] != 0) {
            tc1 = "<p><small><b>" + ContentArray[23] + "</b> followers</small></p>";
        }
        $('#tipper-comm-1').html("<a href='" + siteURL + "profiles/" + ContentArray[18] + "'> <img src='" + profileImageURL + ContentArray[20] + "' class='photo' /></a><b>" + ContentArray[19] + "</b><p class='utvmoney-tipper-rating " + ContentArray[22] + "' title='Tipper return: " + ContentArray[21] + "'><i>Tipper return: " + ContentArray[21] + "</i>" + tc1 + "</p>");
        if (ContentArray[29] != 'undefined' && ContentArray[29] != '' && ContentArray[29] != 0) {
            tc2 = "<p><small><b>" + ContentArray[29] + "</b> followers</small></p>";
        }
        $('#tipper-comm-2').html("<a href='" + siteURL + "profiles/" + ContentArray[24] + "'> <img src='" + profileImageURL + ContentArray[26] + "' class='photo' /></a><b>" + ContentArray[25] + "</b><p class='utvmoney-tipper-rating " + ContentArray[28] + "' title='Tipper return: " + ContentArray[27] + "'><i>Tipper return: " + ContentArray[28] + "</i>" + tc2 + "</p>");
        if (ContentArray[35] != 'undefined' && ContentArray[35] != '' && ContentArray[35] != 0) {
            tc3 = "<p><small><b>" + ContentArray[35] + "</b> followers</small></p>";
        }
        $('#tipper-comm-3').html("<a href='" + siteURL + "profiles/" + ContentArray[30] + "'> <img src='" + profileImageURL + ContentArray[32] + "' class='photo' /></a><b>" + ContentArray[31] + "</b><p class='utvmoney-tipper-rating " + ContentArray[34] + "' title='Tipper return: " + ContentArray[33] + "'><i>Tipper return: " + ContentArray[33] + "</i>" + tc3 + "</p>");
    });
    $userAuthSignUpHTML = '<div class="col-4-span"><div class="col-title"><h2>Welcome!</h2><a class="mangoPeopleModalClose cancelButton" title="Cancel">x</a></div><div class="col-body"><div id="modalUserAuth"><p>You are just one more step away from creating your account…</p><form><label><span>Your E-mail Address</span><p><code><b>zaheer.merchant@mangopeople.com</b></code> <a href="#">[ Change this ]</a></p></label><label for="userAuth-FirstName"><span>Your First Name</span><input id="userAuth-FirstName" maxlength="15"  name="userAuth-FirstName" type="text" /></label><label for="userAuth-LastName"><span>Your Last Name</span><input id="userAuth-LastName" maxlength="15" name="userAuth-LastName" type="text" /></label><!-- Remember to carry over state of remember me from previous step --><label for="userAuth-RememberCredentials"><input id="userAuth-RememberCredentials" name="userAuth-RememberCredentials" type="checkbox" checked="checked" /><span>Remember me on this computer</span><small>Note: Don’t select this if you share this computer with others</small></label><input type="submit" id="userAuth-SubmitInit" name="userAuth-SubmitInit" class="medium-submit-button" value="Submit" /></form></div></div></div>';
    $(".link-login").removeAttr("href").click(function () {
        initiateLoginSignupProcess()
    });
    $(".link-feedback").removeAttr("href").click(function () {
        initiateFeedbackProcess()
    });
    /*if ($("ul#primary-navigation li a.last-item-disabled").length) {*/
	if ($("ul#primary-navigation li a.last-item").length) {
        $copyPreFooter = "";
        $("#secondary-navigation > ul > li").each(function (m) {
            if ((m + 1) < $("#secondary-navigation > ul > li").length) {
                $copyPreFooter += "<div>" + $(this).html() + "</div>"
            } else {
                $copyPreFooter += '<div class="last-item">' + $(this).html() + "</div>"
            }
        });
		
		/*
		$("ul#primary-navigation li a.last-item").parent().parent().append('<div id="primary-navigation-extended">' + $copyPreFooter + "</div>");
        $("ul#primary-navigation li a.last-item").click(function () {
            $(this).addClass("active-extended-tab");
            $(this).parent().parent().find("#primary-navigation-extended").show("fast").show();
            $(this).parent().parent().hover(function () {}, function () {
                $(this).parent().parent().parent().find("#primary-navigation-extended").hide("fast");
                $(this).find(".last-item").removeClass("active-extended-tab")
            })
        }).hover(function () {
            $(this).parent().addClass("active-tab")
        }, function () {
            $(this).parent().parent().removeClass("active-tab")
        })
		*/
		
		// New Popular Menu
		$("ul#primary-navigation").after('<div id="primary-nav-extended-cont"><div id="primary-navigation-extended" >' + $copyPreFooter + "</div></div>");
        $("ul#primary-navigation li a.last-item").click(function () {
            $(this).addClass("active-extended-tab");
            $("#primary-navigation-extended").show("fast");
			$("#primary-navigation-extended").mouseover(function(){ popularMenuShow(); }).mouseout(function () {
				popularMenuHide();
			})
        }).hover(function () {
            $(this).parent().addClass("active-tab");
			if($(this).hasClass("active-extended-tab"))
			{
				popularMenuShow();
			}
        }, function () {
            $(this).parent().removeClass("active-tab");
			if($(this).hasClass("active-extended-tab"))
			{
				popularMenuHide();
			}
        });
		
		function popularMenuShow()
		{
			if($("#primary-navigation-extended").hide())
			{
				$("ul#primary-navigation li a.last-item").addClass("active-extended-tab");
				$("#primary-navigation-extended").show();
			}
		}	
		
		function popularMenuHide()
		{
			if($("#primary-navigation-extended").show())
			{
				$("ul#primary-navigation li a.last-item").removeClass("active-extended-tab");
				$("#primary-navigation-extended").hide();
			}
		}
    }
    if ($("#page-company-hud").length) {
        $("#co-add-to-wl").click(addCoToWatchlist)
    }
    var a = 0;
    if ($("#search-tippers").length) {
        $tipperSearchHTML = '<div id="search-tippers-box"><form name="tipper_search" id="tipper_search" action="" onsubmit="return searchTipper();" method="post"><input type="text" id="search-tippers-keywords" name="q" autocomplete="off" /><input type="submit" id="search-tippers-submit" value="Search" class="sm-submit-button" /></form></div>';
        var boxclick;
        $("body").bind("click", function () {
            if (!boxclick) {
                $('#search-tippers-box').remove();
                $('#search-tippers').removeClass('active-element');
            }
            boxclick = false;
        });
        $('#search-tippers').click(function () {
            boxclick = true;
        });
        $('a#search-tippers').attr("href", "javascript:void(0);");
        $("#search-tippers strong").bind("click", function () {
            $(this).parent().addClass("active-element");
            $("#search-tippers-box").remove();
            $("#search-tippers").append($tipperSearchHTML);
            $("#search-tippers-keywords").focus().keypress(function (m) {
                if (m.which == 13) {
                    a = 1;
                    $("#search-tippers-submit").click()
                }
            });
            $(this).parent().parent().hover(function () {})
        }, function () {
            $("#search-tippers-box").remove();
            $("#search-tippers").removeClass("active-element")
        })
    }
    if ($("#page-company-hud").length && !c) {
        var h = $("#page-company-hud").offset().top;
        $(window).scroll(function () {
            if ($(window).scrollTop() > h) {
                $("#page-company-hud").addClass("sticky-header").css("width", $("#page-primary-content").width() - 10 + "px")
            } else {
                $("#page-company-hud").removeClass("sticky-header").css("width", "auto")
            }
        })
    }
    $("#submit-tip-button-1").click(addTipsCheckLogin);
    var d = "";
    var g = "";
    var j = "";
    if (pg == "futures-and-options") {
        var e;
        if (SYMBOL != "" && SYMBOL != null) {
            e = SYMBOL.split("_")
        }
        if (sSymbol == "") {
            sSymbol = e[0]
        }
        var b = chartDateformat(sCurrExpDate, "");
        var d = sSymbol + "_" + sCurrExpDate.replace(/\//g, "-");
        var f = chartDateformat(sNextExpDate, "");
        var g = sSymbol + "_" + next.replace(/\//g, "-");
        if (e[2] != "" && e[2] != undefined && e[3] != "" && e[3] != undefined && e[2] != NaN && e[3] != NaN) {
            g = g + "_" + e[2] + "_" + e[3]
        }
        var l = chartDateformat(sNextToNextExpDate, "");
        var j = sSymbol + "_" + far.replace(/\//g, "-");
        if (e[2] != "" && e[2] != undefined && e[3] != "" && e[3] != undefined && e[2] != NaN && e[3] != NaN) {
            j = j + "_" + e[2] + "_" + e[3]
        }
    }
    if ($("#mf-company-graph").length) {
        $("#mf-company-graph ul li a").bind("click", function () {
            $("#mf-company-graph ul li a").each(function () {
                $(this).removeClass()
            });
            $(this).addClass("active-tab");
            switch ($(this).html()) {
            case "1M":
                initCompanyMFGraph("month");
                break;
            case "6M":
                initCompanyMFGraph("6months");
                break;
            case "1Y":
                initCompanyMFGraph("year");
                break;
            case "3Y":
                initCompanyMFGraph("3years");
                break;
            default:
                initCompanyMFGraph("month");
                break
            }
        })
    }
    if ($("#company-mini-graph").length) {
        $("#company-mini-graph ul li a").bind("click", function () {
            $("#company-mini-graph ul li a").each(function () {
                $(this).removeClass()
            });
            $(this).addClass("active-tab");
            switch ($(this).html()) {
            case "Day":
                initCompanyMiniGraph("day");                
                break;
            case "5D":
                initCompanyMiniGraph("week");               
                break;
            case "1M":
                initCompanyMiniGraph("month");                
                break;
            case "6M":
                initCompanyMiniGraph("6months");                
                break;
            case "1Y":
                initCompanyMiniGraph("year");
                break;
            case "3Y":
                initCompanyMiniGraph("3years");                
                break;
            case "5Y":              
                initCompanyMiniGraph("5years");                
                break;
            case "Current Series":
                initCompanyFOMiniGraph("day", SYMBOL);
                break;
            case f:
                initCompanyFOMiniGraph("day", g);
                break;
            case l:
                initCompanyFOMiniGraph("day", j);
                break;
            default:
                if (pg == "futures-and-options") {
                    initCompanyFOMiniGraph("day", SYMBOL);
                    break
                } else {
                    initCompanyMiniGraph("day.xml");
                    break
                }
            }
        })
    }
    if (pg == "futures-and-options") {
        if (SYMBOL == d) {
            document.getElementById("currentseries").className = "active-tab";
            document.getElementById("nextseries").className = "";
            document.getElementById("farseries").className = ""
        } else {
            if (SYMBOL == g) {
                document.getElementById("nextseries").className = "active-tab";
                document.getElementById("currentseries").className = "";
                document.getElementById("farseries").className = ""
            } else {
                if (SYMBOL == j) {
                    document.getElementById("farseries").className = "active-tab";
                    document.getElementById("currentseries").className = "";
                    document.getElementById("nextseries").className = ""
                }
            }
        }
        initCompanyFOMiniGraph("day", SYMBOL)
    } else {
        if (pg == "mutual-fund") {            
            if(mfCompanyGraph == '1'){
            	initCompanyMiniGraph("day");
            }else{
            	$("#mf-company-graph #1m").removeClass("active-tab");
            	$("#mf-company-graph #6m").removeClass("active-tab");
            	$("#mf-company-graph #1y").removeClass("active-tab");
            	$("#mf-company-graph #3y").removeClass("active-tab");
            	
            	switch (true) {
	            case (mfCategory == 'Debt - FMP' || mfCategory == 'Debt - Short Term' || mfCategory == 'Liquid Fund'):
	            	$("#mf-company-graph #1m").addClass("active-tab");
	                initCompanyMFGraph("month");
	                break;
	            case (mfCategory == 'Debt - Medium Term' || mfCategory == 'Debt - Floaters' || mfCategory == 'Gilt Fund'):
	            	$("#mf-company-graph #6m").addClass("active-tab");
	                initCompanyMFGraph("6months");
	                break;
	            case (mfCategory == 'Equity - Sector Fund' || mfCategory == 'Equity - Index Fund' || mfCategory == 'Debt - MIP Fund' || mfCategory == 'Debt - Income' || mfCategory == 'Debt-with Marginal Equity' || mfCategory == 'Special Fund'):
	            	$("#mf-company-graph #1y").addClass("active-tab");
	                initCompanyMFGraph("year");
	                break;
	            case (mfCategory == 'Equity - Diversified' || mfCategory == 'Equity - ELSS' || mfCategory == 'Equity - Balanced Fund' || mfCategory == 'Funds of Funds'):
	            	$("#mf-company-graph #3y").addClass("active-tab");
	                initCompanyMFGraph("3years");
	                break;
	            default:
	            	$("#mf-company-graph #1m").addClass("active-tab");
	                initCompanyMFGraph("month");
	                break
	            }
            	
            }
        } else {
            initCompanyMiniGraph("day");
        }
    }
    if ($("#wmm-base").length) {
        $("#world-markets-btn-americas input").hover(function () {
            $("#wmm-list-americas").slideDown("fast")
        }, function () {
            $("#wmm-list-americas").slideUp("fast")
        });
        $("#world-markets-btn-europe input").hover(function () {
            $("#wmm-list-europe").slideDown("fast")
        }, function () {
            $("#wmm-list-europe").slideUp("fast")
        });
        $("#world-markets-btn-asia input").hover(function () {
            $("#wmm-list-asia").slideDown("fast")
        }, function () {
            $("#wmm-list-asia").slideUp("fast")
        })
    }
    if ($("#results-filter-menu").length) {
        $("#filter-names").val("").focus();
        $("#results-filter-menu").children().click(function (m) {
            $(this).parent().children().removeClass("active-element");
            $(this).addClass("active-element");
            switch ($(this).attr("id")) {
            case "results-filter-menu-stocks":
                resultsSwitcher();
                break;
            case "results-filter-menu-fno":
                resultsSwitcher(2);
                break;
            default:
                resultsSwitcher()
            }
        })
    }
    positionMPbar;
    $(window).scroll(function () {
        positionMPbar
    });
    $(window).resize(function () {
        positionMPbar
    })
}
function addTipsCheckLogin() {
    if (globalUsess) {
        addTips()
    } else {
        url = "tips";
        validateUserLogin(url)
    }
}(function (a) {
    a.fn.extend({
        autocomplete: function (b, c) {
            var d = typeof b == "string";
            c = a.extend({}, a.Autocompleter.defaults, {
                url: d ? b : null,
                data: d ? null : b,
                delay: d ? a.Autocompleter.defaults.delay : 10,
                max: c && !c.scroll ? 10 : 150
            }, c);
            c.highlight = c.highlight ||
            function (e) {
                return e
            };
            c.formatMatch = c.formatMatch || c.formatItem;
            return this.each(function () {
                new a.Autocompleter(this, c)
            })
        },
        result: function (b) {
            return this.bind("result", b)
        },
        search: function (b) {
            return this.trigger("search", [b])
        },
        flushCache: function () {
            return this.trigger("flushCache")
        },
        setOptions: function (b) {
            return this.trigger("setOptions", [b])
        },
        unautocomplete: function () {
            return this.trigger("unautocomplete")
        }
    });
    a.Autocompleter = function (n, g) {
        var c = {
            UP: 38,
            DOWN: 40,
            DEL: 46,
            TAB: 9,
            RETURN: 13,
            ESC: 27,
            COMMA: 188,
            PAGEUP: 33,
            PAGEDOWN: 34,
            BACKSPACE: 8
        };
        var b = a(n).attr("autocomplete", "off").addClass(g.inputClass);
        var l;
        var r = "";
        var o = a.Autocompleter.Cache(g);
        var e = 0;
        var w;
        var A = {
            mouseDownOnSelect: false
        };
        var t = a.Autocompleter.Select(g, n, d, A);
        var z;
        a.browser.opera && a(n.form).bind("submit.autocomplete", function () {
            if (z) {
                z = false;
                return false
            }
        });
        b.bind((a.browser.opera ? "keypress" : "keydown") + ".autocomplete", function (B) {
            e = 1;
            w = B.keyCode;
            switch (B.keyCode) {
            case c.UP:
                B.preventDefault();
                if (t.visible()) {
                    t.prev()
                } else {
                    v(0, true)
                }
                break;
            case c.DOWN:
                B.preventDefault();
                if (t.visible()) {
                    t.next()
                } else {
                    v(0, true)
                }
                break;
            case c.PAGEUP:
                B.preventDefault();
                if (t.visible()) {
                    t.pageUp()
                } else {
                    v(0, true)
                }
                break;
            case c.PAGEDOWN:
                B.preventDefault();
                if (t.visible()) {
                    t.pageDown()
                } else {
                    v(0, true)
                }
                break;
            case g.multiple && a.trim(g.multipleSeparator) == "," && c.COMMA:
            case c.TAB:
            case c.RETURN:
                if (d()) {
                    B.preventDefault();
                    z = true;
                    return false
                }
                break;
            case c.ESC:
                t.hide();
                break;
            default:
                clearTimeout(l);
                l = setTimeout(v, g.delay);
                break
            }
        }).focus(function () {
            e++
        }).blur(function () {
            e = 0;
            if (!A.mouseDownOnSelect) {
                u()
            }
        }).click(function () {
            if (e++ > 1 && !t.visible()) {
                v(0, true)
            }
        }).bind("search", function () {
            var B = (arguments.length > 1) ? arguments[1] : null;

            function C(G, F) {
                var D;
                if (F && F.length) {
                    for (var E = 0; E < F.length; E++) {
                        if (F[E].result.toLowerCase() == G.toLowerCase()) {
                            D = F[E];
                            break
                        }
                    }
                }
                if (typeof B == "function") {
                    B(D)
                } else {
                    b.trigger("result", D && [D.data, D.value])
                }
            }
            a.each(h(b.val()), function (D, E) {
                f(E, C, C)
            })
        }).bind("flushCache", function () {
            o.flush()
        }).bind("setOptions", function () {
            a.extend(g, arguments[1]);
            if ("data" in arguments[1]) {
                o.populate()
            }
        }).bind("unautocomplete", function () {
            t.unbind();
            b.unbind();
            a(n.form).unbind(".autocomplete")
        });

        function d() {
            var E = t.selected();
            if (!E) {
                return false
            }
            var B = E.result;
            r = B;
            if (g.multiple) {
                var H = h(b.val());
                if (H.length > 1) {
                    var D = g.multipleSeparator.length;
                    var G = a(n).selection().start;
                    var F, C = 0;
                    a.each(H, function (I, J) {
                        C += J.length;
                        if (G <= C) {
                            F = I;
                            return false
                        }
                        C += D
                    });
                    H[F] = B;
                    B = H.join(g.multipleSeparator)
                }
                B += g.multipleSeparator
            }
            b.val(B);
            y();
            b.trigger("result", [E.data, E.value]);
            return true
        }
        function v(D, C) {
            if (w == c.DEL) {
                t.hide();
                return
            }
            var B = b.val();
            if (!C && B == r) {
                return
            }
            r = B;
            B = j(B);
            if (B.length >= g.minChars) {
                b.addClass(g.loadingClass);
                if (!g.matchCase) {
                    B = B.toLowerCase()
                }
                f(B, m, y)
            } else {
                p();
                t.hide()
            }
        }
        function h(B) {
            if (!B) {
                return [""]
            }
            if (!g.multiple) {
                return [a.trim(B)]
            }
            return a.map(B.split(g.multipleSeparator), function (C) {
                return a.trim(B).length ? a.trim(C) : null
            })
        }
        function j(B) {
            if (!g.multiple) {
                return B
            }
            var D = h(B);
            if (D.length == 1) {
                return D[0]
            }
            var C = a(n).selection().start;
            if (C == B.length) {
                D = h(B)
            } else {
                D = h(B.replace(B.substring(C), ""))
            }
            return D[D.length - 1]
        }
        function s(B, C) {
            if (g.autoFill && (j(b.val()).toLowerCase() == B.toLowerCase()) && w != c.BACKSPACE) {
                b.val(b.val() + C.substring(j(r).length));
                a(n).selection(r.length, r.length + C.length)
            }
        }
        function u() {
            clearTimeout(l);
            l = setTimeout(y, 200)
        }
        function y() {
            var B = t.visible();
            t.hide();
            clearTimeout(l);
            p();
            if (g.mustMatch) {
                b.search(function (C) {
                    if (!C) {
                        if (g.multiple) {
                            var D = h(b.val()).slice(0, -1);
                            b.val(D.join(g.multipleSeparator) + (D.length ? g.multipleSeparator : ""))
                        } else {
                            b.val("");
                            b.trigger("result", null)
                        }
                    }
                })
            }
        }
        function m(C, B) {
            if (B && B.length && e) {
                p();
                t.display(B, C);
                s(C, B[0].value);
                t.show()
            } else {
                y()
            }
        }
        function f(C, E, B) {
            if (!g.matchCase) {
                C = C.toLowerCase()
            }
            var D = o.load(C);
            if (D && D.length) {
                E(C, D)
            } else {
                if ((typeof g.url == "string") && (g.url.length > 0)) {
                    var F = {
                        timestamp: +new Date()
                    };
                    a.each(g.extraParams, function (G, H) {
                        F[G] = typeof H == "function" ? H() : H
                    });
                    a.ajax({
                        mode: "abort",
                        port: "autocomplete" + n.name,
                        dataType: g.dataType,
                        url: g.url,
                        data: a.extend({
                            q: j(C),
                            limit: g.max
                        }, F),
                        success: function (H) {
                            var G = g.parse && g.parse(H) || q(H);
                            o.add(C, G);
                            E(C, G)
                        }
                    })
                } else {
                    t.emptyList();
                    B(C)
                }
            }
        }
        function q(E) {
            var B = [];
            var D = E.split("\n");
            for (var C = 0; C < D.length; C++) {
                var F = a.trim(D[C]);
                if (F) {
                    F = F.split("|");
                    B[B.length] = {
                        data: F,
                        value: F[0],
                        result: g.formatResult && g.formatResult(F, F[0]) || F[0]
                    }
                }
            }
            return B
        }
        function p() {
            b.removeClass(g.loadingClass)
        }
    };
    a.Autocompleter.defaults = {
        inputClass: "ac_input",
        resultsClass: "ac_results",
        loadingClass: "ac_loading",
        minChars: 1,
        delay: 400,
        matchCase: false,
        matchSubset: true,
        matchContains: false,
        cacheLength: 10,
        max: 100,
        mustMatch: false,
        extraParams: {},
        selectFirst: true,
        formatItem: function (b) {
            return b[0]
        },
        formatMatch: null,
        autoFill: false,
        width: 0,
        multiple: false,
        multipleSeparator: ", ",
        highlight: function (c, b) {
            return c.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + b.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>")
        },
        scroll: true,
        scrollHeight: 180
    };
    a.Autocompleter.Cache = function (c) {
        var f = {};
        var d = 0;

        function h(m, l) {
            if (!c.matchCase) {
                m = m.toLowerCase()
            }
            var j = m.indexOf(l);
            if (c.matchContains == "word") {
                j = m.toLowerCase().search("\\b" + l.toLowerCase())
            }
            if (j == -1) {
                return false
            }
            return j == 0 || c.matchContains
        }
        function g(l, j) {
            if (d > c.cacheLength) {
                b()
            }
            if (!f[l]) {
                d++
            }
            f[l] = j
        }
        function e() {
            if (!c.data) {
                return false
            }
            var l = {},
                j = 0;
            if (!c.url) {
                c.cacheLength = 1
            }
            l[""] = [];
            for (var n = 0, m = c.data.length; n < m; n++) {
                var q = c.data[n];
                q = (typeof q == "string") ? [q] : q;
                var p = c.formatMatch(q, n + 1, c.data.length);
                if (p === false) {
                    continue
                }
                var o = p.charAt(0).toLowerCase();
                if (!l[o]) {
                    l[o] = []
                }
                var r = {
                    value: p,
                    data: q,
                    result: c.formatResult && c.formatResult(q) || p
                };
                l[o].push(r);
                if (j++ < c.max) {
                    l[""].push(r)
                }
            }
            a.each(l, function (s, t) {
                c.cacheLength++;
                g(s, t)
            })
        }
        setTimeout(e, 25);

        function b() {
            f = {};
            d = 0
        }
        return {
            flush: b,
            add: g,
            populate: e,
            load: function (n) {
                if (!c.cacheLength || !d) {
                    return null
                }
                if (!c.url && c.matchContains) {
                    var m = [];
                    for (var j in f) {
                        if (j.length > 0) {
                            var o = f[j];
                            a.each(o, function (q, p) {
                                if (h(p.value, n)) {
                                    m.push(p)
                                }
                            })
                        }
                    }
                    return m
                } else {
                    if (f[n]) {
                        return f[n]
                    } else {
                        if (c.matchSubset) {
                            for (var l = n.length - 1; l >= c.minChars; l--) {
                                var o = f[n.substr(0, l)];
                                if (o) {
                                    var m = [];
                                    a.each(o, function (q, p) {
                                        if (h(p.value, n)) {
                                            m[m.length] = p
                                        }
                                    });
                                    return m
                                }
                            }
                        }
                    }
                }
                return null
            }
        }
    };
    a.Autocompleter.Select = function (e, l, n, r) {
        var j = {
            ACTIVE: "ac_over"
        };
        var m, f = -1,
            t, o = "",
            u = true,
            c, q;

        function p() {
            if (!u) {
                return
            }
            c = a("<div/>").hide().addClass(e.resultsClass).css("position", "absolute").appendTo(document.body);
            q = a("<ul/>").appendTo(c).mouseover(function (v) {
                if (s(v).nodeName && s(v).nodeName.toUpperCase() == "LI") {
                    f = a("li", q).removeClass(j.ACTIVE).index(s(v));
                    a(s(v)).addClass(j.ACTIVE)
                }
            }).click(function (v) {
                a(s(v)).addClass(j.ACTIVE);
                n();
                l.focus();
                return false
            }).mousedown(function () {
                r.mouseDownOnSelect = true
            }).mouseup(function () {
                r.mouseDownOnSelect = false
            });
            if (e.width > 0) {
                c.css("width", e.width)
            }
            u = false
        }
        function s(w) {
            var v = w.target;
            while (v && v.tagName != "LI") {
                v = v.parentNode
            }
            if (!v) {
                return []
            }
            return v
        }
        function h(v) {
            m.slice(f, f + 1).removeClass(j.ACTIVE);
            g(v);
            var y = m.slice(f, f + 1).addClass(j.ACTIVE);
            if (e.scroll) {
                var w = 0;
                m.slice(0, f).each(function () {
                    w += this.offsetHeight
                });
                if ((w + y[0].offsetHeight - q.scrollTop()) > q[0].clientHeight) {
                    q.scrollTop(w + y[0].offsetHeight - q.innerHeight())
                } else {
                    if (w < q.scrollTop()) {
                        q.scrollTop(w)
                    }
                }
            }
        }
        function g(v) {
            f += v;
            if (f < 0) {
                f = m.size() - 1
            } else {
                if (f >= m.size()) {
                    f = 0
                }
            }
        }
        function b(v) {
            return e.max && e.max < v ? e.max : v
        }
        function d() {
            q.empty();
            var w = b(t.length);
            for (var y = 0; y < w; y++) {
                if (!t[y]) {
                    continue
                }
                var z = e.formatItem(t[y].data, y + 1, w, t[y].value, o);
                if (z === false) {
                    continue
                }
                var v = a("<li/>").html(e.highlight(z, o)).addClass(y % 2 == 0 ? "ac_even" : "ac_odd").appendTo(q)[0];
                a.data(v, "ac_data", t[y])
            }
            m = q.find("li");
            if (e.selectFirst) {
                m.slice(0, 1).addClass(j.ACTIVE);
                f = 0
            }
            if (a.fn.bgiframe) {
                q.bgiframe()
            }
        }
        return {
            display: function (w, v) {
                p();
                t = w;
                o = v;
                d()
            },
            next: function () {
                h(1)
            },
            prev: function () {
                h(-1)
            },
            pageUp: function () {
                if (f != 0 && f - 8 < 0) {
                    h(-f)
                } else {
                    h(-8)
                }
            },
            pageDown: function () {
                if (f != m.size() - 1 && f + 8 > m.size()) {
                    h(m.size() - 1 - f)
                } else {
                    h(8)
                }
            },
            hide: function () {
                c && c.hide();
                m && m.removeClass(j.ACTIVE);
                f = -1
            },
            visible: function () {
                return c && c.is(":visible")
            },
            current: function () {
                return this.visible() && (m.filter("." + j.ACTIVE)[0] || e.selectFirst && m[0])
            },
            show: function () {
                var y = a(l).offset();
                c.css({
                    width: typeof e.width == "string" || e.width > 0 ? e.width : a(l).width(),
                    top: y.top + l.offsetHeight,
                    left: y.left
                }).show();
                if (e.scroll) {
                    q.scrollTop(0);
                    q.css({
                        maxHeight: e.scrollHeight,
                        overflow: "auto"
                    });
                    if (a.browser.msie && typeof document.body.style.maxHeight === "undefined") {
                        var v = 0;
                        m.each(function () {
                            v += this.offsetHeight
                        });
                        var w = v > e.scrollHeight;
                        q.css("height", w ? e.scrollHeight : v);
                        if (!w) {
                            m.width(q.width() - parseInt(m.css("padding-left")) - parseInt(m.css("padding-right")))
                        }
                    }
                }
            },
            selected: function () {
                var v = m && m.filter("." + j.ACTIVE).removeClass(j.ACTIVE);
                return v && v.length && a.data(v[0], "ac_data")
            },
            emptyList: function () {
                q && q.empty()
            },
            unbind: function () {
                c && c.remove()
            }
        }
    };
    a.fn.selection = function (j, b) {
        if (j !== undefined) {
            return this.each(function () {
                if (this.createTextRange) {
                    var l = this.createTextRange();
                    if (b === undefined || j == b) {
                        l.move("character", j);
                        l.select()
                    } else {
                        l.collapse(true);
                        l.moveStart("character", j);
                        l.moveEnd("character", b);
                        l.select()
                    }
                } else {
                    if (this.setSelectionRange) {
                        this.setSelectionRange(j, b)
                    } else {
                        if (this.selectionStart) {
                            this.selectionStart = j;
                            this.selectionEnd = b
                        }
                    }
                }
            })
        }
        var g = this[0];
        if (g.createTextRange) {
            var c = document.selection.createRange(),
                h = g.value,
                f = "<->",
                d = c.text.length;
            c.text = f;
            var e = g.value.indexOf(f);
            g.value = h;
            this.selection(e, e + d);
            return {
                start: e,
                end: e + d
            }
        } else {
            if (g.selectionStart !== undefined) {
                return {
                    start: g.selectionStart,
                    end: g.selectionEnd
                }
            }
        }
    }
})(jQuery);
String.prototype.score = function (m, d) {
    d = d || 0;
    if (m.length == 0) {
        return 0.9
    }
    if (m.length > this.length) {
        return 0
    }
    for (var g = m.length; g > 0; g--) {
        var o = m.substring(0, g);
        var h = this.indexOf(o);
        if (h < 0) {
            continue
        }
        if (h + m.length > this.length + d) {
            continue
        }
        var n = this.substring(h + o.length);
        var f = null;
        if (g >= m.length) {
            f = ""
        } else {
            f = m.substring(g)
        }
        var e = n.score(f, d + h);
        if (e > 0) {
            var a = this.length - n.length;
            if (h != 0) {
                var b = 0;
                var l = this.charCodeAt(h - 1);
                if (l == 32 || l == 9) {
                    for (var b = (h - 2); b >= 0; b--) {
                        l = this.charCodeAt(b);
                        a -= ((l == 32 || l == 9) ? 1 : 0.15)
                    }
                } else {
                    a -= h
                }
            }
            a += e * n.length;
            a /= this.length;
            return a
        }
    }
    return 0
};
var globalURL = "";

function validateUserLogin(b) {
    globalURL = b;
    var a = getCookie("usess");
    if (a.length > 0) {
        redirectUrl()
    } else {
        initiateLoginSignupProcess();
        return false
    }
}
function redirectUrl() {
    var a = siteURL + globalURL;
    globalUsess = true;
    if (globalURL == "addPrediction") {
        getUserPrediction()
    } else if (globalURL == "remindMe") {
        addRemindMe();
    }
    else if (globalURL == "tipperUnsubscribe" && newsLetterAccessKey == '') {
 addTipperUnsubscribe();
	}
	else {
        if (globalURL == "tips") {
            addTips()
        } else {
            if (globalURL == "addtowatchlist") {
                getWatchlist()
            } else {
                if (globalURL == "watchlist") {
                    window.location = watchlistURL;
                } else {
                    if (globalURL.indexOf("watchlist") > -1) {
                        window.location = globalURL;
                    } else {
                        if (globalURL.indexOf("FollowTipper") > -1) {
                            var str = globalURL.split("-");
                            
                            if(str[2] == 2){
		                    	 FollowTipperCheckLogin(2,str[1]);
	                        }else{
		                      	 FollowTipperCheckLogin(1,str[1]);
	                        } 
	                          
                        } else {
                            if (globalURL.length > 0 || globalLogout == true) {
                                window.location = a;
                            }
                        }
                    }
                }
            }
        }
    }
}
function getCookie(a) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(a + "=");
        if (c_start != -1) {
            c_start = c_start + a.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) {
                c_end = document.cookie.length
            }
            return unescape(document.cookie.substring(c_start, c_end))
        }
    }
    return ""
}
function addComopanyStockToWatchlist() {
    var a = globalCompanyName + " ( " + globalCompanySymbol + " ) ";
    a = Url.encode(a);
    var d = strRequired(a);
    var b = siteURL + "ajax_process_watchlist.php";
    var c = "action=addstock&watchlist_id=" + watchlist_id_toaddstock + "&name_symbol=" + a + "&r=" + Math.random();
    $.ajax({
        type: "GET",
        url: b,
        data: c,
        success: function (e) {
            watchlistName_toredirect = replaceSpacesWithDash(watchlistName_toredirect);
            var f = watchlistURL + "/" + watchlistName_toredirect + "/" + watchlist_id_toaddstock;
            globalURL = f;
            redirectUrl()
        }
    })
}
function searchTipper() {
    searchTipperKeywords = $("#search-tippers-keywords").val();
    searchTipperKeywords = searchTipperKeywords.replace(/^\s+|\s+$/g, "");
    var a = searchTipperKeywords.length;
    if (a == 0) {
        alert("Please Enter Tipper Name To Search.");
        $("#search-tippers-keywords").focus();
        return false
    } else {
        if (a < 3) {
            alert("Please Enter At Least 3 Chatacters To Search Tipper.");
            $("#search-tippers-keywords").focus();
            return false
        } else {
            var b = new RegExp("^[ a-zA-Z0-9'_-]+$");
            if (b.test(searchTipperKeywords)) {
                searchTipperKeywords = searchTipperKeywords.toLowerCase();
                searchTipperKeywords = searchTipperKeywords.replace(/[ ]+/g, "-");
                searchTipperKeywords.replace(/'/g, "%27");
                url = siteURL + "tipper/" + searchTipperKeywords;
                $("#tipper_search").attr("action", url);
                return true
            } else {
                alert("Please Enter Alphanumeric Search keyword");
                $("#search-tippers-keywords").focus();
                return false
            }
        }
    }
}

function FollowTipperCheckLogin(pagefrom,followtipperID) {

    var flag = 0;
    var url;
    var a = getCookie("usess");
    if (a.length > 0) {
        var LoggedTipperID = getCookie("tuid");
        if (LoggedTipperID != followtipperID) {
            var param = 'r=' + Math.random() + '&LoggedTipperID=' + LoggedTipperID + '&followtipperID=' + followtipperID;
            $.ajax({
                type: "GET",
                url: callURL + 'ajax_followtipper.php',
                data: param,
                dataType: "html",
                success: function (res) {
                	if(pagefrom == 2){
                		 var tipperName = $("#user_img_"+followtipperID).attr('alt');                		 	                   
                	}else{
	                    var tipperName = $('.tipper-avatar-img').attr('alt');
	                    if (typeof(tipperName) == "undefined") {
	                        $rowID = "#tipper_" + followtipperID + " a";
	                        tipperName = $($rowID).attr('alt');
	                    }
                    }
                    if (res.indexOf("Duplicate") > "-1") {
                        var alertmsg = "<div id='wl-move-stocks-process' class='wl-modal-dialog'><input type='button' class='sm-submit-button mangoPeopleModalClose' value='X' onclick='$.modal.close();' title='Cancel' /><h2>Follow Tipper: Notice</h2><p class='um-modal-notice-body'>You are already following " + tipperName + ".</p><input type='button' class='medium-submit-button' value='Ok' id='wl-move-stocks-submit'  onclick='javascript:window.location=watchlistURL;'/></div>";
                        $.modal.close();
                        $.modal(alertmsg, {
                            opacity: 90,
                            focus: false,
                            overlayId: 'mangoPeopleModalOverlay',
                            containerId: 'mangoPeopleModalContainer',
                            closeClass: 'mangoPeopleModalClose',
                            persist: false
                        });
                    } else {
                        var alertmsg = "<div id='wl-move-stocks-process' class='wl-modal-dialog'><input type='button' class='sm-submit-button mangoPeopleModalClose' value='X' onclick='changefollowbuttons("+pagefrom+",1,"+followtipperID+")' title='Cancel' /><h2>Follow Tipper: Success</h2><p class='um-modal-notice-body'>You are now following " + tipperName + ".</p><input type='button' class='medium-submit-button' value='Ok' id='wl-move-stocks-submit'  onclick='javascript:window.location=watchlistURL;'/></div>";
                        $.modal.close();
                        $.modal(alertmsg, {
                            opacity: 90,
                            focus: false,
                            overlayId: 'mangoPeopleModalOverlay',
                            containerId: 'mangoPeopleModalContainer',
                            closeClass: 'mangoPeopleModalClose',
                            persist: false
                        });
                    }
                }
            });
        } else {
            var alertmsg = "<div id='wl-move-stocks-process' class='wl-modal-dialog'><input type='button' class='sm-submit-button mangoPeopleModalClose' value='X' onclick='$.modal.close();' title='Cancel' /><h2>Follow Tipper: Error</h2><p class='um-modal-notice-body'>You cannot follow your own tips.</p><input type='button' class='medium-submit-button' value='Ok' id='wl-move-stocks-submit'  onclick='$.modal.close();'/></div>";
            $.modal.close();
            $.modal(alertmsg, {
                opacity: 90,
                focus: false,
                overlayId: 'mangoPeopleModalOverlay',
                containerId: 'mangoPeopleModalContainer',
                closeClass: 'mangoPeopleModalClose',
                persist: false
            });
            return false;
        }
    } else {
        url = "FollowTipper-" + followtipperID+"-"+pagefrom;
        validateUserLogin(url);
    }
};


function unFollowTipperCheckLogin(pagefrom,followtipperID) {
    var flag = 0;
    var url;
    var a = getCookie("usess");
    if (a.length > 0) {
        var LoggedTipperID = getCookie("tuid");
        
            var param = 'r=' + Math.random() + '&LoggedTipperID=' + LoggedTipperID + '&followtipperID=' + followtipperID;
            $.ajax({
                type: "GET",
                url: callURL + 'ajax_unfollowtipper.php',
                data: param,
                dataType: "html",
                success: function (res) {
                	if(pagefrom == 2){
                		 var tipperName = $("#user_img_"+followtipperID).attr('alt');                  		            		 	                   
                	}else{
	                	var tipperName = $('.tipper-avatar-img').attr('alt');
	                    if (typeof(tipperName) == "undefined") {
	                        $rowID = "#tipper_" + followtipperID + " a";
	                        tipperName = $($rowID).attr('alt');
	                    }
	                }
	                    
                    if(res == 1)
                    {
						var alertmsg = "<div id='wl-move-stocks-process' class='wl-modal-dialog'><input type='button' class='sm-submit-button mangoPeopleModalClose' value='X' onclick='changefollowbuttons("+pagefrom+",2,"+followtipperID+")' title='Cancel' /><h2>Unfollow Tipper: Success</h2><p class='um-modal-notice-body'>You are no longer following " + tipperName + ".</p><input type='button' class='medium-submit-button' value='Ok' id='wl-move-stocks-submit'  onclick='changefollowbuttons("+pagefrom+",2,"+followtipperID+")'/></div>";
						$.modal.close();
						$.modal(alertmsg, {
							opacity: 90,
							focus: false,
							overlayId: 'mangoPeopleModalOverlay',
							containerId: 'mangoPeopleModalContainer',
							closeClass: 'mangoPeopleModalClose',
							persist: false
						});
                    }
                }
            });
        
    } else {
        url = "FollowTipper-" + followtipperID;
        validateUserLogin(url);
    }
};

function changefollowbuttons(pg,type,followtipperID)
{
	if(pg == 2)
	{
		if(type == 2){
			$.modal.close();
			$("#follow-but-"+followtipperID).attr("value","Follow");
			$("#follow-but-"+followtipperID).attr("onClick","FollowTipperCheckLogin("+pg+","+followtipperID+")");
		}else{
			$.modal.close();
			//$("#follow-but-"+followtipperID).before('<a href="http://utvmoney.mangopeople.com/profiles/'+followtipperID+'#tipper-profile" class="follow-tab-link">following</a>');
			$("#follow-but-"+followtipperID).attr("value","Unfollow");
			$("#follow-but-"+followtipperID).attr("onClick","unFollowTipperCheckLogin("+pg+","+followtipperID+")");
		}
	}else{
		if(type == 2){
			$.modal.close();
			//$("#followTipperbutton").attr("value","Follow");
			//$("#followTipperbutton").attr("onClick","FollowTipperCheckLogin("+pg+","+followtipperID+")");
			window.location.reload();
		}else{
			$.modal.close();
			//$("#followTipperbutton").attr("value","Unfollow");
			//$("#followTipperbutton").attr("onClick","unFollowTipperCheckLogin("+pg+","+followtipperID+")");
			window.location.reload();
		}
	}
}

function searchAtBestTipper() {
    searchTipperKeywords = $("#search-tippers-name").val();
    searchTipperKeywords = searchTipperKeywords.replace(/^\s+|\s+$/g, "");
    var a = searchTipperKeywords.length;
    if (a == 0) {
        alert("Please Enter Tipper Name To Search.");
        $("#search-tippers-name").focus();
        return false
    } else {
        if (a < 3) {
            alert("Please Enter At Least 3 Chatacters To Search Tipper.");
            $("#search-tippers-name").focus();
            return false
        } else {
            var b = new RegExp("^[ a-zA-Z0-9'_-]+$");
            if (b.test(searchTipperKeywords)) {
                searchTipperKeywords = searchTipperKeywords.toLowerCase();
                searchTipperKeywords = searchTipperKeywords.replace(/[ ]+/g, "-");
                searchTipperKeywords.replace(/'/g, "%27");
                url = siteURL + "tipper/" + searchTipperKeywords;
                $("#tipper_search").attr("action", url);
                return true
            } else {
                alert("Please Enter Alphanumeric Search keyword");
                $("#search-tippers-name").focus();
                return false
            }
        }
    }
};
function getnews_bydate(objchk){var selval = objchk.value;$("#hid_date").val(selval);$("#frmarticle").submit();}
function addRemindMe() {
    $.ajax({
        type: "GET",
        url: siteURL + "budget2011/add_remindMe_ajax.php",
        data: "email=" + getCookie("email") + "&remindMePG=" + remindMePG + "&remindMeDate=" + remindDate + "&rand=" + Math.random(),
        dataType: "html",
        success: function (b) {
            alert("Thank you. We will send you an email on the day of the event");
        }
    })
}


function addTipperUnsubscribe() {
//alert(getCookie("email"));alert(getCookie("tuid"));
   $.ajax({
        type: "GET",
        url: siteURL + "followtipper_unsubscribe_ajax.php",
        data: "tipperId=" + getCookie("tuid") + "&eid=" + getCookie("email") + "&unsub=" + unsub+"&typ=" + typ + "&accesskey=" + newsLetterAccessKey  +   "&rand=" + Math.random(),
	dataType: "html",
        success: function (b) {
			
			if (b.indexOf("|") > -1) {
                var a = b.split("|");
				status = a[0];		// 1 = No value selected; 2 = value selected;
				data = a[1];
            }

			if(status==1){$unsubscribe_html='<div class="tip-share-container"><p>'+data+'</p><p><a onclick="unsubscribe_submit(1,'+typ+')" class="medium-submit-button">Continue</a></p></div>';}
			else {$unsubscribe_html='<div class="tip-share-container"><p>'+data+'</p><p><a onclick="unsubscribe_submit(2,'+typ+')" class="medium-submit-button">Continue</a></p></div>';}
							
			$.modal.close(); $.modal($unsubscribe_html, { opacity: 90, focus: false, overlayId: 'mangoPeopleModalOverlay', containerId: 'submit-tips-process', closeClass: 'mangoPeopleModalClose', persist: false});	
        }
    })
}

function unsubscribe_submit(x,t) {
	if(x==1){window.location=siteURL+"follow-tipper/unsubscribe/"+t;}
	else{window.location=siteURL;}
}

