function setOpacity(obj, opacity) 
{
 opacity = (opacity == 100)?99.999:opacity; 
 obj.style.filter = "alpha(opacity:"+opacity+")"; 
 obj.style.KHTMLOpacity = opacity/100;  
 obj.style.MozOpacity = opacity/100;
 obj.style.opacity = opacity/100;
}

function obj_show(objname,option)
{
	if (obj=document.getElementById(objname))
	{
		if (option)
			obj.style.visibility='visible';
		else
			obj.style.display='block';
	}
	
}

function obj_hide(objname,option)
{
	if (obj=document.getElementById(objname))
	{
		if (option)
			obj.style.visibility='hidden';
		else
			obj.style.display='none';
	}
}

function bgcenter()
{
	y=window.pageYOffset;
	if (!y)
	{
		y=document.body.scrollTop ;
	}
	if (!y)
	{
		y=document.documentElement.scrollTop;
	}

	document.getElementById('outside1').style.top=y+'px';
	document.getElementById('outside2').style.top=y+'px';
}

function myRandom(min,max) 
{
  return(min+parseInt(Math.random()*(max-min+1)));
} 

function loadoutside()
{
	setOpacity(document.getElementById('outside1'), 70);
}

function closeoutside()
{
	document.getElementById('outside1').style.display='none';
	document.getElementById('outside2').style.display='none';
}

function openoutside()
{
	if (document.getElementById('outside').innerHTML!='error')
	{
		document.getElementById('outside1').style.display='block';
		document.getElementById('outside2').style.display='block';
	}
}

function do_query(myurl)
{
	var jetzt = new Date();
	ajaxRequest(myurl+'&time='+jetzt.getTime(),'outside',0,'','openoutside()');
}

function do_now_form(myurl,myform)
{
	var jetzt = new Date();
	document.getElementById('outside_erg').innerHTML=='';
	ajaxRequestPost(myurl+'&time='+jetzt.getTime(),'outside_erg',0,myform,'if (document.getElementById(\'outside_erg\').innerHTML==\'ok\') {location.reload();} else {myhtml=document.getElementById(\'outside_erg\').innerHTML;document.getElementById(\'outside_erg\').innerHTML=\'error\';document.getElementById(\'outside\').innerHTML=myhtml;}');
}

function do_now(myurl)
{
	var jetzt = new Date();
	document.getElementById('outside_erg').innerHTML=='';
	ajaxRequest(myurl+'&time='+jetzt.getTime(),'outside_erg',0,'','if (document.getElementById(\'outside_erg\').innerHTML==\'ok\') location.reload()');
}

function popup(Ziel,breite,hoehe) 
{
	if(top.mypopup) 
		if(!top.mypopup.closed) 
			top.mypopup.close();

	if (breite&&hoehe)
		mypopup = open(Ziel,'myPopUp',"width="+breite+",height="+hoehe+",statusbar=no,toolbar=no,locationbar=no,directories=no,scrollbars=yes,status=no,menubar=no,resizable=yes");
	else
		mypopup = open(Ziel,'_blank');
}

var faq_old=0;
function faq(obj)
{
	num=obj.id;
	num=num.replace(/faq/ig,'');
	num=num.replace(/head/ig,'');
	
	if (faq_old) 
	{
		document.getElementById('faq'+faq_old+'head').className='faqhead';
		document.getElementById('faq'+faq_old+'text').className='faqtext';
	}
	
	if (faq_old!=num)
	{
		document.getElementById('faq'+num+'head').className='faqhead_on';
		document.getElementById('faq'+num+'text').className='faqtext_on';
		faq_old=num;
	} else faq_old=0;
}

var dropdown=new Array();

function dropdown_click(uid)
{
	for(key in dropdown) 
		if (key!=uid) 
			{
				document.getElementById(key+'_2').className='unten';
				document.getElementById(key+'_1').className='oben';
			}
	
	if (document.getElementById(uid+'_2').className=='unten_on')
	{
		document.getElementById(uid+'_2').className='unten';
		document.getElementById(uid+'_1').className='oben';
	}
	else
	{
		document.getElementById(uid+'_2').className='unten_on';
		document.getElementById(uid+'_1').className='oben_on';
	}
}

function show_item(obj,obj2)
{
	if (document.getElementById(obj2))
		document.getElementById('item_inner').innerHTML=document.getElementById(obj2).innerHTML+document.getElementById(obj).innerHTML;
	else
		document.getElementById('item_inner').innerHTML=document.getElementById(obj).innerHTML;
	document.getElementById('item').style.display='block';
	document.getElementById('shadow').style.display='block';
}

function hide_item()
{
	document.getElementById('item').style.display='none';
	document.getElementById('shadow').style.display='none';
}


function people_over(obj)
{
	document.getElementById(obj).className='people_on';
}

function people_out(obj)
{
	document.getElementById(obj).className='people';
}

var people='';

function people_on(obj)
{
	if (people) document.getElementById(people).className='people';
	document.getElementById(obj).className='people_on';
	document.getElementById('right').innerHTML=document.getElementById('right_'+obj).innerHTML;
	
	people=obj;
}

var kontakt='';

function kontakt_on(obj)
{
	if (kontakt) document.getElementById(kontakt).className='kontakt';
	document.getElementById(obj).className='kontakt_on';
	document.getElementById('kontakt_info').innerHTML=document.getElementById('text_'+obj).innerHTML;
	
	kontakt=obj;
}


var pulldown=0;
var pulldown_obj=null;
var pulldown_on=0;

function pulldown_over(obj)
{
	pulldown_on=1;
	pulldown_holder();
	if (obj.id=='pulldown_main') 
		obj.className='pulldown_on';
	else
		obj.className='pulldown_sub_on';
}

function pulldown_out(obj)
{
	if (obj.id=='pulldown_main') 
	{
		pulldown_obj=obj;
		window.setTimeout('pulldown_now('+pulldown+')',100);
	}
	else
		obj.className='pulldown_sub';
}

function pulldown_now(num)
{
	if(num==pulldown)
	{
		pulldown_on=0;
		pulldown_obj.className='pulldown';
		pulldown_obj=null;
	}
}



function pulldown_holder(obj)
{
	pulldown++;
	if (!pulldown_on&&obj)
		if (obj.className='pulldown')
		{
			obj.className='pulldown_over';
		}
}

var termin_on=1;


function cor_year(num)
{
	if (num<2000) num+=1900;
	return num;
}

function cor_date(num)
{
	num=num*1;
	if(num<10) num='0'+num;
	return num;
}

min_date = new Date();

var termin_d=0;
var termin_m=0;
var termin_j=0;

var termin_d_org=0;
var termin_m_org=0;
var termin_j_org=0;

function termin(obj)
{
		if (termin_on==1)
		{
			termin_d=0;
			termin_m=min_date.getMonth();
			termin_j=cor_year(min_date.getYear());
			if (!isNaN(document.send.d_d.value)&&!isNaN(document.send.d_m.value*1)&&!isNaN(document.send.d_j.value*1)) 
			{
				termin_d=document.send.d_d.value*1;
				termin_m=document.send.d_m.value*1-1;
				termin_j=document.send.d_j.value*1;
			}
			
			termin_d_org=termin_d;
			termin_m_org=termin_m;
			termin_j_org=termin_j;
			
			if (termin_d==0) termin_d=1;
			termin_render();
			document.getElementById('termin').className='termin_on';
		}
		termin_on=0;
}

function termin_off()
{
	document.getElementById('termin').className='termin_off';
	window.setTimeout('termin_on=1;',1)
}

var monate=new Array('Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember');



function termin_render()
{
	jetzt = new Date();
	jetzt.setDate(termin_d);
	jetzt.setMonth(termin_m);
	jetzt.setYear(termin_j);
	
	jetzt.setDate(1);

	html='<div class="inner">';
	html+='<table cellspacing="0" cellpadding="0" border="0" width="100%">';
	html+='<tr>';
	
	if (jetzt>min_date)
		html+='<td><div class="termin_left" onclick="termin_minus()"><x></div></td>';
	else
		html+='<td><div class="month"><x></div></td>';
	
	html+='<td><div class="termin_center">'+monate[termin_m]+' '+termin_j+'</div></td>';
	html+='<td><div class="termin_right"  onclick="termin_plus()"><x></div></td>';
	html+='</tr>';
	
	html+='</table>';
	
	html+='<div class="month">Mo</div>';
	html+='<div class="month">Di</div>';
	html+='<div class="month">Mi</div>';
	html+='<div class="month">Do</div>';
	html+='<div class="month">Fr</div>';
	html+='<div class="month">Sa</div>';
	html+='<div class="month">So</div>';
	
	num=jetzt.getDay()*1;
	if (num==0) num=7;
	if (num==1) num=8;
	num--;
	c_num=0;
	for(i=1;i<=num;i++)
	{
		html+='<div class="day_dis"><x></div>';
		c_num++;
	}

	for(i=1;i<=31;i++)
	{
		jetzt.setDate(i);
		if (termin_m==jetzt.getMonth())
		{
			if (jetzt<min_date)
				html+='<div class="day_dis">'+i+'</div>';
			else
				if (termin_m_org==jetzt.getMonth()&&termin_j_org==cor_year(jetzt.getYear())&&termin_d_org==jetzt.getDate())
				html+='<div class="day_on" onclick="termin_this('+jetzt.getDate()+','+(jetzt.getMonth()+1)+','+cor_year(jetzt.getYear())+')">'+i+'</div>';
				else
				html+='<div class="day_off" onclick="termin_this('+jetzt.getDate()+','+(jetzt.getMonth()+1)+','+cor_year(jetzt.getYear())+')">'+i+'</div>';
			num=jetzt.getDay();
			c_num++;
		}
	}
	
	num=7-num;
	
	if (c_num+num!=42) num=num+7;
	
	for(i=1;i<=num;i++)
	{
		html+='<div class="day_dis"><x></div>';
	}

	
	html+='<div class="end"><x></div>';
	
	html+='<div class="termin_close"><a href="#" onclick="termin_off();return false">x schließen</a></div>';
	html+='</div>';
	document.getElementById('termin').innerHTML=html;
}

function termin_minus()
{
	termin_m--;
	if (termin_m<0)
	{
		termin_j--;
		termin_m=11;
	}
	termin_render();
}

function termin_plus()
{
	termin_m++;
	if (termin_m>11)
	{
		termin_j++;
		termin_m=0;
	}
	termin_render();
}

function termin_this(tag,monat,jahr)
{
	termin_d_org=tag;
	termin_m_org=monat-1;
	termin_j_org=jahr;
	
	document.send.d_d.value=cor_date(tag);
	document.send.d_m.value=cor_date(monat);
	document.send.d_j.value=jahr;
	termin_render();
}

function display(obj)
{
	document.getElementById(obj).style.display='block';
}

function hide(obj)
{
	document.getElementById(obj).style.display='none';
}

function check(url)
{
	ajaxRequestPost(url,'ajax',0,document.send,'check_error()');
}

var old_errors=new Array();

function check_error()
{
	errors=document.getElementById('ajax').innerHTML;
	teile=errors.split('|');
	
	for(key in old_errors)
	if(old_errors[key])
	{
		if (document.getElementById(key))
		{
			if (old_errors[key]!=1)
				document.getElementById(key).className=old_errors[key];
			else
				document.getElementById(key).className='no_error';
		}
		old_errors[key]=0;
	}
	
	for(i in teile)
	if (teile[i])
	{
		if (document.getElementById(teile[i]))
		{
			old_errors[teile[i]]=document.getElementById(teile[i]).className;
			if (!old_errors[teile[i]]) old_errors[teile[i]]=1;
			document.getElementById(teile[i]).className='error';
			
		}
	}
	if (teile[0]=='ok')
	{
		location.href=teile[1].replace('&amp;','&');
	}
	else
		display('error');
}

function bundesland_on(obj)
{
	if (document.getElementById(obj).className!='absolute_def')
		document.getElementById(obj).className='absolute';
}

function bundesland_off(obj)
{
	if (document.getElementById(obj))
		if (document.getElementById(obj).className!='absolute_def')
			document.getElementById(obj).className='absolute_dis';
}

function bundesland_def(obj)
{
	if (document.getElementById(obj))
	{
		window.setTimeout("bundesland_layer()",10);
		document.getElementById(obj).className='absolute_def';
	}
}

function bundesland_layer()
{
		if (document.getElementById('bundesland_layer'))
		{
			document.getElementById('bundesland_show_layer_inner').innerHTML=document.getElementById('bundesland_layer').innerHTML;
			document.getElementById('bundesland_show_layer').style.display='block';
		}
}

function bundesland_close_layer()
{
	document.getElementById('bundesland_show_layer').style.display='none';
}

function quis_check()
{
	my_error=0;
	if (!document.send.frage1[0].checked && !document.send.frage1[1].checked && !document.send.frage1[2].checked)	my_error=1;
	if (!document.send.frage2[0].checked && !document.send.frage2[1].checked && !document.send.frage2[2].checked)	my_error=1;
	if (!document.send.frage3[0].checked && !document.send.frage3[1].checked && !document.send.frage3[2].checked)	my_error=1;
	if (!my_error){hide('error2');hide('quis_fragen');display('bewerbung');}else	display('error2');
}

var bilder=new Array();
var next_id=0;
var last_id=0;

function bild_der_galerie(galerie,bildnr)
{
	
	if(bilder[bildnr+1]){
		next_id=bildnr+1;
		document.getElementById('next').style.display='block';
	} else {
		document.getElementById('next').style.display='none';
	}
	
	if(bilder[bildnr-1]){
		last_id=bildnr-1;
		document.getElementById('last').style.display='block';
	} else {
		document.getElementById('last').style.display='none';
	}
	
	document.getElementById('big_pic').src=bilder[bildnr];	
	
	document.getElementById('shadow').style.display='block';
	
	var objLightboxContainer = document.getElementById('ajax');
	objLightboxContainer.innerHTML=document.getElementById('ajax_pic').innerHTML;
	
	// TP PK Start: Calculate Lightbox-Position
	var objViewportDims    = getViewportDimensions();
	var objLightboxContent = objLightboxContainer.getElementsByTagName('table')[0];
	
	var iPosTop  = ( objViewportDims.height - parseInt( objLightboxContent.style.height, 10 ) ) / 2;
	var iPosLeft = ( objViewportDims.width - parseInt( objLightboxContent.style.width, 10 ) ) / 2;
	
	// If IE6 or Viewport is too small => absolute positioning
	if (
			(
				( iPosTop < 0 ) ||
				( iPosTop < 0 )
			) ||
			(
				( typeof window.innerWidth == 'undefined' ) &&
				( typeof document.documentElement != 'undefined' ) && 
				( typeof document.documentElement.clientWidth != 'undefined' ) && 
				( document.documentElement.clientWidth != 0 )
			)
		)
	{
		y = window.pageYOffset;
		if (!y)
		{
			y = document.body.scrollTop ;
		}
		if (!y)
		{
			y = document.documentElement.scrollTop;
		}
		objLightboxContainer.style.position = 'absolute';
	}
	// Alle anderen mit fixierter Positionierung 
	else
	{
		objLightboxContainer.style.position = 'fixed';
		y = 0;
	}
	
	iPosTop  = ( iPosTop  > 0 ? iPosTop  : 0 );
	iPosLeft = ( iPosLeft > 0 ? iPosLeft : 0 );

	objLightboxContainer.style.left    = [ iPosLeft, 'px' ].join('');
	objLightboxContainer.style.top     = [ ( y + iPosTop ), 'px' ].join('');
	objLightboxContainer.style.display = 'block';	
	objLightboxContainer.style.zIndex = 1001;
	document.getElementById('shadow').style.zIndex = 1000;
	document.getElementById('big_pic').style.zIndex = 1002;	
	// TP PK End
	
	shadowfix();
	
	
}

/**
 * Get the Viewport-dimensions (x-Browser-compatible)
 */ 
function getViewportDimensions()
{
	var viewportwidth;
	var viewportheight;
	
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	
	if ( typeof window.innerWidth != 'undefined' )
	{
		viewportwidth  = window.innerWidth,
		viewportheight = window.innerHeight
	}
	
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	
	else if (
				( typeof document.documentElement != 'undefined' ) && 
				( typeof document.documentElement.clientWidth != 'undefined' ) && 
				( document.documentElement.clientWidth != 0 )
			)
	{
	   viewportwidth  = document.documentElement.clientWidth,
	   viewportheight = document.documentElement.clientHeight
	}
	
	// older versions of IE
	
	else
	{
	   viewportwidth  = document.getElementsByTagName('body')[0].clientWidth,
	   viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}
	return {'width':viewportwidth,'height':viewportheight};
}


function shadowfix()
{
			if (document.getElementById('shadow').style.display=='block')
			{
				window.setTimeout('shadowfix()',1);
				for(i=1;i<=100;i++)
				{
					if (document.body.scrollTop||document.body.scrollLeft)obj=document.body;else obj=document.documentElement;
					y=obj.scrollTop+100;
					document.getElementById('shadow').style.top=obj.scrollTop+'px';
				}
			}
}

 
function bild_der_galerie_schliessen(){
	document.getElementById('shadow').style.display='none';
	document.getElementById('ajax').style.display='none';

}
