// JavaScript Document

//creates table of champions for display

function getChampionInfo(champType,champArray,champTotal) { 
// champType = image filename prefix/suffix
// champArray = names of champions
// champTotal = number of champions to display

  var noOfColumns = 3;
// Columns to display in can be changed here

  var i=0; champNo=1;
  var championHTML = "";
  var fillEmptyCell = false;
  emptyCells = champTotal % noOfColumns;
  for (champNo=1;champNo<=champTotal;champNo++)
  {
      if (champNo % noOfColumns == 1) {
        // start of repeating row
        championHTML+="<tr><td colspan='3' align='left' valign='top'><img src='../img/common/spacer.gif' alt='.' height='10' width='12' /></td></tr>";
        championHTML+="<tr>";
        
      }
      
      championHTML+="<td width='192' align='left' valign='top'><table width='180' border='0' cellspacing='0' cellpadding='0'>";
      championHTML+="<tr><td width='88' align='left' valign='top'><img src='../img/gallery/champions/img"; 
	  if (champArray[champNo-1][1]) {
	// has picture
		  championHTML+="_" + champType;          
		  if (champNo < 10 ) {
			championHTML+="0";} 
		  championHTML+=champNo;
	  }
	  
	  championHTML+= ".jpg' alt='" + champNo + "' width='70' height='88' class='championsPic' border='1'/></td>";
      championHTML+="<td width='92' align='left' valign='bottom' class='bodyNJ'><span class='code_hdr'>No. " + champNo + "</span><br />"+ champArray[champNo-1][0] +"</td>";
      championHTML+="</tr></table></td>";
      
      if (champNo % noOfColumns == 0) {
        // end of repeating row
        championHTML+="</tr>";
      }

  }


for (i=0; i>emptyCells;i--) {
  championHTML+="<td align='left' valign='top'>&nbsp;</td>";
  fillEmptyCell=true;
}
 
if (fillEmptyCell)
	championHTML+="</tr>";
 
	return championHTML;
}


function getTBInfo() { //get Outer table

  x="<table border='0' cellpadding='0' cellspacing='0' width='608'>";
  x+="<tbody><tr><td colspan='2'><img src='../img/common/spacer.gif' alt='.' height='6' width='12' /></td></tr>";
  x+="<tr><td colspan='2' class='formEvenP15'><span class='code_hdr' id='head" + cellID + "'>" + buttonname + "</span></td></tr>";
  x+="<tr><td colspan='2'><img src='../img/common/spacer.gif' alt='.' width='10' height='2' /></td></tr>";
  x+="<tr><td colspan='2' align='center' valign='top' class='formEvenP15' ><table width='576' border='0' cellspacing='0' cellpadding='0'>";
  x+=whichList;
  x+="<tr><td colspan='3' align='left' valign='top'><img src='../img/common/spacer.gif' alt='.' height='15' width='12' /></td></tr>";
  x+="</table></td></tr>";
  x+="<tr><td colspan='2'><img src='../img/common/spacer.gif' alt='.' height='20' width='10' /></td></tr>";
  x+="<tr><td colspan='2' background='../img/common/hdr_dotline.jpg' style='background-repeat: repeat-x;'><img src='../img/common/spacer.gif' alt='.' height='6' width='12' /></td></tr>";
  x+="</tbody></table>";

  return x;
}

function writeInCella(a,b,d,e) { 
// a is which cellID to change; 
// b is filename of hdrimage (eg. topproducers); 
// removed - c is which quarter awardees list values; 
// d is which awardlist to display (1=Division Directors, 2=Group Directors, 3=Producers, 4=Recruitors, 5=Transactors) 
// e is how many people to display

cellID=a + "table";

//declare all awardees here
dd=getDD();
gd=getGD();
pr=getP();
re=getR();
//tr=getT();
	  
whichList=""; //assign which awardlist to display
buttonname=b;

switch (d) {
 case 1:
  	whichList+=getChampionInfo('dd',dd,e)
 	//leadrsList=getLeadrsList9();
	//whichList+=leadrsList;
	break;
 case 2:
  whichList+=getChampionInfo('gd',gd,e)
  break;
 case 3:
  whichList+=getChampionInfo('pr',pr,e)
  break;
 case 4:
  whichList+=getChampionInfo('re',re,e)  
	break;
 //case 5:
  //whichList+=getChampionInfo('tr',tr,e)   
//	break;

}

info=getTBInfo(); //Outer Table

document.getElementById(cellID).innerHTML = info; //write into specific cell ID

switch (a) {
 case 'top10':
	showTop10();
	break;
 case 'top30':
	showTop30();
	break;
}
}

function init() {
	writeInCella('top10','Top 10 Division Directors',1,10);
	writeInCella('top30','Top 30 Producers',3,30);
	showTop10();
	MM_preloadImages('../img/common/btnO_go.gif','../img/home/btnO_careers.jpg','../img/home/btnO_training.jpg','../img/home/btnO_clientvalues.jpg','../img/home/btnO_newsroom.jpg','../img/home/btnO_30s.jpg','../img/home/btnO_buy.jpg','../img/home/btnO_sell.jpg','../img/home/btnO_lease.jpg','../img/home/btnO_enbloc.jpg','../img/home/btnO_indication.jpg','../img/home/btnO_search.jpg','../img/home/btnO_2.jpg','../img/home/btnO_1.jpg','../img/quicklinks/btnO_abouthsr.jpg','../img/quicklinks/btnO_clientvalues.jpg','../img/quicklinks/btnO_bepartofus.jpg','../img/quicklinks/btnO_assocorner.jpg','../img/quicklinks/btnO_photo.jpg');
}
function hideTop10() {
	document.getElementById('top10View').style.display='';
	document.getElementById('top10Hide').style.display='none';
	document.getElementById('top10').style.display='none';
}
function showTop10() {
	document.getElementById('top10View').style.display='none';
	document.getElementById('top10Hide').style.display='';
	document.getElementById('top10').style.display='';
	hideAllTime();
	hideTop30();
}
function hideAllTime() {
	document.getElementById('alltimeView').style.display='';
	document.getElementById('alltimeHide').style.display='none';
	document.getElementById('alltime').style.display='none';
}
function showAllTime() {
	document.getElementById('alltimeView').style.display='none';
	document.getElementById('alltimeHide').style.display='';
	document.getElementById('alltime').style.display='';
	hideTop10();
	hideTop30();
}
function hideTop30() {
	document.getElementById('top30View').style.display='';
	document.getElementById('top30Hide').style.display='none';
	document.getElementById('top30').style.display='none';
}
function showTop30() {
	document.getElementById('top30View').style.display='none';
	document.getElementById('top30Hide').style.display='';
	document.getElementById('top30').style.display='';
	hideTop10();
  hideAllTime();
}
function hideStart() {
	document.getElementById('top10View').style.display='none';
	document.getElementById('alltimeHide').style.display='none';
	document.getElementById('alltime').style.display='none';
	document.getElementById('top30Hide').style.display='none';
	document.getElementById('top30').style.display='none';
}
function ChangeTitle(btnname) {
   var newtitle = btnname;
   var head1 = document.getElementById("head1");
   head1.firstChild.nodeValue=newtitle;
}