if(ACE){
}else{
       var ACE = {}
}
ACE.tips = []
ACE.dropDownWidth = ''

ACE.createToolTips = function (searchType){
        ACE.dropDownWidth = $('s').getWidth();		
		var tooltip = prepareTooltipArray(searchType);
						
        $$('#seeAlsoNav li').each(function(v) {	
			var nextTip = v.getElementsByClassName('seeAlsoTip')[0];
			if (nextTip == tooltip) {
	                v.observe('mouseover', function(e){
	                        ACE.closeTips()
	                        this.setStyle({display:'block'})
                                if(Prototype.Browser.IE){$('s').hide()}
	                }.bind(nextTip))

	                v.observe('mouseout', function(e){
	                    if(!ACE.isMouseOverIt(this,e)){
	                        this.setStyle({display:'none'})
                                if(Prototype.Browser.IE){$('s').show()}
	                    }
	                }.bind(nextTip))

	                nextTip.observe('mouseover', function(e){
	                        ACE.closeTips
	                        this.setStyle({display:'block'})
                                if(Prototype.Browser.IE){$('s').hide()}
	                }.bind(nextTip))

	                nextTip.observe('mouseout', function(e){
	                    if(!ACE.isMouseOverIt(this,e)){
	                        this.setStyle({display:'none'})
                                if(Prototype.Browser.IE){$('s').show()}
	                    }
	                }.bind(nextTip))
			}
		})
		
		alignTooltips();
}

function prepareTooltipArray(searchType) {
	var tooltip;
	var listItem;
		
	if (searchType == 'cust_serv') {
		listItem = document.getElementById("li_cust_serv");	
		tooltip = document.getElementById("tip_cust_serv");		
		ACE.tips.push("A");
	} else if (searchType == 'projects') {
		listItem = document.getElementById("li_projects");	
		tooltip = document.getElementById("tip_projects");
		ACE.tips.push("B");
	} else if (searchType == 'corp_info') {
		listItem = document.getElementById("li_corp_info");	
		tooltip = document.getElementById("tip_corp_info");
		ACE.tips.push("C");
	}		
		
	var bg = document.createElement('div');
	bg.className = 'tipBG';
	tooltip.appendChild(bg);
		
	return tooltip;
}

function alignTooltips() {
		// Three separate AJAX calls are being made to populate each of the tooltip data.
		// But, all these calls are "asynchronous" -- meaning you cannot guarantee which tooltip
		// data will be populated first.
		ACE.tips.sort();
		for (var i = 0; i < ACE.tips.length; i++) {
			var next = ACE.tips[i];
			var theDiv;
			if (next == 'A') {
				theDiv = document.getElementById("tip_cust_serv");
			} else if (next == 'B') {
				theDiv = document.getElementById("tip_projects");
			} else if (next == 'C') {
				theDiv = document.getElementById("tip_corp_info");
			}
			
			theDiv.removeAttribute("class");
			theDiv.removeAttribute("className");	

			if (i == 0) {
				theDiv.setAttribute("class", "seeAlsoTip");
				theDiv.setAttribute("className", "seeAlsoTip");	
			} else if (i == 1) {
				theDiv.setAttribute("class", "seeAlsoTip seeAlsoTipMiddle");
				theDiv.setAttribute("className", "seeAlsoTip seeAlsoTipMiddle");				
			} else if (i == 2) {
				theDiv.setAttribute("class", "seeAlsoTip seeAlsoTipEdge");
				theDiv.setAttribute("className", "seeAlsoTip seeAlsoTipEdge");				
			}
		}	
}

ACE.isMouseOverIt = function (ele, e){
        return Position.within(ele,Event.pointerX(e), Event.pointerY(e));
}

ACE.closeTips = function(){
        $$('.seeAlsoTip').each(function(v){
                v.setStyle({display:'none'})
        })
}

ACE.createToolTips_NoResults = function (searchType){		
		var tooltip = prepareTooltipArray(searchType);
						
        $$('#altNav li').each(function(v) {	
			var nextTip = v.getElementsByClassName('seeAlsoTip')[0];		
			if (nextTip == tooltip) {
	                v.observe('mouseover', function(e){
	                        ACE.closeTips()
	                        this.setStyle({display:'block'})
	                }.bind(nextTip))

	                v.observe('mouseout', function(e){
	                    if(!ACE.isMouseOverIt(this,e)){
	                        this.setStyle({display:'none'})
	                    }
	                }.bind(nextTip))

	                nextTip.observe('mouseover', function(e){
	                        ACE.closeTips
	                        this.setStyle({display:'block'})
	                }.bind(nextTip))

	                nextTip.observe('mouseout', function(e){
	                    if(!ACE.isMouseOverIt(this,e)){
	                        this.setStyle({display:'none'})
	                    }
	                }.bind(nextTip))
			}
		})
		
		alignTooltips();
}
