//  Mark Bryson's Javascript 
//  Version 2.0 --- January, 14 2003

//--------------------------------------------------------------------/
// Browser Check Object

function bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent;
	this.dom=document.getElementById?1:0

	this.ie4 = (document.all && !this.dom);
	this.ie5 = (this.ver.indexOf("MSIE 5")>-1 && this.dom); 
	this.ie6 = (this.ver.indexOf("MSIE 6")>-1 && this.dom);
	this.ie = (this.ie4||this.ie5||this.ie6)

	this.ns4 = (document.layers && !this.dom);
	this.ns6 = (this.dom && parseInt(this.ver) >= 5);

	this.bw = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6)
	this.newer = (this.ie4 || this.ie5 || this.ie6 || this.ns6);
	this.opera = (this.agent.indexOf("opera") != -1);
	this.mozilla = (this.agent.indexOf("mozilla"));
	return this
}	

function oscheck () {
	this.os = navigator.userAgent.toLowerCase();

	this.mac = this.os.indexOf("mac")>-1
   	this.linux = (this.os.indexOf("inux")!=-1);

	this.win   = ((this.os.indexOf("win")!=-1) || (this.os.indexOf("16bit")!=-1));
	this.win31 = ((this.os.indexOf("windows 3.1")!=-1) || (this.os.indexOf("win16")!=-1) ||
			 (this.os.indexOf("windows 16-bit")!=-1));
	this.win98 = ((this.os.indexOf("win98")!=-1) || (this.os.indexOf("windows 98")!=-1));
	this.winnt = ((this.os.indexOf("winnt")!=-1) || (this.os.indexOf("windows nt")!=-1));
	this.winme = ((this.os.indexOf("win 9x 4.90")!=-1));
    	this.win2k = ((this.os.indexOf("windows nt 5.0")!=-1));
	return this
}

var bw=new bwcheck();
var os=new oscheck();

//--------------------------------------------------------------------/
// Divlayer Object Model

function divlayer(layerID) {
	this.obj = findObj(layerID);
	this.css = this.obj.style;
	this.x = parseInt(this.css.left);
	this.y = parseInt(this.css.top);
	this.w = (bw.ie||bw.ns6)?this.css.width:bw.ns4?this.obj.clip.width:0;
	this.h = (bw.ie||bw.ns6)?this.css.height:bw.ns4?this.obj.clip.height:0;
	this.zindex = this.css.zIndex;
	this.disp = this.css.display;
}

divlayer.prototype.moveTo = function(h,v){
	this.x=h; this.css.left=h;
	this.y=v; this.css.top=v;
}
divlayer.prototype.moveBy = function(h,v) {this.moveTo(this.x+h,this.y+v)}


divlayer.prototype.showHide = function(){
	var status = this.css.visibility
	if (status == "visible" || status == "show") {v=(bw.newer)?'hidden':'hide';}
	else {v=(bw.newer)?'visible':'show';}
	this.css.visibility=v;
}

divlayer.prototype.show = function(){this.css.visibility=(bw.newer)?'visible':'show';}
divlayer.prototype.hide = function(){this.css.visibility=(bw.newer)?'hidden':'hide';}

///////////////////////////////////////////////////////////////////////

function findObj(name)
{
  if (document.getElementById){return document.getElementById(name);}
  else if (document.all){return document.all[name];}
  else if (document.layers){return document.layers[name];}
  else return false;
}

//--------------------------------------------------------------------/
// Layer Moving Functions

function slideBy(obj,dir,num,stop) {
	
	var top = parseInt(obj.top);
	var left = parseInt(obj.left);

	if      (top < stop && dir == "down")   {top += num;obj.top = top;} 
	else if (top >= stop && dir == "down")   {activedown=0;activeup=1;}
	
	if      (top > stop && dir == "up")     {top -= num;obj.top = top;} 
	else if (top <= stop && dir == "up")     {activeup=0;activedown=1;}
	
	if      (left < stop && dir == "right") {left += num;obj.left = left;}
	else if (left >= stop && dir == "right") {activeright=0;activeleft=1;}
	
	if      (left > stop && dir == "left")  {left -= num;obj.left = left;} 
	else if (left <= stop && dir == "left")  {activeleft=0;activeright=1;}

}

//--------------------------------------------------------------------/
// Layer Clip Functions

divlayer.prototype.clipValues = function(val) {
	var clipv = this.css.clip.split("rect(")[1].split(" ");
	if (val == "top") return (bw.ns4)?clipv[0]:parseInt(clipv[0]);
	if (val == "rig") return (bw.ns4)?clipv[1]:parseInt(clipv[1]);
	if (val == "bot") return (bw.ns4)?clipv[2]:parseInt(clipv[2]);
	if (val == "lef") return (bw.ns4)?clipv[3]:parseInt(clipv[3]);
	if (val == "all") {
	var allstr = "Top: " + parseInt(clipv[0]) + "\nRight: " + parseInt(clipv[1]) + "\nBottom: " + parseInt(clipv[2]) + "\nLeft: " + parseInt(clipv[3]); 
	return allstr;}
}

function clipBy(obj,num) {
	btm = clipValues(obj,"bot") + num;
	obj.clip = "rect("+ this.clipValues(obj,'top') +"px "+ this.clipValues(obj,'rig') +"px "+btm+"px "+ this.clipValues(obj,'lef') +"px)";
}

function reset(obj) {
	obj.clip = "rect(0 "+obj.width+" 0 0)"
}

//--------------------------------------------------------------------/
// Table Mouseover

function tblOn(td){td.bgColor = tableColorOn;}
function tblOff(td){td.bgColor = tableColorOff;}

//--------------------------------------------------------------------/
// Layer Writing

divlayer.prototype.writeHTML = function(text) {this.obj.innerHTML = text;}
divlayer.prototype.clearHTML = function() {this.obj.innerHTML = "&nbsp;";}

//--------------------------------------------------------------------/
// Random Image Generator


function rndImage(prefix,target) {
	num = Math.round(Math.random()*(9));
	document.images[target].src = "pictures/"+prefix+"0"+num+".jpg";
}
