//Here we load the link data for the random candidates.
//Note:We will call the images by number located in RandomClient folder

var imagedir = 'images/RandomClients/';
//var Nshow = 5;
var Nshow = 25;

var links = new makeArray("http://www.shemcreekmarina.com/", "http://www.theharborageatashleymarina.com/", "http://www.realtor.com", "http://kingwestlofts.ca/new-sales-0", "http://www.realtor.com", "http://www.monacoresortandspa.com/welcome.html", "http://www.thearborsflagstaff.com/", "http://www.theplazaresidencesaz.com/index1.html", "http://www.arizonabiltmore.com/", "http://www.brickcommons.com/", "http://www.buildingsolutionsllc.com/communities/courtyards.html", "http://www.buildingsolutionsllc.com/communities/sanctuary.html", "http://www.ironwoodproperties.com/magnolia_court/overview.html", "http://www.realtor.com", "http://www.buildingsolutionsllc.com/communities/heritage.html", "http://www.realtor.com", "http://www.buildingsolutionsllc.com/communities/cypress.html", "http://www.buildingsolutionsllc.com/communities/atlantica.html", "http://www.gatortracecountryclub.com/", "http://www.buildingsolutionsllc.com/communities/sanctuary.html", "http://www.realtor.com", "http://www.realtor.com", "http://www.realtor.com", "http://www.theallisonscottsdale.com/", "http://www.realtor.com", "http://www.indianterrace.com/", "http://www.adobemanor.com/", "http://www.realtor.com", "http://www.realtor.com", "http://www.realtor.com", "http://www.realtor.com", "http://www.realtor.com", "http://www.realtor.com", "http://sierraverdevillas.com/features.html", "http://www.mosaichouston.com/", "http://www.realtor.com", "http://www.bartonplaceaustin.com/?gclid=CLjr4sacy60CFYPc4AodOhVkgw", "http://www.realtor.com", "http://www.realtor.com", "http://www.endeavourcondo.com/", "http://www.eloquencecondo.com/", "http://www.infinityatbrickell.com/", "http://www.downtowndoral.com/", "http://www.realtor.com", "http://www.realtor.com", "http://www.thepalmshotelandvillas.com/", "http://www.fontainebleau.com/", "http://www.laprivadaapartments.com/", "http://www.terramiamibeach.com/", "http://www.44monroe.com/", "http://www.oneqrp.com/", "http://www.realtor.com", "http://www.realtor.com", "http://www.kandpbuilders.com/communities/community.asp?comm=Christopher+Pointe", "http://www.realtor.com", "http://www.realtor.com", "http://www.kandpbuilders.com/communities/community.asp?comm=Garretts+Chance", "http://eastonvillage.com/", "http://www.kandpbuilders.com/communities/community.asp?comm=Kingsview", "http://www.kandpbuilders.com/communities/community.asp?comm=Spring+Meadows", "http://www.kandpbuilders.com/communities/community.asp?comm=Oak+Creek", "http://www.kandpbuilders.com/communities/community.asp?comm=Sailors+Quay", "http://www.kandpbuilders.com/communities/community.asp?comm=Strawberry+Glenn", "http://www.evergreenlakes.com/main/", "http://www.twocityplaza.com/", "http://www.realtor.com", "http://gardenspointe.com/", "http://www.realtor.com", "http://www.realtor.com", "http://www.kolterhomes.com/communities/6/paloma/", "http://www.kolterhomes.com/communities/29/nature-walk/", "http://www.kolterhomes.com/communities/5/grande-oaks-at-heathrow/", "http://www.kolterhomes.com/communities/20/lost-river/", "http://www.kolterhomes.com/communities/23/Lake%20Lanier/", "http://www.4001northocean.com/photo-gallery-images-photos-pictures-4001-north-ocean-florida.asp", "http://www.realtor.com", "http://www.canyonranch.com/miamibeach/", "http://www.realtor.com", "http://www.realtor.com", "http://www.realtor.com", "http://www.realtor.com", "http://www.realtor.com", "http://www.rsvlt.com/", "http://onethousandocean.com/?gclid=CJfa14jbza0CFUPd4AodPkufCg", "http://skyviewparc.com/en/", "http://www.realtor.com", "http://www.realtor.com", "http://quailwest.com/?gclid=CM6Bzsfaza0CFYPc4AodOhVkgw", "http://missionclubcondos.com/", "http://www.royaltonhouston.com/", "http://www.kandpbuilders.com/communities/community.asp?comm=Oak+Creek", "http://www.realtor.com", "http://www.mayfairhotelandspa.com/", "http://www.toscanaofdesertridge.com/?gclid=CJqnjY_Wza0CFcZM4AodMC1UiQ", "http://www.realtor.com", "http://www.tempeplace.com/", "http://www.ikonhayfield.com/", "http://www.breakwatersouthbeach.com/?WT.srch=1&WT.mc_id=ppc2p&DCSext.ppc_kw=breakwater+hotel+miami+beach&ppc_ac=Brand&ppc_ag=Brand+Broad&ppc_mt=Broad", "http://www.theedgewestpalm.com/");
var images = new makeArray("81ShemCreekMarina.jpg", "97Harborage.jpg", "17aura.jpg", "92Epic.jpg", "18Axis.gif", "02monaco.jpg", "100TheArbors.jpg", "31theplaza.gif", "64Biltmore.jpg", "91BrickCommons.jpg", "04Courtyards.jpg", "19sanctuary.gif", "20magnoliacourt.jpg", "23segoviasquare.jpg", "24heritageclub.jpg", "25royalpoinciana.jpg", "38cypresskey.jpg", "22Atlantica.jpg", "71GatorTrace.jpg", "104Sanctuary.jpg", "29vantagepointe.gif", "48chesapeake.jpg", "50lakesidevillage.jpg", "53allison.jpg", "55hawthorne.jpg", "67IndianTerrace.jpg", "90AdobeManor.jpg", "41embassy.jpg", "49westoverpark.jpg", "51montego.jpg", "52northparc.jpg", "54marabrisa.jpg", "56arcadia.jpg", "95SierraVerde.jpg", "102Mosaic.jpg", "46stella.jpg", "73BartonPlace.jpg", "26nobebay.gif", "61carlyle.jpg", "62Endeavour.jpg", "65Eloquence.jpg", "66Infinity.jpg", "75DowntownDoral.jpg", "13palladio.gif", "35tao.gif", "69ThePalms.jpg", "103Fountainebleau.jpg", "82LaPrivada.jpg", "87TerraBeachside.jpg", "8944Monroe.jpg", "86OneQueensridgePlace.jpg", "14panorama.gif", "03riviera.gif", "12christopherpointe.gif", "27sailclubclearlake.jpg", "45northshore.gif", "77GarrettsChance.jpg", "79EastonVillage.jpg", "09kingsview.gif", "10springmeadows.gif", "63OakCreek.jpg", "68SaylorsQuay.jpg", "78StrawberryGlenn.jpg", "05evergreenlakes.gif", "06twocityplaza.jpg", "07sanmatera.gif", "16gardenspointe.gif", "30domani.gif", "43canopycreek.jpg", "74Paloma.jpg", "80NatureWalk.jpg", "84GrandeOaks.jpg", "85LostRiverPlantation.jpg", "94Cresswind.jpg", "994001NorthOcean.jpg", "21sanmerano.jpg", "76CanyonRanch.jpg", "44marlinbay.jpg", "58elcolonial.jpg", "59aquabriza.jpg", "57losjardines.jpg", "60puertonuevo.jpg", "88Roosevelt.jpg", "101OneThousandOcean.jpg", "70SkyViewParc.jpg", "28scottsdalebelleview.jpg", "13palladio.gif", "72QuailWest.jpg", "98MissionClub.jpg", "15royalton.gif", "11oakcreek.gif", "47witherspreserve.jpg", "83MayfairHotel.jpg", "105Toscana.jpg", "39santan.jpg", "96TempePlace.jpg", "42ikonhayfield.jpg", "93Breakwater.jpg", "08theedge.gif");

var Nlinks = links.length+1;
			
var randoms=new Array(Nshow);

function get_random(i_num)
{
    var ranNum= Math.floor(Math.random()*(i_num+1)) ;
    if (ranNum > i_num) { ranNum = i_num;}

    return ranNum;
}


function LoadImageLink (ran,s_imageID,s_linkID)
{

// loads individual image/link combo randomly
  o_image = document.getElementById(s_imageID);
  o_link = document.getElementById(s_linkID);

// this needs to be declared as "var" for setting o_link.onclick correctly
// don't really know why but works
	var s_link_href = links[ran];
	o_image.src =   imagedir + images[ran];
//	o_link.href = 'http://' + links[ran];

	o_link.onclick=function () {window.open(s_link_href,"","toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes");};
//	o_link.onclick=function () {window.open(s_link_href)};
}

function RandomClients ()
{

//image ID's in html are imgRandomClients1,imgRandomClients2...imgRandomClientsN
//link ID's in html are linkRandomClients1,linkRandomClients2...linkRandomClientsN

   for (var x = 0; x < Nshow; x++) {
// get random number and check for repeats
    repeat = 1;
    while(repeat) {
   		var ran=get_random(Nlinks-1);
   		var repeat = check_repeat(x-1,ran);
	}
	randoms[x]=ran;

   	imageID = 'imgRandomClients' + x ;
   	linkID = 'linkRandomClients' + x ;   	
	LoadImageLink (ran,imageID,linkID) ;   	
   }
   
  }

function check_repeat (N_x,ran) {
	  for (var j = 0; j <= N_x; j++) {
		if(ran == randoms[j]) {
			return 1;
		}	
	}
	return 0;
}

function makeArray() {

     this.length = makeArray.arguments.length-1;

    for (i = 0; i < makeArray.arguments.length; i++)

        this[i] = makeArray.arguments[i];

}

