function SubmitSearchForm(form, keyword)
{
	if(keyword == '') alert('Please enter a keyword');
	else
	{
		keyword = keyword.replace(' ', '-');
		form.action = '/businessideas/categories/' + keyword + '.html';
		form.submit();
	}	
}

function SubmitFinderForm(type, typeid, costid)
{
	if(type == 0 || typeid == 0) alert('Please select a business idea and category');
	else window.location = '/businessideas/' + type + '/' + typeid + '/page1/cost' + costid + '.html';
}

function SetOptions(type_value, category_select, type_select) 
{
	var select_menu = document.getElementById(type_select);
	if(select_menu.options[0].value == "0") document.getElementById(type_select).remove(0);

	if(type_value == 0) document.getElementById(category_select).options[0] = new Option('Choose', 0);
	else 
	{
		AddFinderOptions(type_value);
		document.getElementById(category_select).disabled = false;	
	}	
}

function removeOptions(selectbox)
{
	var i;
	
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		if(selectbox.options[i].selected) selectbox.remove(i);
	}
}

// Ajax

var xmlHttp;

function AddFinderOptions(type, typeid)
{
	var xmlHttp=null;
	
	try
	 {
		 // Firefox, Opera 8.0+, Safari
		 xmlHttp=new XMLHttpRequest();
	 }
	 
	catch (e)
	 {
		 //Internet Explorer
		 try
		  {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		 catch (e)
		  {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
	 }
	
	if (xmlHttp==null)
	{
		 alert ("Browser does not support HTTP Request");
		 return
	}

	var url = '/businessideas/includes/php/finderoptions.php?type=' + type + '&typeid=' + typeid ; 
	
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")	
		{
			if(document.getElementById('ajax_response'))
				document.getElementById('ajax_response').innerHTML=xmlHttp.responseText;
		}	
		else {}
	}
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}