﻿window.scrollTo = function() { }

var dropDownTimeout = 500;
var dropDownCloseTimer = 0;
var dropDownMenuItem = 0;

function dropDown_open() {
	dropDown_cancelTimer();
	dropDown_close();
	dropDownMenuItem = $(this).find('div').css('visibility', 'visible');
}

function dropDown_close() {
	if (dropDownMenuItem) dropDownMenuItem.css('visibility', 'hidden');
}

function dropDown_timer() {
	dropDownCloseTimer = window.setTimeout(dropDown_close, dropDownTimeout);
}

function dropDown_cancelTimer() {
	if (dropDownCloseTimer) {
		window.clearTimeout(dropDownCloseTimer);
		dropDownCloseTimer = null;
	}
}

document.onclick = dropDown_close;

function dropDown_bind(menuItemId) {
	var selector = '#' + menuItemId;
	$(selector).bind('mouseover', dropDown_open);
	$(selector).bind('mouseout', dropDown_timer);
	$(selector).bind('click', dropDown_close);
}
