/*******************************************
 #   # ##### ####  #####  ####  #### #   #
 #   # #     #   #   #   #     #     #   #
 ##### ##    ####    #    ###  #     #####
 #   # #     #   #   #       # #     #   #
 #   # ##### #   #   #   ####   #### #   #
********************************************/

/******* BrowserIdentification ***********/
var  ns=(document.layers)?1:0;
var  ie=(document.all)?1:0;
var dom=(document.getElementById)?1:0;
var  ns6=(dom&&!ie)?1:0;
/*****************************************/

/******* VisualFunctions *****************/
function ShowLayer() {if (this.css) this.css.visibility='visible'; else document.layers[this.name].visibility="show";}
function HideLayer() {if (this.css) this.css.visibility='hidden' ; else document.layers[this.name].visibility="hide";}
/*****************************************/

/******* OpacityFunctions ****************/
function FadeInPic(actionAfterFinished) {
	   if (!actionAfterFinished) {actionAfterFinished="";} //else alert(actionAfterFinished);
	   eval(this.nsLayer+".show()");if (!this.filter) {eval(actionAfterFinished);return;}
	   if (ie)
	   {
	   	tmp=this.filter.alpha.opacity;
	   	tmp+=this.InSpeed;
	   	this.filter.alpha.opacity=tmp;
	   }
	   if (ns6)
	   {
	   	tmp=parseInt(this.filter.MozOpacity);
	   	tmp+=(this.InSpeed);
	   	this.filter.MozOpacity=tmp+"%";
	   }
	   clearInterval(this.fading);this.fading=0;
	   if (tmp<100)
	   {
	   	this.fading=window.setInterval(this.name+'.fadein("'+actionAfterFinished+'")',0);
	   } else {
	   		eval(actionAfterFinished);
	   	  }

	}
function FadeOutPic(actionAfterFinished) {
	   if (!actionAfterFinished) {actionAfterFinished="";}// else alert(actionAfterFinished);
	   if (!this.filter) {eval(this.nsLayer+".hide()");eval(actionAfterFinished);return;}
	   if (ie)
	   {
	   	tmp=this.filter.alpha.opacity;
	   	tmp-=this.OutSpeed;
	   	this.filter.alpha.opacity=tmp;
	   }
	   if (ns6)
	   {
	   	tmp=parseInt(this.filter.MozOpacity);
	   	tmp-=(this.InSpeed);
	   	this.filter.MozOpacity=tmp+"%";
	   }
	   if (this.fading) {clearInterval(this.fading);this.fading=0;}
	   if (tmp>0)
	   {
	   	this.fading=window.setInterval(this.name+'.fadeout("'+actionAfterFinished+'")',0);
	   } else {
	   		eval(this.nsLayer+".hide()");
	   		eval(actionAfterFinished);
	   	  }
}
/*****************************************/

/*****************************************/
function MoveTo(tx,ty,dx,dy)
{
	cx=parseInt(this.css.left); if (isNaN(cx) || !dx) cx=tx;
	cy=parseInt(this.css.top) ; if (isNaN(cy) || !dy) cy=ty;

	mx=Math.round(tx-cx);
	my=Math.round(ty-cy);
	moved=(mx!=0||my!=0)?1:0;
	dx=(mx)?Math.floor((mx)/10)+mx/Math.abs(mx):0;
	dy=(my)?Math.floor((my)/10)+my/Math.abs(my):0;
	cx+=dx;
	cy+=dy;

	this.css.left=cx;
	this.css.top=cy;

	if (this.moving!=0) {clearInterval(this.moving); this.moving=0;}
	if (moved) this.moving=window.setInterval(this.name+'.moveto('+tx+','+ty+','+dx+','+dy+')',40);
}






/*****************************************/




/******* CreateObjectFunctions ***********/
function GetPic(was,was2,nsLayer){
  	this.filter=(ie)?document.all[was].filters:0;
  	if (ns6) this.filter=document.getElementById(was).style;
  	this.fading=0;
  	this.fadein=FadeInPic;
	this.fadeout=FadeOutPic;
  	this.InSpeed=10;
  	this.OutSpeed=5;
  	this.name=was2;
	this.nsLayer=nsLayer;
  	return this;
}

function GetCss(was,nest,was2) {
  if (ns) if (nest) this.css=document.layers[""+nest].document.layers[""+was]; else this.css=document.layers[""+was];
  if (ie) this.css=document.all[was].style;
  if (dom) this.css=document.getElementById(was).style;

  	this.show=ShowLayer;
  	this.hide=HideLayer;
	this.moving=0;
	this.moveto=MoveTo;
  	this.name=was2;
  return this;}
/*****************************************/

/**********GetScreenDetails **************/
function GetWidth() {
  if (ns) return parseInt(innerWidth);
  if (ie) return document.body.offsetWidth;
  if ((dom)&&(!ie)) return innerWidth;
return 0;
}

function GetHeight() {
  if (ns) return parseInt(innerHeight);
  if (ie) return document.body.offsetHeight;
  if ((dom)&&(!ie)) return innerHeight;
}
/****************************************/




/**********PERFORMANCETEST***************/
function PerfTest() {
   var f1="!!!!!!!!!!!!!!!!!!!!";f2="....................";
//   var f1="llllllllllllllllllll";f2="                    ";
   var starttime=new Date();starttime=starttime.getTime()
   for (i=0;i<1000;i++)
   {
	f=parseInt(i/100);
	status="["+f1.substr(0,f*2)+f2.substr(0,20-f*2)+"]";
   }
   var endtime=new Date();endtime=endtime.getTime();
   var dtime = endtime-starttime;
   return dtime;
}
function startPerfTest(loops)
{
	dPI=0;
	for (k=0;k<loops;k++)
	{
		dPI+=PerfTest();
	}
	dPI=dPI/loops;
	status="";
	return dPI;
}

/********** Imagewechsel *************************/
function FadeImgArray(ImgName,ArrImgSrc,Name,TTime,STime){

	this.ImgName=ImgName;
    this.ArrImgSrc=ArrImgSrc;
    this.CurrPos=0;
    this.name=Name+".start()";
    this.start= FadeImgArrayIdle;
	this.TTime=TTime;
	this.STime=STime;
    return this;


}

function FadeImgArrayIdle(){
	if (this.Hdl)
    	clearTimeout(this.Hdl);

    if (ie)
    	document.images[this.ImgName].filters.blendTrans.Apply();

    if (ns6)
    	document.getElementById(this.ImgName).src = this.ArrImgSrc[this.CurrPos];
    else
    	document.images[this.ImgName].src = this.ArrImgSrc[this.CurrPos];

    if (ie)
    	document.all[this.ImgName].filters.blendTrans.Play();

   	this.CurrPos=(this.CurrPos<(this.ArrImgSrc.length-1))?this.CurrPos+1:0;

    if (this.Hdl){
    	this.Hdl=setTimeout(this.name,this.TTime);
        }
    else
    	this.Hdl=setTimeout(this.name,this.STime);
    }


function popup(imagesrc,title,text)
{
	if (!text) text="";
	nw=window.open("show_image.htm?images/"+imagesrc+"&"+text+"&"+title,"fenster","width=200, height=200");
	return false;
}

function popup_gen(url,width,height)
{
	//nw=window.open(url,"Detailansicht","width="+width+", height="+height);
	if (!ns) nw=window.open(url,"fenster","width="+width+", height="+height+",scrollbars=yes"); else nw=window.open(url,"fenster","width="+width+", height="+height+",resizable=yes,scrollbars=yes");
	return false;
}
