<!--//
/*
The following script creates cross-browser/platform object oriented functions 
for creating and manipultaing dynamic objects.

NOTE: These functions still include branches specific to handling generation 4 browsers (IE & NS),
though the initial checkBrowser() function will check whether the client's browser uses DOM
implementations (generation 5 specific).
*/

var browserSupportURL = "/errors/browser/index.php";																												// Set URL for Browser Support redirect page

/* First check that client's browser supports the dynamic object model (DOM) */
function checkBrowser(){
	
	/* Set up browser-sniffing objects */
	this.win=(navigator.platform=="Win32")?1:0;                                                         // Windows platform specific
	this.mac=(navigator.platform=="MacPPC")?1:0;                                                        // Mac platform specific
	this.ver=navigator.appVersion;
	this.agt=navigator.userAgent;
	this.dom=document.getElementById?1:0;																			                          // Uses W3C DOM standards (5th generation browsers only)
    this.ie8=(this.ver.indexOf("MSIE 8")!=-1 && this.dom)?1:0;
	this.ie7=(this.ver.indexOf("MSIE 7")!=-1 && this.dom)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")!=-1 && this.dom)?1:0;  							                          // IE6 specific
	this.ie5=(this.ver.indexOf("MSIE 5")!=-1 && this.dom)?1:0; 								                          // IE5.0/IE5.5 specific
	this.ie4=(document.all && !this.dom)?1:0;																	                          // IE4 specific
	this.opr=(this.agt.indexOf("Opera")!=-1 && this.dom)?1:0;                                           // Opera specific
	this.cab=(this.agt.indexOf("iCab")!=-1 && this.dom)?1:0;                                            // iCab specific
	this.gko=(this.agt.indexOf("Gecko")!=-1 && this.dom)?1:0;                                           // Uses Gecko DOM implementation (Netscape 6+, Mozilla, Firefox, Camino, K-Meleon)
	this.cmo=(this.agt.indexOf("Camino")!=-1 && this.dom)?1:0;	                                        // Camino specific
	this.ns6=(this.agt.indexOf("Netscape")!=-1 && parseInt(this.ver)>=5 && this.dom)?1:0;	              // NS6+ specific
	this.ns4=(document.layers && !this.dom)?1:0;				                                                // NS4 specific
	this.kon=(this.ver.indexOf("KHTML")!=-1 && this.dom)?1:0;                                           // Uses KHTML DOM implementation (Safari, OmniWeb)
    this.ie=(this.ie8 || this.ie7 || this.ie6 || this.ie5 || this.ie4)?1:0;                                                                   // Allows single test on bw.ie
	this.macie=(this.mac && this.ie)                                                                    // IE on a Mac
	this.nav=(this.ns4)?1:0;																									                          // Allows single test on bw.nav	
	this.bw=(this.ie || this.gko || this.ns4 || this.kon)?1:0;		                                      // All browsers
	
	/* Detect browsers supporting Peppercoin's Small Transaction Suite v2.0 */
	if (this.gko || this.kon || (this.ie && !this.cab)) {                                               // Check whether client is using Gecko, KHTML, or MSIE (but not iCab) browser 
		return this
	} 
	else {
		/* Redirect to Browser Support page */
		document.location.href=browserSupportURL;                                             						// If client is using unsupported browser, redirect them to unsupported browser info page
	}
	
}

function objLayer(id,nest) {

    // THIS if LINE (NOT THE ENCLOSED CODE) ADDED AUG 20 2009
    if (document.getElementById(id) != null) {

/*
alert('' +
'This alert coming from: includes/layerAPI.js\n' +
'id = ' + id + '\n' +
'nest = ' + nest + '\n' +
'document.getElementById(id) = ' + document.getElementById(id) + '\n' +
'');
*/
        nest=(!nest)?'':'document.'+nest+'.'

        /* object pointer */ 
        this.obj=bw.dom?document.getElementById(id):bw.ie4?document.all[id]:bw.ns4?eval(nest+'document.'+id):0	

        /* style reference */
        this.css=bw.dom?document.getElementById(id).style:bw.ie4?document.all[id].style:bw.ns4?eval(nest+'document.'+id):0

        if (bw.macie) {this.x=this.css.pixelLeft; this.y=this.css.pixelTop; this.h=this.obj.clientHeight; this.w=this.obj.clientWidth}	
        if (bw.ie4 || bw.ie5) {this.x=this.css.pixelLeft; this.y=this.css.pixelTop; this.h=this.obj.scrollHeight; this.w=this.obj.scrollWidth}   
        if (bw.ie7 || bw.ie6 || bw.gko) {this.x=this.css.pixelLeft; this.y=this.css.pixelTop; this.h=this.obj.offsetHeight; this.w=this.obj.offsetWidth} 
        if (bw.ns4) {this.x=this.css.left; this.y=this.css.top; this.h=this.obj.document.height; this.w=this.obj.document.width}

        this.defaultTop = this.y	
        this.defaultBottom = this.y + this.h

        this.globalX = 0
        this.globalY = 0

        this.HTML = this.obj.innerHTML;

        return this;

    } //if
}

/* Function to set up method's for browser height & width handling */
function obj_updateDim() {
	if (bw.ie4 || bw.ie5 || bw.ie6 || bw.ie7 || bw.gko) {this.h=this.obj.scrollHeight; this.w=this.obj.scrollWidth}   
	if (bw.ns4) {this.h=this.obj.document.height; this.w=this.obj.document.width}
	/* mac variant */
	if (bw.mac && bw.ie) {this.h=this.obj.clientHeight; this.w=this.obj.clientWidth}
}

/* Function to set element's x/y co-ordinates */
function obj_moveTo(x,y) { 

/*
alert('In includes/layerAPI.js' + '\n' +
'this.obj.id = ' + this.obj.id);
*/

  if (bw.gko) {
		this.x=x + "px"
  	this.y=y + "px"
		this.css.left=this.x
		this.css.top=this.y
  }   
	else if (bw.macie) {
		this.x=x
  	this.y=y
		this.css.pixelLeft=this.x
		this.css.pixelTop=this.y
	}
	else {
		this.x=x
  	this.y=y
		this.css.left=this.x
		this.css.top=this.y
	}
}

/* Function to change element's x/y co-ordinates */
function obj_moveBy(x,y) {
	this.x+=x
	this.y+=y
	if (bw.macie) {
		this.css.pixelLeft=this.x
		this.css.pixelTop=this.y
	}
	else {
		this.css.left=this.x
		this.css.top=this.y
	}	
}

/* Function to change element's stacking order */
function obj_setZIndex(z) {
	this.css.zIndex = z
}

function obj_clipValues(which) {
	if (bw.ns4){
		if (which=="t") return this.css.clip.top
		if (which=="r") return this.css.clip.right
		if (which=="b") return this.css.clip.bottom
		if (which=="l") return this.css.clip.left
	} else {
		var clipv = this.css.clip.split("rect(")[1].split(")")[0].split("px")
		if (which=="t") return Number(clipv[0])
		if (which=="r") return Number(clipv[1])
		if (which=="b") return Number(clipv[2])
		if (which=="l") return Number(clipv[3])
	}
}

/* Function to set element's clip values */
function obj_clipTo(t,r,b,l) {
	if(bw.ns4){
		this.css.clip.top = t
		this.css.clip.right = r
		this.css.clip.bottom = b
		this.css.clip.left = l
	} else {
		this.css.clip="rect("+t+","+r+","+b+","+l+")"
	}
}

/* Function to change element's clip values */
function obj_clipBy(t,r,b,l) {
	this.clipTo(this.clipValues('t')+t,this.clipValues('r')+r,this.clipValues('b')+b,this.clipValues('l')+l)
}

/* Function to make element hidden */
function obj_hide() {
	this.css.visibility=(bw.ns4)?'hide':'hidden'
}

/* Function to make element visible */ 
function obj_show() {
	this.css.visibility=(bw.ns4)?'show':'visible'
}

/* Funtion to not display element */
function obj_displayOff() {
	this.css.display="none"
}

/* Function to display element */
function obj_displayOn() {
	this.css.display="inline"
}

/* Function to change element's visibility */
function obj_vis() {
	if (this.css.visibility=="hidden" || this.css.visibility=="hide") 
	return true;
}

/* Function to re-write element's HTML */
function obj_writeIt(txt) {
	if (bw.ns4){
		this.obj.document.write(txt)
		this.obj.document.close()
	} else {
		this.obj.innerHTML = txt
	}
}

/* Function to change element's background color */
function obj_changeBackColor(c) {
	if (bw.ns4){
		this.css.bgColor = c;
	} else {
		this.css.backgroundColor = c;
	}
}

/* Function to change element's opacity (IE specific) */
function obj_changeAlpha(o) {
	if (bw.ie) {
		this.css.filter = "alpha(opacity="+o+")"
	} else {
		//do nothing
	}
}

/* Function to change element's color (text) */
function obj_changeColor(c) {
	bw.ns4?this.css=this.css:this.css.color=c;
}

/* Function to change element's size */
function obj_sizeBy(w,h){
	this.w=w
	this.h=h
}

objLayer.prototype.changeColor = obj_changeColor
objLayer.prototype.moveTo      = obj_moveTo
objLayer.prototype.moveBy      = obj_moveBy
objLayer.prototype.clipValues  = obj_clipValues
objLayer.prototype.clipTo      = obj_clipTo
objLayer.prototype.clipBy      = obj_clipBy
objLayer.prototype.hide        = obj_hide
objLayer.prototype.show        = obj_show
objLayer.prototype.vis         = obj_vis
objLayer.prototype.displayOff  = obj_displayOff
objLayer.prototype.displayOn   = obj_displayOn
objLayer.prototype.writeIt     = obj_writeIt
objLayer.prototype.setZIndex   = obj_setZIndex
objLayer.prototype.changeBack  = obj_changeBackColor
objLayer.prototype.changeAlpha = obj_changeAlpha
objLayer.prototype.updateDim   = obj_updateDim
objLayer.prototype.sizeBy      = obj_sizeBy

//-->