CustomSelector={open:function()
{$('#gedPopup').show();},close:function()
{$('#gedPopup').hide();},toggle:function()
{if(this.isVisible())
this.close();else
this.open();},isVisible:function()
{if($("#gedPopup").css("display")=="none")
return false
return true;}}
IndexSwitcher={currentIndex:'habitationValue-1',currentIndex:null,switchTo:function(indexType,additionalParam)
{var switchTo=indexType;if(typeof(additionalParam)!='undefined')
switchTo+='-'+additionalParam;if(switchTo==IndexSwitcher.currentIndex)
return false;CustomSelector.close();IndexSwitcher.getIndexData(indexType,additionalParam);},setSelection:function(indexType,additionalParam)
{IndexSwitcher.resetCurrentSelection();IndexSwitcher.setCurrentSelection(indexType,additionalParam);},resetCurrentSelection:function()
{$('#'+IndexSwitcher.currentIndex).removeClass('current');$('#dd_'+IndexSwitcher.currentIndex).removeClass('current');IndexSwitcher.currentIndex=null;},setCurrentSelection:function(indexType,additionalParam)
{IndexSwitcher.currentIndex=indexType;if(typeof(additionalParam)!='undefined')
IndexSwitcher.currentIndex+='-'+additionalParam;$('#'+IndexSwitcher.currentIndex).addClass('current');$('#dd_'+IndexSwitcher.currentIndex).addClass('current');},getCurrentIndex:function()
{},getIndexData:function(indexType,additionalParam)
{$.getJSON("/gedindex/graph/",{indexType:indexType,additionalParam:additionalParam},function(json)
{var googleChart=new GoogleChart(json);googleChart.setImageSrc();IndexSwitcher.setSelection(indexType,additionalParam);IndexSwitcher.regenerateHtml(json);});},regenerateHtml:function(json)
{IndexSwitcher.updateIndexName(json.indexName);IndexSwitcher.updateIndexValue(json.lastPointValue);IndexSwitcher.updateIndexDimension(json.dimension);IndexSwitcher.updateIndexVariation(json.indexVariation);},updateIndexName:function(indexName)
{$('#current-index-name').html(indexName);$('#left-current-index-name').html(indexName);},updateIndexValue:function(indexValue)
{$('#analytics-graph-index-value').html(indexValue);},updateIndexVariation:function(indexVariation)
{$('#analytics-graph-index-variation').html(indexVariation.activityToDisplay);var variation=parseFloat(indexVariation.activity);if(variation>0)
{$('#analytics-graph-direction').attr('class','up');}
else if(variation<0)
{$('#analytics-graph-direction').attr('class','down');}
else
{$('#analytics-graph-direction').attr('class','');}},updateIndexDimension:function(indexDimension)
{$('#analytics-graph-dimension').html(indexDimension);},onDiagrammClick:function()
{var urlToRedirect='/analytics/';var type='';var value='';if(IndexSwitcher.currentIndex.indexOf('habitationValue')!=-1)
{var habitationArr=IndexSwitcher.currentIndex.split('-');type='geo';value=habitationArr[1];}
switch(IndexSwitcher.currentIndex)
{case'USD':type='currency';value='USD'
break;case'EUR':type='currency';value='EUR'
break;case'OIL':type='stat';value='1';break;case'GOLD':type='stat';value='2';break;case'INFLATION':type='stat';value='3';break;case'RTS':type='stat';value='4';break;case'MMVB':type='stat';value='5';break;case'SALARY':type='stat';value='6';break;case'DOW_JONES':type='stat';value='7';break;case'INCOMES':type='stat';value='8';break;case'SPENDING':type='stat';value='9';break;}
urlToRedirect+='?type='+type+'&value='+value;window.location=urlToRedirect;return;}}
function GoogleChart(data)
{this.data=data.points;this.convertedData=this.convert();var minMax=this.getMinMax();this.min=minMax.min;this.minIndex=minMax.minIndex;this.max=minMax.max;this.maxIndex=minMax.maxIndex;this.limit={min:parseInt(this.min-0.1*this.min),max:parseInt(this.max+0.1*this.max)};this.lineColors=new Array('F23307','F207C8','6A07F2','08710F','57561A','F59E06');}
GoogleChart.prototype.getMinMax=function()
{var min=parseFloat(this.data[0]);var max=parseFloat(this.data[0]);var minIndex=0;var maxIndex=0;for(var i in this.data)
{this.data[i]=parseFloat(this.data[i]);if(this.data[i]<min)
{min=this.data[i];minIndex=i;}
if(this.data[i]>max)
{max=this.data[i];maxIndex=i;}}
return{min:min,minIndex:minIndex,max:max,maxIndex:maxIndex};}
GoogleChart.prototype.convert=function()
{var retval='';var length=this.data.length;for(var i in this.data)
{retval+=this.data[i]+',';}
return retval.slice(0,-1);}
GoogleChart.prototype.truncateData=function(data,length)
{var retval=data;if(data.length<=length)return data;var pos=data.indexOf(',',data.length-length);if(pos==-1)return'';return data.slice(pos+1);}
GoogleChart.prototype.buildImageSrc=function()
{var lineColor=this.getColor();var url='http://chart.apis.google.com/chart?chs=400x100&chls=0.8,1,0&chco='+lineColor+'&chm=o,'+lineColor+',0,'+this.minIndex+',5|o,'+lineColor+',0,'+this.maxIndex+',5&cht=ls&chf=c,lg,90,eef1f2,0.5,FFFFFF,0|bg,s,FFFFFF&chg=25,33&chds='+this.limit.min+','+this.limit.max+'&chd=t:';return url+this.truncateData(this.convertedData,2047-url.length);}
GoogleChart.prototype.getColor=function()
{var randKey=Math.floor(Math.random()*this.lineColors.length);return this.lineColors[randKey];}
GoogleChart.prototype.setImageSrc=function()
{$('#google-chart-image').attr('src',this.buildImageSrc());}
function loadDynamic(scriptName){var head=document.getElementsByTagName('head')[0];var script=document.createElement('script');script.type='text/javascript';script.src=scriptName;script.charset="windows1251";head.appendChild(script);}
$(function(){$(window).resize(function(){if($(window).width()>1280){$('.spo').addClass('spoLong');}else{$('.spo').removeClass('spoLong');}});$(".ramblerCounter a").attr('target','_blank');(function(){var memo_list=$("div.foldableMEMO");$.each(memo_list,function(i,j){var memo=$(this);var minner=$(".memo",memo);var inner=$(".inner",memo);var indentsize=memo.attr('fmsize')||100;minner.css({'height':indentsize+'px'});var showfader=function(){minner.animate({'height':indentsize+'px'});$(".fader",memo).show();$(".message",memo).html("остальной текст").unbind('click').click(function(){minner.animate({height:inner.height()});$(".fader",memo).hide();$(".message",memo).html('свернуть').unbind('click').click(function(){showfader();return false;});return false;}).show();}
if(window.DD_belatedPNG){DD_belatedPNG.fix('#apartment .advertMEMO .fader');}
if(inner.height()>minner.height()){var mm=$(".message",memo).get(0);if(mm){mm.onselectstart=function(){return false;};mm.unselectable="on";$(mm).css('-moz-user-select','none');}
showfader();minner.addClass('fixedmemo');}else{minner.css({'height':'auto'}).addClass('automemo');}});})();var more=$("#morepop");if(more.length){var tmout=0;more.mouseenter(function(){var $this=$(this);clearTimeout($this.parent().attr('tmout'));$('#navPopup',$this.parent()).show();}).mouseleave(function(){var $this=$(this);clearTimeout($this.parent().attr('tmout'));$this.parent().attr('tmout',setTimeout(function(){$("#navPopup",$this.parent()).hide();},400));});}
$('.tabs-ico li').click(function(){if(!$(this).hasClass('.active')){$(this).addClass('active').siblings().removeClass('active').parents('.w-tabs').find('.b-tabs-desc').hide().eq($(this).prevAll().length).css('display','block');window.location.replace('#tab_'+$(this).attr('id'));}
return false;});if($('.w-tabs .tabs-ico').size()>0){$('.tabs-ico li#'+window.location.hash.substring(5)).click();}
$(".norubler span.rubler").removeClass('rubler');$("span.rubler").html('P<span>&ndash;</span>');});
