﻿//function openLogin() {
//    $('#login').modal();
//};

//function doLogin() {
//    var username = $('#username').val();
//    var password = $('#password').val();

//    $('#loginStatus').attr('innerHTML', 'Logging in...');

//    $.post('/ajaxactions.aspx?op=login', { username: username, password: password }, doLoginCallback);
//};

//function doLogout() {
//    $.post('/ajaxactions.aspx?op=logout', {}, doLogoutCallback);
//};

//function doLoginCallback(data) {
//    if (data == "0") {
//        $('#loginStatus').attr('innerHTML', 'Incorrect username and/or password. Please try again.');
//    } else {
//        window.location = window.location;
//    };
//};

//function doLogoutCallback(data) {
//    window.location = window.location;
//};

function CheckStatus(sender, arg) {
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    if (prm.get_isInAsyncPostBack()) {
        arg.set_cancel(true);
    };
};

function doShowBox(obj) {
    var t = obj.title || obj.name || null;
    var a = obj.href || obj.alt;
    var g = obj.rel || obj;
    ektb_show(t, a, g);
    obj.blur();
    return false;
}

function checkKeycode(e) {
    var keycode;
    if (window.event) // IE
        keycode = e.keyCode;
    else if (e.which) // Netscape/Firefox/Opera
        keycode = e.which;
    if (keycode == 13)
        return CallSearch();
}

function CallSearch() {
    var objsearchText = document.getElementById('searchtext');
    var searchText = '';
    if ((objsearchText != null)) {
        searchText = objsearchText.value;
        searchText = searchText.replace(/>/gi, " >");
        searchText = searchText.replace(/</gi, "< ");
        objsearchText.value = searchText;
    }
    //This cookie is used for the backbutton to work in search on postback
    //This cookie must be cleared to prevent old search results from displayed            
    if (objsearchText.value.length > 0) {
        document.cookie = 'postbackcookie=';
         var temp = new Array();
        var link = document.location.href;
        temp = link.split('/');
        if (temp.length > 6) {
            document.location.href = '../search.aspx?q=' + searchText.replace('alert', '').replace('confirm', '');
        }
        else {
            document.location.href = 'search.aspx?q=' + searchText.replace('alert', '').replace('confirm', '');
        }
    }
    return false;
}
