/* multimenu */
function startMenu() {
	if (document.all && document.getElementById) {
		var multimenu = document.getElementById('multimenu')
		for (i = 0; i < multimenu.childNodes.length; i++) {
			var ul = multimenu.childNodes[i]
			if (ul.nodeName == 'UL') {
				for (j = 0; j < ul.childNodes.length; j++) {
					var node = ul.childNodes[j]
					if (node.nodeName == 'LI') {
						node.onmouseover = function() { this.className += ' over' }
						node.onmouseout = function() { this.className = this.className.replace(' over', '') }
					}
				}
			}
		}
	}
}

if (window.attachEvent) {
	window.attachEvent('onload', startMenu)
} else {
	window.onload = startMenu;
}


/* categories */
function depShowHide(id) {

	var dep = document.getElementById('depId' + id)
	var img = document.getElementById('depImgId' + id)
	var imgsrc = new String(img.src)

	if(dep.style.display == '') {
		dep.style.display = 'none'
		img.src = imgsrc.replace(/_open\.gif$/, '_close.gif')
	} else {
		dep.style.display = ''
		img.src = imgsrc.replace(/_close\.gif$/, '_open.gif')
	}
}

function depGet(url) {

	var dep = document.location = url
}

/* product-list */
// mění parametry v url
	function changeParam(paramname, mode) {
		var location = new String(window.location)
		if (mode != -1) {
			if (location.match(paramname)) {
				var replaceexp = new RegExp ('(' + paramname + '=)[,%A-Z0-9]*', 'g')
					location = location.replace(replaceexp, '$1' + mode)
			} else {
				if (location.match(/\?/)) {
					location += '&'
				} else {
					location += '?'
				}
				location = location + paramname + '=' + mode;
			}
		}

		if (paramname == 'producer' || paramname == 'sort') {
			location = firstPage(location)
		};

		window.location = location;
	}

	function firstPage(location) {
		return location.replace(/pageno=[0-9]+&?/, '')
	}
	
	// parametr funkce je id šipky (vzestupne[0] nebo sestupne[1])
	function sortMode(button) {
		var form = document.product_list_bar
		changeParam('sortmode', parseInt(form.sortmode.value) + parseInt(button))
	}
