if (document.all) {
        IE=1; NN=0;
        //document.onselectstart=new Function ("return false");
}
else if (document.getElementById) {
        NN=1; IE=0;
        //document.onmousedown=function(e) {return false;};
        //document.onclick=function() {return false;};
}
else {
        IE=0;NN=0
};
/*Browser specific functions */
function ith_getElementById(id) {
                if (NN) return document.getElementById(id);
                else if (IE) return document.all[id];
}

function myDiagram(data, datadate)
{
  this.datas = data;
  this.date = datadate;
  this.day = this.date.getUTCDay();
  this.days = this.date.getUTCDate();
  this.month = this.date.getMonth();
  this.year = this.date.getUTCFullYear();
  this.RoundUp = 100;
  
  this.setPosition=function(top, left)
  {
	this.PositionTop = top;
	this.PositionLeft = left;
  }
  
  this.setCoordinate=function (x,y) {
	var divtext="", PosTop;
	this.x = x;
	this.y = y;
	PosTop = y + this.PositionTop;
	divtext="<div id="+this.id+"y style='position:absolute; left:"+this.PositionLeft+"px; top:"+this.PositionTop+"px; height:"+ y +"px; color:black; border-left: 1px solid; z-index:2'></div>";
	document.write(divtext);
	divtext="<div id="+this.id+"x style='position:absolute; left:"+this.PositionLeft+"px; width:"+x+"px; top:"+PosTop+"px; height:0px; color:black; border-top: 1px solid; z-index:2'></div>";
	document.write(divtext);
	return(this);
  }
  this.xtitle=function(str_xtitle){
	var divtext="", xs_lpos, xs_tpos;
	xs_lpos = parseFloat(ith_getElementById(this.id+'x').style.width) + this.PositionLeft + 10;
	xs_tpos = parseFloat(ith_getElementById(this.id+'y').style.height) + this.PositionTop;
	divtext="<div id="+this.id+"xtitle style='position:absolute; font-family:Arial; font-size:12px; left:"+xs_lpos+"px; top:"+xs_tpos+"px; float:left; z-index:1'>"+str_xtitle+"</div>"
	document.write(divtext);
	return(this);
  }
  this.xscale=function(str_xscale, languageId){
	var divtext="", i, ii, xs_lpos, d, xs_tpos, xs_width, counter = 0, realday = 0, realmonth = (this.month + 1), prevmonthdays, realmonthdays;
	if (str_xscale=="month")
	{
		var tmp_date = this.date.addDays(-30);
		tmp_date = tmp_date.addDays(1);
		counter = tmp_date.getDate();
		for (i=1; i<=30; i++)
		{
			xs_lpos = ((parseFloat(ith_getElementById(this.id+'x').style.width) / 30) * i) + this.PositionLeft - parseFloat(ith_getElementById(this.id+'x').style.width) / 30;
			xs_tpos = (parseFloat(ith_getElementById(this.id+'y').style.height) + this.PositionTop);
			xs_width = parseFloat(ith_getElementById(this.id+'x').style.width) / 30;
			
			if (tmp_date.getUTCDay() == 5 || tmp_date.getUTCDay() == 6) {
				divtext="<div id="+this.id+"xscale"+i+" style='position:absolute; font-family:Tahoma; font-size:10px; color: red; top:"+xs_tpos+"px; left:"+xs_lpos+"px; width:"+xs_width+"px; text-align: center; z-index:1'>"+counter+"</div>";
				document.write(divtext);
				}
			else {
				divtext="<div id="+this.id+"xscale"+i+" style='position:absolute; font-family:Tahoma; font-size:10px;  top:"+xs_tpos+"px; left:"+xs_lpos+"px; width:"+xs_width+"px; text-align: center; z-index:1'>"+counter+"</div>";
				document.write(divtext);
				}
			tmp_date = tmp_date.addDays(1); //this.date.addDays(-30 + i);
			counter = tmp_date.getDate();
		}
		for (i=0; i<=30; i++)
		{
			xs_lpos = ((parseFloat(ith_getElementById(this.id+'x').style.width) / 30) * i) + this.PositionLeft;
			xs_tpos = (parseFloat(ith_getElementById(this.id+'y').style.height) + this.PositionTop  - 5);
			divtext="<div id="+this.id+"xscaleline"+i+" style='position:absolute; top:"+xs_tpos+"px; left:"+xs_lpos+"px; height:11px; color:black; border-left: 1px solid; z-index:1'></div>";
			document.write(divtext);
		}
	}
	if (str_xscale=="week")
	{
		switch(languageId)
		{
			case 0 :
				ii = new Array("Vasárnap", "Hétfő", "Kedd", "Szerda", "Csütörtök", "Péntek", "Szombat")
				break
			case 1 :
				ii = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
				break
			default :
				ii = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
				break
		}
		var tmp_date = this.date.addDays(-7);
		tmp_date = tmp_date.addDays(1);
		realday = tmp_date.getDay();

		for (i=0; i<=ii.length-1; i++)	
		{
			if (realday > 6) realday = realday - 7;
			counter++;
			xs_lpos = ((parseFloat(ith_getElementById(this.id+'x').style.width) / ii.length) * counter) + this.PositionLeft - parseFloat(ith_getElementById(this.id+'x').style.width) / ii.length;
			xs_tpos = (parseFloat(ith_getElementById(this.id+'y').style.height) + this.PositionTop);
			xs_width = parseFloat(ith_getElementById(this.id+'x').style.width) / ii.length;
			
			if (realday == 6 || realday == 0) {
			divtext="<div id="+this.id+"xscale"+i+" style='position:absolute; font-family:Tahoma; font-size:10px; color: red; top:"+xs_tpos+"px; left:"+xs_lpos+"px; width:"+xs_width+"px; text-align: center; z-index:1'>"+ii[realday]+"</div>";
			document.write(divtext);
			}
			else {
			divtext="<div id="+this.id+"xscale"+i+" style='position:absolute; font-family:Tahoma; font-size:10px; top:"+xs_tpos+"px; left:"+xs_lpos+"px; width:"+xs_width+"px; text-align: center; z-index:1'>"+ii[realday]+"</div>";
			document.write(divtext);
			}
			realday = tmp_date.getDay() + counter
		}
		for (i=0; i<=ii.length; i++)
		{
			xs_lpos = ((parseFloat(ith_getElementById(this.id+'x').style.width) / ii.length	) * i) + this.PositionLeft;
			xs_tpos = (parseFloat(ith_getElementById(this.id+'y').style.height) + this.PositionTop  - 5);
			divtext="<div id="+this.id+"xscaleline"+i+" style='position:absolute; top:"+xs_tpos+"px; left:"+xs_lpos+"px; height:11px; color:black; border-left: 1px solid; z-index:1'></div>";
			document.write(divtext);
		}
	}
	if (str_xscale=="year")
	{
		switch(languageId)
		{
			case 0 :
				ii = new Array("Jan", "Feb", "Már", "Ápr", "Máj", "Jún", "Júl", "Aug", "Szept", "Okt", "Nov", "Dec")
				break
			case 1 :
				ii = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec")
				break
			default :
				ii = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec")
				break
		}
		for (i=0; i<=ii.length-1; i++)
		{
			if (realmonth > 11) realmonth = realmonth - 12;
			counter++;
			xs_lpos = ((parseFloat(ith_getElementById(this.id+'x').style.width) / ii.length) * counter) + this.PositionLeft - parseFloat(ith_getElementById(this.id+'x').style.width) / ii.length;
			xs_tpos = (parseFloat(ith_getElementById(this.id+'y').style.height) + this.PositionTop);
			xs_width = parseFloat(ith_getElementById(this.id+'x').style.width) / ii.length;
			divtext="<div id="+this.id+"xscale"+i+" style='position:absolute; font-family:Tahoma; font-size:10px; top:"+xs_tpos+"px; left:"+xs_lpos+"px; width:"+xs_width+"px; text-align: center; z-index:1'>"+ii[realmonth]+"</div>";
			document.write(divtext);
			realmonth = (this.month + 1) + counter
		}
		for (i=0; i<=ii.length; i++)
		{
			xs_lpos = ((parseFloat(ith_getElementById(this.id+'x').style.width) / ii.length	) * i) + this.PositionLeft;
			xs_tpos = (parseFloat(ith_getElementById(this.id+'y').style.height) + this.PositionTop  - 5);
			divtext="<div id="+this.id+"xscaleline"+i+" style='position:absolute; top:"+xs_tpos+"px; left:"+xs_lpos+"px; height:11px; color:black; border-left: 1px solid; z-index:1'></div>";
			document.write(divtext);
		}
	}	return(this);
  }
  this.yscale=function(yscale, fullwidth, linecolor)
  {
	var divtext="", ys_lpos, ys_tpos, i, ys_width, yt_tpos, yl_pos, maxyscale, yscaletitle;
	var max = this.datas[0];
	for (i = 1; i <= data.length; i++) {
		if (max < data[i]) {max = data[i]}
	}
	if (fullwidth)
	{
		ys_width = parseFloat(ith_getElementById(this.id+'x').style.width) + 5;
		for (i=0; i<=yscale; i++)
		{
			ys_lpos = this.PositionLeft - 5;
			ys_tpos = ((parseFloat(ith_getElementById(this.id+'y').style.height) / yscale) * i) + this.PositionTop;
			divtext="<div id="+this.id+"yscaleline"+i+" style='position:absolute; top:"+ys_tpos+"px; left:"+ys_lpos+"px; height:0px; width:"+ys_width+"px; color:"+linecolor+"; border-top: 1px solid; z-index:1'></div>";
			document.write(divtext);
		}
	}
	ys_width = 11;
	for (i=0; i<=yscale; i++)
	{
		ys_lpos = this.PositionLeft - 5;
		ys_tpos = ((parseFloat(ith_getElementById(this.id+'y').style.height) / yscale) * i) + this.PositionTop;
		divtext="<div id="+this.id+"yscaleline"+i+" style='position:absolute; top:"+ys_tpos+"px; left:"+ys_lpos+"px; height:0px; width:11px; color:black; border-top: 1px solid; z-index:1'></div>";
		document.write(divtext);
	}
	for (i=0; i<=yscale; i++)
	{
		yt_lpos = this.PositionLeft - 38;
		yt_tpos = ((parseFloat(ith_getElementById(this.id+'y').style.height) / yscale) * i) + this.PositionTop - 8;
		maxyscale = (Math.round(((max) / this.RoundUp) + 0.5) * this.RoundUp);
		yscaletitle = Math.round((maxyscale / yscale) * (yscale - i))
		this.ymax = maxyscale;
		divtext="<div id="+this.id+"yscalel"+i+" style='position:absolute; font-family:Tahoma; font-size:10px; top:"+yt_tpos+"px; left:"+yt_lpos+"px; height:10px; color:black; width:30px; text-align:right; z-index:1'>"+yscaletitle+"</div>";
		document.write(divtext);
	}
	return(this);
  }
  this.DrawBox = function(boxwidth, boximg1, boximg2)
  {
  	var divtext="", box_top, box_left, i, box_height, box_width, counter=0, pre, nex; 
  	var oneUnit = parseFloat(ith_getElementById(this.id+'y').style.height) / this.ymax;
	var max = this.datas[0];
	for (i = 1; i <= data.length; i++) {
		if (max < data[i]) {max = data[i]}
	}
	for (i = 0; i <= this.datas.length-1; i++)
	{
	counter++
	pre = this.id+"xscaleline"+i
	nex = this.id+"xscaleline"+counter
	box_left = parseFloat(ith_getElementById(pre).style.left);
	img_left = (((parseFloat(ith_getElementById(nex).style.left) - parseFloat(ith_getElementById(pre).style.left)) - boxwidth) / 2) + box_left;
	
	box_height = (oneUnit * this.datas[i]);
	box_top = Math.round(this.y - box_height + 0.5);
	box_width = Math.round(parseFloat(ith_getElementById(this.id+'x').style.width) / this.datas.length);
	
	if (i%2==0)
		divtext="<div id="+this.id+"box"+i+" style='position:absolute; width:"+box_width+"px; top:"+this.PositionTop+"px; left:"+img_left+"px; height:"+this.y+"px; z-index:1'><img src='"+boximg1+"' title = "+data[i]+"  style='position: absolute; vertical-align:bottom; width:"+boxwidth+"px; height:"+box_height+"px; top:"+box_top+"px'/></div>";
	else
		divtext="<div id="+this.id+"box"+i+" style='position:absolute; width:"+box_width+"px; top:"+this.PositionTop+"px; left:"+img_left+"px; height:"+this.y+"px; z-index:1'><img src='"+boximg2+"' title = "+data[i]+"  style='position: absolute; vertical-align:bottom; width:"+boxwidth+"px; height:"+box_height+"px; top:"+box_top+"px'/></div>";
		
	document.write(divtext);
	}
	return(this);
  }
  this.setBackGround = function(bgpic)
  {
	var divtext="", img_top, img_left, img_height, img_width;
	
	img_top = this.PositionTop;
	img_left = this.PositionLeft + 1;
	img_height = ith_getElementById(this.id+'y').style.height;
	img_width = ith_getElementById(this.id+'x').style.width;
	
	divtext="<div id="+this.id+"bgimg style='position:absolute; width:"+img_width+"; top:"+img_top+"px; left:"+img_left+"px; height:"+img_height+"; z-index:1'><img src='"+bgpic+"' width="+img_width+" height="+img_height+" style = 'z-index:-1'/></div>";
	document.write(divtext);
	return(this);
  }
  this.DiagramTitle = function(Dtitle)
  {
	var divtext="", title_left = this.PositionLeft + 1, title_top = this.PositionTop - 20;
	divtext="<div id="+this.id+"diaTitle style='position:absolute; font-family:Arial; font-size:16px; font-weight:bold; top:"+title_top+"px; left:"+title_left+"px; z-index:1'>" + Dtitle + "</div>";
	document.write(divtext);
	return(this);
  }
}