function LocationAndSize(){
	this.left = 0;
	this.top = 0;
	this.width = 0;
	this.height = 0;
}

function getWindowSize(obj){
	obj = obj || document.body;

	var ls = new LocationAndSize();
	var w, h;
	var t, l;
	var objTemp;

	//get top and left
	objTemp = obj;
	t = objTemp.offsetTop;
	l = objTemp.offsetLeft;
	
	while(objTemp.offsetParent){
		objTemp = objTemp.offsetParent;
		t += objTemp.offsetTop;
		l += objTemp.offsetLeft;
	}

	//get width, height
	
	if(obj.offsetWidth){
		w = obj.offsetWidth;
		h = obj.offsetHeight;
	}

	if(obj.clientWidth){
		w = obj.clientWidth;
		h = obj.clientHeight;
	}
	if(document.body){
		if(obj == document.body){
			if(document.documentElement.clientWidth){
				if(document.documentElement.clientWidth > w)
					w = document.documentElement.clientWidth;
				if(document.documentElement.clientHeight > h);
				h = document.documentElement.clientHeight;
			}
			if(window.innerWidth){
				if(window.innerWidth > w)
					w = window.innerWidth;
				if(window.innerHeight > h)
					h = window.innerHeight;
			}
		}
	}	
	if(obj.scrollWidth){
		if(obj.scrollWidth > w)
			w = obj.scrollWidth;
		if(obj.scrollHeight > h)
			h = obj.scrollHeight;
	}

	ls.top = t;
	ls.left = l;
	ls.width = w;
	ls.height = h;

	return ls;
}

function checkForSubmit(pObj, pSubmitId){
	if(event.keyCode == 13){
		var thisId = pObj.id;
		var ctrlId = '';
		var submitButton;
		
		if(thisId.indexOf('_') > -1){
			ctrlId = thisId.substring(0, thisId.lastIndexOf('_')+1);
			thisId = thisId.substring(thisId.lastIndexOf('_')+1);
		}
		
		submitButton = document.getElementById(ctrlId + pSubmitId);
		if(submitButton){
			submitButton.click();
			return false;
		}else{
			return true;
		}
	}	
}



/* Loading Code */
function showLoading(divId){
	var div = document.getElementById(divId);
	/*if(div){
		var divLoading = document.createElement('div');
		divLoading.className = 'Loading';
		div.appendChild(divLoading);
		
		var ls = getWindowSize(div);
		divLoading.style.left = ls.left + 'px';
		divLoading.style.top = ls.top + 'px';
		divLoading.style.width = ls.width + 'px';
		divLoading.style.height = ls.height + 'px';
		divLoading.style.display = 'inline';
		setOpacity(70, divLoading);
	}*/
}
/* END:Loading Code */


/* Gallery Popup code */
var _backgroundHeight = -1;
var _stopResize = false;
function galleryShow(alignTo){        //1=center, 2=top, 3=curr pos
	var ca = new ClientArea();
	_backgroundHeight = ca.TotalHeight;
	
	showWindow('imageBrowse', alignTo);
	//safari does not make the div 100%, so do it manually
	var div = document.getElementById('imageBrowse');
	if(div.offsetWidth < ca.width)
		div.style.width = ca.width + 'px';
	
	_stopResize = false;
	doGalleryResize();
	
}

function doGalleryResize(){
	if(_dialogueBackground){
		var popupDiv = document.getElementById('imageBrowse');
		if(popupDiv){
			var ls = new LocationSize(popupDiv);
			if(_backgroundHeight > -1 && ls.top + ls.height <= _backgroundHeight)
				_dialogueBackground.style.height = _backgroundHeight + 'px';
			else if(ls.top + ls.height > _backgroundHeight)
				_dialogueBackground.style.height = (ls.top + ls.height) + 'px';
		}
		//resizeDialogueToTop();
	}
	if(_stopResize == false)
		setTimeout(doGalleryResize, 500);
}
/*END: Gallery Popup code */










