﻿/* -----------------------------------------------------------------------	
	Show the calendar (using PopCalendar.js library)

	invokeCtrl: The control that use to specify the postion of the calendar
	outputCtrlId: Id of the output control that store to selected date
	format: Format of the date, might be dd/mm/yyyy or dd-mm-yyyy 
					or anything you like (must contains "dd", "mm" and "yyyy")
-----------------------------------------------------------------------	*/
// show action menu for a portlet
function _showActionMenu(parent, id){
	var nTop = 0, nLeft = 0;
	var objParent = parent;	
	while (objParent.tagName!="BODY")
	{
		nTop = nTop + objParent.offsetTop;
		objParent = objParent.offsetParent;
	}
	objParent = parent;
	while (objParent.tagName!="BODY")
	{
		nLeft = nLeft + objParent.offsetLeft;
		objParent = objParent.offsetParent;
	}
	
	var objMenuLayer = document.getElementById(id);
	var objMenu = objMenuLayer.style;
	objMenu.top = nTop + parent.offsetTop + 10;
	objMenu.left = nLeft;
	objMenu.visibility = "visible";
}

// show action menu itself
function _showMe(actionMenu){
	var objMenu = actionMenu.style;
	objMenu.visibility = "visible";
}

// hide action menu
function _hideMe(actionMenu){
	var objMenu = actionMenu.style;
	objMenu.visibility = "hidden";
}

// hide (minimize) a portlet in a desktop of ViePortal
function _An(id){
	_hideViePortalElement(id);
	_hideViePortalElement(id + "_M");
	_showViePortalElement(id + "_R");
}

// show (restore) a minimized portlet in a desktop of ViePortal
function _Hien(id){
	_hideViePortalElement(id + "_R");
	_showViePortalElement(id);
	_showViePortalElement(id + "_M");
}

// temporary close a portlet in a desktop of ViePortal
function _Dong(id){
	_hideViePortalElement(id);
}

// show an element on ViePortal desktop (inline on webpage)
function _showViePortalElement(id){
	var objElement = document.getElementById(id);
	if(!objElement)
		return;
	var objStyle = objElement.style;
	if(!objStyle)
		return;
	objStyle.display = "";
}

// hide an element on ViePortal desktop (inline on webpage)
function _hideViePortalElement(id){
	var objElement = document.getElementById(id);
	if(!objElement)
		return;
	var objStyle = objElement.style;
	if(!objStyle)
		return;
	objStyle.display = "none";
}

