// getElementWidth-----------------------------------------------------------------------------
function getElementWidth(anObj) {
    if (typeof anObj.clip !== "undefined") {
        return anObj.clip.width;
    } else {
        if (anObj.style.pixelWidth) {
            return anObj.style.pixelWidth;
        } else {
            return anObj.offsetWidth;
        }
    }
}

// getElementHeight---------------------------------------------------------------------------
function getElementHeight(anObj) {
    if (typeof anObj.clip !== "undefined") {
        return anObj.clip.height;
    } else {
        if (anObj.style.pixelHeight) {
            return anObj.style.pixelHeight;
        } else {
            return anObj.offsetHeight;
        }
    }
}

// getWindowHeight---------------------------------------------------------------------------
function getWindowHeight() {

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    return(window.innerHeight);
  } 
  if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    return(document.documentElement.clientHeight);
  }
  if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    return(document.body.clientHeight);
  }
}

// getWindowWidth---------------------------------------------------------------------------
function getWindowWidth() {

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    return(window.innerWidth);
  } 
  if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    return(document.documentElement.clientWidth);
  }
  if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    return(document.body.clientWidth);
  }
}
//To get all a elements in the document with a “info-links” class.
//    getElementsByClassName(document, "a", "info-links");
//To get all div elements within the element named “container”, with a “col” class.
//    getElementsByClassName(document.getElementById("container"), "div", "col"); 
//To get all elements within in the document with a “click-me” class.
//    getElementsByClassName(document, "*", "click-me"); 
    
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}
// PlaceImage------------------------------------------------------------------------------
// source - string - URL of image
// target - string - id of image element contained within a image placeholder div 

var PIImg 
var PISource
var PITarget

function PlaceImage(source,target) { 
  
  PISource = source
  PITarget = target
 
//  tObj = document.getElementById(PITarget);
//  tObj.width =40
//  tObj.height =40
//  tObj.style.marginLeft=200 + 'px'
//  tObj.style.marginTop=200 + 'px'
//  tObj.src='images/spinner40.gif'
 
  PIImg = new Image()
  PIImg.src = source
  PlaceImage2()
}  

function PlaceImage2() { 
  if (!PIImg.complete) {
    setTimeout("PlaceImage2()",50)
    return;
  }
  tObj = document.getElementById(PITarget)
  if (tObj.parentNode.currentStyle){
    h = parseInt(tObj.parentNode.currentStyle.height)
    w = parseInt(tObj.parentNode.currentStyle.width)
  } else {
    h = tObj.parentNode.offsetHeight  
    w = tObj.parentNode.offsetWidth
  }
     
  iW = PIImg.width
  iH = PIImg.height

  if ((h/iH)<(w/iW)) {
    tObj.height=h 
    tObj.width=h/iH*iW  
    tObj.style.marginTop = 0 + 'px'
    tObj.style.marginLeft = Math.round((w-h/iH*iW)/2) + 'px'
  } else {
    tObj.width=w 
    tObj.height=w/iW*iH 
    tObj.style.marginLeft =  0 + 'px'  
    tObj.style.marginTop = Math.round((h-w/iW*iH)/2) + 'px' 
//force top        
    tObj.style.marginTop = '0px'   
  }     

  tObj.src = PISource
}

// Shadow class handlers-------------------------------------------------------------------
var gradientshadow={}
gradientshadow.depth=7 //Depth of shadow in pixels
gradientshadow.containers=[]

gradientshadow.create=function(){
//var a = document.all ? document.all : document.getElementsByTagName('*')
var a = getElementsByClassName(document,"*","shadow")
for (var i = 0;i < a.length;i++) {

		for (var x=0; x<gradientshadow.depth; x++){
			var newSd = document.createElement("DIV")
			newSd.className = "shadow_inner"
			newSd.id="shadow"+gradientshadow.containers.length+"_"+x //Each shadow DIV has an id of "shadowL_X" (L=index of target element, X=index of shadow (depth) 
			if (a[i].getAttribute("rel"))
				newSd.style.background = a[i].getAttribute("rel")
			else
				newSd.style.background = "#222222" //default shadow color if none specified
			
			var parent = a[i].parentNode;
            parent.appendChild(newSd) ;
		/*	document.body.appendChild(newSd) */
		}
	gradientshadow.containers[gradientshadow.containers.length]=a[i]
	
}
gradientshadow.position()

}

gradientshadow.position=function(){
if (gradientshadow.containers.length>0){
	for (var i=0; i<gradientshadow.containers.length; i++){
		for (var x=0; x<gradientshadow.depth; x++){
  		var shadowdiv=document.getElementById("shadow"+i+"_"+x)
			shadowdiv.style.width = gradientshadow.containers[i].offsetWidth + "px"
			shadowdiv.style.height = gradientshadow.containers[i].offsetHeight + "px"
			shadowdiv.style.left = gradientshadow.containers[i].offsetLeft + x + "px"
			shadowdiv.style.top = gradientshadow.containers[i].offsetTop + x + "px"
		}
	}
}
}
if (window.addEventListener)
window.addEventListener("load", gradientshadow.create, false)
else if (window.attachEvent)
window.attachEvent("onload", gradientshadow.create)

// displayStatus -------------------------------------------------------------------------
function displayStatus(msgStr) {
  window.status=msgStr;
  return true
}

//hideStatus Hide Status bar -------------------------------------------------------------
function hideStatus(){
  window.status=''
  return true
}
//decode email address ------------------------------------------------------------------
function decodeEA(ea){
elink = 'mailto:' + reversestring(ea);
window.location=elink;
}
function reversestring(s){
splitext = s.split("");
revertext = splitext.reverse();
reversed = revertext.join("");
return reversed;
}
