function adjustImageLoc(img,box){ // no longer used.
	var h=getNumPx(Element.extend(box).getStyle('height'));
	var m=Math.round(parseInt(h-parseInt(img.naturalHeight))/2);
	if(typeof img.naturalWidth != 'undefined'){
		Element.extend(img).setStyle({'width':img.naturalWidth+'px',height:img.naturalHeight+'px','margin-top':m+'px'});
	}else{
//		var o=Element.extend(img);
//		img.style.margin=m;
//		o.setStyle({'margin-top':m+'px 0px 0px 0px'});
	}
}
function mouseOverImageBox(box,onflag){
	if(onflag==true){
		Element.extend(box).setStyle({'border-color':'#666 #eee #eee #666',opacity:0.80,filter:'alpha(opacity=80)'});
	}else{
		Element.extend(box).setStyle({'border-color':'#eee #666 #666 #eee',opacity:0.99,filter:'alpha(opacity=99)'});
	}
}
document.scroll = function(){
   return {
      x: this.body.scrollLeft || this.documentElement.scrollLeft,
      y: this.body.scrollTop  || this.documentElement.scrollTop
   };
};
function getOpacity(o) {
//	return Element.extend(e).getStyle('opacity');
	var e=Element.extend(o);
	var value = e.getStyle('opacity');
	if (value) return parseFloat(value);
	value = e.getStyle('filter');
	var ret=value.match(/alpha\(opacity=(.*)\)/);
	if (ret != null && ret[1]!=null){
		if (ret[1]) return parseFloat(ret[1]) / 100;
		else return 0;
	}
	return null;
}
function isIE(){ return /MSIE/.test(navigator.userAgent); }
function isGeko(){ return navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1;}
function isOpera(){ return /Opera\s[1-8]/.test(navigator.userAgent);}
function isSafari(){ return /Safari/.test(navigator.userAgent);}
function getNumPx(s){
	if(!s)return;
	s.replace('px','');
	return parseInt(s);
}
function reverseDisplay(id){
    try{
        e = $(id);
    }catch(e){
        return;
    }
	if(e.style.display=='none'){
		e.show();
	}else{
		e.hide();
	}
	return false;
}
function showBox(boxId, overlayFlag, centerPos){
    var b=$(boxId);
    if(!b) return false;
	if(overlayFlag==true){
		b.style.zIndex=210;
		var o = $('overlay');
		o.style.zIndex=205;
		o.show();
		var v=getScrollSize();
		if(isSafari()){v.height*=5;}
		o.setStyle({width:v.width+'px',height:v.height+'px'});	
	}else{
 	   b.setStyle({'z-index':10});
	}
	if(centerPos==true){
		setCenterPosition(b);
	}
	b.setStyle({display:'block'});
	return false;
}
function hideBox(boxId, overlayFlag){
	if(overlayFlag==true){
		$('overlay').hide();
	}
	$(boxId).setStyle({display:'none'});
    return false;
}
function setCenterPosition(e){
	e.setStyle({position:'absolute'});
    var scrollY = getWinYOffset();
    var d = e.getDimensions(e);
    var setX = ( getWindowWidth()  - d.width ) / 2;
    var setY = ( getWindowHeight() - d.height ) / 2 + scrollY;
    setX = ( setX < 0 ) ? 0 : setX;
    setY = ( setY < 0 ) ? 0 : setY;
	e.setStyle({left:Math.round(setX)+'px',top:Math.round(setY)+'px'});
}  
function getWinYOffset(){
  if(window.scrollY) return window.scrollY; // Mozilla
  if(window.pageYOffset) return window.pageYOffset; // Opera, NN4
  if(document.documentElement && document.documentElement.scrollTop){ // IE
   return document.documentElement.scrollTop;
  }else if(document.body && document.body.scrollTop){
   return document.body.scrollTop;
  }
  return 0;
}
function getWinXOffset(){
  if(window.scrollX) return window.scrollX; // Mozilla
  if(window.pageXOffset) return window.pageXOffset; // Opera, NN4
  if(document.documentElement && document.documentElement.scrollLeft){ // IE
   return document.documentElement.scrollLeft;
  }else if(document.body && document.body.scrollLeft){
   return document.body.scrollLeft;
  }
  return 0;
}
function getScrollSize(){
   return {
      width: document.documentElement.scrollWidth || document.body.scrollWidth,
      height: document.documentElement.scrollHeight || document.body.scrollHeight 
   };	
}
function getWindowWidth(){
  if(window.innerWidth) return window.innerWidth; // Mozilla, Opera, NN4
  if(document.documentElement && document.documentElement.clientWidth){ //IE
   return document.documentElement.clientWidth;
  }
  else if(document.body && document.body.clientWidth){
   return document.body.clientWidth;
  }
  return 0;
}
function getWindowHeight(){
  if(window.innerHeight) return window.innerHeight; // Mozilla, Opera, NN4
  if(document.documentElement && document.documentElement.clientHeight){ // IE
   return document.documentElement.clientHeight;
  }
  else if(document.body && document.body.clientHeight){
   return document.body.clientHeight;
  }
  return 0;
}
