
/*  included in Application.cfm  */
function show_login(destination) {
		window.top.location.href= destination;
	}

/* included in detail_panel.cfm, manage.cfm  */
function popupMessage(msg_type,email_addr,node_id,doc_name,area_name, app_url) {
	var appUrl = app_url.substring(0, app_url.lastIndexOf("/") +1 );
	var region= area_name.substring(area_name.indexOf("\\") + 1 );
	var to = email_addr;
	var subject;
	var body;
	if (msg_type == 'checkin') {
	 subject = "Your Checked Out TeamLink Document"; 
	 body = '\nThe file ' + doc_name + ' is checked out to you in the TeamLink\n' + 
		region +' area.  \n\nPlease check it in at your earliest convenience using the link below:\n\n' +
		appUrl + 'index.cfm?doc_id=' + node_id + 
		'\n\nPlease note that you will have to log into the application to check the file in.\n\nThank you!'
	}
   if (msg_type == 'FILE') {
	 subject = "Item Now Available in TeamLink"; 
	 body = '\nThis is to notify you that a new or updated version of the file ' + doc_name + ' now is in place in the TeamLink\n' + 
		region +' area.  \n\nIt may be accessed using the link below:\n\n' +
		appUrl + 'index.cfm?doc_id=' + node_id + 
		'\n\nPlease note that you will have to log into the application to access the file.\n\nThank you!'
	}

   if (msg_type == 'DTBS') {
	 subject = "Database Updated in TeamLink"; 
	 body = '\nThis is to notify you that new or updated information is now in place in the ' + doc_name + ' Database in the TeamLink\n' + 
		region +' area.  \n\nIt may be accessed using the link below:\n\n' +
		appUrl + 'index.cfm?doc_id=' + node_id + 
		'\n\nPlease note that you will have to log into the application to access the Database.\n\nThank you!'
	}

   if (msg_type == 'ECAL') {
	 subject = "Calendar Updated in TeamLink"; 
	 body = '\nThis is to notify you that new or updated entries are now in place in the Calendar in the TeamLink\n' + 
		region +' area.  \n\nIt may be accessed using the link below:\n\n' +
		appUrl + 'index.cfm?doc_id=' + node_id + 
		'\n\nPlease note that you will have to log into the application to access the Calendar.\n\nThank you!'
	}


	var doc = "mailto:" + to  + "&subject=" + escape(subject) + "&body=" + escape(body); 

	window.location.href = doc;
}

/*  Implements Link from tree item */
function go2item_fn(in_node_id,in_shw,sess_token) {
	var id = parseInt(in_node_id);
	var show = in_shw;
	parent.right.location.href="detail_panel.cfm?" + sess_token + "&node_id=" + id + "&shw=" + show;
	parent.detail_toolbar.location.href="detail_toolbars.cfm?" + sess_token + "&node_id=" + id + "&shw=" + show; 
	}



/*  Implement click vs doubleclick action on File, Calendar and Database icons in detail_panel.cfm  */
var iTimeoutId = null;

function dolist_fn(v_nodeid)	{
	  iTimeoutId = setTimeout("list_this(" + v_nodeid + ")", 400);

	}
/* Files */
function doshow_fn(v_nodeid) {
	  if (iTimeoutId)  {
	    window.clearTimeout(iTimeoutId);
	    show_this(v_nodeid);
	  }
	  else  {
	    list_this(v_nodeid);  
	  }
	}

/* Files */
function show_this(v_nodeid) {
		location.href="manage.cfm?node_id=" + v_nodeid + "&operation=ReadOnly"
		return false;
	}

/* All */
function list_this(v_nodeid) {
		location.href="manage.cfm?node_id=" + v_nodeid + "&operation=Drilldown&shw=Y"
		return false;
	}

/* Calendars and Databases */
function doshownew_fn(v_nodeid, v_linkstr) {
	  if (iTimeoutId)  {
	    window.clearTimeout(iTimeoutId);
	    show_new(v_linkstr);
	  }
	  else  {
	    list_this(v_nodeid);  
	  }
	}

/* Calendars and Databases */
function show_new(v_linkstr, v_nodeid) {
		var newWindow;
		newWindow = window.open(v_linkstr, v_nodeid); 
		return false;
	}


/*  
	Toolbar expand, collapse, refresh functions
*/

	function expand_fn(in_nodeid) {
	parent.left.location.href="tree_panel.cfm?maxdepth=-1"
	parent.detail_toolbar.location.href="detail_toolbars.cfm" 
	parent.right.location.href="detail_panel.cfm?node_id=" + in_nodeid
	}

	function collapse_fn(in_nodeid) {
	parent.left.collapse_all ()
	parent.detail_toolbar.location.href="detail_toolbars.cfm" 
	parent.right.location.href="detail_panel.cfm?node_id=" + in_nodeid
	}

	function refresh_fn() {
	parent.left.location.href="tree_panel.cfm?maxdepth=-1"
	}




/* Navigation for Admin functions */

	/*  Menu items:  required to clear 'Back to List' button if previously displayed */
	function admin_fn(fn_target) {
		parent.right.location.href=fn_target
		parent.parent.detail_toolbar.location.href='admin_toolbars.cfm' 
	}

	/*  Navigation to child table within sub-frame */
	function adminNav_fn(fn_target,shw_btn) {
		parent.location.href=fn_target
		parent.parent.detail_toolbar.location.href='admin_toolbars.cfm?flag=' + shw_btn 
	}

	/*  Navigation to child table */
	function adminNavDir_fn(fn_target,shw_btn) {
		parent.right.location.href=fn_target
		parent.parent.detail_toolbar.location.href='admin_toolbars.cfm?flag=' + shw_btn 
	}


	/* Navigation return from child table */
	function adminNavBack_fn(fn_target) {
		parent.right.location.href=fn_target
		parent.detail_toolbar.location.href='admin_toolbars.cfm' 
	}
