// JSAPI V 1.0
//             by CybWarrior
// http://www.cybwarrior.com
// mailto:cybwarrior@nexen.net
var JSAPI_IE=navigator.appName=='Microsoft Internet Explorer';
var JSAPI_NS=navigator.appName=='Netscape';
var JSAPI_Layers=new Array();
var JSAPI_Sounds=new Array();
var Mouse=new Object;

if(JSAPI_NS)document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=function(NSEvent){
	Mouse.x=JSAPI_IE ? event.x : JSAPI_NS ? NSEvent.pageX : false;
	Mouse.y=JSAPI_IE ? event.y : JSAPI_NS ? NSEvent.pageY : false;
	Mouse.button=JSAPI_IE ? event.button : JSAPI_NS ? NSEvent.which : false;
}

function Layer(tag, left, top, visibility){
	this.index=JSAPI_Layers.length;
	this.tag=tag;
	this.Refresh=function(){
		if(JSAPI_IE){
			this.left=parseInt(this.Layer.style.left);
			this.top=parseInt(this.Layer.style.top);
			this.width=this.Layer.offsetWidth;
			this.height=this.Layer.offsetHeight;
			this.visibility=(this.Layer.style.visibility=='visible' ? true : false);
		}
		if(JSAPI_NS){
			this.left=this.Layer.left;
			this.top=this.Layer.top;
			this.width=this.Layer.clip.width;
			this.height=this.Layer.clip.height;
			this.visibility=(this.Layer.visibility=='show' ? true : false);
		}
	}
	this.Show=function(){
		if(JSAPI_IE)this.Layer.style.visibility='visible';
		if(JSAPI_NS)this.Layer.visibility='show';
		this.Refresh();
	}
	this.Hide=function(){
		if(JSAPI_IE)this.Layer.style.visibility='hidden';
		if(JSAPI_NS)this.Layer.visibility='hide';
		this.Refresh();
	}
	this.Move=function(left, top){
		if(JSAPI_IE){
			this.Layer.style.left=left;
			this.Layer.style.top=top;
		}
		if(JSAPI_NS){
			this.Layer.left=left;
			this.Layer.top=top;
		}
		this.Refresh();
	}
	this.Resize=function(width, height){
		if(JSAPI_IE){
			this.Layer.style.width=width;
			this.Layer.style.height=height;
		}
		if(JSAPI_NS){
			this.Layer.width=width;
			this.Layer.height=height;
		}
		this.Refresh();
	}
	this.Rotate=function(x, y, ang){
		var x1=this.left - x;
		var y1=y - this.top;
		ang*=2 * Math.PI / 360;
		var xbis=parseInt(x + (x1 * Math.cos(ang) - y1 * Math.sin(ang)));
		var ybis=parseInt(y - (x1 * Math.sin(ang) + y1 * Math.cos(ang)));
		if(xbis.toString()=='NaN')xbis=0;
		if(ybis.toString()=='NaN')ybis=0;
		this.Move(xbis, ybis);
	}
	this.ARotate=function(x, y, ang, stages, stage){
		var parseAng=ang / stages;
		if(stage==undefined)stage=0;
		this.Rotate(x, y, parseAng);
		if(++stage<stages)setTimeout('JSAPI_Layers[' + this.index + '].ARotate(' + x + ', ' + y + ', ' + ang + ', ' + stages + ', ' + stage + ');', 10);
	}

	if(JSAPI_IE){
		document.write('<div id=JSAPILayer' + this.index + ' style="position:absolute;left:' + left + ';top:' + top + ';visibility:' + (visibility ? 'visible':'hidden') + ';">' + tag + '</div>');
		this.Layer=document.all['JSAPILayer' + this.index];
	}
	if(JSAPI_NS){
		document.write('<layer id=JSAPILayer' + this.index + ' left=' + left + ' top=' + top + ' visibility=' + (visibility ? 'show':'hide') + '>' + tag + '</layer>');
		this.Layer=document.layers['JSAPILayer' + this.index];
	}

	JSAPI_Layers[this.index]=this;
	this.Refresh();
}
function Sound(url){
	this.index=JSAPI_Sounds.length;
	this.url=url;
	this.Play=function(){
		if(JSAPI_IE)document.all['JSAPISound' + this.index].play();
		if(JSAPI_NS)document.embeds['JSAPISound' + this.index].play();
	}
	this.Stop=function(){
		if(JSAPI_IE)document.all['JSAPISound' + this.index].stop();
		if(JSAPI_NS)document.embeds['JSAPISound' + this.index].stop();
	}
	document.write('<embed name=JSAPISound' + this.index + ' src=' + this.url + ' hidden=true autostart=false loop=false mastersound></embed>');
	JSAPI_Sounds[this.index]=this;
}