﻿function isValidMember(flink) {
    if ($("#txtVSOID").val() == "") {
        alert("Please enter your VSOID Number. Eg. XX-000000-000");
        $("#txtVSOID").focus();
    } else if ($("#txtPassword").val() == "") {
        alert("Please enter your Password for the VSOID Number!");
        $("#txtPassword").focus();
    } else {
        startwait();
        $.post("vsoid.ashx?task=checkuser&u=" + $("#txtVSOID").val() + "&p=" + $("#txtPassword").val(), function (data) {
            if (data == 1) {
                document.location.href = flink;
            } else if (data == 0) {
                waitmes(0, "Invalid VSOID No. or Password.");
            }
        });        
    }
    return false;
}

function startwait() {
    $(".wait").attr("css", "wait");
    $(".wait").css("display", "block");
}

function stopwait() {
    $(".good").removeClass("good");
    $(".bad").removeClass("bad");
    $(".wait").attr("css", "wait pwait");
    $(".wait").html("Signing In, Please wait ...");
    $(".wait").css("display", "none");
}

function waitmes(t, mess) {
    if (t == 1) {
        $("p.wait").addClass("good");
        $("p.wait").html(mess);
    } else {
        $("p.wait").addClass("bad");
        $("p.wait").html(mess);
    }
}

function Search(e,n,l) {
    var o = document.getElementById("txtSearch");
    if (n == 1) {
        if (o.value == "") return false;
        if (e.keyCode == 13) {
            document.location.href = l + "Search.aspx?s=" + o.value;
        }
    } else {
        if (o.value == "") return false;
        document.location.href = l + "Search.aspx?s=" + o.value;
    }
}

function formatURL(input) {
    return input.replace(/(http\:\/\/[\w\.\-\?\!\&\=]+)/g,'<a class="netlnk" target="_blank" href="$1">$1</a>');
    //return input.replace(/<br>/gim, '\n').replace(/(ftp|http|https|file):\/\/[\S]+(\b|$)/gim,'<a href="$&" class="netlnk" target="_blank">$&</a>').replace(/([^\/])(www[\S]+(\b|$))/gim,'$1<a href="http://$2" class="netlnk" target="_blank">$2</a>').replace(/\n/gim, '<br>');
}
