function start() {
	backToTop();
	rotateQuotes();
	} 
	 
	window.onload = start; 

// START OF BACK TO TOP CODE


function backToTop(box, options, index)
{
    this.targetX = 530;
    this.targetY =  -450;
    this.interval = 50;
    this.menu = box;
    this.index = index;
    this.options = options;
    this.hasInner = typeof(window.innerWidth) == 'number';
    this.hasElement =  document.documentElement
        && document.documentElement.clientWidth;    
	this.move = function ()
	{//move function start
		jQuery(this.menu).css('left', this.nextX + 'px').css('top', this.nextY + 'px');
	};  
	this.computeShifts = function ()
	{
	    var de = document.documentElement;	
	    this.shiftX =
	        this.hasInner
	        ? pageXOffset
	        : this.hasElement
	          ? de.scrollLeft
	          : document.body.scrollLeft;
/*	    if (this.targetX < 0)
	    {
	        if (this.hasElement && this.hasInner)
	        {
	            // Handle Opera 8 problems
	            this.shiftX +=
	                de.clientWidth > window.innerWidth
	                ? window.innerWidth
	                : de.clientWidth
	        }
	        else
	        {
	            this.shiftX +=
	                this.hasElement
	                ? de.clientWidth
	                : this.hasInner
	                  ? window.innerWidth
	                  : document.body.clientWidth;
	        }
	    }
*/	
	    this.shiftY = 
	        this.hasInner
	        ? pageYOffset
	        : this.hasElement
	          ? de.scrollTop
	          : document.body.scrollTop;
	    if (this.targetY < 0)
	    {
	        if (this.hasElement && this.hasInner)
	        {
	            // Handle Opera 8 problems
	            this.shiftY +=
	                de.clientHeight > window.innerHeight
	                ? window.innerHeight
	                : de.clientHeight
	        }
	        else
	        {
	            this.shiftY +=
	                this.hasElement
	                ? document.documentElement.clientHeight
	                : this.hasInner
	                  ? window.innerHeight
	                  : document.body.clientHeight;
	        }
	    }
	};
	this.doFloat = function()
	{
	    var stepX, stepY;
	
	    this.computeShifts();
	
	    stepX = (this.shiftX + 
	        this.targetX - this.nextX) * .07;
	    if (Math.abs(stepX) < .5)
	    {
	        stepX = this.shiftX +
	            this.targetX - this.nextX;
	    }
	
	    stepY = (this.shiftY + 
	        this.targetY - this.nextY) * .07;
	    if (Math.abs(stepY) < .5)
	    {
	        stepY = this.shiftY + 
	            this.targetY - this.nextY;
	    }
	
	    if (Math.abs(stepX) > 0 ||
	        Math.abs(stepY) > 0)
	    {
	        this.nextX += stepX;
	        this.nextY += stepY;
	        this.move();
	    }
		
	    setTimeout('funcFloating[' + this.index + '].func()', this.interval);
	};	
	this.initSecondary = function()
	{
	    this.computeShifts();
	    this.nextX = this.shiftX +
	        this.targetX;
	    this.nextY = this.shiftY +
	        this.targetY;
	    this.move();
	};	
	this.position = function(targetX, targetY)
	{
		if(typeof(targetX) == 'number')
		{
			this.targetX = targetX;
		}else if(typeof(targetX) == 'string')
		{
			switch(targetX)
			{
				case 'left':
					this.targetX = 5;
					break;
				case 'right':
					this.targetX = -((jQuery(this.menu).outerWidth()) + 5);
					break;									
			}
			
		}	
		if(typeof(targetY) == 'number')
		{
			this.targetY = targetY;
		}else if(typeof(targetY) == 'string')
		{
			switch(targetY)
			{
				case 'top':
					this.targetY= 5;
					break;
				case 'bottom':

					this.targetY = -((jQuery(this.menu).outerHeight() + 5));
					
					break;								
			}
			
		}				
		
	};
	this.init = function()
	{
		jQuery(this.menu).css('position', 'absolute');
		if(typeof(this.options)  == 'object')
		{
			for(var i in this.options)
			{
				switch(i)
				{
					
					case 'targetX':
					case 'targetY':
						if(typeof(this.options[i]) == 'number')
						{
							this[i] = this.options[i];
						}else if(typeof(this.options[i]) == 'string')
						{
							switch(this.options[i])
							{
								case 'top':
									this.targetY= 5;
									break;
								case 'bottom':
									this.targetY = -((jQuery(this.menu).outerHeight() + 5));									
									break;
								case 'left':
									this.targetX = 5;
									break;
								case 'right':
									this.targetX = -((jQuery(this.menu).outerWidth()) + 5);
									break;									
							}
							
						}
						break;	
					default:
						this[i] = this.options[i];				
				}
			}
		}		
		
	    this.initSecondary();
	    this.doFloat();
	}
		      
};

// Some browsers init scrollbars only after
// full document load.
var funcFloating = {};
jQuery.fn.floating = function(options)
{
	return jQuery(this).each(
	
		function(i)
		{		
			var nextIndex = 0;
			for(var index in funcFloating)
			{
				nextIndex = parseInt(index);
			}	
			funcFloating[nextIndex + 1] = {};	
			funcFloating[nextIndex + 1].box = this;	
			funcFloating[nextIndex + 1].obj = new backToTop(this, options, (nextIndex + 1));
			funcFloating[nextIndex + 1].func = function(){ funcFloating[nextIndex + 1].obj.doFloat(); };
			if (document.layers)
			{
				funcFloating[nextIndex + 1].obj.init();
			}else
			{
				
				funcFloating[nextIndex + 1].obj.init();
				funcFloating[nextIndex + 1].obj.initSecondary();
			}
			
		}
	);
};
jQuery.fn.floatingPosition = function(targetX, targetY)
{
	return jQuery(this).each(
	
		function(i)
		{	
			for(var j in funcFloating)
			{
				if(funcFloating[j].box == this)
				{
					funcFloating[j].obj.position(targetX, targetY);
				}
			}
			
		}
	);	
};


// END OF BACK TO TOP CODE

// START OF ROTATING QUOTES CODE


function makeQuotes(q){
      this.quote = q;
      this.write = writeQuotes;
   }

function makeAuthor(a,l,f){
	this.author = a;
	this.link = l;
	this.follow = f;
	this.write2 = writeAuthor;
}

   function writeQuotes(){
      var str = this.quote;
      return str;
   }

function writeAuthor(){
	var str = '';
	str += this.author + '<br>';
        str +=  '<a href="' + this.link + '">' + this.follow + '</a>';
	return str;
}

var authorArray = new Array();

/*
authorArray[0] = new makeAuthor("Move Items Between Lists With JavaScript",'http://sfmktgdev02.penscotrust.com/company/testimonials.aspx#','Read More').write2();

authorArray[1] = new makeAuthor("Build an XML-Based Tree Control With JavaScript",'http://www.devx.com/getHelpOn/Article/11874','Read More').write2();

authorArray[2] = new makeAuthor("Automate Your Form Validation",'http://www.devx.com/gethelpon/10MinuteSolution/16474','Read More').write2();
*/

   authorArray[0] = new makeAuthor(
       "David Dewar <br> - -Attendee- - <br>Chicago",
       'http://sfmktgdev02.penscotrust.com/company/testimonials.aspx',
       'Read More').write2();

   authorArray[1] = new makeAuthor(
       "Jay Michalowski <br>- -President- - <br>First IRA Mortgage",
       'http://sfmktgdev02.penscotrust.com/company/testimonials.aspx',
       'Read More').write2();

   authorArray[2] = new makeAuthor(
       "John W. Tedmon <br>- -President- - <br>Financial Forum Group, LLC",
       'http://sfmktgdev02.penscotrust.com/company/testimonials.aspx',
       'Read More').write2();

var quotesArray = new Array();
   quotesArray[0] = new makeQuotes(
      "Very excellent educational material on the different self-directed investment options available!").write();

   quotesArray[1] = new makeQuotes(
      "The show was a 10 out of 10 for First IRA Mortgage.").write();

   quotesArray[2] = new makeQuotes(
      "...one of the best Financial symposiums I have attended in 35 years").write();



var nIndex = 0;
var timerID = null;
function rotateQuotes(){
	var len = quotesArray.length;
	if(nIndex >= len)
		nIndex = 0;
	document.getElementById('sbR_clientQuotes_quote').innerHTML = quotesArray[nIndex];
	document.getElementById('sbR_clientQuotes_author').innerHTML = authorArray[nIndex];
	nIndex++;
	timerID = setTimeout('rotateQuotes()',6000);
}
function pauseQuotes() {
	if (timerID != null) {
		clearTimeout(timerID);
		timerID = null;
	}
}

function playQuotes() {
	if (timerID == null) {
		timerID = setTimeout('rotateQuotes()', 1000);
	}
}



// END OF ROTATING QUOTES CODE









