//Set up our text fader.
window.onload = function()
{
	//How long does the fade last?
	Duration = 700;
	//How long until the next one fades in?
	Hangtime = 200; 
	//How long does each one showup for? 
	RotateSpeed = 8000;
	//What's the tip element	
	Tip = $('tip');
	//What are the tips?
	Tips = new Array();
	Tips[0] = "What do PEO's offer?";
	Tips[1] = 'What is the "Co-Employment Relationship?"';
	Tips[2] = 'What are the benefits of leasing?';
	Tips[3] = 'How should clients choose a PEO?';
	Tips[4] = 'Side-by-side Comparison (Without and with PEO services)';
	Tips[5] = 'With leasing is there a minimum payroll requirement?';
	Tips[6] = 'What is the required number of employees that I can run?';
	Tips[7] = 'What if my contractor client asks: What if I get "rained out" and cannot run payroll for a week?';
	Tips[8] = 'Will the client save money using an employee leasing provider?';
	Tips[9] = "We're signed on with the leasing company, what is the process for running payroll?";
	Tips[10] = 'Can General Contractors cover subcontractors through leasing?';
	Tips[11] = 'Why should I sign with a leasing company as opposed to a stand alone policy?';
	Tips[12] = 'What does the leasing company do for me?';
	Tips[13] = 'Can you cover multi-state accounts?';
	Tips[14] = 'What does the leasing company do for my client?';
	Tips[15] = 'Common misconceptions of leasing companies.';
	Tips[16] = 'Why do business with I-Brokers?';
	Tips[17] = 'Does the broker sign the client directly or is this done through your office?';

	
	TipURLs = new Array();
	TipURLs[0] = 'http://www.i-brokers.net/pages/faq.php#1';
	TipURLs[1] = 'http://www.i-brokers.net/pages/faq.php#2';
	TipURLs[2] = 'http://www.i-brokers.net/pages/faq.php#3';
	TipURLs[3] = 'http://www.i-brokers.net/pages/faq.php#4';
	TipURLs[4] = 'http://www.i-brokers.net/pages/faq.php#5';
	TipURLs[5] = 'http://www.i-brokers.net/pages/faq.php#6';
	TipURLs[6] = 'http://www.i-brokers.net/pages/faq.php#7';
	TipURLs[7] = 'http://www.i-brokers.net/pages/faq.php#8';
	TipURLs[8] = 'http://www.i-brokers.net/pages/faq.php#9';
	TipURLs[9] = 'http://www.i-brokers.net/pages/faq.php#10';
	TipURLs[10] = 'http://www.i-brokers.net/pages/faq.php#11';
	TipURLs[11] = 'http://www.i-brokers.net/pages/faq.php#12';
	TipURLs[12] = 'http://www.i-brokers.net/pages/faq.php#13';
	TipURLs[13] = 'http://www.i-brokers.net/pages/faq.php#14';
	TipURLs[14] = 'http://www.i-brokers.net/pages/faq.php#15';
	TipURLs[15] = 'http://www.i-brokers.net/pages/faq.php#16';
	TipURLs[16] = 'http://www.i-brokers.net/pages/faq.php#18';
	TipURLs[17] = 'http://www.i-brokers.net/pages/faq.php#19';
	
	//Private vars.	
	LastRandom = null;	
	FirstRun = true;	
	
	FadeObj = new fx.Opacity(Tip, {duration: Duration});
	
	//Let the initial one sit for a bit?
	//setTimeout('ShowTip()', RotateSpeed);
	ShowTip();
}

//The next three functions are about the text fader and
//sadly have to be split up because javascript has no wait/sleep.
//They're best read straight through as one or two functions.
function ShowTip()
{
	FadeObj.toggle();
	//Add some extra hang time after the fade.
	setTimeout('FlipTip()', Duration+Hangtime);
}

function FlipTip()
{	
	Number = GetRandomNumber();
	Tip.innerHTML = '<div id="tiptext">' + 
							Tips[Number] + 
							'</div><div id="tipclick">' + 
							'<a href="'+TipURLs[Number]+'">' +
							'Find out more &raquo;</a></div>';
							
							
	FadeObj.toggle();	
	setTimeout('ShowTip()', RotateSpeed);
}

function GetRandomNumber()
{
	RandomNumber = Math.round((Tips.length - 1)*Math.random());
	//Don't want to show the same one twice in a row. 
	if(RandomNumber == LastRandom)
	{
		RandomNumber = GetRandomNumber();	 
	}

	LastRandom = RandomNumber;
	
	return RandomNumber;
}


//Time for the suckerfish code.
sfHover = function() {
	var sfEls = document.getElementById("interface").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
