
var ChangeCount=1;var showCurrent='previous_week';var showNext='previous_month';showBeds='2br';function ShowIndicesCell(compareType,cell,name,beds){switch(name){case'latest_value_'+beds:cell.className='idc';break;case compareType+'_value_'+beds:cell.className='idc';CalculateChange(cell,compareType,beds,ChangeCount);ChangeCount++;break;case"change_amount":cell.className='ihc';break;case"description":case"change_percentage":cell.className='idc';break;default:cell.className='ihc';break;}}
function UpdateIndicesTableBedsChanged(selectedBeds){try{showBeds=selectedBeds;UpdateIndicesTable(showBeds,showCurrent);}
catch(e){alert(e);}}
function ToggleIndicesTableBeds(){if(showBeds=='all'){showBeds='studio';}
else if(showBeds=='studio'){showBeds='1br';}
else if(showBeds=='1br'){showBeds='2br';}
else if(showBeds=='2br'){showBeds='3br';}
else if(showBeds=='3br'){showBeds='4br';}
else if(showBeds=='4br'){showBeds='studio';}
UpdateIndicesTable(showBeds,showCurrent);}
GlobalLookup.setSingleton("CurrentBedSelection",true);GlobalLookup.addListener("CurrentBedSelection",SetCurrentlyShowingBeds);GlobalLookup.addListener("CurrentBedSelection",function(newValue){var currentBeds;if(newValue==0){currentBeds='studio'}else if(newValue==1){currentBeds='1br'}else if(newValue==2){currentBeds='2br'}else if(newValue==3){currentBeds='3br'}else if(newValue==4){currentBeds='4br'}
UpdateIndicesTableBedsChanged(currentBeds);});GlobalLookup.addListener("CurrentBedSelection",function(newValue){var currentBeds;if(newValue==0){currentBeds='studio'}else if(newValue==1){currentBeds='bdrm1'}else if(newValue==2){currentBeds='bdrm2'}else if(newValue==3){currentBeds='bdrm3'}else if(newValue==4){currentBeds='4plus'}
$("#ctl00_ContentPlaceHolder1_IndexTrendGraphControl1_ChartBedRooms").val(newValue);$("#ctl00_ContentPlaceHolder1_PropertyTrendGraphControl1_ChartBedRooms").val(newValue);TrendBedChange(currentBeds);});function SetCurrentlyShowingBeds(newValue){var currentlyShowing=document.getElementById('currentlyShowingBeds');var currentBeds;if(newValue==0){currentBeds='studio'}else if(newValue==1){currentBeds='1br'}else if(newValue==2){currentBeds='2br'}else if(newValue==3){currentBeds='3br'}else if(newValue==4){currentBeds='4br'}
if(currentlyShowing){if(currentBeds=='all'){currentlyShowing.innerHTML='All Bedrooms';}
else if(currentBeds=='studio'){currentlyShowing.innerHTML='Studio';}
else if(currentBeds=='1br'){currentlyShowing.innerHTML='1 Bedrooms';}
else if(currentBeds=='2br'){currentlyShowing.innerHTML='2 Bedrooms';}
else if(currentBeds=='3br'){currentlyShowing.innerHTML='3 Bedrooms';}
else if(currentBeds=='4br'){currentlyShowing.innerHTML='4 Bedrooms';}}
$('#UnitTypeDDL').val(newValue);var currentSelectedNumber=$(".SelectedBedNumber")
if(currentSelectedNumber){currentSelectedNumber.removeClass("SelectedBedNumber");var selectedBed=$('#thematicBeds'+currentBeds);if(selectedBed){selectedBed.addClass("SelectedBedNumber");}}}
function UpdateIndicesTable(beds,compareType){var tables=document.getElementsByTagName("table");for(var i=0;i<tables.length;i++){if(tables[i].id.indexOf('them_')==-1){continue;}
var cells=tables[i].getElementsByTagName("td");for(var x=0;x<cells.length;x++){var name=cells[x].getAttribute("name");if(name!=null){ShowIndicesCell(compareType,cells[x],name,beds);}}
cells=tables[i].getElementsByTagName("th");for(var x=0;x<cells.length;x++){var name=cells[x].getAttribute("name");if(name!=null){ShowIndicesCell(compareType,cells[x],name,beds);}}}
ChangeCount=1;}
function hideShowLinks(str){showCurrent=str;var currentlyShowing=document.getElementById('currentlyShowing');if(str=='year_over_year'){currentlyShowing.innerHTML='Yr over Yr';showNext='previous_week';}
else if(str=='previous_week'){currentlyShowing.innerHTML='Prev. Wk';showNext='previous_month';}
else if(str=='previous_month'){currentlyShowing.innerHTML='Prev. Mo';showNext='year_over_year';}}
function CalculateChange(cell,compareType,beds,count){var current=document.getElementById(cell.id.replace(compareType,'latest'));var name=current.getAttribute("name");var changeAmount=document.getElementById(cell.id.replace(compareType+'_value_'+beds,'')+'change_amount');var changePercentage=document.getElementById(cell.id.replace(compareType+'_value_'+beds,'')+'change_percentage');var currentHTML=current.innerHTML.replace('$','').replace(',','').replace('%','').replace(' ','');var toFixedLength=1;if(!isNaN(currentHTML)){var cellHTML=cell.innerHTML.replace('$','').replace(',','').replace('%','').replace(' ','');var chgAmount=currentHTML-cellHTML;var chgPercent=(currentHTML-cellHTML)/cellHTML*100;changeAmount.innerHTML=chgAmount.toFixed(1);if(isNaN(chgPercent)||!isFinite(chgPercent)){changePercentage.innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;-';}
else if(chgPercent.toFixed(toFixedLength)>=0){changePercentage.style.color='#006fa0';if(chgPercent.toFixed(toFixedLength)!=0){changePercentage.innerHTML='<span style="font-weight:bold;">&#9650</span>&nbsp;'+chgPercent.toFixed(toFixedLength)+'%';;}
else{changePercentage.innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;0.0%';}}
else{changePercentage.style.color='#006fa0';changePercentage.innerHTML='<span style="font-weight:bold;">&#9660;</span>';changePercentage.innerHTML=changePercentage.innerHTML+chgPercent.toFixed(toFixedLength)+'%';}}
else if(currentHTML=='-'){changePercentage.innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;-';}}