/*******************************************
 #   # ##### ####  #####  ####  #### #   #
 #   # #     #   #   #   #     #     #   #
 ##### ##    ####    #    ###  #     #####
 #   # #     #   #   #       # #     #   #
 #   # ##### #   #   #   ####   #### #   #
********************************************/

/******* BrowserIdentification ***********/
var  ns=(document.layers)?1:0;
var dom=(document.getElementById)?1:0;
var  ie=(document.all)?1:0;
var ns6=(dom && !ie)?1:0;
/*****************************************/

/******* VisualFunctions *****************/
function ShowLayer() {this.css.visibility='visible';}
function HideLayer() {this.css.visibility='hidden' ;}
function ClipLayer(left,top,right,bottom)
{
	if	(ns6 || ie )
	{
		this.css.clip	=	'rect('+top+' '+right+' '+bottom+' '+left+')';
	}
	if	(ns)
	{
		this.css.clip.top		=	top;
		this.css.clip.left		=	left;
		this.css.clip.bottom	=	bottom;
		this.css.clip.right	=	right;
	}
}

/*****************************************/

/******* 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.clip=ClipLayer;
	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;
}