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 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 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');
}


function display(obj)
{
	if (document.getElementById(obj))
		document.getElementById(obj).style.display='block';
}


function check(url,form)
{
	ajaxRequestPost(url,'ajax',0,form,'check_error()');
}

function check2(url,form)
{
	document.getElementById('ajax').innerHTML='';
	check2_listener();
	form.submit();
}

function check2_listener(){
	if (document.getElementById('ajax').innerHTML=='')
	{
		window.setTimeout("check2_listener()",1);
	}
	else
	{
		window.setTimeout('check_error()',1);
	}
}

var old_errors=new Array();

function check_error()
{
	errors=document.getElementById('ajax').innerHTML;
	teile=errors.split('|');
	//alert(errors);
	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]=='beratungok')
	{
		beratung(teile[1]);
	}
	else
	if (teile[0]=='ok')
	{
		if (teile[1])
		{
			teile[1]=teile[1].replace('&amp;','&');
			location.href=teile[1];
		}
		if (teile[2])
		{
			teile[2]=teile[2].replace('&amp;','&');
			eval(teile[2]);
		}
		hide_layer();
	}
}

function un_check_error()
{
	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;
	}
}

var merke_menu=new Array();
var menu_out_timer_num=null;

function menu_over(s_id,s_bild,s_class,s_obj)
{
	clearTimeout(menu_out_timer_num);
	if (merke_menu['s_id']!=s_id)
	{
		menu_out_now();
		merke_menu['s_id']=s_id;
		merke_menu['s_bild']=document.getElementById('menu_'+s_id).src;
		merke_menu['s_class']=s_obj.className;
		merke_menu['s_obj']=s_obj;

		document.getElementById('menu_'+s_id).src=s_bild;
		s_obj.className=s_class;
		document.getElementById('sub_'+s_id).style.display="block";
	}
}

function menu_out()
{
	clearTimeout(menu_out_timer_num);
	menu_out_timer_num=window.setTimeout('menu_out_now();',500);
}

function menu_out_now()
{
	if (merke_menu['s_id'])
	{
		document.getElementById('menu_'+merke_menu['s_id']).src=merke_menu['s_bild'];
		merke_menu['s_obj'].className=merke_menu['s_class'];
		document.getElementById('sub_'+merke_menu['s_id']).style.display="none";
		merke_menu['s_id']=null;
	}
}

function getCookie(cookieName)
{
 if(document.cookie)
  gespeichert = document.cookie;
 else
  return false;
  test=gespeichert.split("; ");
  for (i=0;i<=test.length-1;i++)
  {
  	teile=test[i].split('=');
  	if (teile[0]==cookieName)
  		return teile[1];
  }
 return false;
}

function setCookie(cookieName,cookieValue)
{
  document.cookie =cookieName+'='+cookieValue+';';
}

var ticker_pos=0;
var ticker_fps=40;
var ticker_pixel=1;
var ticker_run_stop=0;
var ticker_add_timer=0;




function ticker(starttime)
{
	obj=document.getElementById('ticker');
	if (!obj) return false;

	if (ticker_run_stop)
	{
		window.setTimeout('ticker(\''+starttime+'\')',10);
		return false;
	}

	if (ticker_add_timer)
	{
		starttime=starttime*1+ticker_add_timer*1;
		ticker_add_timer=0;
	}


	var zeit = new Date();
	var ms = zeit.getTime();
	if (!starttime) starttime=zeit.getTime();
	diff=ms-starttime;
	time_pixel=(1/ticker_fps)*1000;
	pos=Math.round(diff/time_pixel)*ticker_pixel;
	if (pos>ticker_width)
	{
		pos=0;
		starttime=ms;
	}

	if (ticker_pos!=pos*-1)
	{
		ticker_pos=pos*-1;
		obj.style.marginLeft=ticker_pos+'px';
	}

	window.setTimeout('ticker('+starttime+')',25);
}

var timer_run_num=null;

function ticker_stop()
{
	if (timer_run_num) window.clearTimeout(timer_run_num);
	timer_run_num=null;

	if (!ticker_run_stop)
	{
		var zeit = new Date();
		ticker_run_stop=zeit.getTime();
	}
}

function ticker_run()
{
	if (timer_run_num) window.clearTimeout(timer_run_num);
	timer_run_num=window.setTimeout("ticker_run_timer()",100);
}

function ticker_run_timer()
{
	var zeit = new Date();
	ticker_add_timer=zeit.getTime()-ticker_run_stop;
	ticker_run_stop=0;
}

function my_init()
{
	starttime=0;
	//if (getCookie('Ticker'))
		//starttime=getCookie('Ticker');
	window.setTimeout("ticker(0)",1000);
}

var shop_gal_on=1;
var shop_gal_ov=0;

function shop_gal_over(obj)
{
	akt=obj.id.replace('gal_nav_','');

	if(akt!=shop_gal_on)
	{
		obj.className=obj.className.replace('off')+' on';
		shop_gal_ov=akt;

		/*obj=document.getElementById('gal_bild_'+shop_gal_ov);
		obj.style.display='block';

		obj=document.getElementById('gal_bild_'+shop_gal_on);
		obj.style.display='none';*/

	}
}

function shop_gal_out()
{
	if (shop_gal_ov)
	{
		/*obj=document.getElementById('gal_bild_'+shop_gal_on);
		obj.style.display='block';

		obj=document.getElementById('gal_bild_'+shop_gal_ov);
		obj.style.display='none';*/

		obj=document.getElementById('gal_nav_'+shop_gal_ov);
		obj.className=obj.className.replace('on')+' off';
		shop_gal_ov=0;
	}
}

function shop_gal_click(obj)
{
	akt=obj.id.replace('gal_nav_','');
	if (akt!=shop_gal_on)
	{
		obj=document.getElementById('gal_bild_'+akt);
		obj.style.display='block';

		obj=document.getElementById('gal_bild_'+shop_gal_on);
		obj.style.display='none';

		shop_gal_ov=shop_gal_on;
		shop_gal_on=akt;
		shop_gal_out();
	}
}

function show_layer(url)
{
	ajaxRequest(url,'layer',0,'','show_layer_now()');
}

function show_layer_now()
{
	obj=document.getElementById('layer');
	obj.style.display='block';

	if (!document.documentElement)
		mwidth=window.innerWidth-obj.offsetWidth;
	else
		mwidth=document.documentElement.clientWidth-obj.offsetWidth;

	if (mwidth<0)
		mwidth=0;
	else
		mwidth=Math.round(mwidth/2);

	if (!document.documentElement)
		mheight=window.innerHeight-obj.offsetHeight;
	else
		mheight=document.documentElement.clientHeight-obj.offsetHeight;

	if (mheight<0)
		mheight=0;
	else
		mheight=Math.round(mheight/2);

	if (!document.documentElement)
	{
		mwidth+=	window.scrollLeft;
		mheight+=	window.scrollTop;
	}
	else
	{
		mwidth+=	document.documentElement.scrollLeft;
		mheight+=	document.documentElement.scrollTop;
	}

	obj.style.left=mwidth+'px';
	obj.style.top=mheight+'px';



}

function hide_layer()
{
	obj=document.getElementById('layer');
	obj.style.display='none';
	obj.innerHTML='';
}




function schliessen()
{
		myclose=1;
		window.setTimeout('closesprachboxnow()',100);
}

var myclose=1;
function closesprachboxnow()
{
		if (myclose==1)
			if (document.getElementById) document.getElementById('sprachbox').style.visibility='hidden';
}



function schliessenCountry()
{
		myCountryclose=1;
		window.setTimeout('closecountryboxnow()',100);
}

var myCountryclose=1;
function closecountryboxnow()
{
		if (myCountryclose==1)
			if (document.getElementById) document.getElementById('countrybox').style.visibility='hidden';
}



function setElement(id,eigenschaft,wert)
{
	if (document.getElementById)
	{
		if ((eigenschaft=='className')||(eigenschaft=='innerHTML')) {
			eval("document.getElementById('"+id+"')."+eigenschaft+"='"+wert+"';");
		} else {
			eval("document.getElementById('"+id+"').style."+eigenschaft+"='"+wert+"';");
		}
	}
}


/*
	Box
*/
var activeNav = '1';

// Left Navigation
function changeBoxNav(inactive, active, check)
{
	if (check == 'true') {
		if ('mainLinkActive_'+activeNav != inactive) {
			makeBoxNav(inactive, active);
		}
	} else {
		makeBoxNav(inactive, active);
	}
}

function makeBoxNav(inactive, active) {
	document.getElementById(inactive).style.display ='none';
	document.getElementById(inactive).style.visibility ='hidden';

	document.getElementById(active).style.display ='block';
	document.getElementById(active).style.visibility ='visible';
}

// Text
function changeBoxText(inactive, active)
{
changeMainInnerText(inactive, 1);
	// Text-Box
	document.getElementById('text_'+inactive).style.display ='none';
	document.getElementById('text_'+inactive).style.visibility ='hidden';

	document.getElementById('text_'+active).style.display ='block';
	document.getElementById('text_'+active).style.visibility ='visible';

	// Scroller
	document.getElementById('text_scroller_'+inactive).style.display ='none';
	document.getElementById('text_scroller_'+inactive).style.visibility ='hidden';

	document.getElementById('text_scroller_'+active).style.display ='block';
	document.getElementById('text_scroller_'+active).style.visibility ='visible';


//alert(inactive);
}

function changeMainInnerText(layer, id)
{
	for (var i=1; i<=3; i++)
	{
		document.getElementById('text_'+layer+'_'+i).style.display ='none';
		document.getElementById('text_'+layer+'_'+i).style.visibility ='hidden';

		if (document.getElementById('scroller_'+layer+'_'+i)) {
			document.getElementById('scroller_'+layer+'_'+i).className = 'scrollerInactive';
		}
	}

	if (document.getElementById('scroller_'+layer+'_'+id)) {
		document.getElementById('scroller_'+layer+'_'+id).className = 'scrollerActive';
	}
	document.getElementById('text_'+layer+'_'+id).style.display ='block';
	document.getElementById('text_'+layer+'_'+id).style.visibility ='visible';
}

// Box
function changeBox(active)
{
	changeBoxNav('mainLinkActive_'+activeNav, 'mainLinkActive_'+active, false);

	document.getElementById('mainLinkInactive_'+activeNav).style.display ='block';
	document.getElementById('mainLinkInactive_'+activeNav).style.visibility ='visible';

	// Text aussen Div
	changeBoxText(activeNav, active);


	activeNav = active;
}


/*
	FAQ
*/
function changeFAQ(id, plus, minus)
{
	Effect.toggle('faq_'+id, 'slide', { duration: 0.5 });

	if (document.getElementById('faq_'+id).style.display == 'none') {
		document.getElementById('head_faq_'+id).src=minus;
	} else {
		document.getElementById('head_faq_'+id).src=plus;
	}
}



/*
	Menue
*/
function changeMenu(id, inOut, change)
{
	if (change != 'true')
		return;

	if (inOut == 'in') {
		document.getElementById(id+'_inactive').style.display ='none';
		document.getElementById(id+'_inactive').style.visibility ='hidden';

		document.getElementById(id+'_active').style.display ='block';
		document.getElementById(id+'_active').style.visibility ='visible';
	} else {
		document.getElementById(id+'_inactive').style.display ='block';
		document.getElementById(id+'_inactive').style.visibility ='visible';

		document.getElementById(id+'_active').style.display ='none';
		document.getElementById(id+'_active').style.visibility ='hidden';
	}
}
