// If you want the quotebox to be hidden until the user scrolls the
// page down past a certain element, then set this variable to the
// id of that element.  Otherwise set it to null ('').
//
var element_below_which_quotebox_will_be_displayed = '';

var quotebox_display_time = 9200; // in milliseconds.


// Don't change these a, b, and c variables until after you've got
// the quotebox working properly.
//
var a = '<div class="quote">';
var b = '</div><div class="author">&#8211; ';
var c = '</div>';


// You can specify different quotes for different pages on your site,
// or just delete these if/else lines leaving only the quotes.push()
// lines -- then all your quotes will be the same on all pages of your
// site.
//
var quotes = new Array;

	quotes.push(a + "They do a wonderful job for me.  The prices are good.  They accommodate in every way that they can." + b + "Robin Persoon" + c);
	quotes.push(a + "They bend over backwards for me." + b + "Nadine Grigsby" + c);
//	quotes.push(a + "I think we get great service from them. We get great prices. They take good care of their customers!" + b + "Mike Esposito" + c);
	quotes.push(a + "Their customer service is exceptional.  I have never had a quality complaint with them." + b + "Mark Reiners" + c);
	quotes.push(a + "They're very easy to deal with.  They ship on time, they respond quickly and satisfactory." + b + "Jim Martensen" + c);
	quotes.push(a + "Madison Forms has continuously produced great customer service and superior quality throughout the years I have worked with them.  They are quick to respond and have yet to disappoint in their efforts." + b + "Catherine Iannuzzi" + c);
	quotes.push(a + "Worked with Madison Forms for years.  Very service and quality oriented." + b + "Ed Szafranski" + c);
	quotes.push(a + "I like Madison Forms' quality, service, and people." + b + "Kerry Nemec" + c);
	quotes.push(a + "Madison Forms is a great company!" + b + "Nadine Grigsby" + c);
	quotes.push(a + "Very confident in Madison Forms.  Good supplier." + b + "Tanya Peterson" + c);
//	quotes.push(a + "Everything runs very smoothly with them.  They always follow-up with me." + b + "Angela Hall" + c);


//
// You probably don't need to change anything below here.
//

var curquote = -1;

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent)
		{
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function topOfElement(eID)
{
	var i = findPos(document.getElementById(eID));
	return i[1];
}

function position_quotebox()
{
	if(document.body)
	{
		var disp = '';
		if(navigator.userAgent.indexOf("MSIE 5") > -1 || navigator.userAgent.indexOf("MSIE 6") > -1)
		{
			// IE <7 don't support position:fixed.
			disp = 'block';
		}
		else
		{
			var scrollpos = window.pageYOffset ? window.pageYOffset : document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
			if(element_below_which_quotebox_will_be_displayed != ''   &&   document.getElementById(element_below_which_quotebox_will_be_displayed)   &&   scrollpos < topOfElement(element_below_which_quotebox_will_be_displayed))
			{
				disp = 'none';
			}
			else
			{
				disp = 'block';
			}
		}
		document.getElementById("quotebox").style.display = disp;
	}
}

function init_quotebox()
{
	display_quote();
	position_quotebox();
	setInterval("rotate_quotebox()", quotebox_display_time);
}

function rotate_quotebox()
{
	if(document.getElementById("quotebox").style.display == 'none')
		return;
	for(i=90; i>=0; i-=10)
	{
		var delay = (100 - i) * 10;
		setTimeout("set_opacity('quotebox'," + i + ")", delay);
	}
	setTimeout("display_quote()", 1050);
	setTimeout("set_opacity('quotebox',100)", 1060);
}

function display_quote()
{
	curquote++;
	if(curquote >= quotes.length) { curquote = 0; }
	document.getElementById("quotebox-inner").innerHTML = quotes[curquote];
}

function set_opacity(eID,opVal)
{
	var newvalue = opVal == 100 ? opVal : '.' + opVal;
	document.getElementById(eID).style.opacity = newvalue;
}


function schedule_onload_action(newfunc)
{
	var already_scheduled = window.onload;
	if(typeof window.onload != 'function')
	{
		window.onload = newfunc;
	}
	else
	{
		window.onload = function()
		{
			already_scheduled();
			newfunc();
		}
	}
}

function schedule_onresize_action(newfunc)
{
	var already_scheduled = window.onresize;
	if(typeof window.onresize != 'function')
	{
		window.onresize = newfunc;
	}
	else
	{
		window.onresize = function()
		{
			already_scheduled();
			newfunc();
		}
	}
}

function schedule_onscroll_action(newfunc)
{
	var already_scheduled = window.onscroll;
	if(typeof window.onscroll != 'function')
	{
		window.onscroll = newfunc;
	}
	else
	{
		window.onscroll = function()
		{
			already_scheduled();
			newfunc();
		}
	}
}

schedule_onload_action(init_quotebox);
schedule_onresize_action(position_quotebox);
schedule_onscroll_action(position_quotebox);

