// XDHTML Cross-Browser DHTML Library l
// All code copyright 2001 Rod Morelos, www.e-syed.net/viewsrc | www20.brinkster.com/viewsrc
// Feel free to use this script for personal use, all I ask is that this code comment remain in tact.
// If you're are thinking of using this code for profit, you MUST get my permission before doing so.
// Thank you. - Rod Morelos (viewsrc@hotmail.com)

// Browser check (needed)
function checkBrowser()
{
this.agent=navigator.userAgent;
this.ver=navigator.appVersion;
this.dom=document.getElementById?1:0;
this.win=this.agent.indexOf('Windows')>-1;
this.mac=this.agent.indexOf("Mac")>-1;
this.ie4=(document.all && !this.dom)?1:0;
this.ie5=(this.ver.indexOf('MSIE 5')>-1 && this.dom)?1:0;
this.ie6=(this.ver.indexOf('MSIE 6')>-1 && this.dom)?1:0;
this.ie4mac=(this.ie4 && this.mac);
this.ie5mac=(this.ie5 && this.mac);
this.ns4=(document.layers && !this.dom)?1:0;
this.ns6=(this.dom && parseInt(this.ver) >= 5)?1:0;
this.ie=(this.ie4 || this.ie5 || this.ie6 || this.ie4mac || this.ie5mac);
this.ns=(this.ns4 || this.ns6);
this.w3c=(this.ie5 || this.ie6 || this.ns6 || this.ie5mac);
this.bw=(this.ie4 || this.ie5 || this.ie6 || this.ns4 || this.ns6);
return this;
}
var bw=new checkBrowser();

// get browser window width
function getpagewidth()
{
if (bw.ie) return document.body.clientWidth+document.body.scrollLeft;
else if (bw.ns) return window.innerWidth+window.pageXOffset;
}

// get browser window height
function getpageheight()
{
if (bw.ie) return document.body.clientHeight+document.body.scrollTop;
else if (bw.ns) return window.innerHeight+window.pageYOffset;
}

// get document scroll x
function pagescrollx()
{
if (bw.ie) return document.body.scrollLeft;
else if (bw.ns) return window.pageXOffset;
}

// get document scroll y
function pagescrolly()
{
if (bw.ie) return document.body.scrollTop;
else if (bw.ns) return window.pageYOffset;
}

// Get mouse x and y coordinates
function getmousexy(e)
{
mousex=bw.ns?e.pageX:event.clientX+document.body.scrollLeft;
mousey=bw.ns?e.pageY:event.clientY+document.body.scrollTop;
}

// Page object positioning
function pageObject()
{
this.x=0; this.y=0;
this.x2=getpagewidth()-20;
this.y2=getpageheight()-4;
this.x50=this.x2/2;
this.y50=this.y2/2;
return this;
}		

// Makes crossbrowser object
function makeObject(obj)


{
this.css=bw.w3c?document.getElementById(obj).style:bw.ie4?document.all[obj].style:null;
this.oref=bw.w3c?document.getElementById(obj):bw.ie4?document.all[obj]:null;
this.showIt=f_showIt;
this.hideIt=f_hideIt;
this.showhide=f_showhide;
this.setDisplay=f_setDisplay;
this.x; this.y;
this.moveIt=f_moveIt;
this.moveBy=f_moveBy;
this.moveCenter=f_moveCenter;
this.setLeft=f_getLeft;
this.setTop=f_getTop;
this.getLeft=f_getLeft;
this.getTop=f_getTop;
this.writeIt=f_writeIt;
this.fg=f_fg;
this.bg=f_bg;
this.bgImage=f_bgImage;
this.width=f_width;
this.height=f_height;
this.setw=f_setw;
this.seth=f_seth;
this.setwh=f_setwh;
this.clipIt=f_clipIt;
this.clipBy=f_clipBy;
this.getzIndex=f_getzIndex;
this.setzIndex=f_setzIndex;
return this;
}

// Makes an object's visibiltiy visible
function f_showIt() { this.css.visibility='visible'; }

// Makes an object's visibiltiy hidden
function f_hideIt() { this.css.visibility='hidden'; }

// Hide object if it's visible and visa versa
function f_showhide()
{
this.css.visibility=(this.css.visibility=='visible' || this.css.visibility=='')?'hidden':'visible';
}

// Sets the object's display property
function f_setDisplay(disp) { this.css.display=disp; }

// Move object to
function f_moveIt(x,y)
{
this.x=x; this.y=y;
this.css.left=this.x;
this.css.top=this.y;
}

// Move object by
function f_moveBy(x,y)
{
this.x=this.x+x; this.y=this.y+y;
this.css.left=this.x;
this.css.top=this.y;
}

// Move object to center of browser window
function f_moveCenter()
{
var pageObj=new pageObject();
this.moveIt(pageObj.x50-this.width()/2,pageObj.y50-this.height()/2);
}

// Set left position of object
function f_setLeft(x) { this.x=x; this.css.left=this.x; }

// Set top position of object
function f_setTop(y) { this.y=y; this.css.top=this.y; }

// Get left position of object
function f_getLeft()
{
if (bw.ns6) { if (this.css.left) return parseInt(this.css.left); else return this.oref.offsetLeft; }
else if (bw.ie) { if (this.css.pixelLeft) return parseInt(this.css.pixelLeft);	else return this.oref.offsetLeft; }
}

// Get top position of object
function f_getTop()
{
if (bw.ns6) { if (this.css.top) return parseInt(this.css.top); else return this.oref.offsetTop; }
else if (bw.ie) { if (this.css.pixelTop) return parseInt(this.css.pixelTop); else return this.oref.offsetTop; }
}

// Writing content to object
function f_writeIt(text) { this.oref.innerHTML=text; }

// Changes the foreground color of the object
function f_fg(color) { this.css.color=color; }

// Changes the background color of the object
function f_bg(color) { if (bw.ie4 || bw.w3c) this.css.backgroundColor=color; }

// Changes the background image of the object
function f_bgImage(image) { this.css.backgroundImage='url('+image+')'; this.css.background='url('+image+')'; }

// Get object width
function f_width()
{
if (bw.ie) if (this.css.pixelWidth) return this.css.pixelWidth; else return this.oref.offsetWidth;
else if (bw.ns6) if (this.css.width) return parseInt(this.css.width); else return this.oref.offsetWidth;
}

// Get object height
function f_height()
{
if (bw.ie) if (this.css.pixelHeight) return this.css.pixelHeight; else return this.oref.offsetHeight;
else if (bw.ns6) if (this.css.height) return parseInt(this.css.height); else return this.oref.offsetHeight;
}

// Set object width
function f_setw(w)
{
if (bw.ie4) this.css.pixelWidth=w;
else if (bw.w3c) this.css.width=w;
}

// Set object height
function f_seth(h)
{
if (bw.ie4) this.css.pixelHeight=h;
else if (bw.w3c) this.css.height=h;
}

// Set object width and height
function f_setwh(w,h)
{
if (bw.ie4)
{
this.css.pixelWidth=w;
this.css.pixelHeight=h;
}
else if (bw.w3c)
{
this.css.width=w;
this.css.height=h;
}
}


// Clipping object to...
function f_clipIt(t,r,b,l) { this.css.clip='rect('+t+','+r+','+b+','+l+')'; }

// Clipping object by...
function f_clipBy(t,r,b,l) { this.clipIt(t+t,r+r,b+b,l+l); }

// Sets the object z-index
function f_setzIndex(zOrder) { this.css.zIndex=zOrder; }

// Gets the object z-index
function f_getzIndex() { if (this.css.zIndex=='') return 0; else return this.css.zIndex; }
/*
end XDHTML API functions
*/


/*
Miscellaneous JS functions
*/

// Reload function
function reloadIt() { setTimeout('history.go(0)',200); }

// Random numbers
rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd()
{
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
}

function rand(number) { return Math.ceil(rnd()*number); }

// Disable focusing for all links in document (IE and NS6 only)
function hideFocus()
{
if (bw.ie4)
{
for (var i=0;i<document.links.length;i++)
{
document.links[i].onfocus = function() { this.blur(); }
}
}
else if (bw.w3c)
{
atags = document.getElementsByTagName('a');
for (var i=0;i<atags.length;i++) { atags[i].onfocus = function() { this.blur(); } }
}
}

// Image Functions:
// Preload Images
function preloadImg()
{
var preImg=new Array();
for (var i=0;i<arguments.length;i++)
{
preImg[i]=new Image();
preImg[i].src=arguments[i];
}
}

/*
Miscellaneous JS functions
*/
