var a_lert = function(msg) {
    //alert('a_lert: ' + msg);
}


function showHide(group, ans){
    var showID = group + '_' + ans;
    var showRadID = 'radio_' + group + '_' + ans;
    
    $('#[id^=' + group + '_]').hide();
    $('#[id^=radio_' + group + '_]').removeClass('radioOn');

    $('#' + showID).show();
    if ($('#' + showID).length > 0) $('#' + showRadID).addClass('radioOn');
}

function procForm(){
    //alert("procForm()");
    var IFG = "{ifg}";
    try {
    var vrec = $('#mainForm\\:persisted_form_section').val();           
        inputs = document.getElementsByTagName("input");
        for (var b = 0; b < inputs.length; b++) {
           //if( inputs[b].name.substr(0,6) == "frm_cp" ||  inputs[b].name.substr(0,6) == "frm_op") { 
           if( inputs[b].name.substr(0,4) == "frm_") { 
                if (inputs[b].type == "text" || inputs[b].type == "hidden"){
                     vrec = vrec + inputs[b].name + "{psep}" + inputs[b].value + IFG;
                }  if (inputs[b].type == "radio" && inputs[b].checked == true ) {
                     vrec = vrec + inputs[b].name + "{psep}" + inputs[b].value + IFG ;
                }   if (inputs[b].type == "checkbox" ) {
                     vrec = vrec + inputs[b].name + "{psep}" + inputs[b].checked + IFG;
                }
           }

        }

        selects = document.getElementsByTagName("select");
        for (var b1 = 0; b1 < selects.length; b1++) {
            if( (selects[b1].name.substr(0,4) == "frm_") && selects[b1].selectedIndex > 0) { 
                    vrec = vrec + selects[b1].name + "{psep}" + selects[b1].options[selects[b1].options.selectedIndex].value + IFG;
                    //a_lert("adding pair : " + selects[b1].name + "=" +  selects[b1].options[selects[b1].options.selectedIndex].value);
            }
        }
        /*
        var channel = getQueryValue('channel');
        var subchannel = getQueryValue('subchannel');
        if( channel != undefined && channel != '') {
            vrec  +=  'frm_c_channel{psep}' + channel;
        }
        if( subchannel != undefined && subchannel != '') {
            vrec  += 'frm_c_subchannel{psep}' + subchannel;
        } 
        */
        $('#mainForm\\:persisted_form_section').val(vrec);
        //alert("FINAL params = \n" + vrec);

     } catch(error) {
         a_lert('error:' + error);
     }
     
}





var reqinfo_init = function()
{
    //alert("reqinfo_init");
/*
    $("a.result_link").click(function(e) {
            a_lert("clicked");    
        });
    
    $("input#test").click(function(e) {
            a_lert("test");    
        });
*/

}


/* pass in name to get value */
/*
function getQueryValue ( name )
{
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( window.location.href );
    if( results == null )
        return "";
    else
        return results[1];
};
*/

jQuery().ready(reqinfo_init);
