function OnSubmit(evt,ID,IsCarSearchMode)
{
	if (evt==null) evt=window.event;
	var Source=(evt.srcElement?evt.srcElement:evt.target);
	if (!IsCarSearchMode) IsCarSearchMode=false;
	if (IsCarSearchMode==false)
	{
		var FilterByClass=document.getElementById("FilterByClass");
		var FilterByBrand=document.getElementById(Source.id.substr(0,Source.id.lastIndexOf("_"))+"_FilterByBrandControl");
		var FilterByType=document.getElementById(Source.id.substr(0,Source.id.lastIndexOf("_"))+"_FilterByTypeControl");
		var FilterBySeason=document.getElementById(Source.id.substr(0,Source.id.lastIndexOf("_"))+"_FilterBySeasonControl");
		var FilterBySize=document.getElementById(Source.id.substr(0,Source.id.lastIndexOf("_"))+"_FilterBySizeControl");
		document.getElementById("FilterParams").value=
			FilterByClass.value+";"+FilterByBrand.value+";"+FilterByType.value+";"+FilterBySeason.value+";"+FilterBySize.value;
	}
	else
	{
		var FilterByClass=document.getElementById("FilterByClass");
		var FilterByCarBrand=document.getElementById(Source.id.substr(0,Source.id.lastIndexOf("_"))+"_FilterByCarBrand");
		var FilterByCarModel=document.getElementById(Source.id.substr(0,Source.id.lastIndexOf("_"))+"_FilterByCarModel");
		var FilterByCarType=document.getElementById(Source.id.substr(0,Source.id.lastIndexOf("_"))+"_FilterByCarType");
		var FilterByCarSeason=document.getElementById(Source.id.substr(0,Source.id.lastIndexOf("_"))+"_FilterByCarSeason");
		var CarTyreType=" ";
		for (var Index=0;Index<3;Index++)
		{
			if (document.getElementById(Source.id.substr(0,Source.id.lastIndexOf("_"))+"_CarTyreType_"+Index).checked==true)
			{
				CarTyreType=Index;
					break;
			}
		}
		document.getElementById("FilterParams").value=
			(document.getElementById("SearchModeType").value=="Car"?"CAR"+CarTyreType:"")+
			FilterByClass.value+";"+FilterByCarBrand.value+";"+FilterByCarModel.value+";"+FilterByCarType.value+";"+FilterByCarSeason.value;
	}
	if (document.forms[0].action.indexOf("alias")!=-1)
		document.forms[0].action="http://"+document.forms[0].action.substr(document.forms[0].action.lastIndexOf("?alias=")+7)+"/tabid/"+ID+"/Default.aspx";
	else
		if (document.forms[0].action.indexOf("tabid")!=-1)
			document.forms[0].action=document.forms[0].action.replace(/tabid\/\d+/,"tabid/"+ID);
		else
			document.forms[0].action=document.forms[0].action.substr(0,document.forms[0].action.lastIndexOf("/")+1)+"tabid/"+ID+"/default.aspx";
	if (document.getElementsByName("__VIEWSTATE")[0])
		document.getElementsByName("__VIEWSTATE")[0].name="__NOVIEWSTATE";
	if (document.getElementsByName("__EVENTTARGET")[0])
		document.getElementsByName("__EVENTTARGET")[0].name="__NOEVENTTARGET";
	if (document.getElementsByName("__EVENTARGUMENT")[0])
		document.getElementsByName("__EVENTARGUMENT")[0].name="__NOEVENTARGUMENT";
}

function OnSubmitRemoveQueryString()
{
    if (document.forms[0].action.indexOf("pageNr")!=-1){
        document.forms[0].action=document.forms[0].action.replace(/\??pageNr=\d+/,"");
    }
    
    if (document.forms[0].action.indexOf("FilterParams")!=-1){
        document.forms[0].action=document.forms[0].action.replace(/&?FilterParams=[^&]*/,"");
    }
}
OnSubmitRemoveQueryString();
