//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 links=new makeArray("http://www.thebeaurivage.com/","http://www.monacoresortandspa.com/welcome.html","http://rivierafl.com/index2.html","http://www.thesttropez.com/index.html","http://www.evergreenlakes.com/main/","http://www.twocityplaza.com/","http://www.sanmatera.com/index2.html","http://www.theedgewestpalm.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=Christopher+Pointe","http://www.thepalladio.net/","http://www.panoramatowers.com/index2.html","http://www.royaltonhouston.com/","http://gardenspointe.com/","http://www.auracondos.com/","http://www.axiscondos.com/","http://www.buildingsolutionsllc.com/communities/sanctuary.html","http://www.ironwoodproperties.com/magnolia_court/overview.html","http://www.kolterprop.com/residential_detail.php?id=12","http://www.lakeshoreandersen.com/index.htm","http://www.newcenturycompanies.com/displayProp.asp?ID=56","http://www.newcenturycompanies.com/HCBoynton.htm","http://www.newcenturycompanies.com/RoyalP.html","http://www.nobebay.com/contact.asp","http://www.sailclubclearlake.com/welcome.html","http://www.scottsdalebelleview.com/","http://www.sebringbuilders.com/vantage/index.html","http://www.thedomani.com/","http://www.theplazaresidencesaz.com/index1.html","http://www.valenciagrande.com/","http://www.villaalhambra.com/","http://www.villazamora.com/","http://www.taocondos.com/","http://www.atlanticmarinaholdings.com/projects.html","http://www.atlanticmarinaholdings.com/projects.html","http://www.buildingsolutionsllc.com/communities/cypress.html","http://www.calibercommunities.com/SanTan/index.html","http://www.charlestonwetslip.com/","http://www.embassy1414.com/indexFlash.htm","http://www.ikonhayfield.com/","http://www.kolter.com/residential_detail.php?id=24","http://www.marlinbay-keys.com/","http://www.northshoreresidences.net/index.shtml","http://www.stellalife.com/indexFlash.htm","http://www.witherspreserve.com/","http://www.chesapeaketempe.com/","http://www.westoverparc.com/","http://www.lakesidevillageaz.com/","http://www.themontego.com/","http://www.northparcliving.com/","http://www.theallisonscottsdale.com/","http://www.marabrisa.com/","http://www.hawthornephoenix.com/","http://www.loftsatarcadia.com/","http://www.urbanicemiami.com/","http://urbanicemiami.com/elcolonial/index.html","http://urbanicemiami.com/aquabriza/index.html","http://urbanicemiami.com/puertonuevo/index.html","http://www.carlyleresidences.com/");
var images=new makeArray("01beaurivage.jpg","02monaco.jpg","03riviera.gif","04stTropez.gif","05evergreenlakes.gif","06twocityplaza.jpg","07sanmatera.gif","08theedge.gif","09kingsview.gif","10springmeadows.gif","11oakcreek.gif","12christopherpointe.gif","13palladio.gif","14panorama.gif","15royalton.gif","16gardenspointe.gif","17aura.jpg","18Axis.gif","19sanctuary.gif","20magnoliacourt.jpg","21sanmerano.jpg","22lakeshore.gif","23segoviasquare.jpg","24heritageclub.jpg","25royalpoinciana.jpg","26nobebay.gif","27sailclubclearlake.jpg","28scottsdalebelleview.jpg","29vantagepointe.gif","30domani.gif","31theplaza.gif","32valenciagrande.gif","33villaalhambra.gif","34villazamora.gif","35tao.gif","36harborageftlauderdale.gif","37harboragepalmbeach.gif","38cypresskey.jpg","39santan.jpg","40harborageashley.jpg","41embassy.jpg","42ikonhayfield.jpg","43canopycreek.jpg","44marlinbay.jpg","45northshore.gif","46stella.jpg","47witherspreserve.jpg","48chesapeake.jpg","49westoverpark.jpg","50lakesidevillage.jpg","51montego.jpg","52northparc.jpg","53allison.jpg","54marabrisa.jpg","55hawthorne.jpg","56arcadia.jpg","57losjardines.jpg","58elcolonial.jpg","59aquabriza.jpg","60puertonuevo.jpg","61carlyle.jpg");

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];

}
