function clientSniff()
{
 	this.isDOM1 = (document.getElementById)? true:false
 	this.isIE4 = (!this.isDOM1 && document.all)? true:false
 	this.isIE5 = (this.isDOM1 && document.all)? true:false
 	this.isNN4 = (document.layers)? true:false
 	this.isNN6 = (this.isDOM1 && !document.all)? true:false
 	this.isJ = navigator.javaEnabled()
	
 	return this 
}
var browser = new clientSniff()
function wmLayer(name,obj,alpha)
{
	this.name = name  //the name you have given to this aLayer
	this.obj = obj || "" //the actual id of the html element
	this.getDOM = w__getCSS  //method for obtaining a reference to the style object
	this.dom = this.getDOM()  //holds the style object
	this.activity = 0  //used to step through various actions within an animation
	this.speed = 50  //how fast should I be doing things? default=50ms
	//fontmetrics
	this.setFM = w__setFM
	//visibility
	this.setV = w__setV
	//layer z - index
	this.setZ = w__setZ
	//positioning
	this.x = parseInt(this.dom.left);
	this.y = parseInt(this.dom.top);
	this.startX = this.x;
	this.startY = this.y;
	//end positioning
	//dimensions
	this.w = parseInt(this.dom.width);
	this.h = parseInt(this.dom.height);
	this.setDims = w__setDims;
	//end dimensions
	//animation
	this.animlist = new Array() //the list of animations
	this.AddAnim = addAnim  //method for adding anims to list
	this.ReplaceAnim = replaceAnim
	this.clock = null  //timer
	this.loop = false  //true = loop anim
	this.Start = animate  //method to start animations
	this.Pause = pauseanim  //toggles animation stop/start
	//end animation
	//movement
	this.moveBy = w__moveBy;
	this.moveTo = w__moveTo;
	this.slideTo = w__slideTo;
	this.incX = null;
	this.incY = null;
	this.dx = null;//x direction
	this.dy = null;//y direction
	this.circleTo = w__circleTo;
	this.xxx = 0;
	//Layer transparency
	this.alpha = alpha || 0  //holds the current alpha value for layer default=0
	this.setAlpha = setA  //metod to set alpha value
	if(alpha!=false)this.setAlpha(this.alpha)  //initialises alpha for layer
	this.fadeIn = alphaUp //method to make layer more opaque(increase alpha)
	this.fadeOut = alphaDn  //method to make layer less opaque(decrease alpha)
	//End layer transparency
	return this
}
function w__getCSS()
{  //returns a reference to this object's style object
	if(browser.isIE4)return document.all[this.obj].style
	if(browser.isDOM1)return document.getElementById(this.obj).style
}
function w__setZ(z)
{
	this.dom.zIndex = z
}
function w__setV(v)
{
	this.dom.visibility = ""+v
}
function w__setFM(ff,fz,fs,fw,fc)
{
	if(typeof(fz)=="number")fz = fz+"px"
	this.dom.fontFamily = ff
	this.dom.fontSize = fz
	this.dom.fontStyle = fs
	this.dom.fontWeight = fw
	this.dom.color = fc
	
}
function w__moveTo(x,y)
{
	this.x = x;
	this.y = y;
	this.dom.left = x;
	this.dom.top = y;
}
function w__moveBy(x,y) 
{
    this.dom.left = parseInt(this.dom.left) + x;
    this.dom.top  = parseInt(this.dom.top) + y;
	this.x = parseInt(this.dom.left);
	this.y = parseInt(this.dom.top);
}
function w__setDims(w,h)
{
	if(w<0)w=0
	if(h<0)h=0
	this.dom.width = w;
	this.dom.height = h;
	this.w = w;
	this.h = h;
}
function setA(a)
{
	this.alpha = a  //make sure alpha is current
	if(browser.isIE4||browser.isIE5)this.dom.filter="alpha(opacity="+this.alpha+")" //0 to 100
	if(browser.isNN6)this.dom.MozOpacity=parseInt(this.alpha)/100; //0 to 1
}
function alphaUp(to,step,speed)
{
	if(this.alpha<to)
	{
		this.speed = speed  //set speed for this fade
		this.setAlpha(this.alpha+=step)  //set the new alpha value
	}
	else
	{
		this.setAlpha(to)  //because <0 or >100 makes no sense
		this.activity+=1  //weve completed the fade so go to next anim action
		this.speed=50	//set speed back to default
	}
}
function alphaDn(to,step,speed)
{
	if(this.alpha>to)
	{
		this.speed = speed
		this.setAlpha(this.alpha-=step)
	}
	else
	{
		this.setAlpha(to)
		this.activity+=1
		this.speed=50
	}
}
function addAnim(str)
{
	this.animlist[this.animlist.length] = str  //add anim action to list
}
function replaceAnim(i,str)
{
	this.animlist[i] = str
}
function pauseanim()
{		//if the anim is paused, un-pause it and vice versa
	if(this.clock=="paused"||this.clock==null)this.clock="go"
	else this.clock="paused"
	this.Start()
}
function animate()
{
	if(this.clock!="paused")
	{
		if(this.activity<this.animlist.length)
		{
			eval(this.name+"."+this.animlist[this.activity])
			this.clock = setTimeout(this.name+".Start()",this.speed)
		}
		else 
		{
			if(this.loop==true)
			{
				this.activity=0
				this.clock = setTimeout(this.name+".Start()",this.speed)
			}
			else 
			{
				this.clock = "paused"
			}
		}
	}
}
function w__slideTo(x,y,step,spd)
{

	this.speed = spd
	if(this.incX==null || this.incY==null)
	{
		this.incX=-(this.x-x)/step;
		this.incY=-(this.y-y)/step;
		this.dx = (this.incX>0)? "pos":"neg";
		this.dy = (this.incY>0)? "pos":"neg";
	}
	go=true;
	
	if(this.incX != 0 && this.dx=="pos")go = (this.x+this.incX<x)? true:false;
	if(go && this.incX != 0 && this.dx=="neg")go = (this.x+this.incX>x)? true:false;
	
	if(go && this.incY != 0 && this.dy=="pos")go = (this.y+this.incY<y)? true:false;
	if(go && this.incY != 0 && this.dy=="neg")go = (this.y+this.incY>y)? true:false;

	if(go)
	{
		xx  = this.x+this.incX;
		yy = this.y+this.incY;
		this.moveTo(xx,yy);
	}
	else
	{
		this.moveTo(x,y);
		this.activity += 1;
		this.startX = this.x;this.startY = this.y;
		this.incX = null;this.incY=null;
		this.speed = 50	
	}
	//
}
function w__circleTo(rc,step,arc,sweep,scaleX,scaleY,spd)
{
this.speed = spd
this.dx = (step > 0)? "pos":"neg";
if(sweep == 0)
{
	go = true;
}
else
{
	if(this.dx == "pos")
	{
		go = (this.xxx <= sweep)? true:false;
		
	}
	else
	{
		go = (this.xxx >= -sweep)? true:false;
		
	}
}
if(this.offX==null||this.offY==null)
{
	ta = (360-arc) * (Math.PI/180)
	this.offX = (-rc*scaleX) * Math.cos(ta)
	this.offY = (-rc*scaleY) * Math.sin(-ta)
}
if(go){	
		xr = ((this.xxx + arc) * (Math.PI/180));
		xc = ((rc*scaleX) *(Math.cos(xr)))+(this.offX); 
		yc = ((rc*scaleY) *(Math.sin(xr)))+(this.offY);
		this.xxx+=step;
		this.moveTo(xc+this.startX,yc+this.startY);}
		else{this.activity += 1;this.startX = this.x;this.startY = this.y;this.xxx = 0;this.speed=50;this.offX=null;this.offY=null}

}
function getScreen()
{

 this.h = (browser.isNN4||browser.isNN6)? window.innerHeight : (browser.isIE5||browser.isIE4)? document.body.clientHeight : 0;
 this.w = (browser.isNN4||browser.isNN6)? window.innerWidth : (browser.isIE5||browser.isIE4)? document.body.clientWidth : 0;
 return this;
}

