﻿$(document).ready(function() {

    $("#loginLink").click(function() {
        if ($("#loginForm").is(":hidden")) {
            //$("#loginForm").show(800);
           document.getElementById('loginForm').style.display = 'block';
        }
        else {
            //$("#loginForm").hide(800);
            document.getElementById('loginForm').style.display = 'none';
        }
    });

});

function closeForm() {
    setTimeout('("#loginForm").slideUp("fastest")', 0);
}




/*/////////////////////////////////////////////////////////////////////

HELP FUNCITONS
will open the help screen

/////////////////////////////////////////////////////////////////////*/
var newwindow = '';

function openWin(url, title, width, height) {
    newWin = window.open(url, title, 'toolbar=no,resizable=no,scrollbars=yes,width=' + width + ', height=' + height + ',top=10,left=10');
}

function sQ(url) {
    if (!newwindow.closed && newwindow.location) {
        newwindow.location.href = url;
    }
    else {

        var width = 670;
        var height = 520;
        var left = parseInt((screen.availWidth / 2) - (width / 2));
        var top = parseInt((screen.availHeight / 2) - (height / 2));
        var windowFeatures = "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top + ",toolbar=no,resizable=no,scrollbars=yes";
        newwindow = window.open(url, 'SnapQuote', windowFeatures);
        if (!newwindow.opener) newwindow.opener = self;
    }
    if (window.focus) { newwindow.focus() }
    return;
}

function openHelp(URL) {
    helpWin = window.open(URL, 'HELP', 'toolbar=no,resizable=yes,scrollbars=yes,width=400,height=400,top=10,left=10');
}

function helpDesk(URL) {
    helpWin = window.open(URL, 'helpDesk', 'toolbar=no,resizable=no,scrollbars=no,width=725,height=500,top=10,left=10');
}

function openNews(URL) {
    helpWin = window.open(URL, 'HELP', 'toolbar=no,resizable=yes,scrollbars=yes,width=860,height=660,top=10,left=10');
}


/*/////////////////////////////////////////////////////////////////////

PAGE LOAD FUNCTION

/////////////////////////////////////////////////////////////////////*/
function pageLoad() {
//    if (document.getElementById) {
//        document.getElementById('hidepage').style.visibility = 'hidden';
//    }
//    else {
//        if (document.layers) {
//            document.hidepage.visibility = 'hidden';
//        }
//        else {
//            document.all.hidepage.style.visibility = 'hidden';
//        }
//    }
}
/*/////////////////////////////////////////////////////////////////////

LOGIN FUNCTIONS
handles the changing of the username/password values when the user clicks
to enter their credentials

/////////////////////////////////////////////////////////////////////*/
function userFieldFocus() {
    document.getElementById('login_username').value = '';
}
function passFieldFocus() {
    document.getElementById('login_password').type = 'password';
    document.getElementById('login_password').value = '';
}
function userFieldBlur() {
    if (document.getElementById('login_username').value.length == 0) {
        document.getElementById('login_username').value = 'Username';
    }
}
function passFieldBlur() {
    if (document.getElementById('login_password').value.length == 0) {
        document.getElementById('login_password').type = 'text';
        document.getElementById('login_password').value = 'Password';
    }
}
/*/////////////////////////////////////////////////////////////////////

TOP SEARCH FUNCTIONS
handles the swap of the two forms (quotes and charts).

/////////////////////////////////////////////////////////////////////*/
function searchSwitch(_id) {
    if (_id == 'searchchart') {
        document.getElementById(_id).style.display = 'block';
        document.getElementById('searchquotes').style.display = 'none';
    } else if (_id == 'searchquotes') {
        document.getElementById(_id).style.display = 'block';
        document.getElementById('searchchart').style.display = 'none';
    }
}
/*/////////////////////////////////////////////////////////////////////

SHOW HIDE FUNCTIONS
handles the show hide features for modules (portfolio).

/////////////////////////////////////////////////////////////////////*/
function show(id) {
    el = document.getElementById(id);
    if (el.style.display == 'none') {
        el.style.display = '';
        el = document.getElementById('more' + id);
        el.innerHTML = 'hide';
    } else {
        el.style.display = 'none';
        el = document.getElementById('more' + id);
        el.innerHTML = 'show';
    }
}
/*/////////////////////////////////////////////////////////////////////

ALTERNATE ROW COLOR FUNCTIONS
handles the alternate row colors for modules (portfolio).

/////////////////////////////////////////////////////////////////////*/
function trmouseover(row) {
    var i = 0;
    for (i = 0; i < row.cells.length; i++) {
        row.cells.item(i).bgColor = '#F0EDE3';
    }
}

function trmouseout(row) {
    var i = 0;
    for (i = 0; i < row.cells.length; i++) {
        row.cells.item(i).bgColor = '';
    }
}
/*/////////////////////////////////////////////////////////////////////

JUMP MENU FUNCTION
handles the jump to menu for modules (portfolio).

/////////////////////////////////////////////////////////////////////*/
function MM_jumpMenu(targ, selObj, restore) { //v3.0
    eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");
    if (restore) selObj.selectedIndex = 0;
}
/*/////////////////////////////////////////////////////////////////////

TRADING FUNCTION
handles different funcntions used by trading modules.

/////////////////////////////////////////////////////////////////////*/
function orderPrice() {

    if (document.tradeForm.orderType[0].checked) {
        document.tradeForm.price.value = "";
        document.tradeForm.price.disabled = true;
        document.tradeForm.term.value = "MKT";
    }
    if ((document.tradeForm.orderType[1].checked) || (document.tradeForm.orderType[2].checked)) {
        document.tradeForm.price.value = "";
        document.tradeForm.price.disabled = false;
        document.tradeForm.term.value = "GTC";
        document.tradeForm.price.focus();
    }
}

/*/////////////////////////////////////////////////////////////////////

PORTFOLIO FUNCTION
handles different functional used by portfolio modules.

/////////////////////////////////////////////////////////////////////*/

function cancel_order(cancelId) {
    var where_to = confirm("Are you sure you wish to cancel this Order?");
    if (where_to == true) {
        window.location = "limitStopHistory.php?Action=Delete&cancelId=" + cancelId;
    }
}


/*/////////////////////////////////////////////////////////////////////

FAQs
show/hive layer for the answer.

/////////////////////////////////////////////////////////////////////*/

function toggle(obj) {
    var el = document.getElementById(obj);
    el.style.display = (el.style.display != 'none' ? 'none' : '');
    return false;
}

function toggleLayer(theshown, thehidden, thehidden2, signup, thestyle) {
    var d = document;

    if (!thestyle) {
        thestyle = 'block';
    }

    if (theshown != '') {
        if (d.getElementById(theshown).style.display == 'none' || (d.getElementById(theshown).style.display == '' && thestyle != 'table-row')) {
            if (thestyle == 'table-row') {
                d.getElementById(theshown).style.display = '';
            }
            else {
                d.getElementById(theshown).style.display = thestyle;
            }
        }
        else {
            if (!signup) {
                d.getElementById(theshown).style.display = 'none';
            }
        }
    }

    if (thehidden) {
        d.getElementById(thehidden).style.display = 'none';
    }

    return false;

    if (thehidden2) {
        d.getElementById(thehidden2).style.display = 'none';
    }
}

function quote(symbol) {
    window.location.href = "../../public/quotes/quotes.aspx?symbol=" + symbol;
}