
/* *******************************************************************************************
 *         INIT                                                                              *
 ******************************************************************************************* */

function init() {
	positionDocFoot() ;
	if (window.addEventListener) {
		window.addEventListener( "resize", positionDocFoot, false ) ;
	} else if (window.attachEvent) {
		window.attachEvent( "onresize", positionDocFoot ) ;
	}
}

/* *******************************************************************************************
 *         Popup                                                                             *
 ******************************************************************************************* */

function popWinOpen(winW,winH,sUrl,sName,iResize,iScroll,iStatus) {
	if (screen) {
		if ((screen.height - winH) < 150) {
			var winX = (screen.width - winW) / 2;
			var winY = 0;
		} else {
			var winX = (screen.width - winW) / 2;
			var winY = (screen.height - winH) / 2;
		}
		var popWindow = window.open(sUrl,sName,"resizable=" + iResize + ",menubar=0,scrollbars=" + iScroll + ",status=" + iStatus + ",width=" + winW + ",height=" + winH + ",top=" + winY + ",left=" + winX + "");
		if (popWindow) popWindow.focus();
	} else {
		window.open(sUrl,sName,"resizable=" + iResize + ",menubar=0,scrollbars=" + iScroll + ",status=" + iStatus + ",width=" + winW + ",height=" + winH);
	}
}

//<a href="/path/file.ext" onClick="popWinOpen(600,560,'/path/file.ext','myWin',0,0,0); return false">Linktext</a>

/* *******************************************************************************************
 *         Get absolute position of any element                                              *
 ******************************************************************************************* */

function getElementTop(el) {
	try {
		if (!el && this) {
			el = this ;
		}
		var posTop = el.offsetTop ;
		var elPar = el.offsetParent ;
		while (elPar != null) {
			posTop += elPar.offsetTop ;
			elPar = elPar.offsetParent ;
		}
		return posTop ;
	} catch (e) {
		return 0 ;
	}
}




/* *******************************************************************************************
 *         MISC                                                                              *
 ******************************************************************************************* */
function winStatus(str) {
	if (str != "") {
		str = "http://" + location.host + str ;
	}
	window.status = str ;
}

function positionDocFoot() {
	try {
		var winHeight = (document.all) ? document.body.offsetHeight - 4 : document.body.clientHeight ;
		var pos_main  = getElementTop(document.getElementById("pos_main")) + 10 ;
		var plate_1   = (document.getElementById("plate_1")) ? getElementTop(document.getElementById("plate_1")) + 61 : 0 ;
		var plate_2   = (document.getElementById("plate_2")) ? getElementTop(document.getElementById("plate_2")) + 61 : 0 ;
		var plate_3   = (document.getElementById("plate_3")) ? getElementTop(document.getElementById("plate_3")) + 61 : 0 ;
		var plate_4   = (document.getElementById("plate_4")) ? getElementTop(document.getElementById("plate_4")) + 61 : 0 ;
		var plate_5   = (document.getElementById("plate_5")) ? getElementTop(document.getElementById("plate_5")) + 61 : 0 ;
		var plate_6   = (document.getElementById("plate_6")) ? getElementTop(document.getElementById("plate_6")) + 61 : 0 ;
		var maxHeight = Math.max(pos_main, plate_1, plate_2, plate_3, plate_4, plate_5, plate_6) ;
		//maxHeight += 61 ;
		//window.status = "maxHeight:" + maxHeight ;
		if (maxHeight < winHeight - 35) {
			maxHeight = winHeight - 35 ;
		}
		document.getElementById("doc_foot").style.top = maxHeight + "px" ;
	} catch (e) {}
}







