//This Library contains all the common Javascript functions for this application
//Brian Allison
//5/8/06
//ballison@lotus911.com
function getViewportHeight() {
		 if (window.innerHeight!=window.undefined) return window.innerHeight;
		 if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
		 if (document.body) return document.body.clientHeight; 
		 return window.undefined; 
}
function getViewportWidth() {
		 if (window.innerWidth!=window.undefined) return window.innerWidth; 
		 if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
		 if (document.body) return document.body.clientWidth; 
		 return window.undefined; 
}
function setModalMaskSize(div){
		 var theBody = document.getElementsByTagName("BODY")[0];
		 		 		 
		 var fullHeight = getViewportHeight();
		 var fullWidth = getViewportWidth();
		 
		 // Determine what's bigger, scrollHeight or fullHeight / width
		 if (fullHeight > theBody.scrollHeight) {
		 		 popHeight = fullHeight;
		 } else {
		 		 popHeight = theBody.scrollHeight;
		 }
		 
		 if (fullWidth > theBody.scrollWidth) {
		 		 popWidth = fullWidth;
		 } else {
		 		 popWidth = theBody.scrollWidth;
		 }
		 
		 div.style.height = popHeight + "px";
		 div.style.width = popWidth + "px";

}
function showNextFileupload(  ) {
	var div = document.getElementById('NewAttachmentDiv' )
	var divArr = div.getElementsByTagName('div')
	var shown = false
	for (i = 0 ; i < divArr.length; i++){
		if ( shown == false ) {
			if (divArr[i].className != 'AttTitleDiv' ){
				if (divArr[i].style.display == 'none') {
					divArr[i].style.display = 'block'
					shown = true
				}
			}
		}
	}
}
function styleActionBar(){
	var tblArr = document.getElementsByTagName('table')
	var div = document.getElementById('actionBarDiv')
	if (tblArr[0].id != 'NoActionBarTbl') {
		var tbl = tblArr[0]
		tbl.id = 'ActionBarTbl'
		tbl.className = 'ActionBarTbl'
		var lnkArr = tbl.getElementsByTagName('a')
		for (i = 0 ; i < lnkArr.length ; i++) {
			var htmStr = lnkArr[i].innerHTML
			if( htmStr.indexOf( 'Save as Draft' ) >= 0 ) {
				lnkArr[i].href = '#'
			}
		}
		var hrArr = document.getElementsByTagName('hr')
		hrArr[0].style.display = 'none'
	}
}
function styleDocumentActionBar(){
	var tblArr = document.getElementsByTagName('table')
	var div = document.getElementById('actionBarDiv')
	var lnkinnerhtm = ''
	var htmStr = ''
	if (tblArr[0].id != 'NoActionBarTbl') {
		var hrArr = document.getElementsByTagName('hr')
		hrArr[0].style.display = 'none'
		var tbl = tblArr[0]
		tbl.style.display = 'none'
		var tdArr = tbl.getElementsByTagName('td')
		for (i = 0 ; i < tdArr.length ; i++) {
			htmStr = htmStr + '<div class="ActBtnDiv" id="Act' + i + 'BtnDiv" onmouseover="this.style.border = \'outset  2px #8080FF\';" onmouseout="this.style.border = \'solid #8080FF 2px\'" >' + tdArr[i].innerHTML + '</div>'
		}
		div.innerHTML = htmStr
		div.style.display = 'block'
	}
}

