var Undefined=String("undefined");
var Bracket='"';
var btnDisabled="btnDisabled";
var tabindex="";
var BtnColor="BGColor1";
var BtnColor2="BtnColor2";
var BtnColorOver="BGColorOver";
var BtnColorOver2="BGColorOver2";
var BtnColorDown="BGColorDown";
var BtnColorDown2="BGColorDown2";
var BtnBorderColor="BlackBGColor";
var BtnColorDisabled="BGColor1Disabled";
var BtnColor2Disabled="BtnColor2Disabled";
var BtnText="BtnText";

var CurrentFolder=null;
var old_id=null; 


function fSetCookie(name, value, expires, path, domain, secure) 
{
        var curCookie = name + "=" + escape(value) +
                ((expires) ? "; expires=" + expires.toGMTString() : "") +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                ((secure) ? "; secure" : "")
        if ((name + "=" + escape(value)).length <= 4000)
                document.cookie = curCookie
}
function fGetCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return null
	else
	{
	        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
	        if (cookieEndIndex == -1)
	                cookieEndIndex = document.cookie.length
	        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
	}
}

function fIsDefined( id, fr ) {
	if( id != null )
	{
		fr = ( (fr==null) ? "f_top" : fr );
		return  (window.frames[fr] && String(window.frames[fr].document.all[id])!=Undefined);
	} else 
		return false;
}

function fSrc( id,value ) {
	if(fIsDefined(id)){
		window.f_top.document.all[id].src=value;		
	}
}

function fDisplay(id,value){
	if(fIsDefined(id)){
		window.f_top.document.all[id].style.display=value;
	}
}

function fClassName(id,name){
	if(fIsDefined(id)){
		window.f_top.document.all[id].className=name;
	}
}
function fVisibility(id,value){
	if(fIsDefined(id)){
		window.f_top.document.all[id].style.visibility=value;
	}
}

function fStop(){
	alert("Sorry, this functionality currently is under construction")
	return false;
}

function fWinClose(win){if(win!=null && !win.closed) win.close();}
function fWinFocus(win){if(win!=null) win.focus();}
function fWinOpen(win,sURL,sName,sFeatures){
	fWinClose(win);
	win=window.open(sURL,sName,sFeatures);
	fWinFocus(win);
	return win;
}

function fReWrite(id,str){
	if(window.frames[id])
	{
		// if(is.ie6)
			window.frames[id].document.open("about:blank","_self","",true);
		window.frames[id].document.write(str);
		window.frames[id].document.close();
	}
}

function ShowLoadingStatus()
{
	fReWrite( "f_main",'<body class="deff8"><table width="100%" height="100%" border=0 cellspacing=0 cellpadding=0><tr><td class="TextClass" align=center><img border=0 align=middle width=205 height=27 src="'+imgPath+'common/wait2.gif" align=""></td></tr></table></body>');
}

var frameOutputBody0JS=null;

function WriteF_TOP()
{
	fReWrite("f_top",frameOutputBody0JS)
}

function WriteF9(str)
{
	if(window.f_9) 
		fReWrite("f_9","<html>"+str+"</html>"); 
}

var RefreshTimeout=null;
function DoSessionAlive(rerun){
	if(RefreshTimeout != null)
		window.clearTimeout(RefreshTimeout);
	if(rerun==null) 
		fSrc("RefreshImg","index.cfm?fuseaction="+escape("home.KeepSessionAlive")+"&"+ClientURLToken+"&rnd="+escape(Math.random()));
	RefreshTimeout=window.setTimeout("DoSessionAlive()",900000)
}


function WriteTi(value,id){    
	if(fIsDefined( id, "f_top" ))
	{	    
		window.f_top.document.all[id].innerHTML = value;
	}
}


function fOnLoadF_TOP()
{
	//DspText2();
	//DspText4();
}

//function name, frame name
function fRun(name,fr){
	fr=((fr==null) ? "f_main" : fr );
	if(name!=null && (window.frames[fr]) && String(eval("window.frames[fr]."+((name.indexOf("(")>=0)?name.substring(0,name.indexOf("(")):name))!=Undefined)){
		onerror = function(msg,url,lno)
		{ 
			return true; 
		}
		window.frames[fr].onerror = function(msg,url,lno) 
		{
			return true;
		}
		eval("window.frames[fr]."+name+((name.indexOf("(")<0)?"()":""));
		window.frames[fr].onerror = null;
		onerror = null;
	}
	return false;
}

function WriteT1(str)
{
  WriteTi(str,"TextT1");
}


var Text2Str=""; 
function WriteInText2(str)
{	
	Text2Str+=str;
}

function DspText2()
{
	if(Text2Str!="")
	{
		WriteTi(Text2Str,"TextT2");
		Text2Str="";
	}
}

var Text3Str=""; 
function WriteInText3(str)
{
	Text3Str+=str;
}

function DspText3()
{
	if(fIsDefined("TextT3"))
		WriteTi(Text3Str,"TextT3");
	Text3Str="";
}

function ClearText3()
{
	Text3Str="";
	WriteTi("","TextT3");
}


function AddBeginLeftButton1(BWidth,BHeight)
{
	WriteInText2("<tr><td width="+BWidth+" height="+BHeight+">");
}

function AddBeginLeftButton2(BWidth,BHeight)
{
	WriteInText2("<tr><td width="+BWidth+" height="+BHeight+"><img border=0 src='"+URLImages+"icons/1x1.gif' width="+BWidth+" height=1><br>");
}

function AddLeftButton(fid, lnk, MOver,MOut,BHeight,Name,img,ht)
{
	WriteInText2("<table width='100%' border=0 cellspacing=0 cellpadding=0 class=fr2button id='"+fid+"' onClick="+Bracket+lnk+Bracket);
	WriteInText2(" onmouseover="+Bracket+"document.all."+fid+"1.className='fr2buttonover';document.all."+fid+"2.className='fr2buttonover';document.all."+fid+"3.className='fr2buttonover';"+MOver+Bracket+" onmouseout="+Bracket+"document.all."+fid+"1.className='fr2button';document.all."+fid+"2.className='fr2button';document.all."+fid+"3.className='fr2button';"+MOut+Bracket);
	WriteInText2("><tr valign=middle");
	WriteInText2(" style='cursor: hand;'");
	WriteInText2("><td width=6 id='"+fid+"1' class='fr2button' valign=top height="+BHeight+"><img src='"+URLImages+"common/g3.gif' width=6 height=6></td><td width='100%' id='"+fid+"2' class='fr2button' valign=middle height="+BHeight+"><font class='btn'");
	WriteInText2(" style='cursor: hand;'");
	WriteInText2("><b>"+Name+"</b></font></td><td id='"+fid+"3' class='fr2button' valign=middle><img src='"+URLImages+"icons/"+img+"' height=20 border=0 align=right vspace=3></td><td width=1 class='buttonline'><img src='"+URLImages+"icons/1x1.gif' width=1 height="+ht+"></td></tr></table><table width='100%' border=0 cellspacing=0 cellpadding=0 height=1 class='buttonline'><tr><td class='buttonline' width='100%'><img src='"+URLImages+"icons/1x1.gif' width=10 height=1></td></tr></table></td></tr>");
}

// Add Folder
function AddBeginFolder(){
	WriteInText3("<table border=0 cellspacing=0 cellpadding=0 width='100%' align=left height=10><tr><td align=left><table border=0 cellspacing=0 cellpadding=0 align=left><tr><td width=5><img src='"+URLImages+"icons/1x1.gif' border=0 width=7 height=1></td>");
}

function AddFolder(BtnW,fid,dlink,fldBG,tabs,Name){
	WriteInText3("<td width="+BtnW+"align=left valign=top><table width="+BtnW+" border=0 cellspacing=0 cellpadding=0 onclick="+Bracket+"top.SwitchFolder('"+fid+"');"+dlink+Bracket+" style='cursor: hand;'><tr id='FID"+fid+"' class='FolderBG2'><td width=4><img src='"+URLImages+"common/t_l1.gif' width=4 height="+tabs+"></td><td width="+eval(BtnW+"-8")+" valign=middle align=center><b><font class='tab'>"+Name+"</b></font></td><td width=4><img src='"+URLImages+"common/t_r1.gif' width=4 height="+tabs+"></td></tr><tr><td width="+BtnW+" height=1 colspan=3 class='FolderBG2' id='FolderBG"+fid+"IDLine' style='visibility:hidden;'><img height=1 width=1 border=0 src='"+URLImages+"icons/1x1.gif'></td></tr></table></td><td width=1></td>");
}

function AddEndFolder(){
	WriteInText3("<td width=5><img src='"+URLImages+"icons/1x1.gif' width=5 height=1></td></tr></table></td></tr>");
}
// Add Buttons
function AddBeginButtons(height1,width,height2){
	WriteInText3("<tr><td height="+height1+" width="+width+" valign=middle><div id='FolderBG_tmp' style='width:"+width+"px; height:"+height2+"px; position: relative; visibility:visible'>");
}	
function AddButtonsDiv(fid,width,height,TabsQuant,fldBG){
	WriteInText3("<div id='FolderBG"+fid+"ID' style='width:"+width+"px; height:"+height+"px; position: absolute; visibility:hidden; top: 0px; left: 0px;'><table border=0 cellspacing=0 cellpadding=0 align=left><tr><td id='BID"+fid+"' colspan="+TabsQuant+" class=FolderBG2 height="+height+" width="+width+" left valign=top><table border=0 cellspacing=2 cellpadding=0 width='100%'>");
}
	
function AddButton(caption,func,width,height,tipcaption,enable,name)
{
	WriteInText3(AddButtonAdvaced(caption,func,width,height,tipcaption,enable,name))
}

function PrintButton(caption, lin, BtnW, BtnH, tipscaption, Enable, id,RealCount,btnLen){
	WriteInText3("<td height=1 align=center>");
	AddButton(caption, lin, BtnW, BtnH, tipscaption, Enable, id);
	WriteInText3("</td>");
	AddEndButton(RealCount, btnLen);
}

function PrintButton2(caption, lin, BtnW, BtnH, tipscaption, Enable, id){
	AddButton(caption, lin, BtnW, BtnH, tipscaption, Enable, id);
	WriteInText3("</td>");
}

function AddEndButton(RealCount,btnLen){
	if(RealCount==5) WriteInText3("<td width='100%' "+((btnLen>=5)?" rowspan=2":"")+"></td></tr><tr>");
}

function AddEndButtons(RealCount,btnLen){
	if(RealCount<5) WriteInText3("<td width='100%'"+((btnLen>=5)?" rowspan=2":"")+"></td></tr>");
}

function AddBeginButton2(NumCol,NumRow,fldBG){
	WriteInText3(((NumCol==1)?"<tr id='"+fldBG+"R"+NumRow+"'"+((NumRow>2)?" style='display:none'":"")+">":"")+"<td id='"+fldBG+"R"+NumRow+"C"+NumCol+"' align=left"+((NumRow==2 && NumCol==5)?" style='display:none'":"")+">");
}

function AddButtonAdvaced(caption,func,width,height,tipcaption,enable,name)
{
	mode=1;
	thisbutton='';
	if(1)
		{
			if(enable=="True")
			{
				thisbutton+="<table cellspacing=0 style='border: 1pt solid;' cellpadding=0 class='"+BtnBorderColor+"' border=0 width="+width+" height="+height+" onclick="+Bracket+func+";return false;"+Bracket+" style='cursor:hand;'";
				thisbutton+="><tr><td><table style='border: 1pt solid;' cellspacing=0 cellpadding=0 border=0 width='100%' height='100%' class='"+BtnColor2+"' onmouseover="+Bracket+"this.className='"+BtnColorOver2+"'"+Bracket+" onmouseout="+Bracket+"this.className='"+BtnColor2+"'"+Bracket+" onmousedown="+Bracket+"this.className='"+BtnColorDown2+"'"+Bracket+" onmouseup="+Bracket+"this.className='"+BtnColorOver2+"'"+Bracket+"><tr><td class='"+BtnColor+"'><table cellspacing=0 style='border: 1pt solid;' cellpadding=0 border=0 width='100%' height='100%' class='"+BtnColor+"' onmouseover="+Bracket+"this.className='"+BtnColorOver+"'"+Bracket+" onmouseout="+Bracket+"this.className='"+BtnColor+"'"+Bracket+" onmousedown="+Bracket+"this.className='"+BtnColorDown+"'"+Bracket+" onmouseup="+Bracket+"this.className='"+BtnColorOver+"'"+Bracket+"><tr><td class='"+BtnText+"'><a tabindex="+tabindex+" href="+Bracket+"javascript: void "+func+Bracket+" class='"+BtnText+"'>"+caption+"</a></td></tr></table></td></tr></table></td></tr></table>";
			}
			else
			{
				thisbutton+="<table cellspacing=0 style='border: 1pt solid; cursor:hand;' cellpadding=0 class='"+BtnBorderColor+"' border=0 width="+width+" height="+height;
				thisbutton+="><tr><td><table style='border: 1pt solid; cursor:hand;' cellspacing=0 cellpadding=0 border=0 width='100%' height='100%' class='"+BtnColor2Disabled+"'><tr><td><table cellspacing=0 style='border: 1pt solid; cursor:hand;'  cellpadding=0 border=0 width='100%' height='100%' class='"+BtnColorDisabled+"'><tr><td class='"+btnDisabled+"'>"+caption+"</td></tr></table></td></tr></table></td></tr></table>";			
			}
		}
		else{
			thisbutton+="<table cellspacing=0 style='border: 1pt solid;' cellpadding=0 class='"+BtnBorderColor+"' border=0 width="+width+" height="+height;
			if(enable=="True") thisbutton+=" onclick="+Bracket+func+";return false;"+Bracket+" style='cursor:hand;'";
			thisbutton+="><tr><td><table style='border: 1pt solid;' cellspacing=0 cellpadding=0 border=0 width='100%' height='100%' class='"+BtnColor+"'<tr><td class='"+((enable=="True")?BtnText:btnDisabled)+"'>";
			if(enable=="True") thisbutton+="<a tabindex="+tabindex+" href="+Bracket+"javascript: void "+func+Bracket+" class='"+BtnText+"'>";
			thisbutton+=caption+((enable=="True")?"</a>":"")+"</td></tr></table></td></tr></table>";
		}
	return thisbutton
}

function SwitchFolder(FolderID)
{
	fClassName("FID"+old_id,"FolderBG2");
	fClassName("FolderBG"+old_id+"IDLine","FolderBG2");
	fClassName("BID"+old_id,"FolderBG2");
	if(!fIsDefined("FID"+FolderID))
	{		
		return;
	}
	fClassName("FID"+FolderID,"FolderBG1");
	fClassName("FolderBG"+FolderID+"IDLine","FolderBG1");
	fClassName("BID"+FolderID,"FolderBG1");
	old_id = FolderID;
	SwitchFolderFullName("FolderBG"+FolderID+"ID");
}

function SwitchFolderFullName(FolderID)
{
	fVisibility(CurrentFolder,"hidden")
	fVisibility(CurrentFolder+"Line","hidden")
	fVisibility(FolderID,"visible")
	fVisibility(FolderID+"Line","visible")
	CurrentFolder=FolderID;
}

function GoToLocation(Module,vFuseAction,Params){
	if(window.f_main){
		var FuseAction=Module+"."+vFuseAction;
		if( String(window.f_main.SubmitFormF8) != Undefined)
		{
			window.f_main.SubmitFormF8(Module,FuseAction,Params);
		}	
		else
		{
			window.f_main.location.href="index.cfm?fuseaction="+FuseAction+((Params!="")?"&"+Params:"");
		}
	}
	return false;
}

function GoToSubmenu(fuseaction,Params){
	if(window.f_submenu) {
		window.f_submenu.location.href="index.cfm?fuseaction="+fuseaction+((Params!="")?"&"+Params:"");
	}
	return false;
}

function GoToLogin(s){
	window.f_main.location.href="index.cfm?fuseaction=login.login&"+ClientURLToken+"&nexturl="+escape(window.f_main.location+((s!=null)?"&"+s:""));
	return false;
}

function GoToRegister(s){
	window.f_submenu.location.href="index.cfm?fuseaction=login.registration&"+ClientURLToken+"&nexturl="+escape(window.f_main.location+((s!=null)?"&"+s:""));
	return false;
}

function ViewBestell(nr){
  var win;
  win=window.open("index.cfm?fuseaction=bestell.viewbestell&num=" + nr +"&" + ClientURLToken,"viewbestellung","'status,scrollbars,resizable,width=640,height=400,left=10,top=10'");
  win.focus();	
}

function SwitchLanguage(lng)
{
  window.f9.location.href="setlang.cfm?lang=" + lng;
}