function f_redirect (s_url, n_timer) {
	if (!n_timer) {
		window.location = s_url;
		return;
	}
	n_timer--;
	var e_counter = document.getElementById('timer');
	e_counter.innerHTML = n_timer;
	setTimeout("f_redirect('" + s_url + "'," + n_timer + ")", 1000);
}
function f_showOptions (e_link) {
	// hide link
	var e_li = e_link.parentNode;
	e_li.style.display = 'none';
	
	// show options
	var e_ul = e_li.parentNode;
	var a_lis = e_ul.getElementsByTagName('LI');
	for (var i = 0; i < a_lis.length; i++) {
		if (a_lis[i].className == 'moreOptions')
			a_lis[i].style.display = 'list-item';
	}
	return false;
}

var a_pdata = [];
var a_prevSelection = [];

function f_swatchPreview (n_swatchNum, n_colorNum) {
	if (window.e_swatchTO) {
		clearTimeout(window.e_swatchTO);
		window.e_swatchTO = null;
	}
	var e_image, n;
	for (n = 0; e_image = document.getElementById('searchSwatch' + n_swatchNum + '_' + n); n++)
		e_image.className = n == n_colorNum ? 'searchSwatchSelected' : 'searchSwatch';

	var a_prod = a_pdata[n_swatchNum][n_colorNum];
	e_image = document.getElementById('searchImg' + n_swatchNum);
	e_image.src = '/catalog/graphics/prods/' + escape(a_prod[0]) + 'thumb.jpg';
	window.e_swatchTO = setTimeout('f_swatchSelect(' + n_swatchNum + ',' + n_colorNum + ')', 500);
}
function f_swatchRestore (n_swatchNum) {
	if (window.e_swatchTO) {
		clearTimeout(window.e_swatchTO);
		window.e_swatchTO = null;
	}
	
	var n_prevCoor = a_prevSelection[n_swatchNum] ? a_prevSelection[n_swatchNum] : 0;
	window.e_swatchTO = setTimeout('f_swatchSelect(' + n_swatchNum + ',' +  n_prevCoor + ')', 500);
}
function f_swatchSelect (n_swatchNum, n_colorNum) {
	if (window.e_swatchTO) {
		clearTimeout(window.e_swatchTO);
		window.e_swatchTO = null;
	}
	a_prevSelection[n_swatchNum] = n_colorNum;

	var e_image, n;
	for (n = 0; e_image = document.getElementById('searchSwatch' + n_swatchNum + '_' + n); n++)
		e_image.className = n == n_colorNum ? 'searchSwatchSelected' : 'searchSwatch';

	var a_prod = a_pdata[n_swatchNum][n_colorNum];
	e_image = document.getElementById('searchImg' + n_swatchNum);
	e_image.src = '/catalog/graphics/prods/' + escape(a_prod[0]) + 'thumb.jpg';

	var e_elem = document.getElementById('searchLink' + n_swatchNum);
	e_elem.href = '/' + escape(a_prod[0]) + '.html';

	e_elem = document.getElementById('searchName' + n_swatchNum);
	e_elem.innerHTML = a_prod[1];
	e_elem.href = '/' + escape(a_prod[0]) + '.html';

	e_elem = document.getElementById('searchPrice' + n_swatchNum);
	e_elem.innerHTML = '$' + a_prod[2] + '<span>per ' + a_prod[3] + '</span>';
}
