function loadSelect(f_name,select_name,val)
{

        var the_one = eval('document.'+f_name+'.'+select_name);

        for(x=0;x < the_one.length;x++)
        {
            if (the_one.options[x].value == val)
            {
                 /* the_one.options.selectedIndex = x */
                 the_one.options[x].selected = true;
                 break;
            }
        }

        the_one = "";


}
function displayTotal(n)
{
        document.getElementById('numFound').innerHTML = 'Total Found: ' + n;
}

function clearTotal()
{
        document.getElementById('numFound').innerHTML = '';
}


function searchAgain()
{
        statusBar();
        ajaxEngine.sendRequest( 'searchAgain' )
}

function getBuyerDetail(t,r)
{
        // statusBar();
        out = t;
        document.location = 'getBuyerDetail.php?r=' + out + '&oldr=' + r;
	

}

function getAwardDetail(t,r)
{
        out = t;
        document.location = 'getAwardDetail.php?r=' + out + '&oldr=' + r;
}

function getSolDetail(r,t)
{
        out = r;        
        document.location = 'getSolDetail.php?r=' + out + '&oldr=' + t;
}

function statusBar()
{
	ostr = '<table width="97%" cellspacing="0" cellpadding="0">';
	ostr += '<tr><td align="right">';
	ostr += '<table border="0" cellpadding="2" cellspacing="0" width="200" align="right" style="border: 1px solid #000;">';
	ostr += '<tr style="font-size:12px; font-weight:bold;color:#000000;background-color:#f1f1f1; ">';
	ostr += '<td style="font-weight:bold;border-bottom: 1px solid #000; " width="200" align="center">Loading Results</td></tr>';
	ostr += '<tr><td style="font-size:10px" class="content" valign="center" align="center">';
	ostr += '<img hspace="5" vspace="5" src="images/sprocket.gif" /></td></tr>';
	ostr += '</table>';
	ostr += '</td></tr>';
	ostr += '</table><br/><br/>';
	// document.getElementById('fbiSearchResult').innerHTML = ostr;
        // ajaxEngine.sendRequest( 'statusBar' );
}

function getAgencyData(a,ac,b)
{
	document.location = 'agencyData.php?agency='+a+'&ac='+ ac+'&b=' + b;
	
}
function getOfficeData(a,o,ac,b)
{
	document.location = 'officeData.php?agency=' + a + '&office=' + o + '&ac='+ac + '&b='+b;
	
}
function performFbnSearch(t,l) {

                if(t != 'reset') 
                {
                checked = 0;    
                f = document.fbnSearch;
                out = 'keyword=' + escape(f.keywordIn.value) + '|';
                v = f.keywordIn.value;                  
                if(v.length > 2)
                        checked = 1;

                f = document.fbnSearch;
                out += 'solAwardNumber=' + escape(f.solAwardNumber.value) + '|';
		if(l == 'email')
                	out += 'email=' + f.email.value + '|';
                v = f.solAwardNumber.value;
                if(v.length > 2)
                        checked = 1;

                v = f.popPostalCode.value;                      
                if(v.length > 2)
                {
                        checked = 1;
                        out += 'popPostalCode=' + escape(f.popPostalCode.value) + '|';
                }


                v = f.typeIn.value;
                if(v.length > 0)
                {
                        checked = 1;
                        out += 'typeIn=' + escape(f.typeIn.value) + '|';
                }

                for(x = 0;x < f.agency.options.length;x++)
                {
                        if(f.agency.options[x].selected)
                        {
                                if(f.agency.options[x].value != "")
                                {
                                        out += 'agency[]=' + f.agency.options[x].value + '|';
                                        checked = 1;
                                }
                        }
                }

                for(x = 0;x < f.classcode.options.length;x++)
                {
                        if(f.classcode.options[x].selected)
                        {
                                if(f.classcode.options[x].value != "")
                                {
                                        out += 'classCode[]=' + f.classcode.options[x].value + '|';
                                        checked = 1;
                                }
                        }
                }

		if(f.postedDate.type != 'hidden')
		{
                for(x = 0;x < f.postedDate.options.length;x++)
                {
                        if(f.postedDate.options[x].selected)
                        {
                                if(f.postedDate.options[x].value != "")
                                {
                                        out += 'postedDate=' + f.postedDate.options[x].value + '|';
                                        checked = 1;
                                }
                        }
                }
		}


                for(x = 0;x < f.stateIn.options.length;x++)
                {
                        if(f.stateIn.options[x].selected)
                        {
                                if(f.stateIn.options[x].value != "")
                                {
                                        out += 'stateIn[]=' + f.stateIn.options[x].value + '|';
                                        checked = 1;
                                }
                        }
                }

                if(f.stateInCo.type != 'hidden')
                {
               		for(x = 0;x < f.stateInCo.options.length;x++)
                	{
                        	if(f.stateInCo.options[x].selected)
                        	{
                                	if(f.stateInCo.options[x].value != "")
                                	{
                                        	out += 'stateInCo[]=' + f.stateInCo.options[x].value + '|';
                                        	checked = 1;
                                	}
                        	}
                	}
		}

                for(x = 0;x < f.naicsCode.options.length;x++)
                {
                        if(f.naicsCode.options[x].selected)
                        {
                                if(f.naicsCode.options[x].value != "")
                                {
                                        out += 'naicsCode[]=' + f.naicsCode.options[x].value + '|';
                                        checked = 1;
                                }
                        }
                }

                for(x = 0;x < f.setAside.options.length;x++)
                {
                        if(f.setAside.options[x].selected)
                        {
                                if(f.setAside.options[x].value != "")
                                {
                                        out += 'setAside[]=' + f.setAside.options[x].value + '|';
                                        checked = 1;
                                }
                        }
                }

                        if(checked == 1)
                        {
                                // statusBar();
                                // ajaxEngine.sendRequest( 'performFbnSearch','r=' + out);
				if(l != "email")
					document.location = 'performFbnSearch.php?r='+ out;
				else
					document.location = 'setEmailPref.php?r='+ out;
                        }
                }
}

function popWin( url, name, width, height, scroller )
{
        var outStr = 'height=' + height + ',width=' + width;
        if (!scroller)
        {
                outStr = outStr + ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no';
        }
        else
        {
                outStr = outStr + ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no';
        }
                window.open(url, name, outStr);
}

