/**
 * Functions related to the search bar
 * @author Benjamin A. Dezile
 */


/**
 * Select where to search
 * @param val		Search location [site|web|profile|friends]
 * @return
 */
function selectWhere(val)
{
$('#source').val(val);
var val2 = val;
if (val2 == 'site') val2 = 'Koobimark';
else if (val2 == 'profile') val2 = 'Your profile'; 
$('#where_val').html(val2.substring(0,1).toUpperCase()+val2.substring(1));
$('.whereLink').removeClass('yellow');
$('#where_'+val).addClass('yellow');
var text = "";
if (val == 'web')
	{
	text += "<div class='text2 white big'>What search engine?</div>";
	text += "<div id='whatSelect_body'>";
	text += "	<div><a href=\"javascript:selectWhat('Google');\" id='what_Google' class='whatLink link text medium white yellow'>Google</a></div>";
	text += "	<div><a href=\"javascript:selectWhat('Yahoo');\" id='what_Yahoo' class='whatLink link text medium white'>Yahoo</a></div>";
	text += "	<div><a href=\"javascript:selectWhat('Bing');\" id='what_Bing' class='whatLink link text medium white'>Bing</a></div>";
	text += "	<div><a href=\"javascript:selectWhat('Ask');\" id='what_Ask' class='whatLink link text medium white'>Ask</a></div>";
	text += "	<div><a href=\"javascript:selectWhat('Amazon');\" id='what_Amazon' class='whatLink link text medium white'>Amazon</a></div>";
	text += "	<div><a href=\"javascript:selectWhat('Wikipedia');\" id='what_Wikipedia' class='whatLink link text medium white'>Wikipedia</a></div>";
	text += "	<div><a href=\"javascript:selectWhat('Ebay');\" id='what_Ebay' class='whatLink link text medium white'>Ebay</a></div>";
	text += "	<div><a href=\"javascript:selectWhat('Mininova');\" id='what_Mininova' class='whatLink link text medium white'>Mininova</a></div>";
	text += "</div>";
	selectWhat('Google'); 
	$('#searchForm').attr('target','_blank');
	$('#searchForm').attr('action',URLRoot+'search/');
	}
else
	{
	text += "<div class='text2 white big'>What to search for?</div>";
	text += "<div id='whatSelect_body'>";
	text += "	<div><a href='javascript:selectWhat(\"Koobies\")' id='what_Koobies' class='whatLink link white yellow'>Koobies</a></div>";
	text += "	<div><a href='javascript:selectWhat(\"Categories\")' id='what_Categories' class='whatLink link white'>Categories</a></div>";
	text += "	<div><a href='javascript:selectWhat(\"Sections\")' id='what_Sections' class='whatLink link white'>Sections</a></div>";
	if (val == 'site' && $('#logged').val() == 1)
		{
		text += "<div><a href='javascript:selectWhat(\"People\")' id='what_People' class='whatLink link white'>People</a></div>";
		}
	text += "</div>";
	selectWhat('Koobies');
	if (document.centralTab == null)
		{
		/* HOME */
		$('#searchForm').attr('target','');
		$('#searchForm').attr('action',URLRoot+'page/');
		}
	else 
		{
		/* PAGE or PROFILE */
		$('#searchForm').attr('target','centralTab');
		$('#searchForm').attr('action',URLRoot+'search/');
		}
	}
$('#whatSelect').html(text);
return;
}


/**
 * Select what to search for
 * @param val
 * @return
 */
function selectWhat(val)
{
$('#type').val(val);
$('#what_val').html(val.substring(0,1).toUpperCase()+val.substring(1));
$('.whatLink').removeClass('yellow');
$('#what_'+val).addClass('yellow');
return;
}		
 
 
