
/* *******************************************************************************************
 *         INIT                                                                              *
 ******************************************************************************************* */

function init(id) {
	setMenuMarker(id) ;
	setDocFootHideLay() ;
	if (window.attachEvent) {
		window.attachEvent("onresize", function(){ setMenuMarker(id); setDocFootHideLay(); }) ;
	} else if (window.addEventListener) {
		window.addEventListener("resize", function(){ setMenuMarker(id); setDocFootHideLay(); }, true) ;
	}
}

/* *******************************************************************************************
 *         TOP MENU / DOC FOOT                                                               *
 ******************************************************************************************* */

function setMenuMarker(id) {
	var markerPos   = getElementLeft( document.getElementById("topmenu_" + id) ) - 2 ;
	var menuLinePos = getElementTop( document.getElementById("top_menu_line") ) ;
	var markerObj   = document.getElementById("top_menu_marker") ;
	markerObj.style.top     = (menuLinePos - 5) + "px" ;
	markerObj.style.left    = markerPos + "px" ;
	markerObj.style.display = "block" ;
}

function setDocFootHideLay() {
	var obj = document.getElementById("docfoot_white") ;
	obj.style.top     = 0 ;
	obj.style.display = "none" ;
	var winW = (document.all) ? document.body.offsetWidth - 20 : document.body.clientWidth ;
	var winH = (document.all) ? document.body.offsetHeight - 4 : document.body.clientHeight ;
	if (document.body && document.body.scrollHeight) {
		scrollH = (document.body.scrollHeight < winH) ? winH : document.body.scrollHeight ;
	} else if (document.documentElement && document.documentElement.offsetHeight){
		scrollH = (document.documentElement.offsetHeight < winH) ? winH : document.documentElement.offsetHeight ;
	} else {
		scrollH = winH ;
	}
	obj.style.top     = (scrollH - 15) + "px" ;
	obj.style.left    = ((winW / 2) - 380) + "px" ;
	obj.style.display = "block" ;
}

/* *******************************************************************************************
 *         Get absolute position of any element                                              *
 ******************************************************************************************* */
 
 function getElementLeft(el) {
	if (!el && this) {
		el = this;
	}
	var posLeft = el.offsetLeft;
	var elPar = el.offsetParent;
	while (elPar != null) {
		posLeft += elPar.offsetLeft;
		elPar = elPar.offsetParent;
	}
	return posLeft;
}


function getElementTop(el) {
	if (!el && this) {
		el = this;
	}
	var posTop = el.offsetTop;
	var elPar = el.offsetParent;
	while (elPar != null) {
		posTop += elPar.offsetTop;
		elPar = elPar.offsetParent;
	}
	return posTop;
}


/* *******************************************************************************************
 *         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);
	}
}

function addEvent(sectionId, parentMetaId) {
	var params = "" ;
	if (sectionId != "") {
		params += "?section_id=" + sectionId ;
	}
	if (parentMetaId != "") {
		params += (params != "") ? "&" : "?" ;
		params += "parent_meta_id=" + parentMetaId ;
	}
	popWinOpen(380,550,"/jsp/calendar/index.jsp" + params,"EventWin",1,0,1) ;
}

function openWeather(url) {
	popWinOpen(225,580,url,"WeatherWin",1,0,0) ;
}


function winStatus(str) {
	if (str != "") {
		str = "http://" + location.host + str ;
	}
	window.status = str ;
}


