$(document).ready(function()
{	
	// fixas IE nuo vienodo plocio dropdown list'o
	if ($.browser.msie) $('#test_searchCategorySelect')
		.css({'position':'relative','z-index':'9999'})
	    .bind('focus mouseover', function() { $(this).addClass('expand').removeClass('clicked'); })
	    .bind('click', function() { $(this).toggleClass('clicked'); })
	    .bind('mouseout', function() { if (!$(this).hasClass('clicked')) { $(this).removeClass('expand'); }})
	    .bind('blur', function() { $(this).removeClass('expand clicked'); });
	
	
	var value = '';
	value = $('#test_searchCategorySelect option:selected').attr('value');
    
    if(value != '')
    {
		$.post('/modules/functions.php', {cat_id: value}, 
		function(data)
		{
			var output = '<option value=""> - visi gamintojai - </option>';
			var i = 0;
			$.each(data, function() 
			{	
				output = output + '<option value="' + data[i].id + '">' + data[i].title + ' (' + data[i].count + ')</option>';
				i = i + 1;
			});
			$('#test_searchManufacturerSelect').html(output);	
		}, 'json')
    }
    
    $('#test_searchCategorySelect').change(function()
    {
    	value = $('#test_searchCategorySelect option:selected').attr('value');
        if(value != ''){
        	$.post('/modules/functions.php', {cat_id: value}, 
	        	function(data)
	        	{
	        		var output = '<option value=""> - visi gamintojai - </option>';
	        		var i = 0;
	        		$.each(data, function() 
	        		{	
	        			output = output + '<option value="' + data[i].id + '">' + data[i].title + ' (' + data[i].count + ')</option>';
	        			i = i + 1;
	        		});
	        		$('#test_searchManufacturerSelect').html(output);	
	        	}, 'json')
		}
    });   
});