

/* ---------------------------------  utilities  --------------------------------- */


function wf()
{
	document.w.q.focus();
}

function ff()
{
	document.f.q.focus();
}

function pf()
{
	document.p.q.focus();
}

function gf()
{
	document.g.q.focus();
}


function addBookmark(title,url) {
if (window.sidebar) { 
window.sidebar.addPanel(title, url,""); 
} else if( document.all ) {
window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
return true;
}
}


function GetURLParam( 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 unescape(results[1].replace(/\+/g, " "));
}


/* borrowed same function, but need to get rid of possible "s in query. */
function GetURLParamForEbay( 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 unescape(results[1].replace(/%22/g, " "));
}



function LoadKeywords(results)
{

	var web_path = "http://www.quadsearches.com/results/?cx=017104366701421859428%3aifvyhl1qdvy&amp;cof=FORID%3a10&q=" + GetURLParam('q');
	var forums_path = "http://www.quadsearches.com/results/forums/?cx=017104366701421859428%3Aelog9juahey&cof=FORID%3A10&q=" + GetURLParam('q');
	var shopping_path = "http://www.quadsearches.com/results/shopping/?cx=017104366701421859428%3Amoi62luer84&cof=FORID%3A9&q=" + GetURLParam('q');
	var google_path = "http://www.quadsearches.com/results/google/?cx=017104366701421859428%3Amech3yy2xa0&cof=FORID%3A10&q=" + GetURLParam('q');
	
	switch(results)
	{
		case "web":
			document.getElementById("forums_side_link").setAttribute("href", forums_path);
			document.getElementById("shopping_side_link").setAttribute("href", shopping_path);
			document.getElementById("google_side_link").setAttribute("href", google_path);
		break;
		
		case "forums":
			document.getElementById("web_side_link").setAttribute("href", web_path);
			document.getElementById("shopping_side_link").setAttribute("href", shopping_path);
			document.getElementById("google_side_link").setAttribute("href", google_path);
				
			document.getElementById("loadthreadsvalue").setAttribute("value", GetURLParam('q'));
		break;
		
			
		case "shopping":
			document.getElementById("web_side_link").setAttribute("href", web_path);
			document.getElementById("forums_side_link").setAttribute("href", forums_path);
			document.getElementById("google_side_link").setAttribute("href", google_path);
		
			document.getElementById("loadproductsvalue").setAttribute("value", GetURLParam('q'));
		break;
		
		case "google":
			document.getElementById("web_side_link").setAttribute("href", web_path);
			document.getElementById("forums_side_link").setAttribute("href", forums_path);
			document.getElementById("shopping_side_link").setAttribute("href", shopping_path);
								
			document.getElementById("loadgooglevalue").setAttribute("value", GetURLParam('q'));
		break;
	}

return null;

}




function toggleDiv(DivID, State) /*[ 1 visible, 0 hidden ]*/
{
    if (document.layers) /*[ NN4 ]*/
    {
        document.layers[DivID].display = State ? "block" : "none";
    }
    else if (document.getElementById) /*[ DOM3 ]*/
    {
        var obj = document.getElementById(DivID);

        obj.style.display = State ? "block" : "none";
    }
    else if (document.all)  /*[ IE4 ]*/
    {
        document.all[DivID].style.display = State ? "block" : "none";
    }
	 
}
function hideStatus()
{
	window.status = "";
	return true;
}





/* ---------------------------------  search controls  --------------------------------- */



function pages_control(search_keyword)
{
	var searchControl = new GSearchControl();

	searchControl.setResultSetSize(GSearch.LARGE_RESULTSET);
	searchControl.setLinkTarget(GSearch.LINK_TARGET_SELF); /* the default behavior launches links to new window, which is great for search links and keeps on site, but this applies to more results link as well and don't want to open a bunch of windows on people */
	
	searcher = new GwebSearch();
	options = new GsearcherOptions();
	searcher.setSiteRestriction("017104366701421859428:ifvyhl1qdvy", null, "http://www.quadquestions.com/results.html?cx=017104366701421859428%3Aifvyhl1qdvy&cof=FORID%3A11&q=__QUERY__&sa=QuadEngine.com+Search&hl=__HL__");

	
	options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
	options.setNoResultsString("Your search - <strong>" + search_keyword + "</strong> - did not match any pages in our database.");
	searchControl.addSearcher(searcher, options);
	
	
	// tell the searcher to draw itself and tell it where to attach
	searchControl.draw(document.getElementById("pages_results"));
	
	// execute an inital search
	searchControl.execute(search_keyword);
}





function threads_control(search_keyword)
{
	var searchControl = new GSearchControl();

	searchControl.setResultSetSize(GSearch.LARGE_RESULTSET);
	searchControl.setLinkTarget(GSearch.LINK_TARGET_SELF); 
		
	searcher = new GwebSearch();
	options = new GsearcherOptions();
	searcher.setSiteRestriction("017104366701421859428:elog9juahey", null, "http://www.quadquestions.com/more-threads.html?cx=017104366701421859428%3Aelog9juahey&cof=FORID%3A11&q=__QUERY__&sa=Search+forums+only&hl=__HL__");

	
	options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
	options.setNoResultsString("Your search - <strong>" + search_keyword + "</strong> - did not match any threads in the forums.");
	searchControl.addSearcher(searcher, options);
	
	
	// tell the searcher to draw itself and tell it where to attach
	searchControl.draw(document.getElementById("threads_results"));
	
	// execute an inital search
	searchControl.execute(search_keyword);
}


function products_control(search_keyword)
{
	var searchControl = new GSearchControl();

	
	// default result set size is small, which we want for products to accomodate other services like ebay

	searchControl.setLinkTarget(GSearch.LINK_TARGET_SELF); 

	searcher = new GwebSearch();
	options = new GsearcherOptions();
	searcher.setSiteRestriction("017104366701421859428:moi62luer84", null, "http://www.quadquestions.com/more-products.html?cx=017104366701421859428%3Amoi62luer84&cof=FORID%3A9&q=__QUERY__&sa=Search+shopping+sites+only&hl=__HL__");
        
	options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
	options.setNoResultsString("Your search - <strong>" + search_keyword + "</strong> - did not match any products.");
	searchControl.addSearcher(searcher, options);
	
	
	// tell the searcher to draw itself and tell it where to attach
	searchControl.draw(document.getElementById("products_results"));
	
	// execute an inital search
	searchControl.execute(search_keyword);
}



function google_control(search_keyword)
{
	var searchControl = new GSearchControl();

	searchControl.setResultSetSize(GSearch.LARGE_RESULTSET);
	searchControl.setLinkTarget(GSearch.LINK_TARGET_SELF); 
		
	searcher = new GwebSearch();
	options = new GsearcherOptions();
	searcher.setSiteRestriction("017104366701421859428:mech3yy2xa0", null, "http://www.quadquestions.com/more-google.html?cx=017104366701421859428%3Amech3yy2xa0&cof=FORID%3A11&q=__QUERY__&sa=Search+Google&hl=__HL__");
        
	options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
	options.setNoResultsString("Your search - <strong>" + search_keyword + "</strong> - did not match any pages.");
	searchControl.addSearcher(searcher, options);
	
	
	// tell the searcher to draw itself and tell it where to attach
	searchControl.draw(document.getElementById("google_results"));
	
	// execute an inital search
	searchControl.execute(search_keyword);
}

	 
	 
	 
	
