	function checkMainForm()
	{
		var f=$('mybigfatsearchform');

		if ($("querytext").value=="")
		{
			alert("Please enter a search term");
			return false;
		}

		if ($('mybigfatsearchform').mode2.value=='hub')
		{
			var url='/hub/'+encodeURIComponent($("querytext").value)+'/';
			if (f.cacheticket.value!='')
				url += f.cacheticket.value+"/";
			window.location.href=url;
			return false;
		}
		
		if (f.mode2.value=='search')
		{
			var url="/web/" + encodeURIComponent(f.query.value)+"/" 
			if (f.cacheticket.value!='')
				url += f.cacheticket.value+"/";
			window.location.href=url;
			return false;
		}

		/*
		if ((!$('EB_cb').checked) && (!$('AM_cb').checked) && (!$('GB_cb').checked) && (!$('SP_cb').checked) && (!$('YS_cb').checked))
		{
			alert("Sorry, you must select at least once source");
			return false;
		}
		*/
		
		var k=$('indexmainspace');
		if (k != null)
			k.innerHTML='<img src="/img3/loading_animation.gif" alt="" />';
			
		k=$('whats-hot');
		if (k != null)
			k.innerHTML='<img src="/img3/loading_animation.gif" alt="" />';
			
		//clearMainForm();
		
		return true;
	}
	
	
	function clearMainForm() // remove not used fields
	{
		var f=$('mybigfatsearchform');
		// check for all fields
		
		if (f.fromPrice.value=='')
			f.fromPrice.parentNode.removeChild(f.fromPrice);
			
		if (f.uptoPrice.value=='')
			f.uptoPrice.parentNode.removeChild(f.uptoPrice);

		if (f.seller.value=='')
			f.seller.parentNode.removeChild(f.seller);
			
		if (f.title_inc.value=='')
			f.title_inc.parentNode.removeChild(f.title_inc);

		if (f.title_exc.value=='')
			f.title_exc.parentNode.removeChild(f.title_exc);

		if (f.summary_inc.value=='')
			f.summary_inc.parentNode.removeChild(f.summary_inc);

		if (f.summary_exc.value=='')
			f.summary_exc.parentNode.removeChild(f.summary_exc);

		if (f.country_inc.value=='')
			f.country_inc.parentNode.removeChild(f.country_inc);

		if (f.country_exc.value=='')
			f.country_exc.parentNode.removeChild(f.country_exc);

		//if (f.test.value=='')
		//	f.test.parentNode.removeChild(f.test);

		if (f.site.value=='')
			f.site.parentNode.removeChild(f.site);
			
		if (f.rating[0].checked)
		{
			for(i=0;i<f.rating.length;i++)
				f.rating[i].parentNode.removeChild(f.rating[i]);
		}
		
		// setup for default filters
		
		// mode
		
		if (!f.modeEB.checked)
		{
			f.modeEB.checked=true;
			f.modeEB.value=-1;
		}
		else
		{
			f.modeEB.parentNode.removeChild(f.modeEB);
		}
			
		if (!f.modeAM.checked)
		{
			f.modeAM.checked=true;
			f.modeAM.value=-1;
		}
		else
		{
			f.modeAM.parentNode.removeChild(f.modeAM);
		}
		
		if (!f.modeGB.checked)
		{
			f.modeGB.checked=true;
			f.modeGB.value=-1;
		}
		else
		{
			f.modeGB.parentNode.removeChild(f.modeGB);
		}
		
		if (!f.modeSP.checked)
		{
			f.modeSP.checked=true;
			f.modeSP.value=-1;
		}
		else
		{
			f.modeSP.parentNode.removeChild(f.modeSP);
		}
		
		if (!f.modeYS.checked)
		{
			f.modeYS.checked=true;
			f.modeYS.value=-1;
		}
		else
		{
			f.modeYS.parentNode.removeChild(f.modeYS);
		}
		
		
		if (f.continent.value=='Americas')
			f.continent.parentNode.removeChild(f.continent);

		if (f.country.value=='US')
			f.country.parentNode.removeChild(f.country);


		if (!f.titleFilter.checked)
		{
			f.titleFilter.checked=true;
			f.titleFilter.value=-1;
		}
		else
		{
			f.titleFilter.parentNode.removeChild(f.titleFilter);
		}


		if (!f.zeroPriceFilter.checked)
		{
			f.zeroPriceFilter.checked=true;
			f.zeroPriceFilter.value=-1;
		}
		else
		{
			f.zeroPriceFilter.parentNode.removeChild(f.zeroPriceFilter);
		}
		
		if (!f.imagesFilter.checked)
		{
			f.imagesFilter.checked=true;
			f.imagesFilter.value=-1;
		}
		else
		{
			f.imagesFilter.parentNode.removeChild(f.imagesFilter);
		}
		
		
		if (f.tab.value=='eyeq_tab')
			f.tab.parentNode.removeChild(f.tab);
		
		
		
		

			
		//condition ? exec1() : exec2;
		
	}

	
	function checkFilter(obj)
	{
		if (($('titleFilter').checked) && ($('descriptionFilter').checked))
		{
			alert("You can not use title and description filter together");
			obj.checked=false;
		}
	}


	function filterByContinent(obj)
	{
		var continent=obj.value;
		
		var lStr1='action=getcountries&continent='+continent;
		var res=sendXmlHttpRequest('/search.php', lStr1);
		var countries = eval('(' + res + ')');
		
		var f=$('mybigfatsearchform');
		var countries_obj=f.country;
		
		while(c=countries_obj.firstChild)
			countries_obj.removeChild(c);
			
		for(country in countries)
		{
			var oOption = document.createElement('OPTION');
			countries_obj.options.add(oOption);
			oOption.innerHTML = countries[country];
			oOption.value = country;			
		}
	}


	function showCountryFilter()
	{
		if ($('countryFilter').checked)
			$('countryFilterContent').style.display="block";
		else
			$('countryFilterContent').style.display="none";
	}
	
	// filters section
	
	function ShowFiltersHistory(tab)
	{
		if ($j('#filterHistory').css("display")!='block')
		{
			var lStr1 = 'action=getfilterhistory&returnto=async&tab='+tab;
			var innerHTML = sendXmlHttpRequest('/search.php', lStr1);
			//if (innerHTML=='')
				//innerHTML='No filter data yet';
			$j('#filterHistory').html(innerHTML);
			//$j('#filterHistory').slideDown("fast");
			$j('#filterHistory').css("display",'block');
		}
		else
		{
			$j('#filterHistory').html("&nbsp;");
			$j('#filterHistory').slideUp("fast");
		}
	}
	
	
	function renameFilter(id)
	{
		$("input"+id).readOnly=false;
		$("input"+id).style.backgroundColor="#FFFFE0";
		$("rename"+id).style.display="none";
		$("save"+id).style.display="inline";
		$("input"+id).focus();
	}


	function saveFilterName(id)
	{
		var new_name=$("input"+id).value;

		if (id=='')
		{
			var f=$("mybigfatsearchform");
			f.name.value=new_name;
		}
		else
		{
			var lStr1 = 'action=savefiltername&returnto=async&id='+id+"&name="+new_name;
			var res=sendXmlHttpRequest('/search.php', lStr1);
		}

		$("input"+id).readOnly=true;
		$("rename"+id).style.display="inline";
		$("save"+id).style.display="none";
		$("input"+id).style.backgroundColor="#FFFFFF";
	}

	function DeleteFilterFromHistory(id, tab)
	{
		var lStr1 = 'action=deletefilterfromhistory&returnto=async&id='+id+'&tab='+tab;
		var res=sendXmlHttpRequest('/search.php', lStr1);
		if (res=='')
			$('filterHistory').style.display="none";			
		$('filterHistory').innerHTML = res; 
	}
	
	function changeLabel(id, name)
	{
		if ($(name+id).checked)
			$(name+id+'label').innerHTML="YES";
		else
			$(name+id+'label').innerHTML="NO";
	}
	
	
function gotoHub()
{
	var f=$('mybigfatsearchform');
	f.mode2.value="hub";
	/*
	f.modeAM.checked=true;
	f.modeEB.checked=true;
	f.modeSP.checked=true;
	f.modeGB.checked=true;
	f.modeYS.checked=true;
	*/
	f.submit();
}
	
			
function green_cart_click()
{

	$("mybigfatsearchform").mode2.value="cart";
	
	if ($("EyeQText")!=null)
		$("EyeQText").style.display="block";
					
	if ($("mybigfatsearchform").query.value=='')
		$("whats-hot").style.display="block";
	else
	{
		if ($("req_type")!=null)
			$("req_type").style.display="block";
	}
					
	$j("#green_search").animate({opacity: 0.5},100);
	$j("#green_hub").animate({opacity: 0.5},100);
	$j("#green_cart").animate({opacity: 1},100);
	
	clearMainForm();	
	
}


function green_search_click()
{
	$("mybigfatsearchform").mode2.value="search";
	if ($("EyeQText")!=null)
		$("EyeQText").style.display="none";
	$("adv_search").style.display="none";
					
	if ($("whats-hot")!=null)
		$("whats-hot").style.display="none";
					
	clearTimeout(window.hot_timeout_id);
	window.hot_timeout_id=0;
					
	if ($("req_type")!=null)
		$("req_type").style.display="none";
					
	if ($("whats-hot")!=null)
		$j("#whats-hot div.top10").css('display','none');
				
	$j("#green_cart").animate({opacity: 0.5},100);
	$j("#green_hub").animate({opacity: 0.5},100);
	$j("#green_search").animate({opacity: 1},100);
}
		
			
function green_hub_click()
{
	$("mybigfatsearchform").mode2.value="hub";
	if ($("EyeQText")!=null)
		$("EyeQText").style.display="none";
	$("adv_search").style.display="none";
					
	if ($("whats-hot")!=null)
		$("whats-hot").style.display="none";
					
	clearTimeout(window.hot_timeout_id);
	window.hot_timeout_id=0;
					
	if ($("req_type")!=null)
		$("req_type").style.display="none";
					
	if ($("whats-hot")!=null)
		$j("#whats-hot div.top10").css('display','none');
					
	$j("#green_cart").animate({opacity: 0.5},100);
	$j("#green_search").animate({opacity: 0.5},100);
	$j("#green_hub").animate({opacity: 1},100);
}
			
	
	
	
	
	
	
	
	
	
	
	