﻿
var bubbleResetID;
var l;
var b;
var bubbleTimer = 500;

function cancelHideSearch()
{
    clearTimeout(bubbleResetID);
}

function startHideSearch(linkID, bubbleID)
{
    l = linkID;
    b = bubbleID;
    bubbleResetID = setTimeout("hideSearch()", 500);
}

function showSearch(linkID, bubbleID)
{
    var a = document.getElementById(linkID);
    
    var div = document.getElementById(bubbleID);
    div.style.visibility = "visible";
    
    opacity(bubbleID,40,100,10);
}

function hideSearch()
{
    var timeToClose = 250;
    opacity(l,100,40,timeToClose);
    opacity(b,100,40,timeToClose);
    setTimeout("closeSearch()",timeToClose);
}

function hideSearchNow(linkID, bubbleID)
{
    l = linkID;
    b = bubbleID;
    var timeToClose = 250;
    opacity(l,100,40,timeToClose);
    opacity(b,100,40,timeToClose);
    setTimeout("closeSearch()",timeToClose);
}

function closeSearch()
{
    var div = document.getElementById(b);
    div.style.visibility = "hidden";
    
    //var a = document.getElementById(l);
    //a.className = '';
    opacity(l,70,100,10);
    
}

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
