// the syntax of the customer names should come from the directory name where the actual files are stored (the below elements are used to compile URLs below, so it is important that they are accurate)


var arrCustomers= [];
arrCustomers[0] = 'Scott and Angie Williams';
arrCustomers[1] = 'Norma Linden';
arrCustomers[2] = 'Allen Mann';
arrCustomers[3] = 'Janet and Rick Bowers';
arrCustomers[4] = 'Karen Schumann';
arrCustomers[5] = 'Terry Bellefleur';
arrCustomers[6] = 'Heartbilt Homes';


fisherYates(arrCustomers); // randomizing function

var arrInfoPageURL=[];
var arrSmallBannerURL=[];
var arrQuoteTxtURL=[];
var strMainBannerURL;

for (intCounter=0;intCounter<=arrCustomers.length-1;intCounter=intCounter+1)
{
	arrInfoPageURL[intCounter] = arrCustomers[intCounter] + '/infopage.html' //url to the customer's referral page
	arrSmallBannerURL[intCounter] = arrCustomers[intCounter] + '/banner_small.jpg' //url for the customer's big banner image
	strMainBannerURL = arrCustomers[0] + '/banner.jpg' //url for the customer's small banner image
	arrQuoteTxtURL[intCounter] = loadFile(arrCustomers[intCounter] + '/mainquote.txt') //url for the customer's quote text
	//alert('arrInfoPageURL[' + intCounter + ']: ' + arrInfoPageURL[intCounter]);
	//alert('arrSmallBannerURL[' + intCounter + ']: ' + arrSmallBannerURL[intCounter]);
	//alert('strMainBannerURL: ' + strMainBannerURL);
	//alert('arrQuoteTxtURL[' + intCounter + ']: ' + arrQuoteTxtURL[intCounter]);
	//intCounter=intCounter+1;
	//alert('hello');
}

document.getElementById('rotate_mainbannerurl').src = strMainBannerURL;

for (intCounter=0;intCounter<=arrCustomers.length-1;intCounter=intCounter+1)
{
	//document.getElementById('rotate_infopageurl' + intCounter).src = arrSmallBannerURL[intCounter];
	document.getElementById('rotate_titletxt' + intCounter).innerHTML = arrCustomers[intCounter];
	document.getElementById('rotate_smallbannerurl' + intCounter).src = arrSmallBannerURL[intCounter];
	document.getElementById('rotate_quotetxturl' + intCounter).innerHTML = arrQuoteTxtURL[intCounter];
}

// alert('got here');

// var temp = loadFile("file:///c:/temp/test.txt");

// alert(temp);

function fisherYates(myArray) 
{
	var i = myArray.length;
	if ( i == 0 ) return false;
	while ( --i ) 
	{
		var j = Math.floor( Math.random() * ( i + 1 ) );
		var tempi = myArray[i];
		var tempj = myArray[j];
		myArray[i] = tempj;
		myArray[j] = tempi;
	}
}

function loadFile(url)
{
	var req = false;
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest && !(window.ActiveXObject))
	{
		try { req = new XMLHttpRequest() }
		catch(e) { req = false }
	}
	else // branch for IE/Windows ActiveX version
	{
		if (window.ActiveXObject)
		{
			try { req = new ActiveXObject("Msxml2.XMLHTTP") }
			catch(e)
			{ 
				try { req = new ActiveXObject("Microsoft.XMLHTTP") }
					catch(e) { req = false }
			}
		}
	}
	if(req)
	{
		req.open("GET", url, false);
		req.send("");
		return req.responseText
	}
	return ''
} 