// JavaScript Document

function printContacts(startNum,numContacts)
{
	// make startNum and numContacts optional
	if(startNum == null)
	{
		var startNum	=	Math.round(100 * Math.random());						// should be the call to the randomizing function.
		if (startNum > AgentArray.length)
			{startNum = startNum - AgentArray.length}
	}
	
 	if(numContacts == null)
	{
		var numContacts	=	2;						// global variable for number of contacts per "page"
	}

	var	hiNum		=	startNum + numContacts;		// set our upper bound for the loop
	var counter		=	0;							// holds count of number of times through the loop
	var contactStr = "";							// holds the string that prints to page
	var defaultphone = "281-894-1000";
	var defaultfax = "281-897-2729";
	var	posFwd	= startNum + numContacts;
	var	posBack	= startNum - numContacts;
	
	if (posFwd >= AgentArray.length)
		{
		posFwd = AgentArray.length - numContacts;
		startNum = posFwd;
		hiNum	=	AgentArray.length;
		}
		
	if (posBack < 1)
	{
		posBack = 1;
		startnum = posBack;
	}
	
	for(i=startNum;i<hiNum;i++){
		counter++;
		if(i >= AgentArray.length)
		{
			i = (AgentArray.length - startNum);
			hiNum = numContacts - counter;			
		} else if (i < 0) {
			i = 0;
			//var tmp = i;
			//i = AgentArray.length + tmp;
		}
		// concatenate together the contacts information
		contactStr  +=  "<div class='frame_set'>";
		contactStr  +=  "<div class='head_shot'>";
		if (AgentArray[i].image == "") {contactStr  +=  "<img style='border: double #000000;' src='http://houstonrealestate24-7.com/files/191530/default.jpg'>" + "</div>";}
		else {contactStr += "<img style='border: double #000000;' src='http://houstonrealestate24-7.com" + AgentArray[i].image + "'></div>"}
		contactStr  +=  "<div class='guts'>";
		contactStr  +=  "<b class='name'>" + AgentArray[i].fname + " " + AgentArray[i].lname + "</b><br /><br />";
		if (AgentArray[i].phone == "") {contactStr += "<b class='info'>" + "Phone: " + defaultphone + "</b><br />"}
		else {contactStr	+=	"<b class='info'>" + "Phone: " + AgentArray[i].phone + "</b><br />";}
		if (AgentArray[i].fax == ""){contactStr  +=  "<b class='info'>" + "Fax: " + defaultfax + "</b><br />";}
		else {contactStr  +=  "<b class='info'>" + "Fax: " + AgentArray[i].fax + "</b><br />";}
		if (AgentArray[i].mobile == ""){contactStr  +=  "<br /><br />";}
		else {contactStr  +=  "<b class='info'>" + "Mobile: " + AgentArray[i].mobile + "</b><br /><br />";}
		if (AgentArray[i].site == ""){contactStr	+=	"<br />";}
		else {contactStr	+=	"<b class='info'><a href='" + AgentArray[i].site + "'>" + "View My Website" + "</a></b><br />";}
		if (AgentArray[i].email != ""){contactStr	+=	"<b class='info'><a href='mailto:" + AgentArray[i].email + "'>" + "Email Me" + "</a></b>";}
		contactStr	+=	"</div></div><br /><br />";
	}
// finished looping, lets give the user paging capabilities.
		contactStr	+=	"<div class='forward'><a href='javascript:printContacts(" + posFwd + "," + numContacts + ");'>Forward " + numContacts + "</a></div>";
		contactStr	+=	"<div class='backward'><a href='javascript:printContacts(" + posBack + "," + numContacts + ");'>Back " + numContacts + "</a></div>";
		
// write the string to the browser.
	writit(contactStr,"target");
}
// Object constructor
function oAgent(lname, fname, phone, fax, mobile, email, image, site) {
	this.fname = fname;
	this.lname = lname;
	this.phone = phone;
	this.fax = fax;
	this.mobile = mobile;
	this.email = email;
	this.image = image;
	this.site = site;
}
// function to write to the document

function printAlpha(letter)
{
var count=0;
while (count < AgentArray.length)
	{
	if (AgentArray[count].lname.charAt(0) = letter)
		{alert (AgentArray[count].lname);
		count++;}
	}
}

function writit(text,id)
{
	if (document.getElementById)
	{
		x = document.getElementById(id);
		x.innerHTML = '';
		x.innerHTML = text;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML = text;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		text2 = '<p>' + text + '</p>';
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}

// Array Skeleton
// AgentArray [] = new oAgent("", "", "", "", "", "", "", "")
//
// Array setup 
// AgentArray[number] = new oAgent("Last Name", "First Name", "Phone Number", "Fax Number", "Mobile/Pager", "email address", "photo URL", "website URL")
//
// photos must be saved as 71px BY 71px images and input here EXACTLY as they are saved in the storage locker
// if you do not have the information for a given field, leave it blank, the program is set with default information for most fields
// please do not put any HTML tags in the info below, if you need modifications to this edit the style sheet or contact Roger for changes

var AgentArray = new Array() //agent information for the array ...
AgentArray [1] = new oAgent("Barcus", "Robert", "832-478-1267", "832-478-1245", "281-650-4422", "", "/files/191530/Robert Barcu.jpg", "http://www.robertbarcus.com") 
AgentArray [2] = new oAgent("Borchers", "Barbara", "832-478-1220", "281-893-8035", "713-515-2125", "barbaraborchers@aol.com", "/files/191530/Borchers_Barbara.jpg", "http://www.barbaraborchers.com/")
AgentArray [3] = new oAgent("Boze", "Lyn H", "832-476-3177", "832-478-1191", "713-822-2351", "", "/files/191530/Boze.jpg", "/content/agentpage.html/168369?brokerid=0&ad_id=281573")
AgentArray [4] = new oAgent("Caballero", "Edgar Y", "832-478-1172", "281-831-8939", "", "edycaballero@msn.com", "/files/191530/Caballero_Edgar.jpg", "")
AgentArray [5] = new oAgent("Cope", "John G", "832-478-1203", "281-440-9337", "832-878-5884", "copejohn@sbcglobal.net", "/files/191530/Cope_John.jpg", "/content/agentpage.html/450708?brokerid=0&ad_id=281573")
AgentArray [6] = new oAgent("Dieguez", "Maria A", "281-897-2730", "832-478-1239", "832-526-5484", "mariadieguez@remax.net", "/files/191530/Dieguez_Maria.jpg", "/content/agentpage.html/1085340?brokerid=0&ad_id=281573")
AgentArray [7] = new oAgent("Flaherty", "Deborah", "832-478-1202", "281-897-2729", "832-766-1704", "debflaherty@hal.org", "", "/content/agentpage.html/1995451?brokerid=0&ad_id=281573") 
AgentArray [8] = new oAgent("Flory", "David", "832-478-1205", "281-477-9681", "", "floryteam@yahoo.com", "/files/191530/Flory_David.jpg", "http://www.davidflory.com/")
AgentArray [9] = new oAgent("Foster", "Brenda E", "281-897-2731", "281-895-0965", "281-352-9687", "brendae@pdq.net", "/files/191530/Foster_Brenda.jpg", "/content/agentpage.html/879826?brokerid=0&ad_id=281573")
AgentArray [10] = new oAgent("Franco", "Victoria E", "832-478-1229", "713-983-8057", "281-450-9133", "vetorres@houston.rr.com", "/files/191530/Torres_Victoria.jpg", "/content/agentpage.html/1350120?brokerid=0&ad_id=281573")
AgentArray [11] = new oAgent("Galvan", "Gracie", "832-478-1246", "", "281-732-0009", "galvangracie@hotmail.com", "/files/191530/Galvan_Gracie.jpg", "/content/agentpage.html/1640845?brokerid=0&ad_id=281573")
AgentArray [12] = new oAgent("Gerhold", "Bette", "281-370-9100", "281-205-4659", "832-715-2160", "bette@bettegerhold.com", "/files/191530/gerhold1.jpg", "http://www.har.com/AWS/AWS.CFM?AGENT_NUMBER=483411")
AgentArray [13] = new oAgent("Gomez", "Martha L", "832-478-1196", "", "832-372-0130", "szzzymartha@houston.rr.com", "/files/191530/Gomez_Martha.jpg", "/content/agentpage.html/617722?brokerid=0&ad_id=281573")
AgentArray [14] = new oAgent("Hagerman", "Paula", "281-897-2715", "281-376-5473", "713-306-3557", "agentpaulah@aol.com", "/files/191530/Hagerman_Paula.jpg", "/content/agentpage.html/613265?brokerid=0&ad_id=281573")
AgentArray [15] = new oAgent("Hoelscher", "Paula", "281-894-1000", "281-897-2729", "281-773-5012", "", "/files/191530/default.jpg", "/content/agentpage.html/5021978")
AgentArray [16] = new oAgent("Huffman", "Lori", "832-478-1175", "281-893-4673", "281-236-8007", "lorib10@hotmail.com", "/files/191530/huffman.jpg", "http://www.lorihuffman.com")
AgentArray [17] = new oAgent("Koehne", "Kendall", "281 897-2732", "281-897-2729", "832-771-5500", "", "/files/191530/Kendall.jpg", "/content/agentpage.html/1071275")
AgentArray [18] = new oAgent("LaFuente", "Ray", "281-897-2713", "281-897-2706", "713-557-4200", "RAY4RAY800@aol.com", "/files/191530/LaFuente_Ray.jpg", "/content/agentpage.html/256198?brokerid=0&ad_id=281573")
AgentArray [19] = new oAgent("Majul-Perez", "Zuri", "832-478-1190", "281-897-2729", "832-731-8910", "", "/files/191530/zuri.jpg", "/content/agentpage.html/3388214")
AgentArray [20] = new oAgent("Martin", "Brian", "832-478-1265", "281-897-2729", "832-746-1587", "bmartin12@sbcglobal.net", "/files/191530/brianmartin.jpg", "/content/agentpage.html/2757902?brokerid=0&ad_id=281573") 
AgentArray [21] = new oAgent("Martin", "Jeff", "832-478-1230", "281-897-2729", "713-416-5066", "", "/files/191530/jeffmartin.jpg", "/content/agentpage.html/3142725") 
AgentArray [22] = new oAgent("Martin", "Twila K", "281-897-2727", "281-897-2729", "713-594-1639", "tmartin@rpghouston.com", "/files/191530/Martin_Twila.jpg", "/content/agentpage.html/253791?brokerid=0&ad_id=281573")
AgentArray [23] = new oAgent("Maxwell", "Jack", "832-478-1186", "", "832-969-6699", "wmaxwell@houston.rr.com", "/files/191530/Maxwell_Jack.jpg", "http://www.Cy-FairRealEstate.com")
AgentArray [24] = new oAgent("Nelson", "Susan", "281-897-2716", "281-897-2718", "281-787-9988", "snelson990@aol.com", "/files/191530/Nelson_Susan.jpg", "/content/agentpage.html/259392?brokerid=0&ad_id=281573")
AgentArray [25] = new oAgent("Patterson", "Bobbie", "281-897-2737", "281-897-2720", "713-542-3208", "bobbie.patterson@gte.net", "/files/191530/Patterson_Bobbie.jpg", "/content/agentpage.html/219447?brokerid=0&ad_id=281573")
AgentArray [26] = new oAgent("Prehoda", "Mark and Amanda", "281-897-2707", "281-897-2711", "281-855-4900", "prehoda@msn.com", "/files/191530/Prehoda.jpg", "http://www.houstonerealestate.com/")
AgentArray [27] = new oAgent("Raymor", "Rick & Suzy", "832-478-1170", "832-478-1187", "281-235-7653", "RickSuzyRaymor@realtor.com", "/files/191530/Raymor_Team.jpg", "http://www.raymorteam.com/")
AgentArray [28] = new oAgent("Robinson", "Charles", "281-897-2735", "936-894-3593", "832-338-5025", "chaseremax4u@yahoo.com", "/files/191530/Robinson_Charles.jpg", "/content/agentpage.html/318963?brokerid=0&ad_id=281573")
AgentArray [29] = new oAgent("Sampaulesi", "Stephen", "281-897-2726", "281-897-2722", "281 477-7777", "", "/files/191530/default.jpg", "/content/agentpage.html/167836?brokerid=0&ad_id=281573")
AgentArray [30] = new oAgent("Singh", "Monty", "832-478-1269", "832-478-1242", "832-434-6572", "", "/files/191530/montysingh.jpg", "/content/agentpage.html/3261307?brokerid=0&ad_id=281573")
AgentArray [31] = new oAgent("Smith", "Thomas", "", "", "713-703-8142", "tomang@ev1.net", "/files/191530/Smith_Tommy.jpg", "")
AgentArray [32] = new oAgent("Souders", "Ron", "832-478-1179", "281-897-2729", "713-992-2487", "", "/files/191530/Ron_Websize_S1.jpg", "")
AgentArray [33] = new oAgent("Sugay", "Maluisa F", "832-478-1177", "832-478-1241", "281-667-8870", "mfsugay@yahoo.com", "/files/191530/Sugay_Maluisa.jpg", "http://www.rmlsrealty.com")
AgentArray [34] = new oAgent("Terlingo", "Kimberly R", "832-478-1226", "832-478-1166", "832-797-6573", "kterlingo@houston.rr.com", "/files/191530/Terlingo_Kimberly.jpg", "http://www.kimberlyterlingo.com")
AgentArray [35] = new oAgent("Wells", "Karen", "832-478-1185", "281-970-7382", "281-989-1170", "karenwells@houston.rr.com", "/files/191530/Wells_Karen.jpg", "/content/agentpage.html/1442000?brokerid=0&ad_id=281573")
