function submitSearchForm(formId, iwActions)
{
    var myForm = document.getElementById(formId);
    
    if (null != myForm)
    {
    		if(null != iwActions)
    		{
    			myForm.iwPreActions.value = iwActions;
    		}
        myForm.submit();      
    }
    return false;  
}   
 
 
function esc(x)
{
    x = escape(x).replace(/\+/g, "%2b");
    if (x.substring(0,2)=="\%u") x="";
    return x;
}
   

function collectBarUrl(formId) 
{
    var p = new Array();var i = 0;var url="";
    var z = document.getElementById(formId);
    var t = null;
    
    t = document.getElementById('q');
    
    if(null != t)
    {
	    if (t.value.length) {p[i++] = 'q=' + esc(t.value);}	
	    if (p.length > 0) {url = p[0];for (var j = 1; j < p.length; j++) { url += "&" + p[j]; }}   
	    z.SearchQuery.value = url;
    }
    return false;
}    

function collectSimpleUrl(formId) 
{
    var p = new Array();var i = 0;var url="";
    var z = document.getElementById(formId);
    var t = null;
    
    t = document.getElementById('s_q');
    
    if(null!= t)
    {
	    if (t.value.length) {p[i++] = 'q=' + esc(t.value);}
	    if (p.length > 0) {url = p[0];for (var j = 1; j < p.length; j++) { url += "&" + p[j]; }}   
	    z.SearchQuery.value = url;
    }
    return false;
}     


function collectAdvancedUrl(formId) 
{
    var p = new Array();var i = 0;var url="";
    var z = document.getElementById(formId);
    var t = null;
    
    t = document.getElementById('as_q');
    
    if(null != t)
    {
        if (t.value.length) {p[i++] = 'as_q=' + esc(t.value);}
        if (typeof(z.as_epq) != 'undefined' && z.as_epq.value.length) {p[i++] = 'as_epq=' + esc(z.as_epq.value);}
        if (typeof(z.as_oq) != 'undefined' && z.as_oq.value.length) {p[i++] = 'as_oq=' + esc(z.as_oq.value);}
        if (typeof(z.as_eq) != 'undefined' && z.as_eq.value.length) {p[i++] = 'as_eq=' + esc(z.as_eq.value);}
        if (typeof(z.as_sitesearch) != 'undefined' && z.as_sitesearch.value.length) {p[i++]='as_sitesearch='+esc(z.as_sitesearch.value);}
        if (typeof(z.as_lq) != 'undefined' && z.as_lq.value.length) {p[i++] = 'as_lq=' + esc(z.as_lq.value);}
        if (typeof(z.as_occt) != 'undefined' && z.as_occt.options[z.as_occt.selectedIndex].value.length){p[i++]='as_occt='+esc(z.as_occt.options[z.as_occt.selectedIndex].value);}
        if (typeof(z.as_dt) != 'undefined' && z.as_dt.options[z.as_dt.selectedIndex].value.length){p[i++]='as_dt='+esc(z.as_dt.options[z.as_dt.selectedIndex].value);}
        if (typeof(z.lr) != 'undefined' && z.lr.options[z.lr.selectedIndex].value != '') {p[i++] = 'lr=' + z.lr.options[z.lr.selectedIndex].value;}
        if (typeof(z.num) != 'undefined' && z.num.options[z.num.selectedIndex].value != '10'){p[i++] = 'num=' + z.num.options[z.num.selectedIndex].value;}
        if (typeof(z.sort) != 'undefined' && z.sort.options[z.sort.selectedIndex].value != ''){p[i++] = 'sort=' + z.sort.options[z.sort.selectedIndex].value;}
		    if (p.length > 0) {url = p[0];for (var j = 1; j < p.length; j++) { url += "&" + p[j]; }}	    
		    z.SearchQuery.value = url;
    }
    return false;
}
         