$(document).ready(function(){
	var findFilterCat=new Array("Application", "product", "waveLength");
	
	for(i = 0; i<findFilterCat.length; i++)
		$('#'+findFilterCat[i]).find('option:first').attr('selected', 'selected').parent('select');
	
	
	$("#search").keyup(function(event){
		if(event.keyCode == 13){
			$("#homeSearchFilterBtn").click();
		}
	});
	$(".miniSearch").keyup(function(event){
		if(event.keyCode == 13){
			$(".searchProduct_btn").click();
		}
	});
});

function submitSearch(){
	var app 		  = document.getElementById("Application").value;
	var product 	  = document.getElementById("product").value;
	var wave 		  = document.getElementById("waveLength").value;
	var searchBox 	  = document.getElementById("search").value;
	var url 		  = "/store/Products?";
	var urlCount 	  = 0;
	var brand         = 0;
	var fluorophore   = 0;
	
	if(app != "000"){
		urlCount ++;
		if(urlCount > 1)
			url += "&";
		url += "applicationId=" + app;
	}
	if (product != "000"){
		urlCount ++;
		if(urlCount > 1)
			url += "&";
		url += "producttypeid=" + product;
	}
	if (wave != "000"){
		urlCount ++;
		if(urlCount > 1)
			url += "&";
		url += "waveId=" + wave;
	}
	if (searchBox != "Search by Part # or Keyword"){
		if(urlCount !=0)url += "&search=" + searchBox ;
		else url += "search=" + searchBox ;
		urlCount ++;
	}
	if(urlCount != 0){
		url += "&brandId=" + brand + "&fluorophoreId=" + fluorophore + "&productId=0";
		window.location = url;
	}
	else{
		alert("Could not search");
		return false;
	}
	
}
