// drop down menu with transitions
// coding: denis@softcomplex.com
// date: 3/12/2009

function f_showOptions () {

	if (window.e_pftimeout) {
		clearTimeout(window.e_pftimeout);
		window.e_pftimeout = null;
	}

	var e_div = this.getElementsByTagName('DIV').item(1);
	if (window.e_dropdown && e_dropdown == e_div)
		return;

	// hide currently displayed block
	if (window.e_dropdown)
		f_hideOptionsNow();

	if (window.e_hiding && e_hiding == e_div) {
		clearTimeout(o_timerFO);
		e_hiding = o_timerFO = null;
	}

	if (window.b_IE && e_div)
		e_div.style.filter='alpha(opacity=1)';

	window.e_dropdown = window.e_showing  = e_div;
	f_fadeIn();
}
function f_hideOptions () {
	if (window.e_pftimeout) {
		clearTimeout(window.e_pftimeout);
		window.e_pftimeout = null;
	}
	window.e_pftimeout = window.setTimeout("f_hideOptionsNow()", 200);
}
function f_hideOptionsNow () {

	if (window.e_hiding) {
		e_hiding.style.display = 'none';
		e_hiding = null;
	}
	if (!window.e_dropdown)
		return;

	window.e_hiding = e_dropdown;
	window.e_dropdown = null;
	f_fadeOut();
}

function f_fadeOut (n_opacity) {

	// end of transition
	if (n_opacity < 0) {
		e_hiding.style.display = 'none';
		window.e_hiding = null;
		window.o_timerFO = null;
		return;
	}
	// new transition
	if (n_opacity == null) {
		if (window.o_timerFO)
			clearTimeout(o_timerFO);
		n_opacity = 99;
	}

	f_setOpacity(e_hiding, n_opacity);
	n_opacity -= 10;

	// cycle
	window.o_timerFO = setTimeout('f_fadeOut(' + n_opacity + ')', 25);
}

function f_fadeIn (n_opacity) {

	// end of transition
	if (n_opacity > 100) {
		f_setOpacity(e_showing, 100);
		window.e_showing = null;
		window.o_timerFI = null;
		return;
	}

	// new transition
	if (n_opacity == null) {
		if (window.o_timerFI)
			clearTimeout(o_timerFI);
		if (!e_showing) return;
		n_opacity = 1;
		e_showing.style.display = 'block';
	}
	f_setOpacity(e_showing, n_opacity);

	n_opacity += 10;

	// cycle
	window.o_timerFI = setTimeout('f_fadeIn(' + n_opacity + ')', 25);
}

function f_liRollOver () {
	if (!this.className)
		this.id = 'rollOver';
}
function f_liRollOut () {
	this.id = '';
}
function f_liClick () {
	var e_link = this.getElementsByTagName('A').item(0);
	if (!e_link) return;
	window.location = e_link.href;
	return false
}
function f_initProdFilter () {
	var a_lis, a_tds = document.getElementById('prodfilter').getElementsByTagName('TD');
	for (var i = 0; i < a_tds.length; i++) {
			a_tds[i].onmouseover = f_showOptions;
			a_tds[i].onmouseout  = f_hideOptions;
			a_lis = a_tds[i].getElementsByTagName('LI');
			for (var j = 0; j < a_lis.length; j++) {
				a_lis[j].onmouseover = f_liRollOver;
				a_lis[j].onmouseout  = f_liRollOut;
				a_lis[j].onclick     = f_liClick;
			}
	}
}

// cross-browser opacity
var a_dropDowns = [];
var s_uaApp  = navigator.userAgent.toLowerCase();
if (s_uaApp.indexOf('opera') != -1 || s_uaApp.indexOf('safari') != -1)
	window.f_setOpacity = function (e_elem, n_opacity) {
		e_elem.style.opacity = n_opacity / 100;
	};
else if (s_uaApp.indexOf('gecko') != -1)
	window.f_setOpacity = function (e_elem, n_opacity) {
		e_elem.style.MozOpacity = n_opacity / 100;
	};
else if (s_uaApp.indexOf('msie') != -1) {
	window.b_IE = true;
	window.f_setOpacity = function (e_elem, n_opacity) {
		try {
			e_elem.filters.alpha.opacity = n_opacity;
		} catch (e) {};
	};
}
else
	window.f_setOpacity = null;
