var winst = new Array();
var Ziel_hoehe = 120;
var Aktuelle_hoehe = 0;
for ( i=0; i < 1; i++ )
 { winst[i] = new Array(2); }

function region_filter(region)
 {
 	 var tempname = document.kalender_bits;
 	 var id = '';
 	 var klasse = '1';

	 document.getElementById('region_all').style.textDecoration = 'none';
	 document.getElementById('region_1').style.textDecoration = 'none';
	 document.getElementById('region_2').style.textDecoration = 'none';
	 document.getElementById('region_3').style.textDecoration = 'none';
	 
	 document.getElementById('region_' + region).style.textDecoration = 'underline';
 
 	 if ( region != 'all' ) {
		 for(var i=0; i<tempname.length; i++) {



			 id = tempname.elements[i].name;

			 if(typeof winst[id] == "undefined")
			 {
			    winst[id] = new Array(2);
			    winst[id][0] = false;
			    winst[id][1] = '';
			 }

			if ( tempname.elements[i].value == region )
			 { 
			 
			  if ( klasse == 1 ) 
			   { klasse = 2; }
			  else
			   { klasse = 1; }
			 
			  document.getElementById('row_' + id).klasseName = 'row_kalender_' + klasse;
			  document.getElementById('row_' + id).style.display = '';
			  document.getElementById('row_' + id).style.visibility = 'visible';
			  
			  if ( winst[id][0] == true )
			   {
			  	document.getElementById('box_' + id).style.display = '';
			  	document.getElementById('box_' + id).style.visibility = 'visible';			   	
			   }
			 }			
			else
			 { 
			  document.getElementById('row_' + id).style.display = 'none';
			  document.getElementById('row_' + id).style.visibility = 'hidden';
			  document.getElementById('box_' + id).style.display = 'none';
			  document.getElementById('box_' + id).style.visibility = 'hidden';
			 }
		 }
	 } 
	 else {
		 for(var i=0; i<tempname.length; i++) {
		 	 id = tempname.elements[i].name;
			 
			 if ( klasse == 1 ) { klasse = 2; }
			 else { klasse = 1; }		 	 
			  
			  document.getElementById('row_' + id).klasseName = 'row_kalender_' + klasse;
			  document.getElementById('row_' + id).style.display = '';
			  document.getElementById('row_' + id).style.visibility = 'visible';
			 
			 if(typeof winst[id] == "undefined")
			 {
			    winst[id] = new Array(2);
			    winst[id][0] = false;
			    winst[id][1] = '';
			 }
			 
			  if ( winst[id][0] == true )
			   {
			  	document.getElementById('box_' + id).style.display = '';
			  	document.getElementById('box_' + id).style.visibility = 'visible';			   	
			   }			  
		 }
	 }	 

 }
 
function ausklappen(id, Ziel_hoehe, Aktuelle_hoehe)
 {
 	
  	
	if ( Aktuelle_hoehe <= Ziel_hoehe ) {
		document.getElementById('hid_'+id).style.overflow = "hidden";
		Aktuelle_hoehe += 30;
		document.getElementById('hid_'+id).style.height = Aktuelle_hoehe + "px";
		window.setTimeout("ausklappen('" + id + "', " + Ziel_hoehe + ", " + Aktuelle_hoehe + ")", 25);
	}
	else
	 {
	  document.getElementById('hid_'+id).style.overflow = "auto";
	  document.getElementById("load_" + id).innerHTML = "";
	   	
  
	 }
 }

function einklappen(id, Ziel_hoehe, Aktuelle_hoehe)
 {

	if ( Aktuelle_hoehe > Ziel_hoehe ) {
		document.getElementById('hid_'+id).style.overflow = 'hidden';
		Aktuelle_hoehe -= 30;
		if ( Aktuelle_hoehe < 0 ) { Aktuelle_hoehe = 0; }
		document.getElementById('hid_'+id).style.height = Aktuelle_hoehe + "px";
		window.setTimeout("einklappen('" + id + "', " + Ziel_hoehe + ", " + Aktuelle_hoehe + ")", 25);
	}
	else
	 {
		document.getElementById('box_'+id).style.display = 'none';
		document.getElementById('box_'+id).style.visibility = 'hidden';
	 }
 }
function klappen(id, date, Ziel_hoehe, Aktuelle_hoehe, mode)
{


 if(typeof winst[id] == "undefined")
 {
    winst[id] = new Array(2);
    winst[id][0] = false;
    winst[id][1] = '';
 }

	if(winst[id][0]) // Aufgeklappt
	{
		if(winst[id][1] == mode) // Zuklappen
		{
			einklappen(id, 0, document.getElementById('hid_'+id).style.height.replace('px', ''));
			// document.getElementById(mode+'_'+id).style.fontSize = "8pt";
			winst[id][0] = false;
		} else { // Anderes aufklappen
			// document.getElementById(winst[id][1]+'_'+id).style.fontSize = "8pt";
			winst[id][1] = mode;
			// document.getElementById(mode+'_'+id).style.fontSize = "9pt";
			document.getElementById('hid_'+id).innerHTML = '<img src="/images/circle-ball.gif" border="0" width="16" height="16">&nbsp;Loading...';
			pc_kalender(id,date,mode,Ziel_hoehe);
		}
	} else { // Zugeklappt
		winst[id][0] = true;
		winst[id][1] = mode;

		var imgs = '<img src="/images/v4/indicator_tiny_red.gif" border="0" width="10" height="10">';
		document.getElementById("load_" + id).innerHTML = imgs;
		document.getElementById("box_" + id).style.display = "";
		document.getElementById("box_" + id).style.height = "30px";
		document.getElementById("box_" + id).style.visibility = "visible";

		pc_kalender(id,date,mode,Ziel_hoehe);
	}
	


}


function get_http_response_cal()
{
  
  try
  {
    if(req_cal.readyState == 4)
    {
      if(req_cal.status == 200)
      {
        if(req_cal.responseText != '')
        {
          
          eval(req_cal.responseText);
        }
      }
      if(document.all && !window.opera)
      {
      req_cal.abort();
      }
      lock_cal = false;
    }
  }
  catch(e)
  {
  }
}