// Basic variables
var outSpeed = "medium";
var outOpacity = .7;
var inSpeed = "fast";
var inOpacity = 1;

// Function for fading icons/popups
function doFade(i){

	// Variables
	var nowIcon, nowPopup, nowIconPos, topPx, leftPx, topPxS, leftPxS;
	
	// Browser detection
	var msie = $.browser.msie;
	var chrome = /chrome/.test( navigator.userAgent.toLowerCase() );
	
	// Variable for icon id
	nowIcon = "#icon" + i;
	nowPopup = "#popup" + i;
	nowIconPos = $(nowIcon).position();
	
	// Height from top of icon
	topPx = nowIconPos.top;
	leftPx = nowIconPos.left;
	
	if(msie == true){
		// Popup showing position (ie)
		topPxS = topPx + 70;
		leftPxS = leftPx + 497;
	}else{
		// Popup showing position (non-ie)
		topPxS = topPx + 70;
		leftPxS = leftPx + 457;
	}
	
	// Position the popups (start as hidden)
	$(nowPopup).css({position: "absolute", top: topPxS, left: leftPxS}).hide();
	
	if(msie == true|chrome == true){
		// Hover function (ie and chrome)
		$(nowIcon).hoverIntent(function(){
			// Show popup
			$(nowIcon).effect("shake", {times: 1, distance: 3});
			$(nowPopup).show("slide", {direction: "up"}, 600);
		},function(){
			// Hide popup
			$(nowPopup).hide("clip", { direction: "vertical" }, 350); // Does nothing in IE6
		});
	}else{
		// Hover function (non-ie)
		$(nowIcon).hoverIntent(function(){
			// Fade icon & show popup
			$(this).effect("shake", {times: 1, distance: 3}).fadeTo(outSpeed, outOpacity);
			$(nowPopup).show("slide", {direction: "up"}, 600);
		},function(){
			// Un-fade icon & hide popup
			$(this).fadeTo(inSpeed, inOpacity);
			$(nowPopup).hide("drop", {direction: "down"}, 650);
		});
	}
}