var hide  = true;
var myTimer;

var helpBubbleArray = new Array();
helpBubbleArray["Home"]="Takes you to MoneyAM Home page";
helpBubbleArray["LogIn"]="Takes you to the login page";
helpBubbleArray["LogOut"]="Logs you out of MoneyAM";
helpBubbleArray["Register"]="Click here to register to our FREE services";
helpBubbleArray["Upgrade"]="Click here to upgrade your account to one of our payment services, why not choose our active service for unlimited streaming prices or Level 2 for the serious trader";
helpBubbleArray["SiteMap"]="Can't find what you want? Try our site map";
helpBubbleArray["MyAccount"]="See your account details, and change personal information when you want";
helpBubbleArray["Contact"]="Our contact details";
helpBubbleArray["Help"]="Having difficulties using something on MoneyAM? Click here for an in depth set of help pages";
helpBubbleArray["Stockwatch"]="Set up multiple streaming watchlists. View the Shares you want in real time so that you never miss a moment on the market";
helpBubbleArray["Level2"]="The Heart of the Beast . see what the pro's see. If you want to get ahead in this market get Level 2!";
helpBubbleArray["Portfolio"]="Set up your own portfolio of the Shares you hold and track them throughout the day";
helpBubbleArray["Trades"]="See the trades as they happen with MoneyAM Trades";
helpBubbleArray["SharesMagazine"]="Shares subscribers can download the magazine and read what our award winning Journalist are thinking this week - Not a subscriber? Just click here to sign up now!";
helpBubbleArray["Research"]="All the tools you need to research your investment needs - from Company Fundamentals to Heatmaps and historic quotes - its all here";
helpBubbleArray["Quote"]="Need a price fast? Click here to get an instant quote.";
helpBubbleArray["Indices"]="See what the worlds major indices are doing from Wall Street to Tokyo.";
helpBubbleArray["TradersRoom"]="Want to know what other serious traders are thinking. Join in the debate on one of the fastest growing financial Bulletin Boards on the web!";
helpBubbleArray["MarketScan"]="Give the market a scan with MoneyAM's easy to use research tools";
helpBubbleArray["Charts"]="Fully configurable charts to help you make those all important investment decisions. ";
helpBubbleArray["Terminal"]="MoneyAM's unique multi frame tool which allows you to see all you need in just one browser window.";
helpBubbleArray["Alerts"]="Set alerts and receive an E mail when your stock is on the move";
helpBubbleArray["StockScreener"]="Set the parameters and get a listing of all the shares that fit your requirements";
helpBubbleArray["News"]="Up to the minute news supplied by AFX, RNS and MoneyAM";
helpBubbleArray["Futures/FX"]="Check out the latest Futures prices by clicking here";
helpBubbleArray["Mobile"]="Never miss out when you are away from your desk. MoneyAM streaming Mobile services will keep you in the know when you are out and about";
helpBubbleArray["InvestorsRoom"]="See what your fellow investors are thinking on one of the web's fastest growing Financial Bulletin Boards";
helpBubbleArray["PersonalFinance"]="Keep up to date with the latest news in Personal finance here";
helpBubbleArray["Savings"]="Use our savings tool to find the best rates from 1079 savings accounts listed";
helpBubbleArray["Banking"]="Use our current accounts tool to find the best rates from over 300.";
helpBubbleArray["Loans"]="New car? Holiday? Pay off Credit Cards? Compare over 400 loans. Use our loan finder to find the best loan on the market whatever your credit rating.";
helpBubbleArray["CreditCards"]="New card? Balance transfer? Find the lowest APR, longest interest free, or highest cashback from over 300 credit cards...";
helpBubbleArray["Mortgages"]="Compare over 7000 mortgages, find the best deal and, in many cases, apply online...";
helpBubbleArray["Pensions"]="Look forward to your retirement and start saving for an income you can enjoy";
helpBubbleArray["Insurance"]="Whether it is Household Insurance, Travel Insurance or medical insurance compare thousands of products to find the right deal for you";
helpBubbleArray["Directory"]="Ever wondered which Broker will best suit your investment and trading needs? Compare the best here to choose the right one for you";

// time to wait to display pop up bubble
var wait = 1.5;

// General help bubble layers (NOT MENU BUTTONS)
function showLayer(obj,lyr,state)
{
	var bubbleLyr = "genericBubble";
	// this is just for on off security
	var doLayer = true;

	if (doLayer)
	{
		setLyr(lyr,obj,bubbleLyr);
		if (state == "visible")
		{
			myTimer = setTimeout('showhide("'+state+'","'+bubbleLyr+'")',wait*1000);
		}else{
			clearTimeout(myTimer);
			showhide(state,bubbleLyr);
		}
	}

	return true;
}

// Help Bubbles for MENU BUTTONS
function helpbubble(obj,lyr,state)
{
	var bubbleLyr = "helpbubble";
	var doLayer = false;
	// Comment out all stuff ... for now ...
	if (document.getElementById)
		doLayer = true;

	/*
	if (doLayer)
	{
		setLyr(lyr,obj,bubbleLyr);
		if (state == "visible")
		{
			myTimer = setTimeout('showhide("'+state+'","'+bubbleLyr+'")',wait*1000);
		}else{
			clearTimeout(myTimer);
			showhide(state,bubbleLyr);
		}
	}else{
		if (obj.title == "")
			obj.title=helpBubbleArray[lyr];
	}
	*/

	return true;

}

function showhide(state,bubbleLyr)
{
	var x = new getObj(bubbleLyr);
	//hide = !hide;
	//x.style.visibility = (hide) ? 'hidden' : 'visible';
	x.style.visibility = state;
}

function setLyr(lyr,obj,bubbleLyr)
{
	var win = new getWindowSize();

	var x = new getObj(bubbleLyr);
	
	x.obj.innerHTML=helpBubbleArray[lyr];

	if (document.all) { // grab thie x-y pos.s if browser is IE
    		var newX = event.clientX + document.body.scrollLeft;
        	var newY = event.clientY + document.body.scrollTop + 15;
	} else {  // grab the x-y pos.s if browser is NS
		var newX = findPosX(obj) + 10;
		var newY = findPosY(obj) + 25;
	}  
		    
	/*if (document.all)
	{
		var newX = event.clientX;
		var newY = event.clientY + 15;
	}else{
		var newX = findPosX(obj) + 10;
		var newY = findPosY(obj) + 25;
	}
	*/
	if (newX + 200 > win.width){
		newX-=200;
	}	

	//= obj.title;
	x.style.top = newY + 'px';
	x.style.left = newX + 'px';
}


function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


function getObj(name)
{
 if (document.getElementById)
 {
	   this.obj = document.getElementById(name);
	   this.style = document.getElementById(name).style;
 }
 else if (document.all)
 {
	   this.obj = document.all[name];
	   this.style = document.all[name].style;
 }
 else if (document.layers)
 {
	   if (document.layers[name])
	   {
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	   }
	   else
	   {
	    this.obj = document.layers.testP.layers[name];
	    this.style = document.layers.testP.layers[name];
	   }
 }
}

function getWindowSize()
{
	if (parseInt(navigator.appVersion)>3) {
 		if (navigator.appName=="Netscape") {
  			this.width = window.innerWidth;
			this.height = window.innerHeight;
 		}
 		if (navigator.appName.indexOf("Microsoft")!=-1) {
			this.width = document.body.offsetWidth;
			this.height = document.body.offsetHeight;
 		}
	}
}



