// dHTML Api 3.0 (C) 2001 by Oki Uimonen, oki.uimonen@mtv3.fi
// Netscape/IE 4.x and W3C DOM Support

// Browser detection --------------------------------------------------------------------------
// if the browser is W3C DOM compatible d_W3C is set to TRUE
// if the browser is Netscape 4.x or IE 4.x d_NS4 or d_IE4 is set to true

var d_IE4,d_NS4,d_W3C,d_capable;

var range=""; var styleObj="";

var d_isMac=0;

if(navigator.appVersion.indexOf("Mac")>0) d_isMac=1;

// Check for W3C DOM Support
if(document.getElementById) {
	d_W3C=true; d_capable=true;
	}

// Check for IE 4.x
else if(document.all) {
    d_IE4=true; d_capable=true;
    range="all.";
    styleObj=".style";
    }

// Check for NS 4.x    
else if(document.layers) {
    d_NS4=true; d_capable=true;
    }

else d_capable=false;

// This function returns a reference to a div name passed in the obj parameter
// If obj is a reference itself the value of obj itself is returned
function d_getObject(obj) {
    var theObj;
    if(typeof obj == "string") {
      if(d_W3C) { theObj=document.getElementById(obj).style; }
		else { theObj=eval("document."+range+obj+styleObj); }
		}
    else { theObj=obj; }
    return theObj;
    }

// Positioning functions ------------------------------------------------------------------------

function d_getX(obj) {
	var x;
	var theObj=d_getObject(obj);
	if(d_W3C) x=parseInt(theObj.left);
	else if(d_IE4) x=theObj.pixelLeft;
	else if(d_NS4) x=theObj.pageX;
	return x;
	}

function d_getY(obj) {
	var y;
	var theObj=d_getObject(obj);
	if(d_W3C) y=parseInt(theObj.top);
	else if(d_IE4) y=theObj.pixelTop;
	else if(d_NS4) y=theObj.pageY;
	return y;
	}


// Return the coordinates of an inline element (not absolutely positioned)
function d_getInlineX(inlineElementName) {
	if(document.all) elementRef=document.all[inlineElementName];
	else if(document.getElementById) elementRef=document.getElementById(inlineElementName);
	else return null;
	x=0; do { x+=elementRef.offsetLeft; } while(elementRef=elementRef.offsetParent);
	return(x);
	}

function d_getInlineY(inlineElementName) {
	if(document.all) elementRef=document.all[inlineElementName];
	else if(document.getElementById) elementRef=document.getElementById(inlineElementName);
	else return null;
	y=0; do { y+=elementRef.offsetTop; } while(elementRef=elementRef.offsetParent);
	return(y);
	}

// Moves the object by dx pixels horizontally and dy pixels vertically
function d_moveBy(obj,dx,dy) {
	var theObj=d_getObject(obj);
	d_moveTo(obj,d_getX(obj)+dx,d_getY(obj)+dy);
	}
    
// Moves the object to x,y
function d_moveTo(obj,x,y) {
	var theObj=d_getObject(obj);
	d_moveX(obj,x);
	d_moveY(obj,y);
   }
    
function d_moveX(obj,x) {
	var theObj=d_getObject(obj);
	if(d_W3C) theObj.left=x+"px";
	else if(d_IE4) theObj.pixelLeft=x;
	else if(d_NS4) theObj.pageX=x;
	}

function d_moveY(obj,y) {
	var theObj=d_getObject(obj);
	if(d_W3C) theObj.top=y+"px";
	if(d_IE4) theObj.pixelTop=y;
	else if(d_NS4) theObj.pageY=y;
	}

// Visibility functions --------------------------------------------------------------------------------------

function d_show() {
    var theObj;
    for(i=0;i<d_show.arguments.length;i++) {
      theObj=d_getObject(d_show.arguments[i]);
      theObj.visibility="visible";
      }
    }
    
function d_hide() {    
    var theObj;
    for(i=0;i<d_hide.arguments.length;i++) {
      theObj=d_getObject(d_hide.arguments[i]);
      theObj.visibility="hidden";
      }
    }

// Size functions -------------------------------------------------------------------------------------------

// returns the width of document area    
function d_getPageWidth() {
	if(window.innerHeight) return window.innerWidth;
	else if(document.body.clientHeight) return document.body.clientWidth;
	}

// returns the height of document area    
function d_getPageHeight() {
	if(window.innerHeight) return window.innerHeight;
	else if(document.body.clientHeight) return document.body.clientHeight;
	}


function d_getObjectWidth(obj) {
	var theObj=d_getObject(obj);  
	if(d_W3C) return theObj.width;
    else if(d_IE4) return document.all[obj].clientWidth;
    else if(d_NS4) return theObj.clip.width;
    }  

// return the height and width of an object
function d_getObjectHeight(obj) {
    var theObj=d_getObject(obj);
    if(d_IE4) return document.all[obj].clientHeight;
    else if(d_NS4) return theObj.clip.height;
    }














// Center object horizontally

function d_centerH(obj) {
    d_moveX(obj,parseInt(d_getPageWidth()/2-d_getObjectWidth(obj)/2));
    }

function d_centerV(obj) {
    d_moveY(obj,parseInt(d_getPageHeight()/2-d_getObjectHeight(obj)/2));
    }
    
// Sets object's forefroundcolor (IE only)    
    
function d_color(obj,color) {
    theObj=d_getObject(obj);
    theObj.color=color;
    }
    
// determines whether the object is a string or a reference
// and returns a reference to it


  
    


    
function d_clip(obj,x1,y1,x2,y2) {
	var theObj=d_getObject(obj);
	if(d_W3C || d_IE4) {
		if(d_isMac && d_IE4) theObj.clip="auto";
		theObj.clip="rect("+y1+"px "+x2+"px "+y2+"px "+x1+"px)";
		}

	else if(d_NS4) {
		theObj.clip.left=x1; theObj.clip.top=y1;
		theObj.clip.right=x2; theObj.clip.bottom=y2;
		}
   }
    
function d_change (obj,newContent) {
	var theObj=d_getObject(obj);
	if(d_W3C) {
		ref=document.getElementById(obj);
		ref.innerHTML=newContent;
		}

	else if(d_IE4) document.all[obj].innerHTML=newContent;

	else if(d_NS4) {
		theObj.document.open();
		theObj.document.writeln(newContent);
		theObj.document.close();
		}
	}
    
function d_zIndex(obj,zindex) {
    var theObj=d_getObject(obj);
    theObj.zIndex=zindex;
    }
    
