// JavaScript Document
function getElem(ename) {

	if (document.all) return document.all[ename];

	if (document.getElementById) return document.getElementById(ename);

}


function waitingBox(ref) {
						var elem = getElem('waitbox');
						TB_overlaySize();
						TB_load_position();
						if (!ref || ref.indexOf('javascript')<0) {
							clickfirst = false;
							document.body.style.cursor = 'wait';
							var ie6 = (document.all && !window.opera && !window.XMLHttpRequest) ? true : false;
							//elem.style.zIndex='999';
							var height = 0;
							var width = 0;
							if (ie6) {
								elem.style.background='';
								//elem.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/eb/img/wait.png,sizingMethod=scale)';								
							} 
							if (!window.opera) {
								height = document.body.clientHeight;
							} else {
								height = document.documentElement.clientHeight;
							}
							elem.style.margin='0';
							elem.style.height=height+'px';
							elem.style.visibility='visible';
						}
						
					} 
					
function TB_overlaySize(){
	//alert(window.scrollMaxY);
	if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) {	
		yScroll = window.innerHeight + window.scrollMaxY;
		xScroll = window.innerWidth + window.scrollMaxX;
		var deff = document.documentElement;
		var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
		var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
		xScroll -= (window.innerWidth - wff);
		yScroll -= (window.innerHeight - hff);
	} else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
		xScroll = document.body.scrollWidth;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
		xScroll = document.body.offsetWidth;
  	}
	
	$("#waitbox").css({"height":yScroll +"px", "width":xScroll +"px"});
	//$("#TB_HideSelect").css({"height":yScroll +"px","width":xScroll +"px"});
}		
function TB_load_position() {
	var pagesize = TB_getPageSize();
	var arrayPageScroll = TB_getPageScrollTop();
	$("#waittext")
	.css({left: (arrayPageScroll[0] + (pagesize[0] - 100)/2)+"px", top: (arrayPageScroll[1] + ((pagesize[1]-100)/2))+"px" })
	.css({display:"block"});
}

function TB_getPageScrollTop(){
	var yScrolltop;
	var xScrollleft;
	if (self.pageYOffset || self.pageXOffset) {
		yScrolltop = self.pageYOffset;
		xScrollleft = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft ){	 // Explorer 6 Strict
		yScrolltop = document.documentElement.scrollTop;
		xScrollleft = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScrolltop = document.body.scrollTop;
		xScrollleft = document.body.scrollLeft;
	}
	arrayPageScroll = new Array(xScrollleft,yScrolltop) 
	return arrayPageScroll;
}

function TB_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight
	arrayPageSize = new Array(w,h) 
	return arrayPageSize;
}	

function TB_remove(){
	$("#TB_overlay").remove();
	$("#TB_load").remove();
}