// Image rotator for home page, top left image
var theImages1 = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array.

theImages1[0] = 'images/fanatics/1image4.png'
theImages1[1] = 'images/fanatics/1image6.png'
theImages1[2] = 'images/fanatics/1image7.png'
theImages1[3] = 'images/fanatics/1image8.png'
theImages1[4] = 'images/fanatics/1image9.png'
theImages1[5] = 'images/fanatics/1image10.png'
theImages1[6] = 'images/fanatics/1image11.png'
theImages1[7] = 'images/fanatics/1image12.png'
theImages1[8] = 'images/fanatics/1image13.png'
theImages1[9] = 'images/fanatics/1image14.png'

// do not edit anything below this line

var j = 0
var p = theImages1.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages1[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage1(){
document.write('<img src="'+theImages1[whichImage]+'" class="left bbone" width="250" height="150" alt="">');
}

// Image rotator for home page, top left image
var theImages2 = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array.

theImages2[0] = 'images/fanatics/2image15.png'
theImages2[1] = 'images/fanatics/2image16.png'
theImages2[2] = 'images/fanatics/2image17.png'
theImages2[3] = 'images/fanatics/2image18.png'
theImages2[4] = 'images/fanatics/2image19.png'
theImages2[5] = 'images/fanatics/2image20.png'
theImages2[6] = 'images/fanatics/2image21.png'
theImages2[7] = 'images/fanatics/2image22.png'
theImages2[8] = 'images/fanatics/2image24.png'
theImages2[9] = 'images/fanatics/2image25.png'


// do not edit anything below this line

var j = 0
var p = theImages2.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages2[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage2(){
document.write('<img src="'+theImages2[whichImage]+'" class="right bbtwo" width="250" height="150" alt="">');
}

// Image rotator for home page, top left image
var theImages3 = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array.

theImages3[0] = 'images/fanatics/3cc_09.03-C.png'
theImages3[1] = 'images/fanatics/3cc_09.03-D.png'
theImages3[2] = 'images/fanatics/3cc_09.03-E.png'
theImages3[3] = 'images/fanatics/3cc_09.03-G.png'
theImages3[4] = 'images/fanatics/3cc_09.03-J.png'
theImages3[5] = 'images/fanatics/3cc_09.03-K.png'
theImages3[6] = 'images/fanatics/3cc_09.03-L.png'
theImages3[7] = 'images/fanatics/3image0.png'
theImages3[8] = 'images/fanatics/3image3.png'

// do not edit anything below this line

var j = 0
var p = theImages3.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages3[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage3(){
document.write('<img src="'+theImages3[whichImage]+'" class="left bbthree" width="250" height="150" alt="">');
}


// locator code

function Querystring(qs) { // optionally pass a querystring to parse
	this.params = {};
	
	if (qs == null) qs = location.search.substring(1, location.search.length);
	if (qs.length == 0) return;

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&'); // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i = 0; i < args.length; i++) {
		var pair = args[i].split('=');
		var name = decodeURIComponent(pair[0]);
		
		var value = (pair.length==2)
			? decodeURIComponent(pair[1])
			: name;
		
		this.params[name] = value;
	}
}

Querystring.prototype.get = function(key, default_) {
	var value = this.params[key];
	return (value != null) ? value : default_;
}

Querystring.prototype.contains = function(key) {
	var value = this.params[key];
	return (value != null);
}

//function checkAddress()
//{
//	// Parse the current page's querystring
//	var qs = new Querystring();
//	var address = '';
//	if (qs.contains("fAddress"))
//	{
//		address= qs.get("fAddress");
//		document.getElementById('addressInput').value = address;
//		searchLocations();
//	}	
//}

// Fader for top banners

// Boolean for browser type
var agt=navigator.userAgent.toLowerCase();
var is_Opera = (navigator.userAgent.indexOf('Opera') != -1); 
var is_MSIE = (navigator.userAgent.indexOf('MSIE') != -1); 
var is_Moz = (navigator.userAgent.indexOf('Gecko') != -1); 
var is_nav = (navigator.userAgent.indexOf('Netscape') != -1 && navigator.userAgent.indexOf('Gecko') != -1);

var arrColors_Black = new Array('000000','3C3C3C','787878','B4B4B4','ffffff','ffffff','B4B4B4','787878','3C3C3C','000000');
var arrColors_Red = new Array('D21033','da5750','e17f70','efbbae','ffffff','ffffff','efbbae','e17f70','da5750','D21033');

// Object class for sign text
function SignText(quote, source)
{
	this.quote = quote;
	this.source = source;
}

// Main function to call from body onLoad
function signsLoader(nCount)
{
	sFunction = 'setOverallTiming(' + nCount + ');';
	for(var x = 1; x < 100; x++)
	{
		setTimeout(sFunction, 10000 * x);
	}
}

// Sets the timing for each set of signs
function setOverallTiming(nCount)
{
	// an array that stores the signText indexes, to prevent duplicates
	// prepopulate with -1's
	var arrSignTextIndexes = new Array(nCount);
	for(var i = 0; i < arrSignTextIndexes.length; i++)
	{
		arrSignTextIndexes[i] = -1;
	}
	
	// replace each signs text with random text from the array
	var obj = null;
	var signText = null;
	for(var x = 0; x < nCount; x++)
	{	
		// Assign a random text replacement
		// Ensure no duplicates	
		var bCheck = true;
		var ran = 0;
		while(bCheck)
		{
			ran = Math.round(Math.random() * (arrSignTexts.length-1) );
			//alert('ran=' + ran);
			var temp = '';
			for(i = 0; i < arrSignTextIndexes.length; i++)
			{
				if(arrSignTextIndexes[i] == ran)
				{
					//alert('false');
					bCheck = false;
				}
				temp = temp + '-' + arrSignTextIndexes[i];
			}
			//alert('temp=' + temp);
			if(bCheck)
			{
				signText = arrSignTexts[ran];
				arrSignTextIndexes[x] = ran;
				// Force false to exit while loop
				bCheck = false;
			}
			else
			{
				bCheck = true;
			}
		}
		
		// Get the sign div, fade out old text, replace with new, fade in new text
		sFunction = 'setColorTiming(' + nCount + ', ' + x + ', "' + signText.quote + '", "' + signText.source + '");';
		setTimeout(sFunction, 100 * (x + 1) * i);
	}
}

function setColorTiming(nCount, nDIV, sQuote, sSource)
{
	// Get a handle to each sign div
	var arrSignDIVs = new Array(nCount);
	var signID = '';
	signID = 1 + nDIV;
	for(i = 0; i < arrColors_Black.length; i++)
	{
		sFunction = 'colorElement("' + signID + '", \'' + sQuote + '\', \'' + sSource + '\', ' + i + ')';
		setTimeout(sFunction, 100 * i);
	}	
}

// Changes the color and sets the HTML if needed
function colorElement(signID, sQuote, sSource, nColor)
{	
	var oQuote = getDocumentObject('signQuote' + signID);
	var oSource = getDocumentObject('signSource' + signID);
	
	oQuote.style.color = '#' + arrColors_Red[nColor];
	//oQuote.fontSize = '1.4em';
	oSource.style.color = '#' + arrColors_Black[nColor];
	
	// If the halfway point, the color should match the background (white atm)
	// If so, time to swap the text (so it isn't noticed)
	if( (arrColors_Black.length / 2) == nColor )
	{
		oQuote.innerHTML = '&ldquo;' + sQuote + '&rdquo;';
		oSource.innerHTML = sSource;
	}
}



function faderDebug()
{
	alert(sFade_Color_All);
}

// General function to get a DOM object by ID, considering differnt browsers
function getDocumentObject(id)
{
	var obj = null;
	if( is_nav )
	{
		obj = eval("document.ids." + id);
	}
	else
	{
		obj = document.getElementById(id);
	}
	return obj;
}