
function airChartData(maxValue,threshold1,threshold2,threshold3,threshold4){var t=this;t.maxValue=maxValue;t.thresholds=new Array();t.thresholds[0]=threshold1;t.thresholds[1]=threshold2;t.thresholds[2]=threshold3;t.thresholds[3]=threshold4;}
function airChartClass(chartId){var t=this;t.chartId=chartId;t.chartDiv=document.getElementById(t.chartId);t.thresholdData=new Array();t.dataValues=new Array();t.images=new Array();t.gasType=new Array();t.unit="&micro;g/m³";t.barHeight=75;t.showTooltipBool=false;t.thresholdData[0]=new airChartData(400,0,0,0,0);t.thresholdData[1]=new airChartData(400,0,0,0,0);t.thresholdData[2]=new airChartData(400,0,0,0,0);t.dataValues[0]=0;t.dataValues[1]=0;t.dataValues[2]=0;t.gasType[0]="Stickstoff";t.gasType[1]="Ozon";t.gasType[2]="Feinstaub";t.images[0]="./AspNetVisualAssets/DataInfoIcons/Background21x21.png";t.images[1]="./AspNetVisualAssets/DataInfoIcons/FactoryIcon.png";t.images[2]="./AspNetVisualAssets/DataInfoIcons/RoadSide20x18.png";t.chartDate="01.01.1970";t.initChart=function(){t.chartDiv.innerHTML="";var chartBorder=document.createElement("div");chartBorder.setAttribute("class","infoBoxAirChartDiv");t.chartDiv.appendChild(chartBorder);chartScale=document.createElement("div");chartScale.setAttribute("class","infoBoxAirChartScale");t.chartDiv.appendChild(chartBorder);chartBorder.appendChild(chartScale);for(var i=1;i<4;i++){var chartDiv=document.createElement("div");chartDiv.setAttribute("class","infoBoxAirChartField");chartDiv.setAttribute("id",t.chartId+"ChartDiv"+i);chartDiv.setAttribute("onmouseover","airChartContainer.showAirBoxTooltip(this.id)");chartDiv.setAttribute("onmouseout","airChartContainer.hideAirBoxTooltip()");chartDiv.setAttribute("onmousemove","airChartContainer.MoveAirBoxTooltip()");chartDiv.onmouseover=function(){t.showAirBoxTooltip(this.id);};chartDiv.onmouseout=function(){t.hideAirBoxTooltip();};chartDiv.onmousemove=function(){t.MoveAirBoxTooltip();};var chartName=document.createElement("div");chartName.setAttribute("class","infoBoxAirChartName"+i);chartName.setAttribute("id",t.chartId+"ChartName"+i);chartBorder.appendChild(chartDiv);chartBorder.appendChild(chartName);}
var chartBR=document.createElement("br");chartBR.setAttribute("clear","all");chartBorder.appendChild(chartBR);for(var i=1;i<4;i++){var chartDiv=document.createElement("div");chartDiv.setAttribute("class","infoBoxAirChartBar");chartDiv.setAttribute("id",t.chartId+"ChartBar"+i);chartBorder.appendChild(chartDiv);}
var chartBR=document.createElement("br");chartBR.setAttribute("clear","all");chartBorder.appendChild(chartBR);for(var i=1;i<5;i++){for(var j=1;j<4;j++){var chartArrow=document.createElement("div");chartArrow.setAttribute("class","infoBoxAirCharArrow"+i);chartArrow.setAttribute("id",t.chartId+"ChartArrow"+i+"_"+j);var heightRatio=t.barHeight/Math.log(t.thresholdData[j-1].maxValue);var height=Math.log(t.thresholdData[j-1].thresholds[i-1])*heightRatio;chartArrow.style.top=(t.barHeight-(8*i)+4)-height+"px";document.getElementById((t.chartId+"ChartDiv"+j)).appendChild(chartArrow);}}
if(!document.getElementById(t.chartId+"infoBoxAirChartTooltip")){var b=document.getElementsByTagName("body");var tooltip=document.createElement("span");tooltip.setAttribute("class","infoBoxAirChartTooltip");tooltip.setAttribute("id",t.chartId+"infoBoxAirChartTooltip");b[0].appendChild(tooltip);}
var dateDiv=document.createElement("div");dateDiv.setAttribute("class","infoBoxAirChartDateSource");dateDiv.setAttribute("id",t.chartId+"infoBoxAirChartDateSource");dateDiv.innerHTML=t.chartDate;t.chartDiv.appendChild(dateDiv);t.setBarDesign(0,t.dataValues[0]);t.setBarDesign(1,t.dataValues[1]);t.setBarDesign(2,t.dataValues[2]);if(t.dataValues[0]==0)t.disableBar(0);if(t.dataValues[1]==0)t.disableBar(1);if(t.dataValues[2]==0)t.disableBar(2);}
t.showAirBoxTooltip=function(value){var ind=parseInt(value.replace(t.chartId+"ChartDiv",""));document.getElementById(t.chartId+"infoBoxAirChartTooltip").innerHTML=t.gasType[ind-1]+": "+t.dataValues[ind-1]+" "+t.unit;document.getElementById(t.chartId+"infoBoxAirChartTooltip").style.display="inline";}
t.hideAirBoxTooltip=function(){document.getElementById(t.chartId+"infoBoxAirChartTooltip").style.display="none";}
t.MoveAirBoxTooltip=function(){document.getElementById(t.chartId+"infoBoxAirChartTooltip").style.top=(airTooltipKoords["Y"]-24)+"px";document.getElementById(t.chartId+"infoBoxAirChartTooltip").style.left=airTooltipKoords["X"]+"px";}
t.disableBar=function(i){t.setBarDesign(i,1);$('#'+(t.chartId+"ChartBar"+(i+1))).css({opacity:0.3});$('#'+(t.chartId+"ChartDiv"+(i+1))).css({opacity:0.3});$('#'+(t.chartId+"ChartName"+(i+1))).css({opacity:0.3});for(var j=1;j<5;j++){$('#'+(t.chartId+"ChartArrow"+j+"_"+(i+1))).css({top:500});}
document.getElementById((t.chartId+"ChartDiv"+(i+1))).setAttribute("onMouseOver","");}
t.setBarDesign=function(i,value){var bar=document.getElementById((t.chartId+"ChartBar"+(i+1)));var heightRatio=t.barHeight/Math.log(t.thresholdData[i].maxValue);var height=Math.log(value)*heightRatio;bar.style.height=height+"px";bar.style.marginTop=(t.barHeight-height+5)+"px";bar.style.backgroundColor=t.getBarColor(i,value);}
t.getBarColor=function(i,value){if(value<t.thresholdData[i].thresholds[3])
return"#1F5F00";if(value<t.thresholdData[i].thresholds[2])
return"#71BF04";if(value<t.thresholdData[i].thresholds[1])
return"#CECF04";if(value<t.thresholdData[i].thresholds[0])
return"#FF8000";return"#930000";}}
var airChartContainer=null;var airTooltipKoords={X:0,Y:0};function loadAirChartContainer(){airChartContainer.initChart();$(document).mousemove(function(e){airTooltipKoords["X"]=e.pageX;airTooltipKoords["Y"]=e.pageY;airChartContainer.MoveAirBoxTooltip();});}
