//  ------------------------------------------------------------
//   Misc.js 
//   ------------------------------------------------------------
//   VCS INFO:
//   
//   $Revision:   1.26  $
//   $Date:   05 Feb 2002 16:31:12  $
//   $Author:   rurman  $
//   $Workfile:   misc.js  $
//   ------------------------------------------------------------
//   INCLUDE DEPEDENCY:
//   WSCAPI/InitPage.js
//   Redist/PopupManager/PopupManager.js
//   ------------------------------------------------------------
//   All Rights Reserved.  Copyright (c) 1988-1999 FileNET Corp.
//   ------------------------------------------------------------

function IDMWSC_showSearchWindow(library,id)
{
	var x = (screen.width - 725) / 2;
	var y = (screen.height - 450) / 2;

	if (id)
		var URL = IDMWSC_baseURL + "/redist/search/search.asp?Library=" + library.getName().returnValue + "&Id=" + id + "&type=storedsearchpopup";
	else
		var URL = IDMWSC_baseURL + "/redist/search/search.asp?Library=" + library.getName().returnValue + "&type=searchpopup";
	var PopupFeatures = "dependent=no toolbar=no,directories=no,location=no,menubar=no,resizable=yes,scrollbars=no,status=no,width=725,height=450,top=" + y + ",left=" + x;

	// Form the unique popup window name.
	if (id)
		var popupName = IDMWSC_PopupManager_generatePopupNamePrefix(library.getName().returnValue, library.getSystemType().returnValue) + "_SearchWindow_" + id;
	else
	{
		var date = new Date();
		var popupNo = new Number(date.valueOf());
		var strPopupNo = popupNo.toString();
		var popupName = IDMWSC_PopupManager_generatePopupNamePrefix(library.getName().returnValue, library.getSystemType().returnValue) + "_SearchWindow_" + strPopupNo;
	}
	IDMWSC_PopupManager_open("SearchPopup", popupName, URL, PopupFeatures, false);
}

//opens the copy folder/doc/search dialog
function IDMWSC_showCopyWindow(library,source,sourceFolder,destination)
{
	var width = 400;
	var height = 200;
	var x = (screen.width - width)/2;
	var y = (screen.height - height)/2;
	
	if ((sourceFolder == null) || (source.getObjectType().returnValue == IDMWSC_objTypeFolder))
		var sourceFolderID = "";
	else
		var sourceFolderID = sourceFolder.getId().returnValue;
	var URL = IDMWSC_baseURL + "/Redist/CopyMove/CopyMove.asp?Library=" + library.getName().returnValue + "&Mode=copy&ID=" + source.getId().returnValue + "&ObjectType=" + source.getObjectType().returnValue + "&Location=" + sourceFolderID;
	if (destination) {
		if (destination.getObjectType().returnValue == IDMWSC_objTypeFolder)
			URL += "&Destination=" + destination.getId().returnValue;
		else
			if (destination.getObjectType().returnValue == IDMWSC_objTypeLibrary)
				URL += "&Destination=" + destination.getName().returnValue;
	}
	var PopupFeatures = "dependent=no,toolbar=no,directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,width=" + width + ",height=" + height + ",top=" + y + ",left=" + x;
	// Form the unique popup window name.
	var popupName = IDMWSC_PopupManager_generatePopupNamePrefix(library.getName().returnValue + "_" + source.getId().returnValue) + "_" + source.getObjectType().returnValue + "_Copy";
	return(IDMWSC_PopupManager_open("Copy", popupName, URL, PopupFeatures, false));
}

//opens the move folder/doc/search dialog
function IDMWSC_showMoveWindow(library,source,sourceFolder,destination)
{
	var width = 400;
	var height = 200;
	var x = (screen.width - width)/2;
	var y = (screen.height - height)/2;
	//get source folder ID, if moving a doc or search
	if ((sourceFolder == null) || (source.getObjectType().returnValue == IDMWSC_objTypeFolder))
		var sourceFolderID = "";
	else
		var sourceFolderID = sourceFolder.getId().returnValue;
	var URL = IDMWSC_baseURL + "/Redist/CopyMove/CopyMove.asp?Library=" + library.getName().returnValue + "&Mode=move&ID=" + source.getId().returnValue + "&ObjectType=" + source.getObjectType().returnValue + "&Location=" + sourceFolderID;
	if (destination) {
		if (destination.getObjectType().returnValue == IDMWSC_objTypeFolder)
			URL += "&Destination=" + destination.getId().returnValue;
		else
			if (destination.getObjectType().returnValue == IDMWSC_objTypeLibrary)
				URL += "&Destination=" + destination.getName().returnValue;
	}	
	var PopupFeatures = "dependent=no,toolbar=no,directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,width=" + width + ",height=" + height + ",top=" + y + ",left=" + x;
	// Form the unique popup window name.
	var popupName = IDMWSC_PopupManager_generatePopupNamePrefix(library.getName().returnValue + "_" + source.getId().returnValue) + "_" + source.getObjectType().returnValue + "_Move";
	return(IDMWSC_PopupManager_open("Move", popupName, URL, PopupFeatures, false));
}

function IDMWSC_showFolderSelectWindow(library,id)
{
	var width = 350;
	var height = 400;
	var x = (screen.width - width)/2;
	var y = (screen.height - height)/2;

	if (id && id.length > 0)
		id = "&ID=" + id;

	var URL;

	if (id)	
		URL = IDMWSC_baseURL + "/Redist/TreeView/FolderSelect.asp?Library=" + library.getName().returnValue + id;
	else
		URL = IDMWSC_baseURL + "/Redist/TreeView/FolderSelect.asp?Library=" + library.getName().returnValue;

	var PopupFeatures = "dependent=no,toolbar=no,directories=no,location=no,menubar=no,resizable=yes,scrollbars=no,status=no,width=" + width + ",height=" + height + ",top=" + y + ",left=" + x;
	// Form the unique popup window name.
	var popupName = IDMWSC_PopupManager_generatePopupNamePrefix(library.getName().returnValue + "_" + top.document.title) + "_FolderSelect_";
	return(IDMWSC_PopupManager_open("FolderSelect", popupName, URL, PopupFeatures, false));
}


// Displays a message box
function IDMWSC_showMessageBox(type, title, text, width, height)
{
	if (!width || width < 300)
		width = 300;
	if (!height || height < 120)
		height = 120;
	var x = (screen.width - width)/2;
	var y = (screen.height - height)/2;

	var icon = type & 0x00000F;
	var iconFile;

	switch (icon) {
		case IDMWSC_iconInformation:
			iconFile = "images/information.gif"
			break;
		case IDMWSC_iconQuestion:
			iconFile = "images/question.gif"
			break;
		case IDMWSC_iconExclamation:
			iconFile = "images/exclamation.gif"
			break;
		case IDMWSC_iconCritical:
			iconFile = "images/critical.gif"
			break;
		default:
			iconFile = "images/information.gif"
			break;
		}

	var PopupFeatures = "dependent=no,toolbar=no,directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,width=" + width + ",height=" + height + ",top=" + y + ",left=" + x;
	// Form the unique popup window name.
	var popupName = IDMWSC_PopupManager_generatePopupNamePrefix("IDMMessageBox");
	var w = IDMWSC_PopupManager_open("MessageBox", popupName, IDMWSC_baseURL + "/Redist/Utility/Blank.htm", PopupFeatures, false);

	w.document.open("text/html", "replace");

	var HTMLText;
	HTMLText =
		"<HTML>" +
		"<HEAD>" +
		"<BASE HREF='" + IDMWSC_baseURL + "/'>";
	
	w.document.write(HTMLText);

	var css;
	if (navigator.appName == "Microsoft Internet Explorer")
		css = "<link rel='stylesheet' type='text/css' href='" + IDMWSC_baseURL + "/CSS/ie.css'>";
	else
		css = "<link rel='stylesheet' type='text/css' href='" + IDMWSC_baseURL + "/CSS/ns.css'>";
	
	w.document.write(css);

	var widthDIV = width - 70;
	var heightDIV = height - 65;
	
	HTMLText = 
		"<TITLE>" + title +
		"</TITLE>" +
		"</HEAD>" +
		"<BODY CLASS=idmDialogWithMargins>" +
		"<table class=idmDialogText border=0 cellpadding=0 cellspacing=0 width=100%>" +
		"  <tr>" +
		"    <td><br>&nbsp;&nbsp;<img src=" + iconFile + " width=32 height=32>&nbsp;&nbsp;&nbsp;&nbsp;</td>" +
		"    <td class=idmDialogText><br><div style='height:" + heightDIV + "; width:" + widthDIV + "; overflow:auto;'>" + text + "</div></td>" +
		"  </tr>" +
		"</table>" +
		"<table class=idmDialogText border=0 cellpadding=0 cellspacing=0 width=100%>" +
		"  <tr>" +
		"    <td align=center>" +
		"	 <form>" +
		"	   <br>" +
		"      <input type=button class=idmDialogText value='  OK  ' name=OK onClick='javascript:window.close()'>" +
		"    </form>" +
		"    </td>" +
		"  </tr>" +
		"</table>" +
		"</BODY>" +
		"</HTML>";

	w.document.write(HTMLText);
	w.document.close();
}

function IDMWSC_showHelpWindow(topic)
{
	var width = screen.width / 2;
	var height = screen.height / 2;
	
	if (width < 600)
		width = 600;
	if (height < 500)
		height = 500;
		
   	var x = screen.width - width - 20;
   	var y = 5;

	var URL = IDMWSC_baseURL + "/Redist/Utility/white.htm";

	var PopupFeatures = "dependent=no,toolbar=no,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,width=" + width + ",height=" + height + ",top=" + y + ",left=" + x;
	// Form the unique popup window name.
	var popupName = IDMWSC_PopupManager_generatePopupNamePrefix("IDMWSHelp");
	var w = IDMWSC_PopupManager_open("IDMWSHelp", popupName, URL, PopupFeatures, false);
	
	if (w)
		IDMWSC_DispatchHelpTopic(w, topic);	// dispatch to the right topic
}

function IDMWSC_DispatchHelpTopic(w, topic)
{
	var helpfile;
	
	topic = topic.toLowerCase(topic);
	switch(topic) {
		case "logon":
			helpfile = "Logon/Logon.htm";
			break;

		case "browsemode":
			helpfile = "Overview/Over_brow_search_mode.htm";
			break;
		case "searchmode":
			helpfile = "Overview/Over_brow_search_mode.htm";
			break;
		case "searchpopup":
		case "storedsearchpopup":
			helpfile = "Search/Search_overview.htm";
			break;

		case "viewing":
			helpfile = "Viewer/Overview_of_viewing.htm";
			break;

		case "checkoutlist":
			helpfile = "Docs/Checkin_out/View_checkout_list.htm";
			break;
		case "versionlist":
			helpfile = "Docs/Versions/View_verlist.htm";
			break;

		case "addfolder":
			helpfile = "Folders/Create_folder.htm";
			break;
		case "copy":
			helpfile = "Docs/Copy_del/Copy_to_folder.htm";
			break;
		case "move":
			helpfile = "Folders/Move_item.htm";
			break;

		case "propertysheetdslibrarychangepassword":
		case "propertysheetislibrarychangepassword":
			helpfile = "Logon/Change_password.htm";
			break;
			
		case "propertysheetdsdocumentfoldersfiledin":
		case "propertysheetdssearchfoldersfiledin":
		case "propertysheetisdocumentfoldersfiledin":
			helpfile = "Reference/Properties/DS_IS_doc_props_foldfile.htm";
			break;
		
		case "propertysheetdslibrarysecurity":
		case "propertysheetdsfoldersecurity":
		case "propertysheetdsdocumentsecurity":
		case "propertysheetdssearchsecurity":
		case "propertysheetisfoldersecurity":
		case "propertysheetisdocumentsecurity":
			helpfile = "Security/Over_sec.htm";
			break;

		case "propertysheetdslibrarygeneral":
			helpfile = "Reference/Properties/DS_lib_gen_props.htm";
			break;

		case "propertysheetdsfoldergeneral":
			helpfile = "Reference/Properties/DS_folder_gen_props.htm";
			break;

		case "propertysheetdsdocumentgeneral":
			helpfile = "Reference/Properties/DS_doc_props_gen.htm";
			break;
		case "propertysheetdsdocumentproperties":
			helpfile = "Reference/Properties/DS_doc_props_props.htm";
			break;

		case "propertysheetdsdocumentpublished":
			helpfile = "Reference/Properties/DS_doc_prop_pub.htm";
			break;

		case "propertysheetdssearchgeneral":
			helpfile = "Reference/Properties/DS_search_props.htm";
			break;

		case "propertysheetislibrarygeneral":
			helpfile = "Reference/Properties/IS_lib_prop_gen.htm";
			break;

		case "propertysheetisfoldergeneral":
			helpfile = "Reference/Properties/IS_folder_gen_props.htm";
			break;

		case "propertysheetisdocumentgeneral":
			helpfile = "Reference/Properties/IS_doc_prop_gen.htm";
			break;
		case "propertysheetisdocumentproperties":
			helpfile = "Reference/Properties/IS_doc_prop_prop.htm";
			break;

		case "ldap":
			helpfile = "Logon/Log_on_to_fileNET_libraries_using_LDAP_logon.htm";
			break;

		default:
			helpfile = "IDMWS.htm";
			break;
		}

	if (w)
		w.document.location.href = IDMWSC_baseURL + "/Application/Help/" + helpfile;
}
