function qte_sp(gpid, lpid, gp1id, gp2id, gp3id, gp4id, gp5id, gp6id, gp7id, gp8id, lp1id, lp2id, lp3id, lp4id, lp5id, lp6id, lp7id, lp8id, cl, ccn, fcui, m, p, w, sac, gtbl, ltbl, qtesp, scl)
{
    if( spActvGcv() == 1 )
    {
        var gpv = qte_v(gp1id, gp2id, gp3id, gp4id, gp5id, gp6id, gp7id, gp8id);
        var lpv = qte_v(lp1id, lp2id, lp3id, lp4id, lp5id, lp6id, lp7id, lp8id);

        if( qtesp == 1 )
        {
            var _qtepf = gpv + "~" + lpv
            cws_sp(_qtepf, cl, ccn, fcui);
        }
        
        qte_ld_dv(gpv, w, sac, gtbl, scl);
        qte_ld_dv(lpv, w, sac, ltbl, scl);
        
        if( qtesp == 1 )
        {
            rfctrfk(m, p, '20', '', 'Preferences');
        
            alert("Your preferences have been updated");
        }
        else
        {
            rfctrfk(m, p, '21', '', '');
        }
    }
}

function qte_spSht(gpid, gp1id, gp2id, gp3id, gp4id, gp5id, gp6id, gp7id, gp8id, cl, ccn, fcui, m, p, w, sac, gtbl, qtesp, scl)
{
    if( spActvGcv() == 1 )
    {
        var gpv = qte_v(gp1id, gp2id, gp3id, gp4id, gp5id, gp6id, gp7id, gp8id);

        if( qtesp == 1 )
        {
            var _qtepf = gpv
            cws_sp(_qtepf, cl, ccn, fcui);
        }
        
        qte_ld_dv(gpv, w, sac, gtbl, scl);
        
        if( qtesp == 1 )
        {
            rfctrfk(m, p, '20', '', 'Preferences');
        
            alert("Your preferences have been updated");
        }
        else
        {
            rfctrfk(m, p, '21', '', '');
        }
    }
}

function qte_v(v1, v2, v3, v4, v5, v6, v7, v8)
{
    var _v = "";
    
    var _v1 = getElementWithId(v1);
    var _v2 = getElementWithId(v2);
    var _v3 = getElementWithId(v3);
    var _v4 = getElementWithId(v4);
    var _v5 = getElementWithId(v5);
    var _v6 = getElementWithId(v6);
    var _v7 = getElementWithId(v7);
    var _v8 = getElementWithId(v8);
    
    _v = qte_ap(_v, _v1);
    _v = qte_ap(_v, _v2);
    _v = qte_ap(_v, _v3);
    _v = qte_ap(_v, _v4);
    _v = qte_ap(_v, _v5);
    _v = qte_ap(_v, _v6);
    _v = qte_ap(_v, _v7);
    _v = qte_ap(_v, _v8);
    
    return _v
}

function qte_ld_dv(c, w, sac, qtedv, scl)
{
    if( spActvGcv() == 1 )
    {
        var _skp = inskp();
        var _sk = _incsk;
        var _skparg = {"sk" : _sk, "skp" : _skp, "c" : c, "w" : w, "sac" : sac, "scl" : scl};
        var _wsargs = JSON.stringify(_skparg);
        var _wsurl = "http://" + window.location.hostname + "/ws/dta.asmx/gqte"

        $.ajax({
          type: "POST",
          url: _wsurl,
          data: _wsargs,
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function(rstxt) {
                var _qtedv = getElementWithId(qtedv);
                _qtedv.innerHTML = rstxt.d;
            }
        });
    }
}

function qte_ap(pv, pd)
{
    var npv = pv;
    var pc = "";
    
    if( pv.length > 0 )
    {
        pc = ","
    }
    
    if( pd.options[pd.options.selectedIndex].value != "" )
    {
        npv += pc + pd.options[pd.options.selectedIndex].value;
    }
    
    return npv;
}


function qte_rtsots(sender, args)
{  	
    try
    {
        var _tarxgsv = args.get_tab().get_value();
        var _tarxgsva = _tarxgsv.split("~");
        rfctrfk(_tarxgsva[0], _tarxgsva[1], '2', '', _tarxgsva[2]);
        
        if( _tarxgsva.length == 4 )
        {
            var _qteIf = "#" + _tarxgsva[3];
            if( $(_qteIf).attr("src") == "blank.html" )
            {
                $(_qteIf).attr("src", "http://chart.interactiveag.com/fcp-v4-professional/fcp/chart_display.aspx");
            }
        }
    }
    catch(er)
    {
    }
   	
   	return true;
}

function qte_spwe(gpid, lpid, gp1id, gp2id, gp3id, gp4id, gp5id, gp6id, gp7id, gp8id, lp1id, lp2id, lp3id, lp4id, lp5id, lp6id, lp7id, lp8id, cl, ccn, fcui, m, p, w, sac, gtbl, ltbl, qtesp, scl, epid, ep1id, ep2id, ep3id, ep4id, ep5id, ep6id, ep7id, ep8id, etbl)
{
    if( spActvGcv() == 1 )
    {
        var gpv = qte_v(gp1id, gp2id, gp3id, gp4id, gp5id, gp6id, gp7id, gp8id);
        var lpv = qte_v(lp1id, lp2id, lp3id, lp4id, lp5id, lp6id, lp7id, lp8id);
        var epv = qte_v(ep1id, ep2id, ep3id, ep4id, ep5id, ep6id, ep7id, ep8id);

        if( qtesp == 1 )
        {
            var _qtepf = gpv + "~" + lpv + "~" + epv;
            cws_sp(_qtepf, cl, ccn, fcui);
        }
        
        qte_ld_dv(gpv, w, sac, gtbl, scl);
        qte_ld_dv(lpv, w, sac, ltbl, scl);
        qte_ld_dv(epv, w, sac, etbl, scl);
        
        if( qtesp == 1 )
        {
            rfctrfk(m, p, '20', '', 'Preferences');
        
            alert("Your preferences have been updated");
        }
        else
        {
            rfctrfk(m, p, '21', '', '');
        }
    }
}