var timeout         = 300;
var closetimer		= 0;
var navmenuitem      = 0;

function jsNav_open()
{	jsNav_canceltimer();
	jsNav_close();
	navmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsNav_close()
{	if(navmenuitem) navmenuitem.css('visibility', 'hidden');}

function jsNav_timer()
{	closetimer = window.setTimeout(jsNav_close, timeout);}

function jsNav_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function() {
	
	
	if ($("#jsTopNav").length > 0) {
		$('#jsTopNav > li').bind('mouseover', jsNav_open);
		$('#jsTopNav > li').bind('mouseout',  jsNav_timer);
	}
	if ($(".png").length > 0) {
		$(document).pngFix(); 
	}

	$('select[name="customer"]').change(function() {
		selected_index = $(this).attr("selectedIndex");
		hide_div();
		$('#category'+selected_index).show();

	});

	function hide_div() {
		for (var i = 0; i < 6; i++) {
			$('#category'+i).hide();
		}
	}

	$(".expand_body").slideUp(0);

	$('.expand').click(function () {
		var id = $(this).attr("id");
		var img_path = $('#e'+id).attr("src");

		$('#eb'+id).slideToggle(400);

		if ($('#e'+id).attr("src").indexOf("expand_off.gif") > -1) {
			img_path = img_path.replace("expand_off.gif","expand_on.gif");
		} else {
			img_path = img_path.replace("expand_on.gif","expand_off.gif");
		}
		$('#e'+id).attr("src",img_path);
	});
   
});

document.onclick = jsNav_close;

