﻿function addLinkEvents() {
    myQuickLinks.each(function(thisLink, i) {
	    thisLink.addEvent('mouseover',function() {
		    resetTimer();
		    showDD(thisLink);
	    });
	    thisLink.addEvent('mouseout',function() {
		    myQLTimer = (function(){ hideThisDD(thisLink,$('popLoc' + thisLink.innerHTML)); }).delay(myQLDispTime);
	    });
    });
    myQuickDDs.each(function(thisDD, i) {
	    thisDD.addEvent('mouseover',function() {
		    resetTimer();
	    });
	    thisDD.addEvent('mouseout',function() {
		    myQLTimer = (function(){ hideOtherDDs(); }).delay(myQLDispTime);
	    });
    });
}

function showDD(inLink) {
    resetTimer();
    hideOtherDDs();
    divToShow = $('popLoc' + inLink.innerHTML);
    currXY = [inLink.getTop(),inLink.getLeft()];
    divToShow.style.top = currXY[0] + 18 + 'px';
    divToShow.style.left = currXY[1] + 'px';
    divToShow.style.display = 'block';
    inLink.style.color = '#F60';
    inLink.style.backgroundImage = 'url(images/tiny-down-arrow-HOV.png)';
}

function hideThisDD(inLink , inObj) {
    inLink.style.color = '';
    inLink.style.backgroundImage = '';
    divToShow.style.display = '';
}

function resetTimer() {
    $clear(myQLTimer);
}

function hideOtherDDs() {
    myQuickDDs.each(function(dropDown, i){
	    dropDown.style.display = 'none';
    });
    myQuickLinks.each(function(thisLink, i) {
	    thisLink.style.color = '';
	    thisLink.style.backgroundImage = '';
    });
}


