var ar = Array(
["error","error-full.jpg","error-thumb.jpg",""],
["altercare","altercare-full.jpg","altercare-thumb.jpg",""],
["artworks","artworks-full.jpg","artworks-thumb.jpg",""],
["bigrapids","bigrapids-full.jpg","bigrapids-thumb.jpg",""],
["brfurn","brfurn-full.jpg","brfurn-thumb.jpg","redirect-to/big-rapids-furniture.htm"],
["c21","c21-full.jpg","c21-thumb.jpg",""],
["cards","cards-full.jpg","cards-thumb.jpg",""],
["carpets","carpets-full.jpg","carpets-thumb.jpg",""],
["chemical","chemical-full.jpg","chemical-thumb.jpg",""],
["coldwell","coldwell-full.jpg","coldwell-thumb.jpg","redirect-to/coldwell-banker.htm"],
["corptitle","corptitle-full.jpg","corptitle-thumb.jpg",""],
["countryinn","countryinn-full.jpg","countryinn-thumb.jpg",""],
["creative","creative-full.jpg","creative-thumb.jpg",""],
["curves","curves-full.jpg","curves-thumb.jpg",""],
["development","development-full.jpg","development-thumb.jpg",""],
["downtown","downtown-full.jpg","downtown-thumb.jpg",""],
["eugenias","eugenias-full.jpg","eugenias-thumb.jpg",""],
["eyecenter","eyecenter-full.jpg","eyecenter-thumb.jpg",""],
["fifththird","fifththird-full.jpg","fifththird-thumb.jpg",""],
["fsu1","fsu1-full.jpg","fsu1-thumb.jpg",""],
["fsu2","fsu2-full.jpg","fsu2-thumb.jpg",""],
["fsudining","fsudining-full.jpg","fsudining-thumb.jpg",""],
["helpusell","helpusell-full.jpg","helpusell-thumb.jpg",""],
["icemountain","icemountain-full.jpg","icemountain-thumb.jpg","redirect-to/ice-mountain.htm"],
["isabella","isabella-full.jpg","isabella-thumb.jpg",""],
["karls","karls-full.jpg","karls-thumb.jpg",""],
["lions","lions-full.jpg","lions-thumb.jpg",""],
["mcmc","mcmc-full.jpg","mcmc-thumb.jpg",""],
["mota","mota-full.jpg","mota-thumb.jpg","redirect-to/mecosta-osceola-transit-authority.htm"],
["orthop","orthop-full.jpg","orthop-thumb.jpg",""],
["pg","pg-full.jpg","pg-thumb.jpg",""],
["preference","preference-full.jpg","preference-thumb.jpg",""],
["ptplus","ptplus-full.jpg","ptplus-thumb.jpg",""],
["rogers","rogers-full.jpg","rogers-thumb.jpg",""],
["rr","rr-full.jpg","rr-thumb.jpg",""],
["schubergs","schubergs-full.jpg","schubergs-thumb.jpg",""],
["silvernail","silvernail-full.jpg","silvernail-thumb.jpg","redirect-to/silvernail-realty.htm"],
["soaring","soaring-full.jpg","soaring-thumb.jpg",""],
["stevejones","stevejones-full.jpg","stevejones-thumb.jpg",""]
);

//var feat = Array("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22");
var feat = Array("welcome-to-mecosta-county","year-of-the-dawg","mecosta-county-alliance","restauranthotel-guide","hitting-the-fairway","the-villages-at-tullymore","lets-walk-big-rapids","fun-things-to-do-in-mecosta-county","legends-ranch","ferris-state-university","festival-of-the-arts","susan-p-wheatlake-foundation","taking-care-of-business","a-very-caring-community","blue-cow-cafe","downtown-big-rapids","small-business","from-small-town-to-the-show","farmers-market","leading-a-frazzled-life","raising-profits","creating-future-successes");

// return array of six unique feature banners
function getUniqueFeatures()
{
	feats = new Array(6);
	i = 0;
	j = 0;
	
	// fill the array and make sure the values are unique
	while (i < 6)
	{
		feats[i] = getRandomFeature();
		j = i - 1;
		while (j > -1)
		{
			if (feats[i] == feats[j])
			{
				i--;
				break;
			}
			j--;
		}
		i++;
	}
	
	return feats;
}

// return array of five unique random ads
function getFiveUniqueAds()
{
	ads = new Array(5);
	i = 0;
	j = 0;
	
	// fill the array and make sure the values are unique
	while (i < 5)
	{
		ads[i] = getRandomAd();
		j = i - 1;
		while (j > -1)
		{
			if (ads[i] == ads[j])
			{
				i--;
				break;
			}
			j--;
		}
		i++;
	}
	
	return ads;
}

// returns a random feature-name 
function getRandomFeature()
{
	n = Math.floor(Math.random() * feat.length);
    return feat[n];
}


// returns a random ad-name 
function getRandomAd()
{
    n = 0
    while (n == 0) // never return error pic
    {
	    n = Math.floor(Math.random() * ar.length);
	}
    return ar[n][0];
}

// return array index of given adName
function getAdIndex(adName)
{
	num = 0;
	i = 0;
	
	while (i < ar.length)
	{
		if (ar[i][0] == adName)
		{
			num = i;
			break;
		}
		
		i++;
	}
	
	return num;
}

// returns URL of ad-button pic
function getSmallPicURL(adName)
{
	return ar[getAdIndex(adName)][2];
}

// returns URL of large ad pic
function getLargePicURL(adName)
{
	return ar[getAdIndex(adName)][1];
}

// returns click-through link URL (to IIS redirector)
function getLink(adName)
{
	return ar[getAdIndex(adName)][3];
}

// returns whether or not this ad has a click-through URL
function hasClickthrough(adName)
{
	ret = false;

	if (ar[getAdIndex(adName)][3] != "")
		ret = true;
	
	return ret;
}

// returns whether or not this ad has a link
function hasLink(adName)
{
	if (ar[getAdIndex(adName)][3] == "")
		return false;
	
	return true;
}

// returns a link to this ad's site
function getLinkURL(adName)
{
	return ar[getAdIndex(adName)][3];
}

