﻿function $(id) 
{
    return document.getElementById(id);
}
function ClickSubmitButton(buttonID) 
{
    var btn = document.getElementById(buttonID);
    btn.click();
}
function ShowProgressBar() 
{
    //http://www.dynamicdrive.com/dynamicindex11/xpprogressbar.htm
    
    var FadeBackground = $("fade");

    //var Width = screen.availWidth;
    //var Height = screen.availHeight;   
    
    //Make the gray DIV fill the page. 
    //FadeBackground.style.width = Width;
    //FadeBackground.style.height = Height;
    //FadeBackground.style.display = 'block';

    //The LB contains the bar
    var LightBox = $("LightBox");
    var top = parseInt((screen.availHeight / 2.2) - (100 / 2.2));      

    LightBox.style.top = top;
    LightBox.style.display = 'block';
    bar1.showBar();
}	
//New search using Google
function GoogleSearchSite()
{

   //http://www.mtrig.com/search.aspx?cx=partner-pub-5794417674926572%3Asw5zkj-2yxa&cof=FORID%3A10&ie=ISO-8859-1&q=test&sa=Search#1131

    var input = $("searchfield");
    var check = $("searchcomments");

    var search = "http://www.mtrig.com/search.aspx?cx=partner-pub-5794417674926572%3Asw5zkj-2yxa&cof=FORID%3A10&ie=ISO-8859-1&q=" + encodeURIComponent(input.value) + "&sa=Search#1131";
    if (check != null && check.checked)
        search += "&comment=true";
        top.location.href = search;

    return false;
}

// Searches the blog based on the entered text and
// searches comments as well if chosen.
//Non google search, removed
function Search() 
{
    var input = $("searchfield");
    var check = $("searchcomments");

    //var search = "search.aspx?q=" + encodeURIComponent(input.value);
    var search = "http://blog.mtrig.com/mtrig/blog/search.aspx?q=" + encodeURIComponent(input.value);
    if (check != null && check.checked)
        search += "&comment=true";
        top.location.href = search;

    return false;
}
// Clears the search fields on focus.
function SearchClear(defaultText) 
{
    var input = $("searchfield");
    if (input.value == defaultText)
        input.value = "";
    else if (input.value == "")
        input.value = defaultText;
}

function removeElement(divNum) {

   // var _mydiv = document.getElementById('BODY');
  //  _mydiv.removeChild(_mydiv.firstChild);


//    var d = document.getElementById('BODY');
      
  //  var olddiv = document.getElementById(divNum);
    //d.removeChild(1);
}

function HideElement(id) 
{
    var TheElm = $(id)
    TheElm.style.visibility = "hidden";
    //document.getElementById(id).style.visibility = "hidden";
}
//-------------------------------------------------------------------------
// POPUP Center Window with Parms 
//' <A class='LayerControlLink' HREF="#" onclick="javascript:openCenteredWindow('GeneralPopUp.aspx?Name=XML&Value=JobID','800','600');">JobID</A>
//-------------------------------------------------------------------------
function OpenCenteredWindow(url, xWidth, xHeight) 
{
    //alert(url);
    var myWindow;
    var height = xHeight;
    var width = xWidth;
    var left = parseInt((screen.availWidth / 2) - (width / 2));
    var top = parseInt((screen.availHeight / 2.2) - (height / 2.2));
    //var top = 1;
    var windowFeatures = 'width=' + width + ',height=' + height + ',resizable=0,dependent,location=no,titlebar=no,scrollbars=no,menubar=no,status=no,left=' + left + ',top=' + top + 'screenX=' + left + ',screenY=' + top;

    //Window called PopUp is named here so only one window can be opened at a time.
    myWindow = window.open(url, 'PopUp', windowFeatures);
}
//-------------------------------------------------------------------------
// Close the popup window if it times out.
//-------------------------------------------------------------------------
function PopUpAutoLoadMethod(ForwardTime) 
{
    //Bring the popup to the front
    window.setTimeout('self.focus()', ForwardTime);

    //close the window before 20 minutes
    window.setTimeout('window.close()', 18 * 60 * 1000);
}
function DDLIndicatorChange(dropdown, textbox) 
{
    var myindex = dropdown.selectedIndex
    var SelValue = dropdown.options[myindex].value
    //alert(SelValue)

    var TextBoxValue = document.getElementById(textbox);
    //TextBoxValue.value = 'something'

    switch (SelValue) {
        case "aroon": 
           TextBoxValue.value = '25,25'
           break;
       case "bands":
           TextBoxValue.value = '20,2'
           break;
       case "chaikin": 
           TextBoxValue.value = '21'
           break;
       case "cci":
           TextBoxValue.value = '20'
           break;
       case "kairi":
           TextBoxValue.value = '20'
           break;
       case "mfi":
           TextBoxValue.value = '14'
           break;
       case "momentum":
           TextBoxValue.value = '10'
           break;
       case "roc":
           TextBoxValue.value = '10'
           break;
       case "mfi":
           TextBoxValue.value = '14'
           break;
       case "rsi":
           TextBoxValue.value = '14'
           break;
       case "stoch":
           TextBoxValue.value = '14,3'
           break;
       case "zscore":
           TextBoxValue.value = '20'
           break;
       case "zscore":
           TextBoxValue.value = '20'
           break;
       case "macd":
           TextBoxValue.value = '12,26,9'
           break;
        default:
            TextBoxValue.value = ''
    }
}

