// JavaScript Document

function $(){
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++){
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

window.onload = function(){
	var dirLinks = $('top_nav').getElementsByTagName('a');
	for (var i = 0; i < dirLinks.length; i += 1) {
		dirLinks[i].href = dirLinks[i].href.replace('directory-sitemap', 'change-directory');
	};
	$("frmLocation").onchange = function(){
		if($("frmLocation").options.selectedIndex != 0 && $("frmCategory").options.selectedIndex != 0){
			$("frmSearch").submit($("frmSearch").form);
		}
	}
	$("frmCategory").onchange = function(){
		if($("frmLocation").options.selectedIndex != 0 && $("frmCategory").options.selectedIndex != 0){
			$("frmSearch").submit($("frmSearch").form);
		}
		if($("frmLocation").options.selectedIndex == 0 && $("frmCategory").options.selectedIndex != 0){
			var _strPath = $("frmCategory").options[$("frmCategory").options.selectedIndex].innerHTML;
			var _strPattern = /[\(\)(\/)]/gi;
			_strPath = _strPath.replace(_strPattern, '');
			_strPath = '../' + _strPath.replace(/\s+/gi, '-').toLowerCase() + '/';
			location.href = _strPath;
			//alert(_strPath);
		}
	}
	$("s1").style.display = 'none';
}