function show_pages(url, tail) {
	var el;
	el = document.getElementById('show');
	el = el.options[el.selectedIndex].value;
	window.location.href = url + el + tail;
}

function _show_pages(url, brand) {
	var el, chops;
	el = document.getElementById('show');
	el = el.options[el.selectedIndex].value;
	chops = window.location.pathname.replace('.html', '').substr(1).split('/');
	if (chops.length == 2) {		
		window.location.href = '/' + chops[0] + '/1/' + el + '/' + chops.slice(1).join('/') + '.html';
	}
	else {
		window.location.href = '/' + chops.slice(0, 2).join('/') + '/' + el + '/' + chops.slice(3).join('/') + '.html';
	}
}

function filter_brand(url) {
	var el, brand;
	el = document.getElementById('brand');
	brand = el.options[el.selectedIndex].value;
	if (brand != '') {
		brand = '/' + brand;
	}
	window.location.href = url + brand + '.html';
}

function _filter_brand(url) {
	var el, chops, brand;
	el = document.getElementById('brand');
	chops = window.location.pathname.replace('.html', '').substr(1).split('/');
	brand = el.options[el.selectedIndex].value;
	if (brand != '') {
		brand = '/' + brand;
	}
	if (chops.length == 2) {
		window.location.href = '/' + chops[0] + '/1/10/' + chops[1] + brand + '.html';
	}
	else {
		window.location.href = '/' + chops.slice(0,3).join('/') + '/' + url + brand + '.html';
	} 
}

function currency(url) {
	var el;
	el = document.getElementById('currency');
	window.location.href = url + 'currency/' + el.options[el.selectedIndex].value;
}

function go_search(url) {
	window.location.href = url + document.getElementById('ProductsWords').value;
}

function show_cat(num) {
	var k, el, sub, op_el, i;
	$("brands").update('Загрузка...');
	cur = 'cat' + num;
	next = 'cat' + (num + 1);
	el = $(cur);
	k = $('sel' + num).value;
	sub = $('sub' + $('sel' + num).options[$('sel' + num).selectedIndex].value).readAttribute('sub');

	i = num+1;
	while ($('cat' + i) != undefined)	{
		$('cat' + i).hide();
		i++;
	}

	if (k > 0 && sub == 1) {
		new Ajax.Updater(next, '/categories/select/' + k,
		{method: 'get', onComplete: function () {eval('$("' + next + '").show();');}});
	}
	new Ajax.Updater('brands', '/brands/select/' + k,
	{method: 'get', onComplete: function () {eval('brands_end();');}});
}
