function defineOtherLayers() {
	// dObj = new LayerObj('id');
	dA = new LayerObj('divA');
	dB = new LayerObj('divB');
	dC = new LayerObj('divC');
	dD = new LayerObj('divD');
	dE = new LayerObj('divE');
	dMenuL = Array(4); for(i=0;i<4;i++) dMenuL[i] = new LayerObj('divMenuL_'+i);
	dMenuT = Array(4); for(i=0;i<4;i++) dMenuT[i] = new LayerObj('divMenuT_'+i);
	dBubble = Array(4); for(i=0;i<4;i++) dBubble[i] = new LayerObj('menuT_'+i+'_bubble');
	dBubbleTxt = Array(4); for(i=0;i<4;i++) dBubbleTxt[i] = new LayerObj('menuT_'+i+'_bubble_text');
	dGroup = new LayerObj('imgGroup');
	dPhone = new LayerObj('divPhone');
	dBox1 = new LayerObj('divBox1');
	dBox2 = new LayerObj('divBox2');
	iBox1 = new LayerObj('imgBox1');
	iBox2 = new LayerObj('imgBox2');
	dPhotoBox = Array(4); for(i=0;i<4;i++) dPhotoBox[i] = new LayerObj('divPhoto'+i);
	dPhotoDrop = Array(4); for(i=0;i<4;i++) dPhotoDrop[i] = new LayerObj('imgDrop'+i);
	dPhotoImg = Array(4); for(i=0;i<4;i++) dPhotoImg[i] = new LayerObj('imgPhoto'+i);
	dPhotoTxt = Array(4); for(i=0;i<4;i++) dPhotoTxt[i] = new LayerObj('txtPhoto'+i);
	dAgent = new LayerObj('divAgent');
	iAgent = new LayerObj('imgAgent');
	dAgentHeader = new LayerObj('box1TxtHdr');
	dBox1Txt = new LayerObj('box1Txt');
	dBox2Hdr = new LayerObj('box2TxtHdr');
	dBox2Txt = new LayerObj('box2Txt');
	dSearchBox = new LayerObj('divSearchBox');
	dSearchBoxMid = new LayerObj('divSearchBoxMid');
	dSpacerBox = new LayerObj('divSpacerBox');
	dSpacerBoxMid = new LayerObj('divSpacerBoxMid');

	// dContent.initResizeContainer(OrigWidth, OrigHeight);
	// dObj.initResize(OrigLeft, OrigTop, OrigWidth, OrigHeight, constrain true/false);
}

function registerOtherEvents() {
	// dObj.obj.onclick = clickfunction;
	for(i=0;i<4;i++) {
		var obj = getObj('menuL_'+i+'_plate');
		obj.onmouseover = menuOverL;
		obj = getObj('menuL_'+i+'_plate');
		obj.onmouseout = menuOutL;
		obj = getObj('menuT_'+i+'_plate');
		obj.onmouseover = menuOverT;
		obj = getObj('menuT_'+i+'_plate');
		obj.onmouseout = menuOutT;
	}
	
	dPhotoBox[0].obj.onclick = jumpMLSRes;
	dPhotoBox[1].obj.onclick = jumpAuction;
	dPhotoBox[2].obj.onclick = jumpMLSCom;
	dPhotoBox[3].obj.onclick = jumpRental;
	
}

function otherMainContent() {
	// Main layout code sequence
	var w = dMain.width;
	var w1 = Math.round(w*0.80);
	var w2 = w-w1;
	var mW = Math.round((w1-(dMenuT[0].width*4))/5);
	var h = dMain.height;
	var h1 = dA.height;
	var h2 = Math.round(h*0.644);
	var h3 = h-h1-h2;
	dMain.setHeight(dContent.height-dMain.top);
	dA.setWidth(w1);
	dB.setSize(w1,h2);
	dC.setSize(Math.round(w1/2),h3);
	dD.setSize(w1-dC.width,h3);
	dD.setLeft(dC.width);
	dE.setWidth(w2-15);
	dE.setLeft(w1);
	dC.setTop(dB.bottomPos);
	dD.setTop(dB.bottomPos);
	dE.setHeight(h);
	
	
	for(i=0;i<4;i++) {
		dMenuT[i].setLeft(mW+Math.round(i*(mW+dMenuT[i].width)));
	}

	var aPhone = constrain(dB.width,dB.height,dPhone.width,dPhone.height);
	dPhone.setSize(aPhone[0],aPhone[1]);
	dPhone.setBottom(0);
	dPhone.initResize(0,268,648,22)
	dPhone.textResize(16,18)


	var aGroup = constrain(dB.width,dB.height-22,dGroup.width,dGroup.height);
	dGroup.setSize(aGroup[0],aGroup[1]);
	dGroup.obj.src = 'scripts/imageresize.php?pic=../images/team/group/group.jpg&w='+aGroup[0]+'&h='+aGroup[1];
	dGroup.setLeft(Math.round((dB.width-aGroup[0])/2));
	var groupBuf = Math.round((dB.height-22-dGroup.height)/3);
	dGroup.setTop(groupBuf);
	resetImageMap(aGroup[0]);
	
	var mPDivW = dE.width;
	var mPDivH = Math.round(dE.height * 0.246);
	var aPBox = constrain(mPDivW,mPDivH,140,111);
	var pBoxBuf = Math.round((dE.height-(4*aPBox[1]))/3);
	var pImgW = Math.round(aPBox[0]*0.857);
	var pImgH = Math.round(pImgW*0.75);
	var pDropW = Math.round(aPBox[0]*0.900);
	var pDropH = Math.round(pDropW*0.77);
	var pDropBuf = Math.round(aPBox[0]*0.1);
	for(i=0;i<4;i++) {
		dPhotoBox[i].setSize(aPBox[0],aPBox[1]);
		dPhotoBox[i].setRight(0);
		dPhotoBox[i].setTop(i*(aPBox[1]+pBoxBuf));
		dPhotoDrop[i].setSize(pDropW,pDropH);
		dPhotoImg[i].setSize(pImgW,pImgH);
		dPhotoDrop[i].setPos(pDropBuf,pDropBuf);
		dPhotoTxt[i].setSize(pImgW,pDropBuf);
		dPhotoTxt[i].setPos(pDropBuf,pImgH+1);
		dPhotoTxt[i].origWidth = 120;
		dPhotoTxt[i].origHeight = 14;
		dPhotoTxt[i].textResize(10, 12);
	}

	var aBox = constrain(dC.width,dC.height,dBox1.width,dBox1.height);
	dBox1.setSize(aBox[0],aBox[1]);
	dBox2.setSize(aBox[0],aBox[1]);
	dBox1.setBottom(0);
	dBox2.setBottom(0);
	dBox1.setLeft(aBox[2]);
	dBox2.setLeft(aBox[2]);

	dBox1.initResizeContainer(323,125);
	iBox1.initResize(0, 0, 323, 125, constrain)
	iBox1.resize(true);
	dAgent.initResize(220,5,86,106);
	dAgent.resize(false);
	iAgent.setSize(dAgent.width-6,dAgent.height-6);
	dAgentHeader.initResize(10,5,200,26);
	dAgentHeader.resize(false);
	dAgentHeader.textResize(20,22);
	dBox1Txt.initResize(10,29,200,80)
	dBox1Txt.resize(false);
	dBox1Txt.textResize(14,16)

	dBox2.initResizeContainer(323,125);
	iBox2.initResize(0, 0, 323, 125, constrain)
	iBox2.resize(true);
	dBox2Hdr.initResize(0,3,323,26)
	dBox2Hdr.resize(false);
	dBox2Hdr.textResize(16,22)
	dBox2Txt.initResize(10,29,295,80)
	dBox2Txt.resize(false);
	dBox2Txt.textResize(10,10)
	
	dSpacerBoxTop = 385;
	
	dMain.setTop(83);
	// attempting to set the top down 15 and the height down 30 to make a 15 pixel border on the top and bottom.
	dMain.setHeight(dMain.height - 30);
	if (dMenuLeft.height > dSpacerBoxTop+30) {
		dSpacerBox.setTop(dSpacerBoxTop);
		dSpacerBox.setHeight(dMenuLeft.height-dSpacerBox.top);
		dSpacerBoxMid.setHeight(dSpacerBox.height-20);
		dSpacerBox.setVisible(true);
	}else{
		dSpacerBox.setTop(0);
		dSpacerBoxMid.setHeight(0);
		dSpacerBox.setVisible(false);	
	}
	showRealtorLogos();
	dContent.setVisible(true);
	// dObj.resize(center true/false);
	// dObj.textResize(OrigFontSize, OrigLineHeight);
}

function menuOverT(e) {
	var evtID = getEventObj(e).id;
	var src = 'images/general/menu_over_t.png';
	var group_num = evtID.substr(6,1);
	dBubble[group_num].setVisible(true);
	dBubbleTxt[group_num].setVisible(true);
	getObj(evtID.substr(0,7)).src = src;
}

function menuOutT(e) {
	var evtID = getEventObj(e).id;
	var src = 'images/general/menu_norm_t.png';
	var group_num = evtID.substr(6,1);
	dBubble[group_num].setVisible(false);
	dBubbleTxt[group_num].setVisible(false);
	getObj(evtID.substr(0,7)).src = src;
}

function constrain(maxWidth,maxHeight,objWidth,objHeight) {
	var rat = Math.min(maxWidth/objWidth,maxHeight/objHeight);
	var w = Math.round(rat*objWidth);
	var h = Math.round(rat*objHeight);
	var wBuf = Math.floor((maxWidth-w)/2);
	var hBuf = Math.floor((maxHeight-h)/2);
	return Array(w,h,wBuf,hBuf);
}
	
function showRealtorLogos() {
	var h = dSpacerBoxMid.height;
	if(h<60) {
		loopRealtorLogos(1);
	}else if(h<130) {
		loopRealtorLogos(3);
	}else if(h<200) {
		loopRealtorLogos(5);
	}else if(h<270) {
		loopRealtorLogos(7);
	}else if(h>=270) {
		loopRealtorLogos(9);
	}
}

function loopRealtorLogos(startHidden) {
	for(i=1;i<startHidden;i++) {
		var top = (Math.floor((i-1)/2)*70)+10;
		getObj('imgRealtorLogo_'+numToStr(i,2)).style.top = top + 'px';
		getObj('imgRealtorLogo_'+numToStr(i,2)).style.visibility = 'visible';
	}
	for(i=startHidden;i<9;i++) {
		getObj('imgRealtorLogo_'+numToStr(i,2)).style.top = 0 + 'px';
		getObj('imgRealtorLogo_'+numToStr(i,2)).style.visibility = 'hidden';
		
	}
}

function resetImageMap(newWidth) {
	var numAgents = getObj('numAgents').value;
	var agentsID = getObj('agentsID').value;
	var arrAgentsID = agentsID.split(",");
	var origWidth = 800;
	var ratio = newWidth/origWidth;
	for(var i=0;i<numAgents;i++) {
		var oCoords = getObj('agentMap_'+numToStr(arrAgentsID[i],2)).value;
		var nCoords = convertCoords(oCoords,ratio);
		getObj('area_'+numToStr(arrAgentsID[i],2)).coords = nCoords;
	}
}

function convertCoords(oCoords,ratio) {
	var arr = oCoords.split(",");
	for(var i=0;i<arr.length;i++) arr[i] = Math.round(arr[i]*ratio);
	return arr.join(",");
}

function jumpMLSRes() {
	//getObj('idx_mls').value = getObj('featured_res_id').value;
	getObj('residentialForm').submit();
}

function jumpAuction() {
	window.location = "auctionLanding.php";
}

function jumpMLSCom() {
	//getObj('idx_mls').value = getObj('featured_com_id').value;
	getObj('commercialForm').submit();
}

function jumpRental() {
	window.location = "advancedSearch_rental.php";
}
