function SetFilter(i_Value)
{
    document.forms['feForm'].elements['act2'].value    = 'set_filter';
    document.forms['feForm'].elements['params2'].value = i_Value;
    if (document.forms['feForm'].elements['type'].value != 'category')
    {
    	document.forms['feForm'].action = "/all-books/";
   	}
   	else
   	{
   		document.forms['feForm'].action = "";
   	}
    document.forms['feForm'].submit();
    return true;
}

function SetSorting(i_Value)
{
    document.forms['feForm'].elements['act2'].value    = 'set_sorting';
    document.forms['feForm'].elements['params2'].value = i_Value;
    document.forms['feForm'].action = "";
    document.forms['feForm'].submit();
    return true;
}

function SelectSeasonSorting(i_Value)
{
    document.forms['feForm'].elements['act2'].value    = 'set_season_sorting';
    document.forms['feForm'].elements['params2'].value = i_Value;
    document.forms['feForm'].action = "";
    document.forms['feForm'].submit();
    return true;
}

function SelectYear()
{
    document.forms['feForm'].elements['act2'].value    = 'set_year';
    document.forms['feForm'].action = "";
    document.forms['feForm'].submit();
    return true;
}

function ShowPageSales(i_PageNo)
{
	document.feForm.act2.value = i_PageNo;
	document.feForm.action = "";
	document.feForm.submit();	
}


function SimpleSearch()
{
	var toSend = true;

	// validate: name
	if (document.simpleForm.search_query.value == "") 
	{
		alert('Please enter search query.');
		toSend = false;
	}

	//if everything is ok then send
	if (toSend == true)
	{
		document.forms['simpleForm'].elements['params'].value = 's';
		document.simpleForm.action = "/search-results.html";
		document.simpleForm.submit();
		return true;
	}	
	return false
}



function ContentSubmit(i_Url)
{
	document.contentForm.act.value = 'post';
	document.contentForm.action = i_Url;
	document.contentForm.submit();
	return true;
}

function SelectCategory()
{
	document.contentForm.act.value = 'select_category';
	document.contentForm.action = '';
	document.contentForm.submit();
	return true;
}

function ShowPage(i_PageNo)
{
	document.contentForm.act.value = i_PageNo;
	document.contentForm.action = "";
	document.contentForm.submit();	
}

function BookNews(i_Url)
{
	document.contentForm.action = i_Url;
	document.contentForm.submit();
	return true;
}

function Search(i_Type)
{
	var toSend = true;

	// validate: name
	if (document.contentForm.search_query.value == "") 
	{
		alert('Please enter search query.');
		toSend = false;
	}

	//if everything is ok then send
	if (toSend == true)
	{
		document.forms['contentForm'].elements['params'].value = i_Type;
		document.contentForm.action = "/search-results.html";
		document.contentForm.submit();
		return true;
	}	
	return false
}

function SearchPage(i_PageNo)
{
	document.forms['contentForm'].elements['page'].value = i_PageNo;
	document.forms['contentForm'].elements['params'].value = 'r';
	document.contentForm.action = '/search-results.html';
	document.contentForm.submit();
	return true;
}

function Subscribe()
{
	document.forms['contentForm'].elements['act'].value = 'subscribe';
	document.contentForm.action = '';
	document.contentForm.submit();
	return true;
}

function Unsubscribe()
{
	document.forms['contentForm'].elements['act'].value = 'unsubscribe';
	document.contentForm.action = '';
	document.contentForm.submit();
	return true;
}