function err_output(message) {
    alert(message);
    history.back();
}

function SelectSearch(i) {
    if (i == 'r_stock_compare')
        document.ChartForm.CompareType[1].checked = true;
    else if (i == 'upperfunction_mov')
        document.ChartForm.UpperFunction[1].checked = true;
    else if (i == 'upperfunction_boil')
        document.ChartForm.UpperFunction[2].checked = true;
    else if (i == 'lowerfunction_rsi')
        document.ChartForm.LowerFunction[1].checked = true;
    else if (i == 'lowerfunction_mon')
        document.ChartForm.LowerFunction[2].checked = true;
    else if (i == 'lowerfunction_macd')
        document.ChartForm.LowerFunction[3].checked = true;
    else if (i == 'lowerfunction_stoch')
        document.ChartForm.LowerFunction[4].checked = true;
}

function SelectBox(i) {
    if (i == 'r_stock_compare')
        document.ChartForm.c_code.focus();
    else if (i == 'upperfunction_mov')
        document.ChartForm.mlen_a.focus();
    else if (i == 'upperfunction_boil')
        document.ChartForm.blen.focus();
    else if (i == 'lowerfunction_rsi')
        document.ChartForm.rsi.focus();
    else if (i == 'lowerfunction_mon')
        document.ChartForm.mon_len.focus();
    else if (i == 'lowerfunction_macd')
        document.ChartForm.macdlen1.focus();
    else if (i == 'lowerfunction_stoch')
        document.ChartForm.k.focus();
}

function CheckError() {
    var v_com1 = document.ChartForm.CompareType[1].checked;
    var v_charttype = document.ChartForm.ChartType.options[document.ChartForm.ChartType.selectedIndex].value;
    var v_tech1,v_tech2;

    if (document.ChartForm.UpperFunction[0].checked)	{v_tech1 = document.ChartForm.UpperFunction[0].value;}
    if (document.ChartForm.UpperFunction[1].checked)	{v_tech1 = document.ChartForm.UpperFunction[1].value;}
    if (document.ChartForm.UpperFunction[2].checked)	{v_tech1 = document.ChartForm.UpperFunction[2].value;}

    if (document.ChartForm.LowerFunction[0].checked)	{v_tech2 = document.ChartForm.LowerFunction[0].value;}
    if (document.ChartForm.LowerFunction[1].checked)	{v_tech2 = document.ChartForm.LowerFunction[1].value;}
    if (document.ChartForm.LowerFunction[2].checked)	{v_tech2 = document.ChartForm.LowerFunction[2].value;}
    if (document.ChartForm.LowerFunction[3].checked)	{v_tech2 = document.ChartForm.LowerFunction[3].value;}
    if (document.ChartForm.LowerFunction[4].checked)	{v_tech2 = document.ChartForm.LowerFunction[4].value;}
    
    if (v_com1) {    // if comparison chart is selected
        if (v_com1) {
            return true;
        }
        
        if ((v_charttype == "bar") || (v_charttype == "candle")) {
            NewWindow('e_ChartErrorMessage.php?error=1','name','600','400','yes');
            return false;
        }
        
        if (v_tech1 == "ma") {
            NewWindow('e_ChartErrorMessage.php?error=2','name','600','400','yes');
            return false;
        }
        else if (v_tech1 == "boil") {
            NewWindow('e_ChartErrorMessage.php?error=3','name','600','400','yes');
            return false;
        }
        
        if (v_tech2 == "rsi") {
            NewWindow('e_ChartErrorMessage.php?error=4','name','600','400','yes');
            return false;
        }
        else if (v_tech2 == "mom") {
            NewWindow('e_ChartErrorMessage.php?error=5','name','600','400','yes');
            return false;
        }
        else if (v_tech2 == "macd") {
            NewWindow('e_ChartErrorMessage.php?error=6','name','600','400','yes');
            return false;
        }
        else if (v_tech2 == "stoch") {
            NewWindow('e_ChartErrorMessage.php?error=7','name','600','400','yes');
            return false;
        }
    }
}

function NewWindow(mypage, myname, w, h, scroll) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
    win = window.open(mypage, myname, winprops);
    <!--win.moveTo(winl, wint);-->
    <!--win.resizeTo(w, h);-->

    if (parseInt(navigator.appVersion) >= 4) {
        win.window.focus();
    }
}

