// JavaScript Document
$(document).ready( function() {
	$("#benchid").ready( function() {
		$("#benchid").change( function() {
		    if($(this).val()){
				$.ajax({
					beforeSend: function(){
    					$("#bloader").html("<img src='/i/wko-loader.gif'>");
						$("#product").html("<option>Searching...</option");
   					},
					url: "/fwo.php?overlord=fwWKOSearch&@benchid="+$(this).val(),
					cache: false,
					success: function(data) {
						if(data) $("#product").html(data);
						else $("#product").html("<option>No Products match your criteria</option");
						$("#bloader").html("");
						$("#product option:first").attr('selected', 'selected');
					}
				});
			}
		});
	});
	$("#teleride").ready( function() {
		$("#teleride").change( function() {
		    if($(this).val()){
				$.ajax({
					beforeSend: function(){
    					$("#tloader").html("<img src='/i/wko-loader.gif'>");
						$("#product").html("<option>Searching...</option");
   					},
					url: "/fwo.php?overlord=fwWKOSearch&@steleride="+$(this).val(),
					cache: false,
					success: function(data) {
						if(data) $("#product").html(data);
						else $("#product").html("<option>No Products match your criteria</option");
						$("#tloader").html("");
						$("#product option:first").attr('selected', 'selected');
					}
				});
			}
		});
	});
	$("#stopstreet").ready( function() {
		$("#stopstreet").change( function() {
		    if($(this).val()){
				$.ajax({
					beforeSend: function(){
    					$("#iloader").html("<img src='/i/wko-loader.gif'>");
						$("#product").html("<option>No Products match your criteria</option");
   					},
					url: "/fwo.php?overlord=fwWKOSearch&stopstreet="+$(this).val()+"&crossstreet="+$("#crossstreet").val(),
					cache: false,
					success: function(data) {
						if(data) $("#product").html(data);
						else $("#product").html("<option>No Products match your criteria</option");
						$("#iloader").html("");
						$("#product option:first").attr('selected', 'selected');
					}
				});
			}
		});
	});
	$("#crossstreet").ready( function() {
		$("#crossstreet").change( function() {
		    if($(this).val()){
				$.ajax({
					beforeSend: function(){
    					$("#iloader").html("<img src='/i/wko-loader.gif'>");
						$("#product").html("<option>No Products match your criteria</option");
   					},
					url: "/fwo.php?overlord=fwWKOSearch&crossstreet="+$(this).val()+"&stopstreet="+$("#stopstreet").val(),
					cache: false,
					success: function(data) {
						if(data) $("#product").html(data);
						else $("#product").html("<option>No Products match your criteria</option");
						$("#iloader").html("");
						$("#product option:first").attr('selected', 'selected');
					}
				});
			}
		});
	});
});