var used="";
var touse="";
var targetwidth=150;
var block=false;
var inshow=false;
var inhide=false;
var xmlhttp=false;
var xmlhttpa=false;
var lang="";
var base="";
var usecomm="";
var bodyopacity=50;
var doScroll=false;
var loadedsub="";
var scommand="";
var bg="#FFFFFF";
var bg2="#000000";
var bgswitch=false;

/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttpa = new ActiveXObject("Msxml2.xmlhttp");
} catch (e) {
try {
xmlhttpa = new ActiveXObject("Microsoft.xmlhttp");
} catch (E) {
xmlhttpa = false;
}
}
@end @*/
if (!xmlhttpa && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttpa = new XMLHttpRequest();
	} catch (e) {
		xmlhttpa=false;
	}
}
if (!xmlhttpa && window.createRequest) {
	try {
		xmlhttpa = window.createRequest();
	} catch (e) {
		xmlhttpa=false;
	}
}


/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

function switchbg()
{
	var ibg=document.getElementById("contentdiv").style.backgroundColor;
	if (!bgswitch)
	{
		document.getElementById("maincontent").style.backgroundColor=bg2;
		bgswitch=true;
	}else
	{
		document.getElementById("maincontent").style.backgroundColor=bg;
		bgswitch=false;
	}
	//document.getElementById("contentdiv").style.backgroundColor="#000000";
	///alert(ibg);
}


function body_onload()
{
	//eval(scommand);
	//opac_up();
	document.getElementById("contentdiv").style.display="block";
	document.getElementById("maincontent").style.background="none";
}



function togglesubmenu(menuname,lpage)
{
/*if (lpage)
	{ 
		document.location=base+"f/"+lang+"/"+lpage+"/"+menuname;
	}
	else*/
	{
		document.location=base+"f/"+lang+"/"+lpage;
	}
		
/*
	if (!block)
	{
		if ((used!=touse) && (menuname!=loadedsub)){
			used=touse;
			hidesubmenu();

			if (typeof(lpage)!='undefined'){loadcontent(lpage);}
			getsubmenu(menuname,"waitforunblock('showsubmenu();')");




		}else{

			if (parseInt(document.getElementById('submenuholder').style.width)<targetwidth)
			{
				getsubmenu(menuname,"showsubmenu();");
			}else
			{
				hidesubmenu();
			}
		}
	}
	*/
}

function waitforunblock(command)
{
	if (!block)
	{
		eval(command);
	}else
	{
		setTimeout ("waitforunblock('"+command+"');",100);
	}
}


function loadcontent(lpage)
{
	if (lpage!='undefined'){
		xmlhttpa.onreadystatechange=function() {
			if (xmlhttpa.readyState==4) {

				var xa=xmlhttpa.responseText.toString();
				document.getElementById("contentdiv").innerHTML=xa;

			}

		}
		xmlhttpa.open("GET", base+"page/"+lang+"/"+lpage,true);
		xmlhttpa.send(null);
		xmlhttpa.onreadystatechange=function() {
			if (xmlhttpa.readyState==4) {


				var xa=xmlhttpa.responseText.toString();
				document.getElementById("contentdiv").innerHTML=xa;

			}


		}
	}

}

function opac_up(){
	if (bodyopacity<100)
	{
		bodyopacity=bodyopacity+10;
		/*document.body.style.opacity=(bodyopacity/100);
		document.body.style.filter="alpha(opacity="+bodyopacity+")";*/
		document.getElementById("maincontent").style.filter="alpha(opacity="+bodyopacity+")";
		document.getElementById("maincontent").style.opacity=(bodyopacity/100);
		setTimeout("opac_up()",10);
	}
}

function opac_down(){
	if (bodyopacity>50)
	{
		bodyopacity=bodyopacity-10;
		/*document.body.style.opacity=(bodyopacity/100);
		document.body.style.filter="alpha(opacity="+bodyopacity+")";*/
		document.getElementById("maincontent").style.filter="alpha(opacity="+bodyopacity+")";
		document.getElementById("maincontent").style.opacity=(bodyopacity/100);
		setTimeout("opac_down()",10);
	}
}

function loadpage(page)
{
	opac_down();
		document.location=base+"f/"+lang+"/"+page;

}

function getsubmenu(menuname,command)
{
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			loadedsub=menuname;

			var xa=xmlhttp.responseText.toString();
			document.getElementById("submenuholder").innerHTML="<tbody>"+xa+"</tbody>";
			setTimeout(command,100);
		}

	}
	xmlhttp.open("GET", base+"submenu/"+lang+"/"+menuname,true);
	xmlhttp.send(null);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			loadedsub=menuname;

			var xa=xmlhttp.responseText.toString();
			document.getElementById("submenuholder").innerHTML="<tbody>"+xa+"</tbody>";
			setTimeout(command,100);
		}

	}

}

function showfast()
{
	document.getElementById('submenuholder').style.width=(parseInt(document.getElementById('submenuholder').style.width)+targetwidth).toString()+"px";
	document.getElementById('maincontent').style.width=(parseInt(document.getElementById('maincontent').style.width)-targetwidth).toString()+"px";
	inshow=false;
	block=false;
	document.getElementById('submenu').style.display="block";
}

function hidefast()
{
	document.getElementById('submenuholder').style.width=(parseInt(document.getElementById('submenuholder').style.width)-targetwidth).toString()+"px";
	document.getElementById('maincontent').style.width=(parseInt(document.getElementById('maincontent').style.width)+targetwidth).toString()+"px";
	inshow=false;
	block=false;
	document.getElementById('submenu').style.display="none";
}

function showsubmenu(fast)
{
	speed=1;
	//alert(speed);
	if (!block || inshow)
	{
		inshow=true;
		block=true;
		showfast();/*
		if (fast)
		{
		showfast();
		}

		if (parseInt(document.getElementById('submenuholder').style.width)<targetwidth)
		{


		document.getElementById('submenuholder').style.width=(parseInt(document.getElementById('submenuholder').style.width)+5).toString()+"px";

		document.getElementById('maincontent').style.width=(parseInt(document.getElementById('maincontent').style.width)-5).toString()+"px";
		setTimeout("showsubmenu("+fast+");",speed);

		}else{*/
		inshow=false;
		block=false;
		document.getElementById('submenu').style.display="block";
		//}
	}

}



function hidesubmenu()
{
	if (!block || inhide)
	{
		block=true;
		hidefast();
		/*
		if (parseInt(document.getElementById('submenuholder').style.width)>0)
		{
		document.getElementById('submenu').style.display="none";
		inhide=true;
		document.getElementById('submenuholder').style.width=(parseInt(document.getElementById('submenuholder').style.width)-5).toString()+"px";

		document.getElementById('maincontent').style.width=(parseInt(document.getElementById('maincontent').style.width)+5).toString()+"px";
		setTimeout("hidesubmenu();",1);

		}else{*/
		inhide=false;
		block=false;
		//}
	}

}

function startvScroll(was,wieviel,width)
{
	doScroll=true;
	vScroll(was,wieviel,width);
}

function stopScroll()
{
	doScroll=false;
}

function vScroll(was,wieviel,width)
{
	ax=parseInt(document.getElementById(was).style.left);
	elewidth=document.getElementById(was).offsetWidth;
	minimum=(elewidth*-1)+width/2;
	if (doScroll){

		//alert(ax);
		newx=ax+wieviel;
		if ((newx>minimum) && newx<(width/5)){
			document.getElementById(was).style.left=newx.toString()+"px";
			setTimeout("vScroll('"+was+"',"+wieviel+","+width+")",10);
		}
		else
		{
			//alert(width+"."+newx+"."+minimum+"."+elewidth);
			doScroll=false;
		}
	}

}

var special_opac=0;
var special_stop=false;
function hide_specials()
{
var elem=document.getElementById("special");
var elem2=document.getElementById("x_maintable");
		special_stop=false;
		bodyopacity=100;
		elem2.style.filter="alpha(opacity="+bodyopacity+")";
		elem2.style.opacity=(bodyopacity/100);
		elem.style.top="0px";
		elem.style.left="0px";
		elem.style.filter="alpha(opacity=0)";
		elem.style.opacity=0;
		elem.style.visibility="hidden";
		special_opac=0;
}

function show_specials(tmpvar)
{
var elem=document.getElementById("special");
var elem2=document.getElementById("x_maintable");
if (!special_stop)
{
	if(tmpvar==1)
	{
		special_stop=false;
		bodyopacity=100;
		elem2.style.filter="alpha(opacity="+bodyopacity+")";
		elem2.style.opacity=(bodyopacity/100);
		elem.style.top="25px";
		elem.style.left="0px";
		elem.style.filter="alpha(opacity=0)";
		elem.style.opacity=0;
		special_opac=0;
		setTimeout("show_specials(3);",10);
		
		
	}else if(tmpvar==2)
	{
		bodyopacity=bodyopacity-5;
		elem2.style.filter="alpha(opacity="+bodyopacity+")";
		elem2.style.opacity=(bodyopacity/100);
		if (bodyopacity>30)
		{
			setTimeout("show_specials(2);",10);
		}else
		{
			setTimeout("show_specials(3);",10);
			elem.style.visibility="visible";
		}
	}else if (tmpvar==3)
	{
		elem.style.visibility="visible";
		special_opac=special_opac+15;
		elem.style.filter="alpha(opacity="+special_opac+")";
		elem.style.opacity=(special_opac/100);
		if (special_opac<100)
		{
			setTimeout("show_specials(3);",10);
		}else
		{
		}
	}
	}else
	{
			special_stop=false;
	}
}




function nextSize(i,incMethod,textLength)
{
if (incMethod == 1) return 20+(5*Math.abs( Math.sin(i/(textLength/3.14))) );
if (incMethod == 2) return 20+(5*Math.abs( Math.cos(i/(textLength/3.14))));
}
function sizeCycle(text,method,dis)
{
	output =  "<font color='#000000'>";
	for (i = 0; i < text.length; i++)
	{
		size = parseInt(nextSize(i +dis,method,text.length));
		//output += "<font style='font-size: "+ size +"px'>" +text.substring(i,i+1)+ "</font>";
	}
	output += "<font style='font-size: "+ size +"px'>" +text+ "</font>";
	document.getElementById("angebotWave").innerHTML = output;
}
function doWave(n)
{
	theText = 'Top-Angebot';
	sizeCycle(theText,2,n);
	if (n > theText.length) {n=0}
	setTimeout("doWave(" + (n+1) + ")", 50);
}

