/* iconBar.js v1.5 */
var messages = new Array(
	"<span style='margin:0px; padding:0px;font-size:9pt;font-weight:bold;'>People Lookup:</span> The most complete, accurate people search tool on the web. Find phone number, address(es), age, birthday, household members and more...",
	"<span style='margin:0px; padding:0px;font-size:9pt;font-weight:bold;'>Background Check:</span> Check your &ldquo;gut&rdquo; feeling about the people you trust in your world. Find criminal records, address history, liens, judgments, phone numbers, relatives, associates, aliases and more on neighbors, dates or associates.",
	"<span style='margin:0px; padding:0px;font-size:9pt;font-weight:bold;'>Reverse Phone:</span> Looking for who is behind an unrecognized number? A hangup? A prank call? Enter a phone number and we&rsquo;ll return information associated with that number including name, address/location, carrier and more.",
	"<span style='margin:0px; padding:0px;font-size:9pt;font-weight:bold;'>Email Search:</span> Find email addresses for just about anyone! Instant Email Lookup report includes email address(es) and mailing address, where available. ",
	"<span style='margin:0px; padding:0px;font-size:9pt;font-weight:bold;'>Other Products:</span> Secure your world by seeking all the information about the people in it. Search by name and find misdemeanors, felonies, sex offender information and more."
);
	
var iconIndex;
var iconWidth;
var iconStartPosition;
var allIcons;
var iconCount;


// change selectedTab since there's no longer a 1:1 correlation between leftnav tabs and icons
if ( selectedTab == 3 ) { selectedTab = 4; }
if ( String(window.location).match("email-search-name.html") ) { selectedTab = 3; }
if ( String(window.location).match("reverse-email.html") ) { selectedTab = 3; }
	

var mouseovericon = function (event) {
	var element = event.element();
	while ( !element.match(".iconBlock") ) { element = element.up(); }
	allIcons.each(function(item, index){
		if ( item.id == element.id ) {
			iconIndex = index;
		}
	});
	// hilite the image
	if ( element.firstDescendant().getStyle("filter") == undefined || element.firstDescendant().getStyle("filter") == "" ) {
		var source = element.firstDescendant().src;
		source = source.endsWith("_over.png") ? source : source.gsub(".png","_over.png");
		element.firstDescendant().writeAttribute({src : source});
	} else {
		var source = element.firstDescendant().readAttribute("style");
		source = source.include("_over.png") ? source : source.gsub(".png","_over.png");
		element.firstDescendant().writeAttribute({style:source});
	}
	
	var pointerPos = 91 + iconWidth * iconIndex;
	$("tooltipPointer").setStyle({left: pointerPos+"px"});
	$("iconTooltip").innerHTML = messages[iconIndex];

	// unhilite the other images
	allIcons.each(function(item, index){
		if ( item.match(".iconBlock") && item.id != element.id ) {
			if ( element.firstDescendant().getStyle("filter") == undefined || element.firstDescendant().getStyle("filter") == "" ) {
				var source = item.firstDescendant().src.gsub("_over.png",".png");
				item.firstDescendant().writeAttribute({src : source});
			} else {
				var source = item.firstDescendant().readAttribute("style");
				source = source.gsub("_over.png",".png");
				item.firstDescendant().writeAttribute({style:source});
			}
		}
	});

}

var mouseouticon = function (event) {
	var element = event.element();
	while ( !element.match(".iconBlock") ) { element = element.up(); }
	if ( element.firstDescendant().getStyle("filter") == undefined || element.firstDescendant().getStyle("filter") == "" ) {
		var source = element.firstDescendant().src.gsub("_over.png",".png");
		element.firstDescendant().writeAttribute({src : source});
	} else {
		var source = element.firstDescendant().readAttribute("style");
		source = source.gsub("_over.png",".png");
		element.firstDescendant().writeAttribute({style:source});
	}
	if ( selectedTab < iconCount ) {
		iconStartPosition = 91 + iconWidth * selectedTab;
		$("tooltipPointer").setStyle({display:"block", left: iconStartPosition+"px"});
		$("iconTooltip").innerHTML = messages[selectedTab];
	} else {
		$("tooltipPointer").setStyle({display:"none"});
		$("iconTooltip").update("");
	}

}

document.observe('dom:loaded', function(){
	$$('div.iconBlock').each(
			function(item){
				//item.observe("mouseover",mouseovericon);
			}
		);
	if ( $("iconContainer") ) {
		$("iconContainer").observe("mouseover",mouseovericon);
		$("iconContainer").observe("mouseout",mouseouticon);
		allIcons = $("iconContainer").immediateDescendants();
		iconCount = $$(".iconBlock").length;
		iconIndex = selectedTab;
		iconWidth = $("peopleSearchIcon").getWidth();
		if ( selectedTab < iconCount ) {
			iconStartPosition = 91 + iconWidth * iconIndex;
			$("tooltipPointer").setStyle({display:"block", left: iconStartPosition+"px"});
			$("iconTooltip").innerHTML = messages[iconIndex];
		} else {
			$("tooltipPointer").setStyle({display:"none"});
			$("iconTooltip").update("");
		}
	}
});