// Defined in Javascripts messages files
var ILFO_FEEDBACK_POPUPEMPTYMESSAGE = "You cannot send an empty feedback field";
var ILSP_TYPEOFDOCUMENTMANDATORYXMLFILE = "XML file must have a value";
var IL_MANDATORYFIELD = "(a value must be provided)";
var EDITORHTMLCOMPLIANTFIELD = "can contain any character except '<', '>' and double quotes.";
var MYTASKSDELCONFIRM = "Do you really want to delete this document?";
var ILAN_AGINDICCONFIG_DOCLISTMINVALUE = "Documents list size should be superior or equal to 1";
var CCILAD_CONTEXTEDITOR_CONFIRMNOBIGDIMRESOLUTION = "The item name you wrote won't take into account.You have to use the right arrow. Do you want to continue ?";
var ILP_PROJECT_CONFIRMDELETE = "Do you really want to delete this project?";
var ILP_DECISIONTREEEDITOR_INVALIDPROCEDURETEXT = "The title of the procedure is invalid";
var EDITORSHOUDBEANUMBER = "must contain a number";
var ILP_QUIZQUESTIONEDITOR_SELECTTOMOVE = "Select the answer to move.";
var ILP_PROJECTUSERS_ALERTSELECTREADERS = "Select readers to remove from list";
var ILP_DOCUMENTWORKFLOWACTIONS_ALERTSELECT2 = "users";
var ILP_DOCUMENTWORKFLOWACTIONS_ALERTSELECT1 = "You must select";
var EDITORMINVALUE = "minimum value is";
var ILP_DECISIONTREEEDITOR_ANSWERMODIFIED = "The answer will not be added. Do you want to continue ?";
var ILBLOBIMPORTERALERTFILE = "You must set the path for the file to upload";
var ILAD_BATCHAGENTDEL_CANNOTDELETEBLOBS = "Cannot delete these objects (blob or folder).";
var CCILAG_CALLTRANSFER_NDOCSMIN = "You must select at least one document";
var ILP_QUICKEDITOR_ALERTDOCDEFEMPTY = "Type of content must be defined";
var ILAD_DOCUMENTADMINISTRATION_MUSTSELECTDOC = "You must select at least one document";
var ILSP_WORKFLOWMODELCONFIRMDELETION = "Do you really want to delete this workflow model?";
var IL_QUIZRENDERER_CONFIRMENDSESSION = "Do you really want to submit the current quiz for evaluation?";
var ILP_CONFIRMRESTOREACTION = "Warning, the content of the document will be replaced by the content of the previous version. Do you really want to restore this document?";
var SCHEDULEWORKFLOWHISTORYPURGEPAGEALERTNODOCDEF = "You must select at least one document definition.";
var ILAN_TEAMMANAGEMENT_DOCMUSTBESELECTED = "At least one Quiz must be selected.";
var SCHEDULINGPAGEALERTINVALIDMINUTE = "Minute of start date can contain digits only.";
var ILSP_INVALIDLOCA = "The localized text is invalid";
var ILP_DECISIONTREEEDITOR_QUESTIONMODIFIED = "The question won't be added. Do you want to continue ?";
var CCILFO_FRONT_FAVORITESDELALL = "Do you really want to remove all content from your bookmarks?";
var ILP_QUESTIONSEDITOR_SELECTTOMOVE = "Select the answer to move";
var SCHEDULEDOCUMENTPURGEPAGEALERTNODOCDEF = "You must select at least one document definition.";
var ILP_SHAREDLIBRARYERRORDETECTED = "An Error has been detected";
var ILAD_SEARCHDIM_NOORGANIZATIONSELECTED = "Select at least one center to add search criteria to.";
var ILP_PROJECT_INSERTNODOC = "You must select at least one document";
var CCILPU_MODIFCONFIRM = "Do you really want to modify these documents?";
var ILP_DOCEDITOR_CHANGEMODECONFIRM = "The document will be saved before changing view mode, continue?";
var ILSP_DIMENSIONITEM_INVALIDDIMITEMNAME = "The name of the dimension item is invalid.";
var ILP_QUESTIONSEDITOR_MAXSIZE = "Text to long to fit";
var FILESYSTEMVALIDITY_INFOMESSAGE = "(it can contain any character except '*', '?', '|', '>', '<' and double quotes)";
var SCHEDULINGPAGEALERTINVALIDDATEMONTH = "Invalid month number.";
var ILAD_BACKOFFICEBATCHUSERDEL_CANNOTDELETEBLOBS = "Cannot delete these objects (blob or folder).";
var SCHEDULINGPAGEALERTINVALIDDATEDAY = "Invalid day number.";
var SCHEDULINGPAGEFREQUENCYINVALIDVALUE = "Frequency must be at greater thar 1.";
var EDITORVALIDITYSTARTDATEAFTERENDDATE = "The validity end date is earlier than the validity start date.";
var ILSP_TYPEOFDOCUMENTINVALIDLOGRENDS = "You must associate a logical renderer to this document definition";
var ILSP_DIMENSIONITEM_NOUSERSELECTED = "You should select at least an object";
var ILSP_CONFIRMDELETEPROPERTY = "All selected properties will be lost. Are you sure you want to continue?";
var ILAN_DOCCHOOSER_INVALIDDATE = "Does not contain a valid date.";
var ILP_SHAREDLIBRARYFILEEXTENSIONCHANGED = "If you change a filename extension, file may become unsuable.%LINESEP%%LINESEP% Are you sure you want to change it?";
var ILAN_ADVMONITORINGCONFIG_STARTDATE_AFTER_ENDDATE = "The end date is earlier than the start date";
var ILP_PROJECTEDITOR_INVALIDNAME = "The name is invalid";
var EDITORSELECTASECTIONFIRST = "Select a section to add.";
var ILP_DECISIONTREEEDITOR_INVALIDSTEPTEXT = "The title of the step is invalid";
var EDITORWRONGTIME = "does not contain a valid time";
var ILP_SHAREDLIBRARYBLOBDELETECONFIRM = "Are you sure you want to delete object:";
var ILP_EDITORLINKS_INVALIDCHANGES = "Changes not authorized";
var ILSP_PHYSICALRENDERER_INVALIDNAME = "The name of the physical renderer is invalid.";
var ILP_DECISIONTREEEDITOR_INVALIDQUESTIONTEXT = "The title of the question is invalid";
var ILFO_TRAINING_CONFIRMDELETESESSIONS = "Do you really want to delete all training sessions from my quizzes box?";
var CCILPU_SELECTOLDDIMITEM = "You must select old dimension item";
var ILAD_DOCUMENTADMINISTRATION_MUSTSELECTVALIDDESTDIMITEM = "You must select a valid category";
var IL_FAVORITESDELETEALL = "Do you really want to remove all content from your favorites?";
var IL_MENULOCKED = "You cannot exit the current page that way.";
var ILP_DECISIONTREEEDITOR_STEPMODIFIED = "The step will not be added. Do you want to continue ?";
var ILP_DOCEDITOR_CONFIRMCHANGEBEFOREPREVIEW = "Do you want to save your changes before previewing?";
var ILP_SHAREDLIBRARYFOLDERCANNOTMODIFIED = "Folder cannot be modified";
var EDITORVISIBILITYSTARTDATEAFTERENDDATE = "The visibility end date is earlier than the visibility start date.";
var EDITORWRONGDATE = "does not contain a valid date";
var IL_QUIZRENDERER_CORRECTALLFREEQUESTIONS = "Please correct all free question before sending corrections.";
var ILSP_CONFIRMPHYSRENDDEL = "Do you really want to delete this physical renderer?";
var ILAN_TEAMVIEW_TEAMMUSTBESELECTED = "At least one team must be selected.";
var ILP_DOCEDITOR_CHANGEMODECONFIRMDECISIONTREE = "The modifications will be lost, continue?";
var ILSP_LOCACONFIRMDESCRIPTIONLOST = "The description set will be lost. Are you sure you want to continue?";
var SCHEDULINGPAGEALERTINVALIDHOUR = "Hour of start date can contain digits only.";
var SCHEDULINGPAGEALERTINVALIDTIMESECOND = "Invalid second number.";
var IL_DATECHECK_STARTDATE_AFTER_ENDDATE = "The end date is earlier than the start date";
var SCHEDULINGPAGEMONTHMUSTBESELECTED = "A month must be selected";
var ILP_DECISIONTREEEDITOR_QUESTIONDATAMODIFIED = "The modifications of the question will be lost. Do you want to continue ?";
var ILP_EDITORLINKS_INVALIDREMOVEREF = "Would you like remove link for selected items?";
var ILP_QUIZEDITOR_CONFIRMPARTDELETE = "Do you really want to delete this part?";
var ILP_TRAININGEDITOR_CONFIRMREMOVEPART = "Do you really want to delete this part?";
var ILSP_TYPEOFDOCUMENTMANDATORYINTERNALNAME = "Internal name must have a value";
var BLOBVIEWER_INVALIDFILEPATH = "File path is invalid";
var ILP_DECISIONTREEEDITOR_NEXTMODIFIED = "The link will not be added. Do you want to continue ?";
var ILP_DECISIONTREEEDITOR_ANSWERDATAMODIFIED = "The modifications of the answer will be lost. Do you want to continue ?";
var CCILAG_COMPARISONMATRIX_NDOCSMIN = "Select at least one handset.";
var ILP_FOLDERCHOOSERCANNOTMOVEBLOBINTOSHAREDLIB = "Cannot move a blob into the Shared Library folder";
var IL_XMLVALIDITY = "(it must start either with a letter, '_' or ':', and may contain any letter, digit, '.' or '-')";
var SCHEDULINGPAGEMANDATORYNAME = "Name is mandatory";
var SCHEDULINGPAGENOWMUSTBESELECTED = "You must select Now to lauch the purge";
var ILP_PROJECTUSERS_CONFIRMREMOVEREADERS = "Do you really want the selected users to be removed from the readers list?";
var ILAD_SEARCHDIM_NOCONTEXTSELECTED = "Select at least one context to add search criteria to.";
var ILP_QUICKEDITOR_ALERTTITLEEMPTY = "Title cannot be empty";
var ILP_QUESTIONSEDITOR_SAVEBEFOREACTION = "Your question must be saved before executing the current action, continue?";
var ILP_SHAREDLIBRARYFOLDERNAMEMISSING = "Folder name is missing";
var CCILAD_CONTEXTEDITOR_CONFIRMDELETION = "Do you really want to delete this working context?";
var ILSP_CONFIRMLOGRENDDEL = "Do you really want to delete this logical renderer?";
var ILSP_LOGICALRENDERER_INVALIDLIST = "The list of physical renderers is invalid.";
var ILP_LIVECOM_SELECTONETEAM = "You must select at least one team";
var ILP_PROJECTUSERS_CONFIRMREMOVEMANAGERS = "Do you really want the selected users to be removed from the managers list?";
var ILP_FIELDEDITOR_CONFIRMQUIT = "Your modifications will be lost. Are you sure you want to quit?";
var ILP_DATEEDITOR_INVALIDDATE = "Date is invalid";
var ILP_SHAREDLIBRARYCONFIRMBLOB = "object";
var ILP_QUESTIONSEDITOR_NOTEXTFORANSWER = "No text found for new answer";
var SCHEDULINGPAGEDATEPRIORTOCURRENTDATE = "Scheduling one purge at a date prior to now will never work";
var IL_QUIZRENDERER_MAXPERCENTAGEVALUE = "The maximum grade is 100%, cannot set more.";
var EDITORBLOBIMPORTERSAVEDOC = "This action will automatically save the document, continue?";
var ILP_QUIZQUESTIONEDITOR_FORBIDDENCHAR = "Cannot add the answer as it contains an invalid character (it can contain any character except '<', '>', '*' and double quotes)";
var ILP_PROJECTUSERS_ALERTLEADERNOTREMOVABLE = "Impossible to remove leader from managers list";
var ILSP_LOGICALRENDERER_INVALIDNAME = "The name of the logical renderer is invalid.";
var ILSP_DASHBOARDEDITORALREAYOPENED = "You cannot have two opened editors at the same time.";
var EDITORCHANGEMODECONFIRM = "The document will be saved before changing view mode, continue?";
var ILP_DECISIONTREEEDITOR_SOLUTIONDATAMODIFIED = "The modifications of the solution will be lost. Do you want to continue ?";
var EDITORSECTIONDELETECONFIRM = "Are you sure you want to remove this section ?";
var ILAN_REPORT_INVALIDNAME = "Invalid report name (cannot contain '<', '>' and double quotes)";
var MYTASKSDELSECTIONCONFIRM = "Do you really want to delete this section?";
var SCHEDULINGPAGEALERTINVALIDTIMEMINUTE = "Invalid minute number.";
var ILP_QUESTIONSEDITOR_MAXSIZEHELP = "Max size:";
var ILFO_TRAINING_CONFIRMRESTART = "All your answers and corrections will be lost. Are you sure you want to restart this Quiz?";
var ILP_QUIZQUESTIONEDITOR_NEEDCORRECTANSWER = "You must have at least one correct answer.";
var ILP_DECISIONTREEEDITOR_PROCEDUREDATAMODIFIED = "The modifications of the procedure will be lost. Do you want to continue ?";
var ILAN_DOCUMENTRECORDS_USERMUSTBESELECTED = "At least one user must be selected.";
var IL_QUIZRENDERER_CONFIRMQUIT = "Your modifications will be lost. Are you sure you want to quit?";
var ILP_SHAREDLIBRARYCONFIRM = "Current %OBJECT% %OBJECTNAME% will be %ACTION% into folder %FOLDER%. %LINESEP%%LINESEP%Would you like to continue?";
var MYTASKSDOCMUSTBESELECTED = "At least one document must be selected";
var ILP_SHAREDLIBRARYBLOSBCONFIRMDELETE = "Are you sure you want to delete selected object(s)?";
var SCHEDULINGPAGEDAYMUSTBESELECTED = "A day must be selected";
var ILSP_DIMENSIONITEM_INVALIDDIMITEMDESC = "The description of the dimension item is invalid.";
var ILAN_ADVMONITORINGCONFIG_ONEDIMMIN = "Select at least one topic.";
var ILSP_CONFIRMCOPYLOCA = "All non-localized texts in the current target language will be filled with the existing ones in your navigator current language. Are you sure you want to continue?";
var ILP_PROJECTUSERS_ALERTSELECTUSERS = "Select users to add to the project";
var EDITORCONFIRMWORKFLOW = "The current document will be saved before executing this action. Do you want to continue ?";
var ILAD_SEARCHITEMEDITOR_INVALIDNAME = "The search criteria code is invalid";
var ILP_QUIZQUESTIONEDITOR_ANSWERALREADYEXIST = "This answer already exist.";
var ILP_DOCEDITOR_CHANGESECTIONCONFIRM = "The document will be saved before changing section, continue?";
var ILP_PROJECTUSERS_ALERTSELECTWRITERS = "Select writers to remove from list";
var IL_USEREDITOR_INVALIDEMAIL = "The e-mail is invalid";
var ILAN_FEEDBACKSPAGE_EMPTYLIST = "At least one feedback needs to be selected";
var ILP_TRAININGEDITOR_CONFIRMREMOVEQUESTION = "Do you really want to delete this question?";
var IL_QUIZRENDERER_CONFIRMENDCORRECTION = "Do you really want to end the current quiz correction and send it to its author?";
var IL_HTMLVALIDITY = "(it can contain any character except '<', '>' and double quotes)";
var SCHEDULINGPAGEALERTINVALIDDAY = "Day of start date can contain digits only.";
var ILAN_ADVMONITORINGCONFIG_TWODIMSMAX = "Select no more than 2 topics.";
var EDITORXMLCOMPLIANTFIELD = "can contain any character except '>', '>', ''', ' ' and double quotes.";
var ILP_DATEEDITOR_WARNINGVISIBILITYDATEWILLBEADAPTED = "Warning, visibility date period may be adapted to validity date period if visibility date period is not compatible with validity date period.";
var ILP_CLASSAREA_CLASSAREADELCONFIRM = "Do you really want to delete this classification area ?";
var MYTASKSALERTDELETEDOCSCONFIRM = "Are you sure you want to delete these documents?";
var EDITORSHOUDBEANINTEGER = "must contain an integer";
var ILBLOBIMPORTERSAVEDOC = "This action will automatically save the document";
var ILSP_WORKFLOWMODELINVALIDINTERNALNAME = "The internal name is invalid";
var ILAD_CLASSAREA_DATAMODIFIED = "The modifications of the classification area will be lost. Do you want to continue ?";
var ILAN_ADVMONITORINGCONFIG_MAXPERIODSINMONTHSLIMIT2 = ". Please, adjust your analysis time frame accordingly.";
var ILBLOBCHOOSERALERTFILE = "You must select a file";
var ILAN_ADVMONITORINGCONFIG_MAXPERIODSINMONTHSLIMIT1 = "The maximum number of months is";
var IL_QUIZRENDERER_HTMLVALIDITY = "This field must be HTML compatible";
var EDITORPOSITIONMANDATORY = "Setting a position for this document is mandatory";
var CCILAD_CONTEXTEDITOR_INVALIDNAME = "The name is invalid";
var IL_USEREDITOR_INVALIDPASSWORDCHECK = "The password confirmation is invalid";
var ILAD_BATCHAGENTDEL_NOELEMENTSELECTED = "You should select at least one criterion in the list to be processed";
var ILSP_TYPEOFDOCUMENTINVALIDINTERNALNAME = "The internal name is invalid";
var ILP_SHAREDLIBRARYBLOBINVALIDFOLDER = "Invalid destination folder for this action";
var IL_USEREDITOR_INVALIDDESCRIPTION = "The comments is invalid";
var ILSP_DIMENSIONITEM_NOTARGETSELECTED = "You should select a dimension item";
var ILP_DECISIONTREEEDITOR_INVALIDDTDESC = "The description is invalid";
var ILP_PROJECTUSERS_ALERTSELECTMANAGERS = "Select managers to remove from list";
var SCHEDULINGPAGECONFIRMPURGE = "Are you sure you want to proceed this purge?";
var ILP_QUIZQUESTIONEDITOR_MCQBADANSWERCOUNT = "A multiple choice question must have at least two answers.";
var ILP_DECISIONTREEEDITOR_SOLUTIONMODIFIED = "The solution won't be added. Do you want to continue ?";
var ILP_DECISIONTREEEDITOR_INVALIDDTTEXT = "The title is invalid";
var ILP_DECISIONTREEEDITOR_INSERTNODESTEP = "This action will insert a new step. Do you want to continue ?";
var SCHEDULINGPAGEALERTINVALIDMONTH = "Month of start date can contain digits only.";
var ILP_QUESTIONSEDITOR_SELECTTOREMOVE = "Select the answer to remove";
var CCILPU_SELECTNEWDIMITEM = "You must select new dimension item";
var ILAN_DOCCHOOSER_FILTERDATEBEFOREPURGEDATE = "The date you entered is earlier than the last purge date, do want to continue?";
var ILP_SHAREDLIBRARYFOLDERNOTEMPTY = "Folder is not empty, please delete all objects inside this folder before trying to delete it.";
var ILSP_WORKFLOWMODELMANDATORYINTERNALNAME = "Internal name must have a value";
var ILP_DECISIONTREEEDITOR_INSERTNODE = "This action will insert a question and an answer. Do you want to continue ?";
var SCHEDULINGPAGEALERTINVALIDDATE = "This date is invalid.";
var SCHEDULEWORKFLOWHISTORYPURGEPAGEALERTSTEP = "Last steps must by at least 2.";
var CCILFO_EASE_NOFILTER = "None";
var ILP_SHAREDLIBRARYCONFIRMMOVE = "moved";
var SCHEDULINGPAGEALERTINVALIDYEAR = "Year of start date can contain digits only.";
var ILSP_DIMENSION_INVALIDDIMNAME = "The name of the dimension is invalid.";
var EDITORINVALIDCHAR = "contains an invalid character";
var EDITORVISIBILITYSTARTDATEAFTERVALIDITYSTARTDATE = "The validity start date can not be earlier than the visibility start date.";
var ILP_EDITORLINKS_INVALIDWOULDBLOB = "Would you like blob";
var CCILPU_VERIFOLDNEWDIMITEM = "You must select different dimension item";
var ILP_FOLDERCHOOSERCANNOTCOPYBLOBINTOSHAREDLIB = "Cannot copy a blob into the Shared Library folder";
var MYTASKSALERTREMOVEMULTIPLEDOCSCONFIRM = "Are you sure you want to remove these documents from the project?";
var ILAN_ADVMONITORINGCONFIG_MAXPERIODSINWEEKSLIMIT2 = ". Please, adjust your analysis time frame accordingly.";
var CCILAG_COMPARISONMATRIX_DOCDEF = "handsets.";
var ILP_EDITORLINKS_INVALIDSETASREF = "to be set a new reference for selected items?";
var ILAN_ADVMONITORINGCONFIG_MAXPERIODSINWEEKSLIMIT1 = "The maximum number of weeks is";
var IL_QUIZRENDERER_TIMELIMITEDENDED = "Time is over, your quiz will be submitted for evaluation.";
var IL_USEREDITOR_PASSWORDDONTMATCH = "Password field and password confirmation field have different values";
var ILSP_WORKFLOWMODELMANDATORYXMLFILE = "XML file must have a value";
var ILP_SHAREDLIBRARYFOLDERDELETECONFIRM = "Are you sure you want to delete folder:";
var ILP_DECISIONTREEEDITOR_INVALIDANSWERTEXT = "The title of the answer is invalid";
var ILP_PROJECTUSERS_CONFIRMREMOVEWRITERS = "Do you really want the selected users to be removed from the writers list?";
var ILSP_CONFIRMDELETEPROPERTYTYPE = "All properties from the selected type will be lost. Are you sure you want to continue?";
var IL_MANDATORYLIST = "(a value must be provided)";
var ILP_DECISIONTREEEDITOR_MODIFICATIONNOTSAVED = "The last modifications will be lost. Do you want to continue ?";
var ILAN_ADVMONITORINGCONFIG_MAXPERIODSINDAYSLIMIT2 = ". Please, adjust your analysis time frame accordingly.";
var ILAN_ADVMONITORINGCONFIG_MAXPERIODSINDAYSLIMIT1 = "The maximum number of days is";
var ILAD_SEARCHITEMEDITOR_INVALIDLOCA = "The localized name is invalid";
var ILP_CANNOTADDTASK_NODOCUMENTSELECTED = "No document selected";
var ILP_FOLDERCHOOSERINSERTFUNCTIONMISSING = "Invalid insert function name";
var IL_DATECHECK_INVALIDDATE = "does not contain a valid date.";
var ILAD_BACKOFFICEBATCHUSERDEL_NOELEMENTSELECTED = "You should select at least one criterion in the list to be processed";
var IL_GENERICRENDERER_CONFIRMTAKELIMITEDTIMEQUIZ = "This is a time limited quiz. Are you sure you want to start it now?";
var ILP_CONFIRMDELETEVERSIONACTION = "Do you really want to delete this version of the document?";
var ILP_SHAREDLIBRARYFOLDERNAMEFILESYSTEMNOTCOMPLIANT = "Invalid folder name.";
var SCHEDULINGPAGEALERTINVALIDTIMEHOUR = "Invalid hour number.";
var IL_USEREDITOR_INVALIDPASSWORD = "The password is invalid";
var ILP_SHAREDLIBRARYBLOBNAMEMISSING = "Blob name is missing";
var CCILAD_MARKETINGUSERS_USERNAMEMODIFIED = "Actions will act on user:";
var EDITORCONFIRMQUIT = "Your modifications since the last save will be lost. Are you sure you want to quit ?";
var IL_USEREDITOR_INVALIDPHONENUMBER = "The phone number is invalid";
var ILAN_AGENTBYAGENTVIEW_DOCMUSTBESELECTED = "At least one user must be selected.";
var IL_USEREDITOR_INVALIDFIRSTNAME = "The firstname is invalid";
var EDITORSECTIONACTIONCONFIRM = "The document will be saved before executing this action, continue ?";
var ILP_SHAREDLIBRARYCONFIRMFOLDER = "folder";
var ILP_PROJECTUSERS_ALERTUSERNOTREMOVABLE = "Impossible to remove yourself from managers list";
var EDITORTOOMANYDECIMALS = "has too many decimals. Maximum is:";
var ILP_SHAREDLIBRARYBLOBNAMEFILESYSTEMNOTCOMPLIANT = "Invalid object name.";
var ILAD_NETWORKEDITOR_CONFIRMQUIT = "Your modifications will be lost. Are you sure you want to quit?";
var ILP_DECISIONTREEEDITOR_INVALIDNEXTTEXT = "The next step link text is invalid";
var CCILAD_CONTEXTEDITOR_INVALIDLOCA = "The localized name is invalid";
var EDITORAUDIENCEMANDATORY = "Setting an audience for each section is mandatory";
var AJAXDISCARDCHANGES = "You have made modifications in this page that have not been saved. Would you like to continue and discard your changes?";
var ILP_QUESTIONSEDITOR_SELECTTOMODIFY = "Select the answer to modify";
var ILSP_INVALIDPROPKEY = "The property key is invalid";
var ILBLOBCHOOSERALERTIMGFILE = "You must select an image type file";
var ILP_MYTASKS_TASKDELCONFIRM = "Do you really want to delete this task ?";
var ILAD_NETWORKEDITOR_INVALIDCODE = "The code is invalid";
var FILTERWRONGDATE = "Invalid date in your filter.";
var ILSP_CONFIRMDELETELOCA = "All existing localized texts for the current target language will be lost. Are you sure you want to continue?";
var IL_USEREDITOR_INVALIDLASTNAME = "The lastname is invalid";
var ILP_QUESTIONSEDITOR_MODIFICATIONLOST = "Your modifications will be lost. Are you sure you want to quit?";
var ILP_NOTEEDITORS_CONFIRMDELETESECTION = "Do you really want to delete this section?";
var ILSP_CONFIRMREPLACELOCA = "All existing localized texts for the current target language will be replaced by your navigator current language ones. Are you sure you want to continue?";
var ILP_EDITORLINKS_INVALIDWOULDDOC = "Would you like the document";
var ILAD_NETWORKEDITOR_DIMSNOTSET = "A value must be provided for each category.";
var EDITORMAXVALUE = "maximum value is";
var CCILPU_SELECTDIM = "You must select a categorie";
var ILP_DATEEDITOR_WARNINGVALIDITYDATEWILLBEADAPTED = "Warning, validity date period may be adapted to visibility date period if validity date period is not compatible with visibility date period.";
var ILAD_NETWORKEDITOR_INVALIDLOCA = "The localized name is invalid";
var ILAN_ADVMONITORINGCONFIG_INVALIDDATE = "does not contain a valid date.";
var ILAD_BACKOFFICEUSEREDITOR_CONFIRMQUIT = "Your modifications will be lost. Are you sure you want to quit?";
var MYTASKSALERTREMOVESINGLEDOCCONFIRM = "Are you sure you want to remove this document from the project?";
var ILP_DECISIONTREEEDITOR_INVALIDSOLUTIONTEXT = "The title of the solution is invalid";
var ILP_DOCUMENTWORKFLOWACTIONS_ALERTMESSAGE2 = "characters.";
var ILSP_INVALIDPROPFILENAME = "The property type name is invalid";
var ILSP_TYPEOFDOCUMENTINSERTWARNING = "Warning, to ensure the document definition creation to be successful, check that database have enough space available. Would you like to continue?";
var ILP_DOCUMENTWORKFLOWACTIONS_ALERTMESSAGE1 = "Your message length must not exceed";
var ILP_CONFIRMMULTIDELETEACTION = "Do you really want to delete these documents?";
var IL_USEREDITOR_INVALIDLOGIN = "The login is invalid";
var SCHEDULINGPURGEPAGEDELETECONFIRM = "Are you sure you want to remove this scheduled task ?";
var ILP_QUIZEDITOR_CONFIRMPARTDATALOST = "Your part modifications will be lost, continue?";
var ILSP_CONFIRMDIMDEL = "Do you really want to delete this dimension?";
var ILSP_PHYSICALRENDERER_INVALIDTARGET = "The target of the physical renderer is invalid.";
var EDITORMAXSIZE = "is too large, maximum number of characters:";
var ILP_SHAREDLIBRARYCONFIRMCOPY = "copied";
var SCHEDULINGPAGEALERTINVALIDSECOND = "Second of start date can contain digits only.";
var ILP_DECISIONTREEEDITOR_PROCEDUREMODIFIED = "The procedure won't be added. Do you want to continue ?";
var ILAN_DOCUMENTSTATUSDASHBOARD_REMINDERDELETECONFIRM = "Do you really want to delete the selected reminder?";
var EDITORMANDATORYFIELD = "Mandatory field";
var ILP_EDITORLINKS_INVALIDWOULDURL = "Would you like the url";
var CCILAG_COMPARISONMATRIX_NDOCSMAX = "Select no more than";
var ILP_DECISIONTREEEDITOR_STEPDATAMODIFIED = "The modifications of the step will be lost. Do you want to continue ?";
var EDITORVALIDITYENDDATEAFTERVISIBILITYENDDATE = "The validity end date can not be later than the visibility end date.";
var ILSP_INVALIDPROPVALUE = "The property value is invalid";
var IL_MAXSIZETOOBIG = "(content size is too big)";
var ILP_SHAREDLIBRARYNOOBJECTSELECTED = "No object selected";
var INSTRASERVLET_URL = "/orangeuk/com.instranet.InstraServlet";
var WEBAPP_URL = "/orangeuk/";
var KEEP_NO_PARAMETER = "NoParameter";
var KEEP_ALL_PARAMETERS = "AllParameters";
var KEEP_PARAMETERS_FORM = "KeepParametersForm";

// Retrieved from jsp/scripts/filter.js
/* used by filterContainer */

var winDimChooserStatus = 0;
var winDimChooser = null;
var DimChooserHeight    = 500;
var DimChooserWidth     = 400;

function filterDimChooserClose() {
   if (winDimChooserStatus == 1) {
      winDimChooserStatus = 0;
      winDimChooser.close();
   }
}
function filterDimChooserIsClosed() {
   winDimChooserStatus = 0;
}
function filterDimChooserIsOpened() {
   winDimChooserStatus = 1;
}

function filterDimChooserClicked() {

   winDimChooser = window.open("", "winDimChooser", 'width=' + DimChooserWidth + ',height=' + DimChooserHeight + ',location=no,menubar=no,resizable=yes,scrollbars=yes,toolbar=no');
	winDimChooser.focus();
}


function filterCheckFilter(formName, filterName) {
   var objElement;
   var strRoot;
	var field, strFieldName, strRealValue;
   var loopEl;
   var tmpElem;
   var form = eval("document."+formName);

   for (loopEl=0; loopEl<form.length; loopEl++) {
      objElement = form.elements[loopEl];

      if (objElement.name.indexOf(filterName)!=0) {
			continue;
		}

      if (objElement.name.length>7 && objElement.name.lastIndexOf("_Custom")==objElement.name.length-7) {
			strFieldName = objElement.value;
			strFieldValue =  eval("document."+formName+"."+strFieldName+".value");
         strRoot = objElement.name.substr(0, objElement.name.length-7);
			field = eval("document."+formName+"."+strRoot);
			field.value = strFieldValue;
      }
	}

   return true;
}

/* used by filterKeywordSearchIn */

function filterKeywordOnClick(checkBox, formName, fieldName) {
   var field = eval("document."+formName+"."+fieldName);
   if (checkBox.checked == false) {
      field.value='false';
   } else {
      field.value='true';
   }
}

var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

function _filterGetDays(month, year) {
   // Test for leap year when February is selected.
   if (1 == month)
      return ((0 == year % 4) && (0 != (year % 100))) || (0 == year % 400) ? 29 : 28;
   else
      return daysInMonth[month];
}


function filterCheckDate(strFormName, strRoot) {
   var nYear, nMonth, nDay;

   var field = eval("document."+strFormName+"."+strRoot+"_Y");
   if (field!=null) {
      nYear = field.value;
      if (isNaN(nYear)) {
         alert(FILTERWRONGDATE);
         field.focus();
         return false;
      }
   }

   field = eval("document."+strFormName+"."+strRoot+"_M");
   if (field!=null) {  
      nMonth = field.value;
      nMonth = nMonth - 1;
      if ((isNaN(nMonth)) || nMonth<0 || nMonth>11) {
         alert(FILTERWRONGDATE);
         field.focus();
         return false;
      }
   }

   field = eval("document."+strFormName+"."+strRoot+"_D");
   if (field!=null) {
      nDay = eval("document."+strFormName+"."+strRoot+"_D").value;
      if ((isNaN(nDay)) || nDay<1 || nDay>_filterGetDays(nMonth, nYear)) {
         alert(FILTERWRONGDATE);
         field.focus();
         return false;
      }     
   }
   return true;
}
// Retrieved from jsp/scripts/form.js
var m_bFormDebug = false;
var m_bCanSubmitForm = true;

var MAXLENGTH_SUFFIX="_MaxLength";
var MINLENGTH_SUFFIX="_MinLength";

var VERIFYSTRING_NOTEMPTY              = 1 << 0;
var VERIFYSTRING_COMPATIBLEXML         = 1 << 1;
var VERIFYSTRING_COMPATIBLEHTML        = 1 << 2;
var VERIFYSTRING_COMPATIBLEFILESYSTEM  = 1 << 3;
var VERIFYSTRING_MAXSIZE               = 1 << 4;
var VERIFYSTRING_MINSIZE               = 1 << 5;

var m_temp_Popups;
var m_tempParentFormName;

function formGetForm(strFormName) {
   if (strFormName == null || strFormName == "") {
      var currentForm;
      var i;
      for (i=0; i<document.forms.length; i++) {
         currentForm = document.forms[i];
         if (_formCheckFieldExist(currentForm.Origin))
            return currentForm;
      }
      return null;
   }

   // Bug IE 6.0
   var foundForm = document.forms[strFormName];

   if (foundForm != null) {
      return foundForm;
   } else {
      for (i=0; i<document.forms.length; i++) {
         if (document.forms[i].name == strFormName)
            return document.forms[i];
      }
      return null;
   }
}

function formRefresh(strFormName) {
   var form;
   form=formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (formRefresh)");
      return false;
   }

   if (!_formCheckSubmitableAndLock())
      return false;

   form.action = form.Origin.value;
   form.target = "_self";
   // If popups must be closed, must do it now
   popupParentCloseAllPopupsOnUnload(strFormName);
   _popupPrepareFormForSubmit(strFormName);
   form.submit();
   return false;
}

function formSubmitExecuteCommand(strFormName, strCommand, strRedirect, strTarget) {
   var form;
   form=formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (formSubmitExecuteCommand)");
      return false;
   }
   if (!_formCheckSubmitableAndLock()) {
      return false;
   }

   form.action = INSTRASERVLET_URL;
   form.target = strTarget;
   form.Command.value = strCommand;
   form.Redirect.value = strRedirect;


   // If popups must be closed, must do it now
   if (strTarget=="_self")
      popupParentCloseAllPopupsOnUnload(strFormName);
   _popupPrepareFormForSubmit(strFormName);
   _formPushContext(strFormName, strTarget);
   form.submit();
   _formPopContext(strFormName, strTarget);
   return false;
}

function formSubmitUrl(strFormName, strUrl, strTarget) {
   var form;

   form=formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (formSubmitUrl)");
      return false;
   }

   if (!_formCheckSubmitableAndLock())
      return false;

   form.action = strUrl;
   form.target = strTarget;
   // If popups must be closed, must do it now
   if (strTarget=="_self")
      popupParentCloseAllPopupsOnUnload(strFormName);
   _popupPrepareFormForSubmit(strFormName);
   _formPushContext(strFormName, strTarget);
   form.submit();
   _formPopContext(strFormName, strTarget);
   return false;
}

function formCheckAll(strFormName, strPrefix) {
   _formSetChecked(strFormName, strPrefix, true);
}

function formUncheckAll(strFormName, strPrefix) {
   _formSetChecked(strFormName, strPrefix, false);
}

function formCheckFieldContent(strFormName, strFieldName, bitField) {
   var form;
   form=formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (formCheckFieldContent)");
      return false;
   }

   var bIsCompliant;
   var checkedField = form.elements[strFieldName];

   if (!_formCheckFieldExist(checkedField)) {
      _formFatal("Cannot find the field " + strFieldName);
      return false;
   }
   if (bitField & VERIFYSTRING_COMPATIBLEXML) {
      bIsCompliant = _formCheckFieldContentXmlCompliant(strFormName, checkedField);
      if (!bIsCompliant)
         return false;
   }
   if (bitField & VERIFYSTRING_COMPATIBLEHTML) {
      bIsCompliant = _formCheckFieldContentHtmlCompliant(strFormName, checkedField);
      if (!bIsCompliant)
         return false;
   }
   if (bitField & VERIFYSTRING_COMPATIBLEFILESYSTEM) {
      bIsCompliant = _formCheckFieldContentFileSystemCompliant(strFormName, checkedField);
      if (!bIsCompliant)
         return false;
   }
   if (bitField & VERIFYSTRING_MAXSIZE) {
      bIsCompliant = _formCheckFieldContentMaxSize(strFormName, checkedField);
      if (!bIsCompliant)
         return false;
   }
   if (bitField & VERIFYSTRING_MINSIZE) {
      bIsCompliant = _formCheckFieldContentMinSize(strFormName, checkedField);
      if (!bIsCompliant)
         return false;
   }
   return true;
}

function formCheckFieldExist(strFormName, strFieldName) {
   var form;
   var field;

   form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (formCheckFieldExist)");
      return false;
   }

   field = form.elements[strFieldName];
   if (_formCheckFieldExist(field))
      return true;
   return false;
}

function _formSetChecked(strFormName, strPrefix, bSetChecked) {
   var form;
   var i;
   var currentElement;

   form=formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (_formSetChecked)");
      return false;
   }
   for (i=0; i<form.elements.length; i++) {
      currentElement = form.elements[i];
      if (currentElement.type == "checkbox" && currentElement.name.indexOf(strPrefix) == 0 && currentElement.disabled == false )
         currentElement.checked = bSetChecked;
   }
}

function _formCheckFieldContentHtmlCompliant(strFormName, checkedField) {
   if (checkedField.value.indexOf('"') != -1
      || checkedField.value.indexOf('<') != -1
      || checkedField.value.indexOf('>') != -1) {
      return false;
   }
   return true;
}

function _formCheckFieldContentXmlCompliant(strFormName, checkedField) {
   var strValue = checkedField.value;
   var curChar;
   var nIndex = 1;

   if ((strValue == null) || (strValue.length == 0))
      return false;

   // Valid characters: letters or [_:]
   curChar = strValue.charCodeAt(0);
   if ((curChar < 0x3A) || ((curChar > 0x3A) && (curChar < 0x41))
      || ((curChar > 0x5A) && (curChar < 0x5F)) || (curChar == 0x60)
      || ((curChar > 0x7A) && (curChar < 0xAA))
      || ((curChar > 0xAA) && (curChar < 0xB5))
      || ((curChar > 0xB5) && (curChar < 0xBA))
      || ((curChar > 0xBA) && (curChar < 0xC0))
      || (curChar == 0xD7) || (curChar == 0xF7)
      ) {
      return false;
   }

   // Valid characters: letters, digits or [_-:.]
   while (nIndex < strValue.length) {
      curChar = strValue.charCodeAt(nIndex);
      
      if ((curChar < 0x2D) || (curChar == 0x2F) || ((curChar > 0x3A) && (curChar < 0x41))
         || ((curChar > 0x5A) && (curChar < 0x5F)) || (curChar == 0x60)
         || ((curChar > 0x7A) && (curChar < 0xAA))
         || ((curChar > 0xAA) && (curChar < 0xB5))
         || ((curChar > 0xB5) && (curChar < 0xBA))
         || ((curChar > 0xBA) && (curChar < 0xC0))
         || (curChar == 0xD7) || (curChar == 0xF7)
         ) {
         return false;
      }
      
      nIndex++;
   }
   
   return true;
}

function _formCheckFieldContentFileSystemCompliant(strFormName, checkedField) {
   if (checkedField.value.indexOf('*') != -1
      || checkedField.value.indexOf('?') != -1
      || checkedField.value.indexOf('"') != -1
      || checkedField.value.indexOf('<') != -1
      || checkedField.value.indexOf('>') != -1
      || checkedField.value.indexOf('|') != -1) {
      return false;
   }
   return true;
}

function _formCheckFieldContentMaxSize(strFormName, checkedField) {
   var form;
   var maxSizeField;
   var nMaxSize;
   var nCheckedFieldSize;

   form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (_formCheckFieldContentMaxSize)");
      return false;
   }

   nCheckedFieldSize = checkedField.value.length;
   maxSizeField = form.elements[checkedField.name + MAXLENGTH_SUFFIX];
   if (!_formCheckFieldExist(maxSizeField)) {
      _formFatal("Cannot find the hidden field " + checkedField.name + MAXLENGTH_SUFFIX + ": it is a mandatory field to check max size");
      return false;
   }
   nMaxSize = parseInt(maxSizeField.value);

   if (isNaN(nMaxSize))
      _formFatal("The field " + maxSizeField.name + " must contain a valid integer as value");

   if (nCheckedFieldSize > nMaxSize) {
      return false;
   }

   return true;
}

function _formCheckFieldContentMinSize(strFormName, checkedField) {
   var form;
   var minSizeField;
   var nMinSize;
   var nCheckedFieldSize;

   form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (_formCheckFieldContentMinSize)");
      return false;
   }

   nCheckedFieldSize = checkedField.value.length;

   minSizeField = form.elements[checkedField.name + MINLENGTH_SUFFIX];
   if (!_formCheckFieldExist(minSizeField)) {
      _formFatal("Cannot find the hidden field " + checkedField.name + MINLENGTH_SUFFIX + ": it is a mandatory field to check min size");
      return false;
   }
   nMinSize = parseInt(minSizeField.value);

   if (isNaN(nMinSize))
      _formFatal("The field " + minSizeField.name + " must contain a valid integer as value");

   if (nCheckedFieldSize < nMinSize) {
      return false;
   }

   return true;
}


function _formCheckFieldExist(field) {
   if (field == null)
      return false;

   return true;
}

function _formPushContext(strFormName, targetName) {
   var form = formGetForm(strFormName);

   if (targetName != "_self") {
      // if there is a _Popups field in the specified form, don't pass its value to the target, because the target could possibly behave also like a parent
      if (form._Popups != null) {
         m_temp_Popups = form._Popups.value;
         form._Popups.value = "";
      }
      // if there is a ParentFormName field in the specified form, don't pass its value to the target, because the target could possibly behave also like a parent
      if (form.ParentFormName != null) {
         m_tempParentFormName = form.ParentFormName.value;
         form.ParentFormName.value = form.name;
      }
   }
}

function _formPopContext(strFormName, targetName) {
   var form = formGetForm(strFormName);

   if (targetName != "_self") {
      if (form._Popups != null) {
         form._Popups.value = m_temp_Popups;
      }
      if (form.ParentFormName != null) {
         form.ParentFormName.value = m_tempParentFormName;
      }
   }
}

function _formFatal(strMessage) {
   if (m_bFormDebug)
      alert("***DEBUG ERROR***\n" + strMessage);
}

function _formError(strMessage) {
   if (m_bFormDebug)
      alert(strMessage);
}

function _formCheckSubmitableAndLock() {
   if (!m_bCanSubmitForm)
      return false;

   m_bCanSubmitForm = false;

   return true;
}

function _formUnlockForSubmit() {
   m_bCanSubmitForm = true;

   return true;
}

// Retrieved from jsp/scripts/popup.js
// Popup methods and variables //

var m_bPopupDebug = false;

var m_bPopupForceClose = false;
var m_bClosePopupsOnUnload = true;

function popupExecuteOnLoad(strFormName, parentFormName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("Cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupExecuteOnLoad)");
      return;
   }
   if (form._CloseOnLoad == null) {
      _popupFatal("A hidden field named '_CloseOnLoad' must exist in the popup window (popupExecuteOnLoad)");
      return;
   }
   if (form._ReloadParentOnLoad == null) {
      _popupFatal("A hidden field named '_ReloadParentOnLoad' must exist in the popup window (popupExecuteOnLoad)");
      return;
   }

   // Perform extra check on window.opener because otherwise this causes errors when we use a popup in an iframe.
   if (window.opener) {
	   window.opener._formUnlockForSubmit();

	   if (form._CloseOnLoad.value == "true")
		   window.opener._popupParentDereferencePopup(parentFormName, this, this.name);

	   if (form._ReloadParentOnLoad.value == "true")
		   window.opener.popupParentReloadAndKeepPopups(parentFormName);
   }
   if (form._CloseOnLoad.value == "true") {
      m_bPopupForceClose = true;
      if (!window.closed)
         window.close();
   }
}

function popupExecuteOnUnload(strFormName, parentFormName) {
   var form = formGetForm(strFormName);
   var popup;

   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupExecuteOnUnload)");
      return;
   }

   if (!m_bPopupForceClose) {

      if (form._CloseOnUnload == null) {
         _popupFatal("An hidden field named '_CloseOnUnload' must exist in the popup window (popupExecuteOnUnload)");
         return;
      }
      if (form._CloseOnUnload.value == "true" || form._CloseOnUnload.value == "") {
         try {
            popup = window.opener._popupParentDereferencePopup(parentFormName, this, this.name);
            if (popup == null) {
               _popupAddCookie("Closed", this.name);
            }
         } catch (e) {
            _popupAddCookie("Closed", this.name);
         }
      }

      if (form._ReloadParentOnUnload == null) {
         _popupFatal("An hidden field named '_ReloadParentOnUnload' must exist in the popup window (popupExecuteOnUnload)");
         return;
      }


      if (form._ReloadParentOnUnload.value == "true")
         window.opener.popupParentReloadAndKeepPopups(parentFormName);

      if (form._CloseOnUnload.value == "true" || form._CloseOnUnload.value == "") {
         if (!window.closed)
            window.close();
      }
   }
}

function popupRefresh(strFormName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupRefresh)");
      return;
   }

   return popupSubmitUrl(strFormName, form.Origin.value, "_self");
}

function popupSubmitUrl(strFormName, strUrl, strTarget) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupSubmitUrl)");
      return;
   }

   form._CloseOnLoad.value="false";
   form._ReloadParentOnLoad.value="false";
   form._CloseOnUnload.value="false";
   form._ReloadParentOnUnload.value="false";
   m_bClosePopupsOnUnload = false;
   formSubmitUrl(strFormName, strUrl, strTarget)

   return false; // must return false
}

function popupSubmitExecuteCommand(strFormName, strCommand, strRedirect, strTarget) {
   return _popupSubmitExecuteCommand(strFormName, strCommand, strRedirect, strTarget, true);
}

//This function is to called only if you're sure the executed strCommand won't refresh
//the current popup. If it does, the popup, will be closed on unload
function popupSubmitExecuteCommandAndNoReload(strFormName, strCommand, strRedirect, strTarget) {
   _popupSubmitExecuteCommand(strFormName, strCommand, strRedirect, strTarget, false);
   _formUnlockForSubmit();
   return false;
}

function _popupSubmitExecuteCommand(strFormName, strCommand, strRedirect, strTarget, bReloadWin) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (_popupSubmitExecuteCommand)");
      return;
   }

   form._CloseOnLoad.value="false";
   form._ReloadParentOnLoad.value="false";
   if (bReloadWin)
      form._CloseOnUnload.value="false";
   else
      form._CloseOnUnload.value="true";
   form._ReloadParentOnUnload.value="false";
   m_bClosePopupsOnUnload = false;
   formSubmitExecuteCommand(strFormName, strCommand, strRedirect, strTarget);
   return false; // must return false
}

function popupClose(strFormName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupClose)");
      return;
   }

   if (!window.closed)
      window.close();
}

function popupCloseAndParentRefresh(strFormName, parentFormName) {
   if (!window.closed) {
      window.opener._popupParentDereferencePopup(parentFormName, this, this.name);
      window.opener.formRefresh(parentFormName);
      popupClose(strFormName, parentFormName);
   }
}

function popupCloseAndForceParentRefresh(strFormName, strParentFormName) {
   window.opener._formUnlockForSubmit(strParentFormName);
   popupCloseAndParentRefresh(strFormName, strParentFormName)
}

function popupCloseAndParentSubmitUrl(strFormName, parentFormName, strUrl) {
   if (!window.closed) {
      var form = formGetForm(strFormName);
      if (form == null) {
         _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupCloseAndParentSubmitUrl)");
         return;
      }

      form._CloseOnUnload.value = "false";
      window.opener._popupParentDereferencePopup(parentFormName, this, this.name);
      window.opener.formSubmitUrl(parentFormName, strUrl, "_self");
      popupClose(strFormName, parentFormName);
   }
}

function popupCloseAndParentExecuteCommand(strFormName, parentFormName, strCommand, strRedirect) {
   if (!window.closed) {
      var form = formGetForm(strFormName);
      if (form == null) {
         _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupCloseAndParentSubmitUrl)");
         return;
      }

      form._CloseOnUnload.value = "false";
      window.opener._popupParentDereferencePopup(parentFormName, this, this.name);
      window.opener.formSubmitExecuteCommand(parentFormName, strCommand, strRedirect, "_self");
      popupClose(strFormName, parentFormName);
   }
}

function _popupGetTopParent(obj) {
   if (obj.opener == null) {
      return obj;
   } else {
      return _popupGetTopParent(obj.opener);
   }
}

function popupTopParentChangeUrl(strUrl) {
   ascendant = _popupGetTopParent(this);
   ascendant.location = strUrl;
}

function popupRefreshAndClose(strFormName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupRefreshAndClose)");
      return;
   }

   return popupSubmitUrlAndClose(strFormName, form.Origin.value, "_self");
}

function popupSubmitUrlAndClose(strFormName, strUrl, strTarget) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupSubmitUrlAndClose)");
      return;
   }

   form._CloseOnLoad.value="true";
   form._ReloadParentOnLoad.value="false";
   form._CloseOnUnload.value="false";
   form._ReloadParentOnUnload.value="false";
   m_bClosePopupsOnUnload = false;
   formSubmitUrl(strFormName, strUrl, strTarget);
   return false; // must return false
}

function popupSubmitExecuteCommandAndClose(strFormName, strCommand, strRedirect, strTarget) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupSubmitExecuteCommandAndClose)");
      return;
   }

   form._CloseOnLoad.value="true";
   form._ReloadParentOnLoad.value="false";
   form._CloseOnUnload.value="false";
   form._ReloadParentOnUnload.value="false";
   m_bClosePopupsOnUnload = false;
   formSubmitExecuteCommand(strFormName, strCommand, strRedirect, strTarget)
   return false; // must return false
}

function popupRefreshAndCloseAndParentRefresh(strFormName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupRefreshAndCloseAndParentRefresh)");
      return;
   }

   return popupSubmitUrlAndCloseAndParentRefresh(strFormName, form.Origin.value, "_self");
}

function popupSubmitUrlAndCloseAndParentRefresh(strFormName, strUrl, strTarget) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupSubmitUrlAndCloseAndParentRefresh)");
      return;
   }

   form._CloseOnLoad.value="true";
   form._ReloadParentOnLoad.value="true";
   form._CloseOnUnload.value="false";
   form._ReloadParentOnUnload.value="false";
   m_bClosePopupsOnUnload = false;
   formSubmitUrl(strFormName, strUrl, strTarget);
   return false; // must return false
}

function popupSubmitExecuteCommandAndCloseAndParentRefresh(strFormName, strCommand, strRedirect, strTarget) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupSubmitExecuteCommandAndCloseAndParentRefresh)");
      return;
   }

   form._CloseOnLoad.value="true";
   form._ReloadParentOnLoad.value="true";
   form._CloseOnUnload.value="false";
   form._ReloadParentOnUnload.value="false";
   m_bClosePopupsOnUnload = false;
   formSubmitExecuteCommand(strFormName, strCommand, strRedirect, strTarget);
   return false; // must return false
}

function popupRefreshAndParentRefresh(strFormName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupRefreshAndParentRefresh)");
      return;
   }

   return popupSubmitUrlAndParentRefresh(strFormName, form.Origin.value, "_self");
}

function popupSubmitUrlAndParentRefresh(strFormName, strUrl, strTarget) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupSubmitUrlAndParentRefresh)");
      return;
   }

   form._CloseOnLoad.value="false";
   form._ReloadParentOnLoad.value="true";
   form._CloseOnUnload.value="false";
   form._ReloadParentOnUnload.value="false";
   m_bClosePopupsOnUnload = false;
   formSubmitUrl(strFormName, strUrl, strTarget);
   return false; // must return false
}

function popupSubmitExecuteCommandAndParentRefresh(strFormName, strCommand, strRedirect, strTarget) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupSubmitExecuteCommandAndParentRefresh)");
      return;
   }

   form._CloseOnLoad.value="false";
   form._ReloadParentOnLoad.value="true";
   form._CloseOnUnload.value="false";
   form._ReloadParentOnUnload.value="false";
   m_bClosePopupsOnUnload = false;
   formSubmitExecuteCommand(strFormName, strCommand, strRedirect, strTarget);
   return false; // must return false
}

function _popupForceClose(strFormName) {
   m_bPopupForceClose = true;
   this.close();
}


// Parent methods and variables //

var m_popupParentOldAction;
var m_popupParentOldCommand;
var m_popupParentOldRedirect;
var m_popups = new Array();
var m_popupParentLoaded = false;

function popupParentExecuteOnLoad(strFormName) {
   var form = formGetForm(strFormName);
   var strPopups;
   var strPopupName;
   var nStart, nEnd, nCounter;
   var iPopup;

   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (popupParentExecuteOnLoad)");
      return;
   }

   if (form._Popups == null) {
      _popupFatal("A hidden field named '_Popups' must exist in the parent window");
      return;
   }
   strPopups = form._Popups.value;
   nStart=1; // a comma precede the name of the window
   nCounter = 0;

   strPopups = popupCookieRemoveClosedPopups("Closed", strPopups);

   while((nEnd = strPopups.indexOf(",", nStart)) != -1) {
      strPopupName = strPopups.substring(nStart, nEnd);
      iPopup = new _IPopup(window.open("", strPopupName, ""), strPopupName);
      m_popups[nCounter]=iPopup;
      nStart = nEnd + 2;
      nCounter++;
   }

   m_popupParentLoaded = true;
}

function popupParentExecuteOnUnload(strFormName) {
   popupParentCloseAllPopupsOnUnload(strFormName);
}

function popupParentHasPopup(strFormName) {
   var form = formGetForm(strFormName);
   if (m_popups != null && m_popups.length>0)
      return true;
   return false;
}

function popupParentOpenPopup(strFormName, name, strCommand, strUrl, width, height) {
   return popupParentOpenCustomPopup(strFormName, name, strCommand, strUrl, width, height, false, true);
}

function popupParentOpenCustomPopup(strFormName, name, strCommand, strUrl, width, height, bCentered, bHasScrollbars) {
   var form = formGetForm(strFormName);
   var newPopup;
   var i;
   var strPopupUrl;
   var strFeatures;
   var temp_Popups;
   var tempParentFormName;
   var strBlankUrl;
   var bSubmitForm;
   var currentDate;
   var diff;

   strBlankUrl = WEBAPP_URL + "blank.htm";

   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (popupParentOpenPopup)");
      return;
   }

   bSubmitForm = true;
   strPopupUrl = strBlankUrl;
   newPopup = null;

   if ((newPopup = _popupIsOpened(name)) != null) {
      // popup already opened
      newPopup.popup.focus();
   } else {
      _popupParentPushContext(strFormName);

      if(strCommand==null || strCommand=="") {
         if (strUrl==null || strUrl=="") {
            bSubmitForm = false;
         } else if (strUrl.indexOf("?") != -1) {
            strPopupUrl = strUrl;
            bSubmitForm = false;
         } else {
            form.action = strUrl;
         }
      } else {
         form.action=INSTRASERVLET_URL;
         form.Command.value=strCommand;
      }

      if (bHasScrollbars)
         strFeatures = "scrollbars=1,";
      else
         strFeatures = "scrollbars=0,";
      if (bCentered) {
         if (isMSIE4)
            strFeatures += "left=" + (screen.width/2 - width/2) + ",top=" + (screen.height/2 - height/2) + ",";
         else if (isNav4)
            strFeatures += "screenX=" + (screen.width/2 - width/2) + ",screenY=" + (screen.height/2 - height/2) + ",";
      }
      strFeatures += "toolbar=0,location=0,directories=0,status=0,resizable=1,copyhistory=0,menuBar=0,width="+width+",height="+height;

      newPopup = window.open(strPopupUrl,name,strFeatures);

      while(!newPopup.location);

      _popupParentReferenceNewPopup(strFormName, newPopup, name);

      if (bSubmitForm) {
         if (_formCheckSubmitableAndLock()) {
            _formPushContext(strFormName, name)

            form.target=name;
            while(newPopup == null) {}
            form.submit();

            _formPopContext(strFormName, name)
         }
      }

      _popupParentPopContext(strFormName);
   }

   return false;
}

function popupParentReloadAndClosePopups(strFormName) {
   var form = formGetForm(strFormName);
   m_bClosePopupsOnUnload = true;
   formRefresh(strFormName);
}

function popupParentReloadAndKeepPopups(strFormName) {
   var form = formGetForm(strFormName);
   m_bClosePopupsOnUnload = false;
   // if the parent is a popup, set correctly the popup's fields
   if (form._CloseOnLoad != null)
      form._CloseOnLoad.value="false";
   if (form._ReloadParentOnLoad != null)
      form._ReloadParentOnLoad.value="false";
   if (form._CloseOnUnload != null)
      form._CloseOnUnload.value="false";
   if (form._ReloadParentOnUnload != null)
      form._ReloadParentOnUnload.value="false";
      m_bClosePopupsOnUnload = false;

   formRefresh(strFormName);
}

function popupParentSubmitUrlAndClosePopups(strFormName, strUrl, strTarget) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupParentSubmitUrlAndClosePopups)");
      return;
   }

   form._CloseOnLoad.value="false";
   form._ReloadParentOnLoad.value="false";
   form._CloseOnUnload.value="false";
   form._ReloadParentOnUnload.value="false";
   m_bClosePopupsOnUnload = true;
   formSubmitUrl(strFormName, strUrl, strTarget);
   return false; // must return false
}

function popupParentSubmitUrlAndKeepPopups(strFormName, strUrl, strTarget) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupParentSubmitUrlAndKeepPopups)");
      return;
   }

   form._CloseOnLoad.value="false";
   form._ReloadParentOnLoad.value="false";
   form._CloseOnUnload.value="false";
   form._ReloadParentOnUnload.value="false";
   m_bClosePopupsOnUnload = false;
   formSubmitUrl(strFormName, strUrl, strTarget);
   return false; // must return false
}

function popupParentSubmitExecuteCommandAndKeepPopups(strFormName, strCommand, strRedirect, strTarget) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _popupFatal("cannot find a valid form ("+strFormName+") in the popup. Probably because some fields are missing (popupParentSubmitUrlAndKeepPopups)");
      return;
   }

   form._CloseOnLoad.value="false";
   form._ReloadParentOnLoad.value="false";
   form._CloseOnUnload.value="false";
   form._ReloadParentOnUnload.value="false";
   m_bClosePopupsOnUnload = false;
   formSubmitExecuteCommand(strFormName, strCommand, strRedirect, strTarget)
   return false; // must return false
}

function _popupParentPushContext(strFormName) {
   var form = formGetForm(strFormName);
   m_popupParentOldAction = form.action;
   m_popupParentOldCommand = form.Command.value;
   m_popupParentOldRedirect = form.Redirect.value;
}

function _popupParentPopContext(strFormName) {
   var form = formGetForm(strFormName);
   form.action = m_popupParentOldAction;
   form.target = "_self";
   form.Command.value = m_popupParentOldCommand;
   form.Redirect.value = m_popupParentOldRedirect;
}

function _popupParentReferenceNewPopup(strFormName, newPopup, name) {
   var nPopupsReferenced = m_popups.length;
   m_popups[nPopupsReferenced] = new _IPopup(newPopup, name);
}

function _popupParentDereferencePopup(strFormName, popup, popupName) {
   var popusArrayCopy;
   var i, j;

   if (m_popupParentLoaded == false)
      return null;

   popupsArrayCopy = new Array();
   j=0;
   for (i=0; i<m_popups.length; i++) {
      if (m_popups[i].name != popupName) {
         popupsArrayCopy[j] = m_popups[i];
         j++;
      }
   }
   m_popups = popupsArrayCopy;
   // calling _popupPrepareFormForSubmit allow to update the _Popups field of the parent dynamically.
   // it allows to quit the parent (clicking on an other tab for example), without keeping old references to closed popups.
   _popupPrepareFormForSubmit(strFormName);
   return popup;
}

function popupParentCloseAllPopupsOnUnload(strFormName) {
   if (m_bClosePopupsOnUnload == true)
      _popupParentCloseAllPopups(strFormName);
}

function _popupParentCloseAllPopups(strFormName) {
   var i;
   var dereferencedPopup;
   while (m_popups != null && m_popups.length>0) {
      dereferencedPopup = _popupParentDereferencePopup(strFormName, m_popups[0].popup, m_popups[0].name);
      try {
         dereferencedPopup._popupForceClose(strFormName);
      } catch (e) {
         _popupFatal("Cannot access to the _popupForceClose() function of the popup, verify that the file popup.js is included in the popup (_popupParentCloseAllPopups) with parameters dereferencedPopup=" + dereferencedPopup + " and strFormName=" + strFormName);
         return;
      }
   }
}

function _popupFatal(strMessage) {
   if (m_bPopupDebug)
      alert("***DEBUG ERROR***\n" + strMessage);
}

function _IPopup(windowObject, windowName) {
   this.popup=windowObject;
   this.name=windowName;
}

function _popupPrepareFormForSubmit(strFormName) {
   var form = formGetForm(strFormName);
   var strPopups;
   var i;
   if (form._Popups == null) {
      return;
   }
   if (m_popups == null) {
      return;
   }

   strPopups = '';
   for (i=0; i<m_popups.length; i++) {
      strPopups += ',' + m_popups[i].name + ',';
   }
   form._Popups.value = strPopups;
}

function _popupIsOpened(name) {
   var i;
   var popup;

   for (i=0; i<m_popups.length; i++) {
      if (m_popups[i].name == name)
         return m_popups[i];
   }
   return null;
}




// TODO: put these functions in cookie.js, change the names, etc...
function _popupAddCookie(strCookieName, strValue) {
   var strCookies = document.cookie;
   var nStart = strCookies.indexOf(strCookieName);
   var nEnd;
   var strValues;

   if (nStart == -1) {
      document.cookie = strCookieName + '=' + strValue;
      return;
   }

   nEnd = strCookies.indexOf(';', nStart);

   if (nEnd == -1)
      strValues = strCookies.substring(nStart + strCookieName.length + 1);
   else
      strValues = strCookies.substring(nStart + strCookieName.length + 1, nEnd);

   if (strValues.indexOf(strValue) >= 0)
      return;

   if (nEnd == -1) {
      document.cookie = strCookies.substring(nStart) + ',' + strValue;
   } else {
      document.cookie = strCookies.substring(nStart, nEnd) + ',' + strValue;
   }
}

var killCookieTime = new Date("January 1, 1970");
var strKillCookieTime = killCookieTime.toGMTString();

function popupCookieRemoveClosedPopups(strCookieName, strPopups) {
   var strCookies = document.cookie;
   var nStart = strCookies.indexOf(strCookieName);
   var nEnd;
   var strValues;
   var names;
   var newNames;
   var popups;
   var newPopups;
   var iName;
   var iPopup;

   if ((nStart == -1) || (strPopups.length == 0)) {
      return strPopups;
   }

   nEnd = strCookies.indexOf(';', nStart);

   if (nEnd == -1)
      strValues = strCookies.substring(nStart + strCookieName.length + 1);
   else
      strValues = strCookies.substring(nStart + strCookieName.length + 1, nEnd);

   if (strValues.length == 0)
      return strPopups;

   names = strValues.split(',');
   newNames = new Array();
   popups = strPopups.split(',');
   newPopups = new Array();

   iName = 0;
   iPopup = 0;
   while (iName < names.length) {
      if (strPopups.indexOf(names[iName]) == -1) {
         newNames[newNames.length] = names[iName];
      }
      iName++;
   }

   while (iPopup < popups.length) {
      if (strValues.indexOf(popups[iPopup]) == -1) {
         newPopups[newPopups.length] = popups[iPopup];
      }
      iPopup++;
   }

   if (newNames.length == 0) {
      // Remove cookie
      document.cookie = strCookieName + "=x;expires=" + strKillCookieTime;
   } else {
      document.cookie = strCookieName + '=' + newNames.join(',');
   }

   if (newPopups.length == 0)
      return "";
   else
      return ',' + newPopups.join(',') + ',';
}

// Retrieved from jsp/scripts/common.js
var isNav4, isMSIE4;

// checking the type and the version of the browser
if ( parseInt(navigator.appVersion) == 4) {
   isNav4 = (navigator.appName == "Netscape");
}

if ( parseInt(navigator.appVersion) >= 4) {
   isMSIE4 = (navigator.appName.indexOf("Microsoft") != -1);
}

// necessary for Netscape 4 to be able to trap key press event
if (isNav4 && navigator.language!="ja") {
   document.captureEvents(Event.KEYPRESS);
   document.onkeypress = disableRKey;
}

function disableRKey(e) {
   if (isMSIE4) {
      if(event.keyCode == 13)
         return false;
   } else {
      if(e!=null && e.which == 13)
         return false;
   }
   return true;
}

function enableNumKeys(e) {
   if (isMSIE4) {
      if(event.keyCode < 48 || event.keyCode > 57)
         return false;
   } else {
      if(e!=null && (e.which < 48 || e.which > 57))
         return false;
   }
   return true;
}

function enableValidChar(e) {
   if (isMSIE4) {
      if( event.keyCode == 38 || event.keyCode == 60 || event.keyCode == 62 || event.keyCode == 13 )
         return false;
   } else {
      if( e!=null && (e.which == '<' || e.which == '>' || e.which == '&' || e.which == 13 || e.which == 13) )
         return false;
   }
   return true;
}


function instranetGetKey(e) {
   if (window.event)
      return window.event.keyCode;
   else if (e)
      return e.which;
   else
      return null;
}

function disableComma(e) {
   if (instranetGetKey(e)==44) {
     return false;
   }
   return true;
}

function trim(inputString) {
   var nStartIndex = 0;
   var nEndIndex = inputString.length;
   var nCode;

   if (inputString.length == 0)
      return inputString;

   nCode = inputString.charCodeAt(nStartIndex);
   while ((nStartIndex < nEndIndex)
         && ((nCode == 8) || (nCode == 10) || (nCode == 13) || (nCode == 32) || (nCode == 160))) {
      nStartIndex++;
      if (nStartIndex < nEndIndex)
         nCode = inputString.charCodeAt(nStartIndex);
   }

   if (nStartIndex < nEndIndex) {
      nCode = inputString.charCodeAt(nEndIndex - 1);
      while ((nEndIndex > nStartIndex)
         && ((nCode == 8) || (nCode == 10) || (nCode == 13) || (nCode == 32) || (nCode == 160))) {
         nEndIndex--;
         if (nEndIndex > nStartIndex)
            nCode = inputString.charCodeAt(nEndIndex);
      }
   }

   if (nStartIndex == nEndIndex)
      return "";
   else
      return inputString.substring(nStartIndex, nEndIndex);
}

// Retrieved from jsp/scripts/logevent.js

/**
 * Call the command CmdDocAck which will mark the document as acknowledged.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   nDocId the external ID of the doc to remove from favorites
 * @param   strCustomString the custom string to store
 *
 * @return  false
 */

function logEventDocAck(strFormName, nDocId, strCustomString) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.UEL_DocAck_DocId.value        = nDocId;
   form.UEL_DocAck_CustomString.value = strCustomString;

   if (form.IsPopup != null && form.IsPopup.value=="true") {
      popupSubmitExecuteCommandAndCloseAndParentRefresh(strFormName, "com.instranet.CmdDocAck", form.Origin.value, "_self");
   } else {
      formSubmitExecuteCommand(strFormName, "com.instranet.CmdDocAck", form.Origin.value, "_self");
   }

   return false;
}


/**
 * Call the command CmdDocVote which will store a vote for this document.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   nDocId the external ID of the doc to remove from favorites
 * @param   strRatingParameterName html parameter name to read.
 * @param   nRating if strRatingParameterName is not set, nRating will be used.
 * @param   strCustomString the custom string to store
 *
 * @return  false
 */

function logEventDocVote(strFormName, nDocId, nRating, strRatingParameterName, strCustomString) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.UEL_DocVote_DocId.value        = nDocId;
   form.UEL_DocVote_CustomString.value = strCustomString;
   form.UEL_DocVote_RatingParameterName.value = strRatingParameterName;
   form.UEL_DocVote_Rating.value= nRating;


   if (form.IsPopup != null && form.IsPopup.value=="true") {
      popupSubmitExecuteCommand(strFormName, "com.instranet.CmdDocVote", form.Origin.value, "_self");
   } else {
      formSubmitExecuteCommand(strFormName, "com.instranet.CmdDocVote", form.Origin.value, "_self");
   }

   return false;
}

// Retrieved from ccil/common/scripts/ccil.js
var CCIL_COMMAND_PREFIX = "CCIL";

function getModuleCommandName(strCommandName) {
   return "com.instranet."+CCIL_COMMAND_PREFIX+strCommandName;
}
// Retrieved from support/selfservice/scripts/ssdscripts.js
var isIE=(navigator.appName.indexOf("Microsoft")!=-1 || navigator.appName.indexOf("MSIE")!=-1);

function indexOnLoad(strFormName) {
   window.focus();
   ilSetKeywordFieldFocus(strFormName);
   popupParentExecuteOnLoad(strFormName);
   changePaginationStyle('paginationTop');
   changePaginationStyle('paginationBottom');
}

function changePaginationStyle(strPagination) {
   if (document.getElementById(strPagination) != null) {
      var paginationText = document.getElementById(strPagination);
      paginationText.innerHTML = paginationText.innerHTML.replace("&lt;&lt;", "&lt;");
      paginationText.innerHTML = paginationText.innerHTML.replace("&gt;&gt;", "&gt;");
      paginationText.innerHTML = paginationText.innerHTML.replace("[", "");
      paginationText.innerHTML = paginationText.innerHTML.replace("]", "");
      paginationText.innerHTML = paginationText.innerHTML.replace( new RegExp(",&nbsp;","g"), "&nbsp;&nbsp;|&nbsp;&nbsp;" );
      paginationText.innerHTML = paginationText.innerHTML.replace( new RegExp("</a>,","g"), "</a> |" );
      paginationText.innerHTML = paginationText.innerHTML.replace( new RegExp("</b>,","g"), "</b> |" );
      paginationText.innerHTML = paginationText.innerHTML.replace("<<", "<");
      paginationText.innerHTML = paginationText.innerHTML.replace(">>", ">");
   }
}

function indexOnUnload(strFormName) {
   popupParentExecuteOnUnload(strFormName);
}

function landingOnLoad(strFormName) {   
   window.focus();
   ilSetKeywordFieldFocus(strFormName);
   popupParentExecuteOnLoad(strFormName);
}

function landingOnUnload(strFormName) {
   popupParentExecuteOnUnload(strFormName);
}

function customersOnLoad(strFormName) {  
   window.focus();
   ilSetKeywordFieldFocus(strFormName);
   popupParentExecuteOnLoad(strFormName);
}

function customersOnUnload(strFormName) {
   popupParentExecuteOnUnload(strFormName);
}


function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

/* navigation */
function goToHomePageNav(strFormName, strUrl) {
   var form;
   form=formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (formRefresh)");
      return false;
   }
   form.DocId.value = 0;
   form.IsLanding.value = false;
   form.Search.value = false;
   form.Keyword.value = '';
   form.CurrentProduct.value = 0;
   
   if (form.TaxSearch != null) {
   form.TaxSearch.value = false;
   }
   
   var filterName = eval("form.TaxFilterName1");
   if (filterName != null) {
      var filter = eval("form." + filterName.value);
      if (filter != null)
         filter.value=0;
   }
   
   formSubmitUrl(strFormName, strUrl, "_self");
   
   return false;
}

function goToLandingPageNav(strFormName, strUrl) {
   var form;
   form=formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (formRefresh)");
      return false;
   }
   form.DocId.value = 0;
   form.Search.value = false;
   form.TaxSearch.value = false;
   
   formSubmitUrl(strFormName, strUrl, "_self");
   
   return false;
}

function goToHandsetPageNav(strFormName, strUrl) {
   var form;
   form=formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (formRefresh)");
      return false;
   
   }
   /*form.HowToCatId.value      = 0;*/
   form.HowToDocId.value      = 0;
   form.HandyLinks.value      = -1;
   form.Search.value          = false;
   form.Keyword.value         = '';
   
   formSubmitUrl(strFormName, strUrl, "_self");
   
   return false;
}

/* search */
function goSearch(strFormName, bResetData) {
   
   var form;
   form=formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (formRefresh)");
      return false;
   }
   
      form.DocId.value=0;
      form.Search.value=true;
   if (bResetData)
      form.ResultsPage.value=1;
      
   var oldTaxName = eval("form.OldTaxName10");
   
   if (oldTaxName!=null)
      form.DocumentTitle.value = oldTaxName.value;
   
   /* used by the taxonomy */
   if (form.DocumentTitle.value.length>0)
      form.DocumentTitle.value = form.DocumentTitle.value;
   
      formSubmitUrl(strFormName, form.Redirect.value, '_self');
   
   return false;
}

function goSearchBtn(strFormName, bResetData) {
   
   var form;
   form=formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+") in the parent. Probably because some fields are missing (formRefresh)");
      return false;
   }
   
   form.TaxSearch.value=false;
   
   goSearch(strFormName, bResetData);
   
   return false;   
}

function handleCharForSearch(evt, strFormName) {
   var nCharCode;
   if(evt.keyCode != null)
      nCharCode = evt.keyCode;
   else if (evt.which != null)
      nCharCode = evt.which;
   if(nCharCode == 13) {
      goSearchBtn(strFormName, true);
      return false;
   }
   return true;
}

/* taxonomy */
function rootTaxSearchClicked (strFormName, strDimId, strDimItemId, bExploreTaxonomy, strTaxonomyName, bResetData, strUrl) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form. Probably because some fields are missing");
      return false;
   }
   /*
   if (form.Keyword.value.length>0)
      return taxSearchClicked(strFormName, strDimId, strDimItemId, bExploreTaxonomy, strTaxonomyName, bResetData);
   else*/
   if (form.OldTaxName10!=null)
      form.OldTaxName10.value = "";
      return goToHomePageNav(strFormName, strUrl); 
}

function taxShowItem(strFormName, strDimId, strDimItemId, bExploreTaxonomy, strTaxonomyName, bResetData) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form. Probably because some fields are missing");
      return false;
   }
   form.ShowTaxLanding.value = true;
   return taxSearchClicked(strFormName, strDimId, strDimItemId, bExploreTaxonomy, strTaxonomyName, bResetData);
}

function taxSearchClicked(strFormName, strDimId, strDimItemId, bExploreTaxonomy, strTaxonomyName, bResetData) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form. Probably because some fields are missing");
      return false;
   }
   
   var taxDim = eval("form.TaxFilterCommunity"+ strDimId);
   if (taxDim != null)
      taxDim.value=strDimItemId;

   form.ExploreTaxonomy.value = bExploreTaxonomy;
      
   form.DocumentTitle.value = trim(strTaxonomyName);
   form.TaxSearch.value = true;
   
   var oldTaxName = eval("form.OldTaxName"+ strDimId);
   if (oldTaxName != null)
      oldTaxName.value = trim(strTaxonomyName);
         
   return goSearch(strFormName, bResetData);         
}

function searchTaxSearchClicked(strFormName, strDimId, strDimItemId, bExploreTaxonomy, selectObject) {
   var strTaxonomyName = "";
   
   if (navigator.appName.indexOf("Microsoft")!=-1 || navigator.appName.indexOf("MSIE")!=-1) {
      strTaxonomyName = selectObject.options[selectObject.selectedIndex].innerText;
   } else {
      strTaxonomyName = selectObject.options[selectObject.selectedIndex].text;
   }
   
   return taxSearchClicked(strFormName, strDimId, strDimItemId, bExploreTaxonomy, strTaxonomyName, true);
}

/* handset downloadbox */

function activateModels(strFormName, strUrl, strElementId, nValueBrand, nValueHandset, strModule, strFormName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   
   var req;

   req = null;
   if (window.XMLHttpRequest)
      req = new XMLHttpRequest();
   else if (window.ActiveXObject)
      req = new ActiveXObject("Microsoft.XMLHTTP");

   if (req == null) {
      alert('Unable to create XMLHttpRequest object...');
      return null;
   }
   
   if (readCookie('HandsetId') != 0)
      nValueHandset = readCookie('HandsetId');
   
   strUrl += '?Brand=' + nValueBrand
          + '&HandsetModels=' + nValueHandset
          + '&Module=' + strModule
          + '&FormName=' + strFormName;
   
   req.open("GET", strUrl, true);
   
   req.onreadystatechange =   function() {
                                 if (req.readyState == 4) {
                                    if (req.status == 200 || req.status == 304) {
                                       document.getElementById(strElementId).innerHTML=req.responseText;
                                    }
                                 }
                              };
   req.send(null);
   return;
}

function displayHandsetBox(strFormName, strUrl, strElementId, nValueBrand, nValueHandset, strModule, strFormName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form. Probably because some fields are missing");
      return false;
   }
   
   form.HandsetModels.value = nValueHandset;
   /*
    * set the cookie for 7 days, the key is HandsetId and the value is the Handset document extId
   **/
   
   setCookie("HandsetId", nValueHandset, 7);
   
   activateModels(strFormName, strUrl, strElementId, nValueBrand, nValueHandset, strModule, strFormName)
   
   return false;
}

function resetSelectedHandset(strFormName, strFilterName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form. Probably because some fields are missing");
      return false;
   }
   
   var filter = eval("form." + strFilterName);
   
   if (filter != null)
      filter.value=0;
   
   deleteCookie("HandsetId");
   
   form.submit();
   
   return false;
}

/* Manage the Handset cookie */
function setCookie(strCookieName, strValue, nDays) {
   
   var date = new Date();
   date.setTime(date.getTime()+(nDays*24*60*60*1000));
   var expires = "; expires="+date.toGMTString();

   document.cookie = strCookieName + "=" + strValue + ";" + expires + "; path=/";
}

function readCookie(strCookieName) {
   var strCookie = strCookieName + "=";
	var aCookieEntries = document.cookie.split(';');
	for(var i=0;i < aCookieEntries.length;i++) {
		var cookieEntry = aCookieEntries[i];
		while (cookieEntry.charAt(0)==' ') cookieEntry = cookieEntry.substring(1,cookieEntry.length);
		if (cookieEntry.indexOf(strCookie) == 0) return cookieEntry.substring(strCookie.length,cookieEntry.length);
	}
	return 0;
}

function deleteCookie(strCookieName) {
   setCookie(strCookieName,"",-1);
}

/* landing whatshot */

function goToLandingPage(strFormName, strLandingUrl, nTopProduct) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form. Probably because some fields are missing");
      return false;
   }
   
   form.CurrentProduct.value=nTopProduct;
   
   return formSubmitUrl(strFormName, strLandingUrl, "_self");   
}

function changeWhatshotTypeOfDoc(strFormName, nDocdefId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form. Probably because some fields are missing");
      return false;
   }
   
   form.SelectedWhatsHotDocdefId.value = nDocdefId;
   
   form.submit();
   
   return false;
}

/* display doc */

function displayDoc(strFormName, strUrl, nDocId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form. Probably because some fields are missing");
      return false;
   }
   
   form.DocId.value = nDocId;
   
   if (nDocId == -1) {
      strUrl = form.Origin.value;
   }
   
   formSubmitUrl(strFormName, strUrl, "_self");
   
   return false;
}

function displayDocUsefulLink(strFormName, strUrl, nDocId, strWTCG) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form. Probably because some fields are missing");
      return false;
   }
   
   form.WTCG.value = strWTCG;
   
   return displayDoc(strFormName, strUrl, nDocId);
}

/* result list */
function changePage(strFormName, strPageName, strPage) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   
   var page = eval("form."+strPageName);
   form.DocId.value = 0;
   page.value=strPage;
   form.submit();
   return false;
}

/* manage yes/no workflow for the feedback/email */
function sendCustomerServices(strFormName, strUrl) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }   
   
   form.Search.value = false;
   if (form.SendCustomer != null)
      form.SendCustomer.value = true;
   
   formSubmitUrl(strFormName, strUrl, "_self");
   
   /*formSubmitUrl(strFormName, form.Origin.value, "_self");*/
   return false;
}

function sendYesToCustomerServices(strFormName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   
   form.Solved.value=true;
   
   formSubmitUrl(strFormName, form.Origin.value, "_self");
   
   return false;
}

function sendCustomerFeedback(strFormName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   
   form.NeedFeedback.value='true';
   
   formSubmitUrl(strFormName, form.Origin.value, "_self");
   
   return false;
}

function sendCustomerContact(strFormName, strUrl) {
      var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   formSubmitUrl(strFormName, strUrl, "_self");
   
   return false;
}

function openPrintableArticle(strFormName, strUrl, nDocId, strWTCG) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   } 
   window.open(strUrl + "?DocId=" + nDocId + "&WTCG=" + strWTCG ,'PrintArticle','height=500,width=700,scrollbars=yes,menubar=no,resizable=yes,status=no,toolbar=no,top=223,left=160');
   
   return false;
}

/* doclist expand search */
function expandSearch(strFormName) {
   return goSearch(strFormName, true);
}

function redirectToStoreLocator (strFormName, strUrl) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   formSubmitUrl(strFormName, strUrl, "_self");
   
   return false;
}

function setStoreLocatorValue(strFormName, inputName, strValue) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   var input = eval("form." + inputName);
   if (input != null) {
      if (input.value == strValue)
         input.value = "";
   }
   
   return false;
}

/* doc solved */
function docSolvedNo(strFormName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form. Probably because some fields are missing");
      return false;
   }

   form.Keyword.value = '';
      
   return goSearch(strFormName, true);
}

function addbookmark(strTitle, strUrl) {
	if (window.sidebar || window.opera && window.print || navigator.appName.indexOf("Netscape")!=-1) {
      /* Firefox & Opera & Safari */
		window.location.replace(strUrl);
		alert('Please press CTRL-D to bookmark this page'); 
		document.title = document.title + " - " + strTitle;
	}
	else if (window.external)
		window.external.AddFavorite(strUrl,strTitle);
}

function backToPrevious(strFormName, bSearch, paramId, strDimId, bExploreTaxonomy, strTaxonomyName, nOldTaxId, bResetData, strHome, strLanding, bFromTaxLanding) {
   var form = formGetForm(strFormName);
   
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   
   if (bFromTaxLanding || (form.FromHandsetLanding != null && form.FromHandsetLanding.value == true)) {
      history.back();
      return false;
   }
   
   form.elements[paramId].value=0;
   form.Search.value=bSearch;
   
   if (bSearch) {
      return taxSearchClicked(strFormName, strDimId, nOldTaxId, bExploreTaxonomy, strTaxonomyName, bResetData);
   }
   
   var tax = eval('form.TaxFilterCommunity'+strDimId);
   tax.value = 0;
   
   if (form.IsLanding.value == "true")
      formSubmitUrl(strFormName, strLanding, "_self");
   else   
      formSubmitUrl(strFormName, strHome, "_self");
      return false;
   }
   
function selectContext(strFormName, nProductId) {
   var form = formGetForm(strFormName);
   
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   form.IsLanding.value = false;
   form.CurrentProduct.value = nProductId;
   form.DocumentTitle.value = document.title;
   return goSearch(strFormName, true);
}

function setSolvingBasicProblem(strFormName, nSolvingId) {
   var form = formGetForm(strFormName);
   
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   form.DocId.value = nSolvingId;
}

function displaySolvingBasicProblem(strFormName, strUrl) {
   var form = formGetForm(strFormName);
   
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   
   if (form.DocId.value != 0)
      displayDoc(strFormName, strUrl, form.DocId.value);
   return false;
}

function hideHandsetChangeModelBox (strFormName, strBoxId, strIconPlus, strIconMinus) {
   var form = formGetForm(strFormName);
   
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   
   if (document.getElementById(strBoxId).style.display != 'block') {
      document.getElementById(strBoxId).style.display='block';
      document.getElementById('hchchangemodelico').src=strIconMinus;
      form.ChangeModel.value = true;
   } else {
      document.getElementById(strBoxId).style.display='none';
      document.getElementById('hchchangemodelico').src=strIconPlus;
      form.ChangeModel.value = false;
   }
   
   return false;
}

function changeHandsetModel(strFormName, strUrl, nValueHandset) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form. Probably because some fields are missing");
      return false;
   }
   
   form.HandsetModels.value = nValueHandset;
   form.HandsetModel.value = nValueHandset;
   form.Keyword.value = '';
   form.Search.value = false;
   form.SearchSpecific.value = false;
   form.HowToDocId.value = 0;
   form.HowToCatId.value = 0;
   form.HandyLinks.value = -1;
   /*
    * set the cookie for 7 days, the key is HandsetId and the value is the Handset document extId
   **/
   
   setCookie("HandsetId", nValueHandset, 7);
   
   return false;
}

function setSearchUrl (strFormName, strSearchUrl) {
   var form = formGetForm(strFormName);
   
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   if (form.SearchUrl != null) {
      form.SearchUrl.value=strSearchUrl;
   }
   
   return false;
}

function handleCharForSearchHCH(evt, strFormName) {
   var nCharCode;
   if(evt.keyCode != null)
      nCharCode = evt.keyCode;
   else if (evt.which != null)
      nCharCode = evt.which;
   if(nCharCode == 13) {
      goSearchFromHCH(strFormName);
      return false;
   }
   return true;
}

function goSearchFromHCH(strFormName) {
   var form = formGetForm(strFormName);
   
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   
   form.SearchSpecific.value = true;
   form.Search.value = true;
   form.HowToDocId.value = 0;
   form.HandyLinks.value = -1;
   
   formSubmitUrl(strFormName, form.SearchUrl.value, '_self');
   
   return false;   
}

function hideHowToMenu(strFormName, strBoxId, strImgId, strIconPlus, strIconMinus) {
   var form = formGetForm(strFormName);
   
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   
   if (document.getElementById(strBoxId).style.display != 'block') {
      document.getElementById(strBoxId).style.display='block';
      document.getElementById(strImgId).src=strIconMinus;
   } else {
      document.getElementById(strBoxId).style.display='none';
      document.getElementById(strImgId).src=strIconPlus;
   }
   form.HowToDocId.value = -1;
   
   return false;
}

/*
function setOpacity(value, strElementId, strDisplay, strIco) {
   document.getElementById(strElementId).style.display = strDisplay;
   document.getElementById(strElementId).style.opacity = value / 10;
   document.getElementById(strElementId).style.filter = 'alpha(opacity=' + value * 10 + ')';
   document.getElementById(strElementId+"parent").src=strIco;
}

function fadeOut(strElementId, strIco) {
   if (isIE) {
      document.getElementById(strElementId).style.filter="blendTrans(duration=2)";
      if (document.getElementById(strElementId).filters.blendTrans.status != 2) {
         document.getElementById(strElementId).filters.blendTrans.apply();
         document.getElementById(strElementId).style.display="none";
         document.getElementById(strElementId).filters.blendTrans.play();
         document.getElementById(strElementId+"parent").src=strIco;
      }
   } else {
      for( var i = 0 ; i <= 100 ; i++ ) {
         setTimeout( 'setOpacity(' + (10 - i / 10) + ',"' + strElementId + '", "none", "' + strIco + '")' , 8 * i );
      }
   }
}

function fadeIn(strElementId, strIco) {
   if (isIE) {
      document.getElementById(strElementId).style.filter="blendTrans(duration=2)";
      if (document.getElementById(strElementId).filters.blendTrans.status != 2) {
         document.getElementById(strElementId).filters.blendTrans.apply();
         document.getElementById(strElementId).style.display="block";
         document.getElementById(strElementId).filters.blendTrans.play();
         document.getElementById(strElementId+"parent").src=strIco;
      }
   } else {
      for( var i = 0 ; i <= 100 ; i++ ) {
         setTimeout( 'setOpacity(' + (i / 10) + ',"' + strElementId + '", "block", "' + strIco + '")' , 8 * i );
      }
   }
}
*/
/* doclisthch */

function listHowToForCat (strFormName, nHowToCatId, strHowToListUrl, strHowToCatName) {   
   var form = formGetForm(strFormName);
   
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   
   form.HandyLinks.value = -1;
   form.HowToDocId.value = -1;
   form.HowToCatId.value = nHowToCatId;  
   form.Search.value = true;    
   form.FromMenu.value = true;
   form.SearchSpecific.value = false;
   form.DocumentTitle.value = strHowToCatName;
   form.Keyword.value = "";
   formSubmitUrl(strFormName, strHowToListUrl, '_self');
   
   return false;
}

function displayHowToDoc(strFormName, strUrl, nDocId, nHowToCatId, bFromMenu, strHowToTitle) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form. Probably because some fields are missing");
      return false;
   }
   
   form.HandyLinks.value = -1;
   form.HowToDocId.value = nDocId;
   form.HowToCatId.value = nHowToCatId;
   form.FromMenu.value = bFromMenu;
   form.DocumentTitle.value = strHowToTitle;
   formSubmitUrl(strFormName, strUrl, "_self");
   
   return false;
}

function backToPreviousHch(strFormName, bSearch, paramId, strHome, bFromMenu) {
   var form = formGetForm(strFormName);
   
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (bFromMenu) {
      form.elements[paramId].value=0;
      form.HandyLinks.value = -1;
      form.Search.value=false;
      formSubmitUrl(strFormName, strHome, '_self');
   } else {
      history.back();
   }
   return false;
}

function displayHandyLinks (strFormName, strUrl, strValue, strHandyName, bFromMenu) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form. Probably because some fields are missing");
      return false;
   }
   form.HandyLinks.value = strValue;
   form.HandyName.value = strHandyName;
   form.FromMenu.value = bFromMenu;
   form.FromSearchList.value = false;
   formSubmitUrl(strFormName, strUrl, "_self");
   return false;
}

function displayPhoneSettings (strFormName, strUrl, strValue, strHandyName, bFromMenu, nDocId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form. Probably because some fields are missing");
      return false;
   }
   form.HandyLinks.value = strValue;
   form.HandyName.value = strHandyName;
   form.FromMenu.value = bFromMenu;
   form.FromSearchList.value = true;
   form.HowToDocId.value = nDocId;
   formSubmitUrl(strFormName, strUrl, "_self");
   return false;
}
// Retrieved from ccil_orangeuk/common/scripts/il.js
var daysInMonth         = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var DimChooserHeight    = 500;
var DimChooserWidth     = 500;

/**
 * View a document in the current window or in a popup depending on a specified boolean
 *
 * @param   strFormName the name of the current HTML form object
 * @param   nDocExtId the identifier of the document to visualize
 * @param   nSecMode the section mode used
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   bViewDocInPopup if true the document will be showed in a popup.
 *
 * @return  false
 */

function ilViewDocument(strFormName, nDocExtId, nSecMode, strUrl, bViewDocInPopup) {
   if (bViewDocInPopup) {
      return ilViewDocumentInPopup(strFormName, strUrl, nDocExtId);
   } else {
      var nIndex = strUrl.indexOf("?",0);
      if (nIndex!=-1) {
         strUrl = strUrl.substring(0, nIndex);
      }
      
      return ilViewDocumentInCurrentWindow(strFormName, nDocExtId, nSecMode, strUrl);
   }
}

/**
 * View a decision tree in the current window or in a popup depending on a specified boolean
 *
 * @param   strFormName the name of the current HTML form object
 * @param   nDocExtId the identifier of the document to visualize
 * @param   nSecMode the section mode used
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   strDTNodeId the absolute id of the node to open the DT on
 * @param   bViewDocInPopup if true the document will be showed in a popup.
 *
 * @return  false
 */
function ilViewDecisionTree(strFormName, nDocExtId, nSecMode, strUrl, strDTNodeId, bViewDocInPopup) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (strDTNodeId != null && form.SelectedNodeAbsExtId != null) {
      form.SelectedNodeAbsExtId.value=strDTNodeId;
      strUrl += "&SelectedNodeAbsExtId="+ strDTNodeId;
   }

   return ilViewDocument(strFormName, nDocExtId, nSecMode, strUrl, bViewDocInPopup);
}



/**
 * View a document in the current window
 *
 * @param   strFormName the name of the current HTML form object
 * @param   nDocExtId the identifier of the document to visualize
 * @param   nSecMode the section mode used
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   strDTNodeId the absolute id of the node to open the DT on
 *
 * @return  false
 */
function ilViewDecisionTreeInCurrentWindow(strFormName, nDocExtId, nSecMode, strUrl, strDTNodeId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (strDTNodeId != null && form.SelectedNodeAbsExtId != null)
      form.SelectedNodeAbsExtId.value=strDTNodeId;

   return ilViewDocumentInCurrentWindow(strFormName, nDocExtId, nSecMode, strUrl);
}



/**
 * View a document in the current window
 *
 * @param   strFormName the name of the current HTML form object
 * @param   nDocExtId the identifier of the document to visualize
 * @param   nSecMode the section mode used
 * @param   strUrl the Renderer URL of the corresponding document
 *
 * @return  false
 */
function ilViewDocumentInCurrentWindow(strFormName, nDocExtId, nSecMode, strUrl) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.DocId.value = nDocExtId;
   form.SecMode.value = nSecMode;
   formSubmitUrl(strFormName, strUrl, "_self");

   return false;
}

/**
 * View a document in a new Popup
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nDocId the identifier of the document to visualize
 *
 * @return  false
 */
function ilViewDecisionTreeDocumentInPopup(strFormName, strUrl, nDocId, strDTNodeId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (strDTNodeId != null && form.SelectedNodeAbsExtId != null)
      form.SelectedNodeAbsExtId.value=strDTNodeId;

   return ilViewDocumentInPopup(strFormName, strUrl, nDocId);
}

/**
 * View a document in a new Popup
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nDocId the identifier of the document to visualize
 *
 * @return  false
 */
function ilViewDocumentInPopup(strFormName, strUrl, nDocId) {
   _ilViewDocumentInPopup(strFormName, strUrl, nDocId, false, "DocumentWindow"+nDocId, false);
   return false;
}



/**
 * View a direct access document in a new windows
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   strPopupName name of the popup
 *
 * @return  false
 */
function ilViewDirectAccessInPopup(strFormName, strUrl, strPopupName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   if (form.Module != null) {
      strUrl = strUrl+"&Module="+ form.Module.value
   }
   window.open(strUrl,strPopupName,"");
   return false;
}


/**
 * View a document in a real Popup.
 * A real popup will be closed on its opener reload.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nDocId the identifier of the document to visualize
 *
 * @return  false
 */
function ilViewDocumentInRealPopup(strFormName, strUrl, nDocId) {
   _ilViewDocumentInPopup(strFormName, strUrl, nDocId, false, "DocumentWindow"+nDocId, true);
   return false
}

/**
 * View a document in a new Popup
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nDocId the identifier of the document to visualize
 * @param   strVersion the version of the current doc (ex: 1.3)
 *
 * @return  false
 */
function ilViewVersionedDocumentInPopup(strFormName, strUrl, nDocId, strVersion) {
   _ilViewDocumentInPopup(strFormName, strUrl, nDocId, true, "DocumentWindow"+strVersion, false);
   return false;
}

/**
 * View a quiz in a new Popup
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nQuizId the identifier of the quiz to visualize
 *
 * @return  false
 */
function ilViewQuizInPopup(strFormName, strUrl, nQuizId) {
   _ilViewDocumentInPopup(strFormName, strUrl, nQuizId, false, "QuizWindow"+nQuizId, false);
   return false;
}

/**
 * View a quiz in a new Popup
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nQuizId the identifier of the quiz to visualize
 * @param   strVersion the version of the current doc (ex: 1.3)
 *
 * @return  false
 */
function ilViewVersionnedQuizInPopup(strFormName, strUrl, nQuizId, strVersion, strVerUUID) {
   strUrl = strUrl + "&DocVerUUID=" + strVerUUID;
   _ilViewDocumentInPopup(strFormName, strUrl, nQuizId, true, "QuizWindow"+strVersion, false);
   return false;
}

/**
 * Displays a quiz.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 *
 * @return  false
 */
function ilViewQuiz(strFormName, strUrl) {
   return _ilViewQuiz(strFormName, strUrl, false);
}

/**
 * Displays a quiz.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 *
 * @return  false
 */
function ilViewVersionnedQuiz(strFormName, strUrl) {
   return _ilViewQuiz(strFormName, strUrl, true);
}

/**
 * Displays a quiz.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 *
 * @return  false
 */
function _ilViewQuiz(strFormName, strUrl, bDisplayVersion) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (bDisplayVersion)
      strUrl = strUrl + "&DisplayVersion=true";
   if (form.IsPopup != null && form.IsPopup.value=="true")
      popupSubmitUrl(strFormName, strUrl, "_self");
   else
      formSubmitUrl(strFormName, strUrl, "_self");

   return false;
}



function _ilViewDocumentInPopup(strFormName, strUrl, nDocId, bDisplayVersion, strPopupName, bIsRealPopup) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   var strModule = form.Module.value;
   strUrl = strUrl + "&IsPopup=true" + "&Module=" + strModule + "&DisplayVersion=" + bDisplayVersion;
   if (form.RendererTargetLanguageId != null)
      strUrl = strUrl + "&RendererTargetLanguageId="+form.RendererTargetLanguageId.value;
   if (bIsRealPopup) {
      strUrl = strUrl + "&TruePopup=true"
      popupParentOpenPopup(strFormName, strPopupName, null, strUrl, 1018, 600);
   } else
      window.open(strUrl,strPopupName,"toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=1018,height=600");

   return false;
}

/**
 * View a reminder in a new Popup
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nDocId the identifier of the document to visualize
 *
 * @return  false
 */
function ilViewReminderInPopup(strFormName, strUrl, nDocId) {
   _ilViewReminderInPopup(strFormName, strUrl, nDocId, false);
   return false;
}

/**
 * View a reminder in a real Popup.
 * A real popup will be closed on its opener reload.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nDocId the identifier of the document to visualize
 *
 * @return  false
 */
function ilViewReminderInRealPopup(strFormName, strUrl, nDocId) {
   _ilViewReminderInPopup(strFormName, strUrl, nDocId, true);
   return false
}

function _ilViewReminderInPopup(strFormName, strUrl, nDocId, bIsRealPopup) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   var strParentFormName = form.ParentFormName.value;
   var strModule = form.Module.value;

   strUrl = strUrl+"&IsPopup=true"+"&Module="+strModule+"&ParentFormName="+strParentFormName;

   if (form.RootParentFormName != null) {
      var strRootParentFormName = form.RootParentFormName.value;
      strUrl = strUrl+"&RootParentFormName="+strRootParentFormName;
   }

   if (bIsRealPopup)
      popupParentOpenPopup(strFormName, "ReminderWindow", null, strUrl, 640, 480);
   else
      window.open(strUrl,"ReminderWindow"+nDocId,"toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=640,height=480");
}


/**
 * View a doc in the main window.
 * To be used from a popup.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strParentFormName the name of the parent form object
 * @param   nDocExtId the external ID of the document to visualize
 * @param   nSecMode the security mode to apply to the doc to display
 * @param   strUrl the Renderer URL of the corresponding document
 *
 * @return  false
 */
function ilViewDocumentFromPopup(strFormName, strParentFormName, nDocExtId, nSecMode, strUrl) {
   var parentForm;
   var win;

   win = ilGetRootOpenerWindow();
   parentForm = win.formGetForm(strParentFormName);
   if (parentForm == null) {
      _formFatal("cannot find a valid form ("+strParentFormName+"). Probably because some fields are missing");
      return false;
   }

   win.ilViewDocumentInCurrentWindow(strParentFormName, nDocExtId, nSecMode, strUrl)

   return false;
}

function ilEaseViewDocumentFromPopup(strFormName, strParentFormName, strTitle, nDocExtId, nSecMode, strUrl) {
   var parentForm;
   var win;

   win = ilGetRootOpenerWindow();

   parentForm = win.formGetForm(strParentFormName);
   if (parentForm == null) {
      _formFatal("cannot find a valid form ("+strParentFormName+"). Probably because some fields are missing");
      return false;
   }

   win.easeViewDocument(strParentFormName, strTitle, nDocExtId, nSecMode, strUrl);

   return false;
}

/**
 * View a feedback in a new Popup
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nDocId the identifier of the document to visualize
 *
 * @return  false
 */
function ilViewFeedbackInPopup(strFormName, strUrl, nDocId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   var strModule = form.Module.value;
   window.open(strUrl+"&IsPopup=true"+"&Module="+strModule,"FeedbackWindow"+nDocId,"toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=560,height=500");

   return false;
}

/**
 * View an alert in a new Popup.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl      the renderer URL of the corresponding document
 * @param   nAlertId    the identifier of the document to visualize
 *
 * @return  false
 */
function ilViewAlertInPopup(strFormName, strUrl, nAlertId) {
   var form              = formGetForm(strFormName);
   var strModule         = form.Module.value;
   var strParentFormName = form.ParentFormName.value;

   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   strUrl = strUrl +"&IsPopup=true"+"&Module="+strModule+"&ParentFormName="+strParentFormName;

   /*popupParentOpenPopup(strFormName, "AlertWindow"+nAlertId, null, strUrl, 560,450);*/

   window.open(strUrl, "AlertWindow"+nAlertId, "toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=560,height=450");

   return false;
}

/**
 * Adds a document to the favorites preference.
 *
 * @param   strFormName the name of the current HTML form object
 * @param nExternalDocumentId the external ID of the doc to add to favorites
 *
 * @return  false
 */
function ilAddFavorites(strFormName, nExternalDocumentId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.AddDocId.value=nExternalDocumentId;
   if (form.IsPopup != null && form.IsPopup.value=="true")
      popupSubmitExecuteCommand(strFormName, getModuleCommandName("CmdFavoritesAdd"), form.Origin.value, "_self");
   else
      formSubmitExecuteCommand(strFormName, getModuleCommandName("CmdFavoritesAdd"), form.Origin.value, "_self");

   return false;
}

/**
 * Empties the favorites documents list.
 *
 * @param   strFormName the name of the current HTML form object
 * @return  false
 */
function ilEmptyFavorites(strFormName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (confirm(IL_FAVORITESDELETEALL)) {
      form.FavoritesRemoveAll.value="true";
      formSubmitExecuteCommand(strFormName, getModuleCommandName("CmdFavoritesDel"), form.Origin.value, "_self");
   }

   return false;
}

/**
 * Removes a document from the favorites documents list
 *
 * @param   strFormName the name of the current HTML form object
 * @param nExternalDocumentId the external ID of the doc to remove from favorites
 *
 * @return  false
 */
function ilRemoveFavorite(strFormName, nDocId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.FavoritesRemoveId.value=nDocId;
   formSubmitExecuteCommand(strFormName, getModuleCommandName("CmdFavoritesDel"), form.Origin.value, "_self");

   return false;
}

// START Remove favorites from boxesdocslist
function ilRemoveFavoriteAndParentRefresh(strFormName, nDocId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form. Probably because some fields are missing");
      return false;
   }

   form.FavoritesRemoveId.value=nDocId;
   popupSubmitExecuteCommandAndParentRefresh(strFormName, getModuleCommandName("CmdFavoritesDel"),  form.Origin.value, "_self")
   return false;
}
// END Remove favorites from boxesdocslist


/**
 * minimize the documents list box
 *
 * @param   strFormName       the name of the current HTML form object
 * @param   strBoxToMinimize  the name of the documents list box to minimize
 * @param   bBoxMinimized     tells if the box is minimized or not
 *
 * @return  false
 */
function ilMinimizeBox(strFormName, strBoxToMinimize, bBoxMinimized) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.BoxToMinimize.value=strBoxToMinimize;
   form.BoxMinimized.value=bBoxMinimized;

   formSubmitExecuteCommand(strFormName, getModuleCommandName("CmdMinimizeBox"), form.Origin.value, "_self");

   return false;
}

/**
 * Allows to change the selected menu tab.
 *
 * @param   strFormName    the name of the current HTML form object
 * @param   strTabSel      the ID of the tab selected
 * @param   strUrl         the URL corresponding to the selected tab
 * @param   strMenuSel     the hidden field used to set the selection
 * @param   strCallBack    if "true", thisfunction will cann menuCallBack which must be declared and define by the caller
 */

function ilSelectMenuTab(strFormName, strTabSel, strUrl, strMenuSel, strCallBack, strMenuLock, strKeptParameters) {
   if (strMenuLock=="true") {
      alert(IL_MENULOCKED);
      return false;
   }

   var menuSel;
   var form = formGetForm(strFormName);

   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   menuSel = eval("document." + form.name + "." + strMenuSel);
   menuSel.value = strTabSel;

   if (form.KeepParameters != null) {
      form.KeepParameters.value = strKeptParameters;
   }

   return _ilGoto(form, strFormName, strUrl, strCallBack, '_self');
}


/**
 * Allows to change the module
 *
 * @param   strFormName    the name of the current HTML form object
 * @param   strUrl         the URL corresponding to the selected tab
 * @param   strCallBack    if "true", thisfunction will can menuCallBack which must be declared and define by the caller
 * @param   strNewModule   the name of the new module to switch to
 */
function ilSelectModule(strFormName, strUrl, strCallBack, strMenuLock, strNewModule, strTarget) {
   if (strMenuLock=="true") {
      alert(IL_MENULOCKED);
      return false;
   }

   var menuSel;
   var form = formGetForm(strFormName);

   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.Module.value = strNewModule;

   if (form.KeepParameters != null) {
      form.KeepParameters.value = "Module";
   }

   return _ilGoto(form, strFormName, strUrl, strCallBack, strTarget);
}

/**
 * Edits the user's informations.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl      the URL used to display the editor popup
 * @param   strAllowSubmit    if "false", the user will not be able to click on submit... No reload of the page.
 *
 * @return  false
 */
function ilEditUserInfo(strFormName, strUrl) {

   popupParentOpenPopup(strFormName, "EditUserInfo", null, strUrl, 430, 320);

   return false;
}

/**
 * Edits a  date.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strDateEditorUrl the date editor URL
 * @param   strDateInputPrefix the date input name prefix defined in the parent form
 *
 * @return  false
 */
function ilEditDate(strFormName, strDateEditorUrl, strDateInputPrefix) {
   return _ilOpenDateEditor(strFormName, strDateEditorUrl,-1, "EditDate", strDateInputPrefix);
}

/**
 * Edits a validity start date.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strDateEditorUrl the date editor URL
 *
 * @return  false
 */
function ilEditStartDate(strFormName, strDateEditorUrl) {
   return _ilOpenDateEditor(strFormName, strDateEditorUrl, 2, "EditStartDate", "");
}

/**
 * Edits a validity end date.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strDateEditorUrl the date editor URL
 *
 * @return  false
 */
function ilEditEndDate(strFormName, strDateEditorUrl, strDateInputPrefix) {
   return _ilOpenDateEditor(strFormName, strDateEditorUrl, 3, "EditEndDate", "");
}

/**
 * Edits a validity start date.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strDateEditorUrl the date editor URL
 *
 * @return  false
 */
function ilEditValidityStartDate(strFormName, strDateEditorUrl, strDateInputPrefix) {
   return _ilOpenDateEditor(strFormName, strDateEditorUrl, 2, "EditValidityStartDate", strDateInputPrefix);
}

/**
 * Edits a validity end date.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strDateEditorUrl the date editor URL
 *
 * @return  false
 */
function ilEditValidityEndDate(strFormName, strDateEditorUrl, strDateInputPrefix) {
   return _ilOpenDateEditor(strFormName, strDateEditorUrl, 3, "EditValidityEndDate", strDateInputPrefix);
}

/**
 * Edits a visibility start date.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strDateEditorUrl the date editor URL
 *
 * @return  false
 */
function ilEditVisibilityStartDate(strFormName, strDateEditorUrl, strDateInputPrefix) {
   return _ilOpenDateEditor(strFormName, strDateEditorUrl, 0, "EditVisibilityStartDate", strDateInputPrefix);
}

/**
 * Edits a visibility end date.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strDateEditorUrl the date editor URL
 *
 * @return  false
 */
function ilEditVisibilityEndDate(strFormName, strDateEditorUrl, strDateInputPrefix) {
   return _ilOpenDateEditor(strFormName, strDateEditorUrl, 1, "EditVisibilityEndDate", strDateInputPrefix);
}

function _ilGoto(form, strFormName, strUrl, strCallBack, strTarget) {
   var kp = form.KeepParameters;

   if (strCallBack != "true") {
      if ((kp == null) || (kp.value.length == 0) || (kp.value == KEEP_ALL_PARAMETERS)) {
         formSubmitUrl(strFormName, strUrl, strTarget);
      } else {
         var strKp = "";

         if (document.forms[KEEP_PARAMETERS_FORM] != null) {
            document.removeChild(document.forms[KEEP_PARAMETERS_FORM]);
         }

         var newForm = document.createElement("FORM");
         newForm.name = KEEP_PARAMETERS_FORM;
         newForm.action = strUrl;
         newForm.target = strTarget;
         newForm.method = "POST";

         // The fields _Popups and _ParentFormName are needed by formSubmitUrl function.
         popupParentCloseAllPopupsOnUnload(form.name); // allow to update correctly _Popups in the source form before copy it
         if (form._Popups != null) {
            var newInput = document.createElement("INPUT");
            newInput.type = "hidden";
            newInput.name = "_Popups";
            newInput.value = form._Popups.value;

            newForm.appendChild(newInput);
         }

         if (form._ParentFormName != null) {
            var newInput = document.createElement("INPUT");
            newInput.type = "hidden";
            newInput.name = "_ParentFormName";
            newInput.value = form._ParentFormName.value;

            newForm.appendChild(newInput);
         }

         if (kp.value != KEEP_NO_PARAMETER) {
            var akp = kp.value.split(",");

            for(i = 0; i < akp.length; i++) {
               var obj = eval("document." + strFormName + "." + akp[i]);
               if (obj != null) {
                  var newInput = document.createElement("INPUT");
                  newInput.type = "hidden";
                  newInput.name = akp[i];
                  newInput.value = obj.value;

                  newForm.appendChild(newInput);
               }
            }
         }
         document.body.appendChild(newForm);

         formSubmitUrl(KEEP_PARAMETERS_FORM, strUrl, strTarget);
      }
   } else {
      menuCallBack(strFormName, strUrl);
   }

   return false;
}


function _ilOpenDateEditor(strFormName, strDateEditorUrl, nDateType, strPopupName, strDateInputPrefix) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (form.Module != null)
      strDateEditorUrl+= "?Module="+form.Module.value;
   strDateEditorUrl+= "&ParentFormName="+form.name;

   // nDateType :
   //    * 0 : Visibility Start Date
   //    * 1 : Visibility End Date
   //    * 2 : Validity Start Date
   //    * 3 : Validity End Date
   if (form.CalendarDate != null)
      form.CalendarDate.value=nDateType;
   if (strDateInputPrefix != "") {
      strDateEditorUrl+= "&DateInputPrefix="+strDateInputPrefix;
      
      var nDay = eval("form." + strDateInputPrefix + "_D");
      var nMonth = eval("form." + strDateInputPrefix + "_M");
      var nYear = eval("form." + strDateInputPrefix + "_Y");
      
      strDateEditorUrl+= "&" + strDateInputPrefix + "_D=" + nDay.value;
      strDateEditorUrl+= "&" + strDateInputPrefix + "_M=" + nMonth.value;
      strDateEditorUrl+= "&" + strDateInputPrefix + "_Y=" + nYear.value;
   }
   else if (form.DateInputPrefix != null)
      strDateEditorUrl+= "&DateInputPrefix="+form.DateInputPrefix.value;

   popupParentOpenPopup(strFormName, strPopupName, null, strDateEditorUrl, 234, 200);

   return false;
}

/**
 * Allows to restart a training session.
 *
 * @param   strFormName          the name of the current HTML form object
 * @param   nUserExamSessionId   the training user id
 *
 * @return  false
 */
function ilRestartTrainingSession(strFormName, nUserExamSessionId, strRedirect) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.UserTrainingSessionId.value = nUserExamSessionId;
   formSubmitExecuteCommand(strFormName, getModuleCommandName("AdmCmdQuizRestart"), strRedirect, "_self");

   return false;
}

function ilRequestTrainingSession(strFormName, strDocId, strDocIdInputName, strRedirect) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   var docInput = eval("form."+strDocIdInputName);
   docInput.value = strDocId;

   formSubmitExecuteCommand(strFormName, getModuleCommandName("AdmCmdQuizRequest"), strRedirect, "_self");
   return false;
}

function ilDeleteTrainingSession(strFormName, nUserExamSessionId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (form.UserTrainingSessionId != null)
      form.UserTrainingSessionId.value = nUserExamSessionId;
   else {
      var input = document.createElement("INPUT");
      input.type = "hidden";
      input.name = "UserTrainingSessionId";
      input.value = nUserExamSessionId;

      form.appendChild(input);
   }

   formSubmitExecuteCommand(strFormName, getModuleCommandName("AdmCmdQuizDelete"), form.Origin.value, "_self");
   return false;
}

function ilDeleteAllTrainingSession(strFormName, strUserExamSessionIds) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (!confirm(ILFO_TRAINING_CONFIRMDELETESESSIONS))
      return false;

   if (strUserExamSessionIds != null && strUserExamSessionIds.length > 0) {
      var userSessions = document.createElement("INPUT");
      userSessions.type = "hidden";
      userSessions.name = "UserTrainingSessionIds";
      userSessions.value = strUserExamSessionIds;

      form.appendChild(userSessions);

      formSubmitExecuteCommand(strFormName, getModuleCommandName("AdmCmdQuizDelete"), form.Origin.value, "_self");
   }
   return false;
}

function ilCheckFieldMaxSize(strFormName, strFieldName, nMaxSize) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   var field = eval("form."+strFieldName);
   if (field != null && field.value.length > nMaxSize) {
      alert(IL_MAXSIZETOOBIG + ' (' +nMaxSize+' max.)');
      ilSetFieldFocus(strFormName, strFieldName);
   }

   return false;
}

function ilCheckFieldHtmlCompatibility(strFormName, strFieldName) {
   if (!formCheckFieldContent(strFormName, strFieldName, VERIFYSTRING_COMPATIBLEHTML)) {
      alert(IL_QUIZRENDERER_HTMLVALIDITY+" "+IL_HTMLVALIDITY);
      ilSetFieldFocus(strFormName, strFieldName);
   }
   return false;
}

function ilFilterDimChooserClicked(strFormName) {
   popupParentOpenPopup(strFormName, "winDimChooser", null, null, DimChooserWidth, DimChooserHeight)
}

/*
   Allows IE and netscape to deal with return key !
*/
function ilGetKey(e) {
   if (window.event)
      return window.event.keyCode;
   else if (e)
      return e.which;
   else
      return null;
}

/*
   Default behavior for HTML Focus in editor pages:
   At the moment, this behavior is giving focus to the first HTML Field
   that is editable -> it means either a 'text' or a 'textarea field type
*/
function ilEditorSetFieldFocus(strFormName) {
   return _ilSetFocus(strFormName, "", false, true, false);
}

/*
   Default behavior for HTML Focus in search pages:
   At the moment, this behavior is giving focus to the keyword Field
   For this function to be useful, the keyword field name **MUST** contain "keyword" string
*/
function ilSetKeywordFieldFocus(strFormName) {
   return _ilSetFocus(strFormName, "keyword", false, false, false);
}

/*
   Default behavior for HTML Focus in basic pages:
   At the moment, the default focus is... no focus
*/
function ilSetDefaultFocus(strFormName) {
   return true;
}

/*
   Focuses and selects the given field name.
   This field **MUST** be an editable field (either text OR textarea field type)
*/
function ilSetFieldFocusAndSelect(strFormName, strFieldName) {
   return _ilSetFocus(strFormName, strFieldName, true, true, true);
}

/*
   Focuses the given field name.
*/
function ilSetFieldFocus(strFormName, strFieldName) {
   return _ilSetFocus(strFormName, strFieldName, false, false, true);
}

/*
   DO ** NOT ** CALL DIRECTLY

   strFormName       the current form name
   strFieldName      the name of the field to focus on
   bSelectField      true for the field to be selected
   bEditableField    true to check if the field to focus is a 'text' or 'textarea' field type
   bExactFieldName   true if the given strFieldName is the exact name of the field to focus
                     otherwise, if strFieldName has a value, it will be used as a pattern
*/
function _ilSetFocus(strFormName, strFieldName, bSelectField, bEditableField, bExactFieldName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (popupParentHasPopup(strFormName) == true) {
      return true;
   }

   if (bExactFieldName == true) {
      if (strFieldName != null && strFieldName.length > 0) {
         var field;
         field = form.elements[strFieldName];

         return _ilFocusField(strFormName, field, bSelectField, bEditableField);
      }
   } else {
      var i;
      var currentElement;

      for (i=0; i<form.elements.length; i++) {
         currentElement = form.elements[i];
         if (currentElement.type == "hidden") {
            continue;
         }

         if (strFieldName != null && strFieldName.length > 0) {
            var strName = currentElement.name.toLowerCase();
            if (strName.indexOf(strFieldName.toLowerCase()) == -1) {
               continue;
            } else {
               if (_ilFocusField(strFormName, currentElement, bSelectField, bEditableField))
                  return true;
            }
         } else {
            if (_ilFocusField(strFormName, currentElement, bSelectField, bEditableField))
               return true;
         }
      }
   }
   return false;
}

/*
   DO ** NOT ** CALL DIRECTLY.

   strFormName       the current form name
   field             the object to focus on
   bSelectField      true for the field to be selected
   bEditableField    true to check if the field to focus is a 'text' or 'textarea' field type
*/
function _ilFocusField(strFormName, field, bSelectField, bEditableField) {
   if (bEditableField) {
      if ((field.type != "text" && field.type != "textarea") || field.disabled == true)
         return false;
   }

   try {
      field.focus();
      if (bSelectField == true)
         field.select();
   } catch (e) {
      return false;
   }
   return true;
}

function ilNewFeedback(strFormName, strFeedbackEditorUrl) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (form.DocId != null)
      form.DocId.value = '';
   if (form.SectionId != null)
      form.SectionId.value = '';
   popupParentOpenPopup(strFormName, "FeedbackEditorWindow", null, strFeedbackEditorUrl, 600, 400);

   return false;
}

function ilBoxesViewAll(strFormName, strBoxName, strViewAllPopupUrl) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.BoxName.value = strBoxName;
   form.BoxNameInit.value = '';

   popupParentOpenPopup(strFormName, strBoxName, null, strViewAllPopupUrl, 500, 350);

   return false;
}

function ilAnalyticsBoxesViewAll(strFormName, strBoxName, strBoxNameInit, nChannel, strViewAllPopupUrl) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.BoxNameInit.value = strBoxNameInit;
   form.Channel.value = nChannel;
   form.BoxName.value = strBoxName;

   popupParentOpenPopup(strFormName, strBoxName, null, strViewAllPopupUrl, 500, 350);

   return false;
}

function ilDirectAccessViewAll(strFormName, strBoxName, strViewAllPopupUrl, dimItemId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.DirectAccessDimItemId.value = dimItemId;
   
   return ilBoxesViewAll(strFormName, strBoxName, strViewAllPopupUrl);
}

/**
 * Allows to get the root window
 * Returns the window which opener is null
 *
 * @return  the root window
 */
function ilGetRootOpenerWindow() {
   var win = window;

   if (win.opener == null)
      return win;

   do {
      win = win.opener;
   } while (win.opener != null);

   return win;
}

function ilResizeFrame(theFrame, strFrameWidth) {
   try {
      var innerDoc;
      if (theFrame.Document)
         innerDoc = theFrame.Document;
      else if (theFrame.contentDocument)
         innerDoc = theFrame.contentDocument;
      else if (theFrame.contentWindow.document)
         innerDoc = theFrame.contentWindow.document;
      else
         window.status = "enable to resize the iframe...";
      objToResize = (theFrame.style) ? theFrame.style : theFrame;
      
      var strHeight;
      if (innerDoc.documentElement.scrollHeight>innerDoc.body.scrollHeight)
         strHeight = innerDoc.documentElement.scrollHeight + 250 +"px";
      else
         strHeight = innerDoc.body.scrollHeight + 250 +"px";

      objToResize.height = strHeight;
      //objToResize.width =  strFrameWidth ;
      if (strFrameWidth != "1px") {
         objToResize.width = strFrameWidth;
      } else {
         objToResize.width = innerDoc.body.scrollWidth + 0 + "px";
      }
      
   } catch (e) {
      window.status = e.message;
   }
}


function ilResizeFrameFromId(nFrameId, strFrameWidth) {
   ilResizeFrame(document.getElementById(nFrameId), strFrameWidth);
}

function ilSetTwoStatesInputClickedFromInputName(strFormName, strInputName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   var input = eval("form."+strInputName);
   _ilSetTwoStatesInputClicked(strFormName, input);
   return false;
}

function ilSetTwoStatesInputClickedFromInputId(strFormName, strInputId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   var input = xGetElementById(strInputId);
   _ilSetTwoStatesInputClicked(strFormName, input);
   return false;
}

function ilSetTwoStatesInputClickedFromInput(strFormName, input) {
   _ilSetTwoStatesInputClicked(strFormName, input);
   return false;
}

function _ilSetTwoStatesInputClicked(strFormName, input) {
   if (input != null)
      input.click();
}

//////////// functions to use for a dynamic refresh/display of the content of a <div> tag //////////////
var m_strTagId = "";

/**
 * Refreshes a jsp included in a div tag
 *
 * @param   strNewTagId the including div tag id value
 * @param   strUrl      the url of the jsp to refresh
**/
function ilRefreshDiv(strNewTagId, strUrl) {
   try {
      m_strTagId = strNewTagId;
      _ilLoadXMLDoc(strUrl);
   } catch(e) {
      var strMsg;
      if (typeof e == "string") {
         strMsg = e;
      } else {
         if (e.message) {
            strMsg = e.message;
         } else {
            strMsg = "Unknown Error";
         }
      }
      alert("Unable to get XML data:\n" + strMsg);
      return;
   }
}

function _ilLoadXMLDoc(strUrl) {
   // branch for native XMLHttpRequest object
   if (window.XMLHttpRequest) {
      req = new XMLHttpRequest();
      req.onreadystatechange = _ilProcessReqChange;
      req.open("GET", strUrl, true);
      req.send(null);
   // branch for IE/Windows ActiveX version
   } else if (window.ActiveXObject) {
      isIE = true;
      req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) {
         req.onreadystatechange = _ilProcessReqChange;
         req.open("GET", strUrl, true);
         req.send();
      } else {
         alert("Fatal error: cannot instanciate xmlhttp object");
      }
   }
}

function _ilProcessReqChange() {
   // only if req shows "loaded"
   if (req.readyState == 4) {
      // only if "OK"
      if (req.status == 200) {
         var tag = document.getElementById(m_strTagId);
         if (tag != null)
            tag.innerHTML = req.responseText;
      } else {
         alert("There was a problem retrieving the XML data:\n" +  req.statusText + "(status: "+req.status+")");
      }
   }
}

/**
 * Changes the display value of the given div tag id value.
 * If the 'display' value of the div tag is 'none' or is not set,
 * switches to 'block'. If the value was 'block', switches to 'none'
 *
 * @param   strDiv   the including div tag id value
 */
function ilToggleDiv(strDivId) {
   var div = xGetElementById(strDivId);

   if (div != null) {
      if (div.style.display == "none") {
         _ilShowDiv(strDivId);
      } else {
         if (div.style.display == "block") {
            _ilHideDiv(strDivId);
         } else {
            _ilShowDiv(strDivId);
         }
      }
   }
   return false;
}

function ilToggleVisibility(strId) {
   var div = xGetElementById(strId);

   if (div != null) {
      if (div.style.visibility == "hidden") {
         div.style.visibility = "visible";
      } else if (div.style.visibility == "visible") {
         div.style.visibility = "hidden";
      } else {
         div.style.visibility = "visible";
      }
   }
   return false;
}

function _ilHideDiv(strDivId) {
   var div = xGetElementById(strDivId);
   if (div != null) {
      div.style.display="none";
   }
}

function _ilShowDiv(strDivId) {
   var div = xGetElementById(strDivId);
   if (div != null) {
      div.style.display="block";
   }
}

function _ilCheckDate(form) {
   var objElement;
   var strRoot;
   var nDay, nMonth, nYear;
   var loopEl;
   var EditorWrongDate = IL_DATECHECK_INVALIDDATE;

   for (loopEl = 0; loopEl < form.length; loopEl++) {
      objElement = form.elements[loopEl];
      if (objElement.name.lastIndexOf('_D') == objElement.name.length-2) {
         strRoot = objElement.name.substr(0, objElement.name.length-2);
         strRoot = _ilExtractFieldName(strRoot);

         nDay = eval('form.' + strRoot + '_D').value;
         nMonth = eval('form.' + strRoot + '_M').value;
         nMonth = nMonth - 1;
         nYear = eval('form.' + strRoot + '_Y').value;

         if (nYear == "" && nMonth == -1 && nDay == "") {  //No field set
            return true;
         } else {
            if ((isNaN(nYear)) || nYear<0) {
               alert("'" + strRoot + "' " + EditorWrongDate + "");
               ilSetFieldFocusAndSelect(form.name, strRoot + "_Y");
               return false;
            }

            if ((isNaN(nMonth)) || nMonth<0 || nMonth>11) {
               alert("'" + strRoot + "' " + EditorWrongDate + "");
               ilSetFieldFocusAndSelect(form.name, strRoot + "_M");
               return false;
            }

            if ((isNaN(nDay)) || nDay<1 || nDay>_ilGetDays(nMonth, nYear)) {
               alert("'" + strRoot + "' " + EditorWrongDate + "");
               ilSetFieldFocusAndSelect(form.name, strRoot + "_D");
               return false;
            }
         }
      }
   }

   return _ilCheckDates(form);
}

function _ilCheckDates(form) {
   if ((form.StartDate_Y != null) && (form.EndDate_Y != null)) {
      var startDate = new Date(form.StartDate_Y.value, form.StartDate_M.value, form.StartDate_D.value, 0, 0, 0, 0);
      var endDate = new Date(form.EndDate_Y.value, form.EndDate_M.value, form.EndDate_D.value, 0, 0, 0, 0);

      if (endDate.getTime() < startDate.getTime()) {
         alert(IL_DATECHECK_STARTDATE_AFTER_ENDDATE);
         return false;
      }
   }

   return true;
}

function _ilExtractFieldName(str) {
   // The str begins with Field_
   if (str.substring(0,6)!='Field_') {
      return str;
   }
   str = str.substring(6);
   strMod = str.substring(str.indexOf('_')+1);
   strNumber = strMod.substring(0,strMod.indexOf('_'));
   if (!isNaN(parseInt(strNumber))) {
      strMod = strMod.substring(strMod.indexOf('_') + 1);
   }

   return strMod;
}

function _ilGetDays(month, year) {
   // Test for leap year when February is selected.
   if (1 == month)
      return ((0 == year % 4) && (0 != (year % 100))) || (0 == year % 400) ? 29 : 28;
   else
      return daysInMonth[month];
}


/**
 * Call the command ILCmdDocVote which will store a vote for this document.
 * Needed by IL to fill the working context.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   nDocId the external ID of the doc to remove from favorites
 * @param   strRatingParameterName html parameter name to read.
 * @param   nRating if strRatingParameterName is not set, nRating will be used.
 * @param   strCustomString the custom string to store
 *
 * @return  false
 */

function ilLogEventDocVote(strFormName, nDocId, nRating, strRatingParameterName, strCustomString) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.UEL_DocVote_DocId.value        = nDocId;
   form.UEL_DocVote_CustomString.value = strCustomString;
   form.UEL_DocVote_RatingParameterName.value = strRatingParameterName;
   form.UEL_DocVote_Rating.value= nRating;

   try {
	   if (form.RatingFeedbackEntered && form.RatingFeedbackEntered.value == "1") {
		   var ratingFrame = document.getElementById("ratingFrame").contentWindow;
		   ratingFrame.submitFeedback("I rated this document '" + form.RatingVoteValue.value + "' because...", form.RatingFeedback.value);
	   }
   } catch (e) {
	   alert("Failed to submit feedback: " + e);
   }

   if (form.IsPopup != null && form.IsPopup.value=="true") {
      popupSubmitExecuteCommand(strFormName, getModuleCommandName("CmdDocVote"), form.Origin.value, "_self");
   } else {
      formSubmitExecuteCommand(strFormName, getModuleCommandName("CmdDocVote"), form.Origin.value, "_self");
   }

   return false;
}


// Retrieved from support/selfservice/scripts/iframe.js
var DEF_VAL_SEARCH   = "Search";


/* Resize the iframe of the blob renderer */
function ssdFrameSizerById(idFrame, width, strBgColor) {
   ssdFrameSizer(document.getElementById(idFrame), width, strBgColor);
}

/* iframe re-sizer */
function ssdFrameSizer(theFrame, width, strBgColor) {
   var framewidth = "100px";
   if (width!=null) framewidth = width;
   try {
      var innerDoc;
      if (theFrame.Document)                    innerDoc = theFrame.Document;
      else if (theFrame.contentDocument)        innerDoc = theFrame.contentDocument;
      else if (theFrame.contentWindow.document) innerDoc = theFrame.contentWindow.document;
      else {
         window.status = "unable to resize the iframe...";
         return;
      }
      objToResize = (theFrame.style) ? theFrame.style : theFrame;

      objToResize.width = framewidth;
      
      if (innerDoc.getElementsByTagName("body")[0]!=null) {
         innerDoc.getElementsByTagName("body")[0].style.width = "95%";
         innerDoc.getElementsByTagName("body")[0].style.margin = "0px";
      }
      if (innerDoc.getElementsByTagName("div")[0]!=null)
         innerDoc.getElementsByTagName("div")[0].style.width="100%";
      if (innerDoc.getElementsByTagName("table")[0]!=null)
         innerDoc.getElementsByTagName("table")[0].style.width="100%";
      if (innerDoc.getElementsByTagName("td")[0]!=null)
         innerDoc.getElementsByTagName("td")[0].style.width="100%";

      if (innerDoc.body.scrollHeight>100) {
         var scrollWidth = 0;
         if (innerDoc.body.scrollWidth)
            scrollWidth = 20;
         objToResize.height = innerDoc.body.scrollHeight + scrollWidth +"px";
      } else {
         objToResize.height = "125px";
      }
      

      innerDoc.getElementsByTagName("body")[0].style.backgroundColor = strBgColor;
      innerDoc.getElementsByTagName("html")[0].style.backgroundColor = strBgColor;
   } catch (e) {
      window.status = e.message;
   }
}

// Retrieved from ccil_orangeuk/common/scripts/il.js
var daysInMonth         = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var DimChooserHeight    = 500;
var DimChooserWidth     = 500;

/**
 * View a document in the current window or in a popup depending on a specified boolean
 *
 * @param   strFormName the name of the current HTML form object
 * @param   nDocExtId the identifier of the document to visualize
 * @param   nSecMode the section mode used
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   bViewDocInPopup if true the document will be showed in a popup.
 *
 * @return  false
 */

function ilViewDocument(strFormName, nDocExtId, nSecMode, strUrl, bViewDocInPopup) {
   if (bViewDocInPopup) {
      return ilViewDocumentInPopup(strFormName, strUrl, nDocExtId);
   } else {
      var nIndex = strUrl.indexOf("?",0);
      if (nIndex!=-1) {
         strUrl = strUrl.substring(0, nIndex);
      }
      
      return ilViewDocumentInCurrentWindow(strFormName, nDocExtId, nSecMode, strUrl);
   }
}

/**
 * View a decision tree in the current window or in a popup depending on a specified boolean
 *
 * @param   strFormName the name of the current HTML form object
 * @param   nDocExtId the identifier of the document to visualize
 * @param   nSecMode the section mode used
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   strDTNodeId the absolute id of the node to open the DT on
 * @param   bViewDocInPopup if true the document will be showed in a popup.
 *
 * @return  false
 */
function ilViewDecisionTree(strFormName, nDocExtId, nSecMode, strUrl, strDTNodeId, bViewDocInPopup) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (strDTNodeId != null && form.SelectedNodeAbsExtId != null) {
      form.SelectedNodeAbsExtId.value=strDTNodeId;
      strUrl += "&SelectedNodeAbsExtId="+ strDTNodeId;
   }

   return ilViewDocument(strFormName, nDocExtId, nSecMode, strUrl, bViewDocInPopup);
}



/**
 * View a document in the current window
 *
 * @param   strFormName the name of the current HTML form object
 * @param   nDocExtId the identifier of the document to visualize
 * @param   nSecMode the section mode used
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   strDTNodeId the absolute id of the node to open the DT on
 *
 * @return  false
 */
function ilViewDecisionTreeInCurrentWindow(strFormName, nDocExtId, nSecMode, strUrl, strDTNodeId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (strDTNodeId != null && form.SelectedNodeAbsExtId != null)
      form.SelectedNodeAbsExtId.value=strDTNodeId;

   return ilViewDocumentInCurrentWindow(strFormName, nDocExtId, nSecMode, strUrl);
}



/**
 * View a document in the current window
 *
 * @param   strFormName the name of the current HTML form object
 * @param   nDocExtId the identifier of the document to visualize
 * @param   nSecMode the section mode used
 * @param   strUrl the Renderer URL of the corresponding document
 *
 * @return  false
 */
function ilViewDocumentInCurrentWindow(strFormName, nDocExtId, nSecMode, strUrl) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.DocId.value = nDocExtId;
   form.SecMode.value = nSecMode;
   formSubmitUrl(strFormName, strUrl, "_self");

   return false;
}

/**
 * View a document in a new Popup
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nDocId the identifier of the document to visualize
 *
 * @return  false
 */
function ilViewDecisionTreeDocumentInPopup(strFormName, strUrl, nDocId, strDTNodeId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (strDTNodeId != null && form.SelectedNodeAbsExtId != null)
      form.SelectedNodeAbsExtId.value=strDTNodeId;

   return ilViewDocumentInPopup(strFormName, strUrl, nDocId);
}

/**
 * View a document in a new Popup
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nDocId the identifier of the document to visualize
 *
 * @return  false
 */
function ilViewDocumentInPopup(strFormName, strUrl, nDocId) {
   _ilViewDocumentInPopup(strFormName, strUrl, nDocId, false, "DocumentWindow"+nDocId, false);
   return false;
}



/**
 * View a direct access document in a new windows
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   strPopupName name of the popup
 *
 * @return  false
 */
function ilViewDirectAccessInPopup(strFormName, strUrl, strPopupName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   if (form.Module != null) {
      strUrl = strUrl+"&Module="+ form.Module.value
   }
   window.open(strUrl,strPopupName,"");
   return false;
}


/**
 * View a document in a real Popup.
 * A real popup will be closed on its opener reload.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nDocId the identifier of the document to visualize
 *
 * @return  false
 */
function ilViewDocumentInRealPopup(strFormName, strUrl, nDocId) {
   _ilViewDocumentInPopup(strFormName, strUrl, nDocId, false, "DocumentWindow"+nDocId, true);
   return false
}

/**
 * View a document in a new Popup
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nDocId the identifier of the document to visualize
 * @param   strVersion the version of the current doc (ex: 1.3)
 *
 * @return  false
 */
function ilViewVersionedDocumentInPopup(strFormName, strUrl, nDocId, strVersion) {
   _ilViewDocumentInPopup(strFormName, strUrl, nDocId, true, "DocumentWindow"+strVersion, false);
   return false;
}

/**
 * View a quiz in a new Popup
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nQuizId the identifier of the quiz to visualize
 *
 * @return  false
 */
function ilViewQuizInPopup(strFormName, strUrl, nQuizId) {
   _ilViewDocumentInPopup(strFormName, strUrl, nQuizId, false, "QuizWindow"+nQuizId, false);
   return false;
}

/**
 * View a quiz in a new Popup
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nQuizId the identifier of the quiz to visualize
 * @param   strVersion the version of the current doc (ex: 1.3)
 *
 * @return  false
 */
function ilViewVersionnedQuizInPopup(strFormName, strUrl, nQuizId, strVersion, strVerUUID) {
   strUrl = strUrl + "&DocVerUUID=" + strVerUUID;
   _ilViewDocumentInPopup(strFormName, strUrl, nQuizId, true, "QuizWindow"+strVersion, false);
   return false;
}

/**
 * Displays a quiz.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 *
 * @return  false
 */
function ilViewQuiz(strFormName, strUrl) {
   return _ilViewQuiz(strFormName, strUrl, false);
}

/**
 * Displays a quiz.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 *
 * @return  false
 */
function ilViewVersionnedQuiz(strFormName, strUrl) {
   return _ilViewQuiz(strFormName, strUrl, true);
}

/**
 * Displays a quiz.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 *
 * @return  false
 */
function _ilViewQuiz(strFormName, strUrl, bDisplayVersion) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (bDisplayVersion)
      strUrl = strUrl + "&DisplayVersion=true";
   if (form.IsPopup != null && form.IsPopup.value=="true")
      popupSubmitUrl(strFormName, strUrl, "_self");
   else
      formSubmitUrl(strFormName, strUrl, "_self");

   return false;
}



function _ilViewDocumentInPopup(strFormName, strUrl, nDocId, bDisplayVersion, strPopupName, bIsRealPopup) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   var strModule = form.Module.value;
   strUrl = strUrl + "&IsPopup=true" + "&Module=" + strModule + "&DisplayVersion=" + bDisplayVersion;
   if (form.RendererTargetLanguageId != null)
      strUrl = strUrl + "&RendererTargetLanguageId="+form.RendererTargetLanguageId.value;
   if (bIsRealPopup) {
      strUrl = strUrl + "&TruePopup=true"
      popupParentOpenPopup(strFormName, strPopupName, null, strUrl, 1018, 600);
   } else
      window.open(strUrl,strPopupName,"toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=1018,height=600");

   return false;
}

/**
 * View a reminder in a new Popup
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nDocId the identifier of the document to visualize
 *
 * @return  false
 */
function ilViewReminderInPopup(strFormName, strUrl, nDocId) {
   _ilViewReminderInPopup(strFormName, strUrl, nDocId, false);
   return false;
}

/**
 * View a reminder in a real Popup.
 * A real popup will be closed on its opener reload.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nDocId the identifier of the document to visualize
 *
 * @return  false
 */
function ilViewReminderInRealPopup(strFormName, strUrl, nDocId) {
   _ilViewReminderInPopup(strFormName, strUrl, nDocId, true);
   return false
}

function _ilViewReminderInPopup(strFormName, strUrl, nDocId, bIsRealPopup) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   var strParentFormName = form.ParentFormName.value;
   var strModule = form.Module.value;

   strUrl = strUrl+"&IsPopup=true"+"&Module="+strModule+"&ParentFormName="+strParentFormName;

   if (form.RootParentFormName != null) {
      var strRootParentFormName = form.RootParentFormName.value;
      strUrl = strUrl+"&RootParentFormName="+strRootParentFormName;
   }

   if (bIsRealPopup)
      popupParentOpenPopup(strFormName, "ReminderWindow", null, strUrl, 640, 480);
   else
      window.open(strUrl,"ReminderWindow"+nDocId,"toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=640,height=480");
}


/**
 * View a doc in the main window.
 * To be used from a popup.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strParentFormName the name of the parent form object
 * @param   nDocExtId the external ID of the document to visualize
 * @param   nSecMode the security mode to apply to the doc to display
 * @param   strUrl the Renderer URL of the corresponding document
 *
 * @return  false
 */
function ilViewDocumentFromPopup(strFormName, strParentFormName, nDocExtId, nSecMode, strUrl) {
   var parentForm;
   var win;

   win = ilGetRootOpenerWindow();
   parentForm = win.formGetForm(strParentFormName);
   if (parentForm == null) {
      _formFatal("cannot find a valid form ("+strParentFormName+"). Probably because some fields are missing");
      return false;
   }

   win.ilViewDocumentInCurrentWindow(strParentFormName, nDocExtId, nSecMode, strUrl)

   return false;
}

function ilEaseViewDocumentFromPopup(strFormName, strParentFormName, strTitle, nDocExtId, nSecMode, strUrl) {
   var parentForm;
   var win;

   win = ilGetRootOpenerWindow();

   parentForm = win.formGetForm(strParentFormName);
   if (parentForm == null) {
      _formFatal("cannot find a valid form ("+strParentFormName+"). Probably because some fields are missing");
      return false;
   }

   win.easeViewDocument(strParentFormName, strTitle, nDocExtId, nSecMode, strUrl);

   return false;
}

/**
 * View a feedback in a new Popup
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl the Renderer URL of the corresponding document
 * @param   nDocId the identifier of the document to visualize
 *
 * @return  false
 */
function ilViewFeedbackInPopup(strFormName, strUrl, nDocId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   var strModule = form.Module.value;
   window.open(strUrl+"&IsPopup=true"+"&Module="+strModule,"FeedbackWindow"+nDocId,"toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=560,height=500");

   return false;
}

/**
 * View an alert in a new Popup.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl      the renderer URL of the corresponding document
 * @param   nAlertId    the identifier of the document to visualize
 *
 * @return  false
 */
function ilViewAlertInPopup(strFormName, strUrl, nAlertId) {
   var form              = formGetForm(strFormName);
   var strModule         = form.Module.value;
   var strParentFormName = form.ParentFormName.value;

   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   strUrl = strUrl +"&IsPopup=true"+"&Module="+strModule+"&ParentFormName="+strParentFormName;

   /*popupParentOpenPopup(strFormName, "AlertWindow"+nAlertId, null, strUrl, 560,450);*/

   window.open(strUrl, "AlertWindow"+nAlertId, "toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=560,height=450");

   return false;
}

/**
 * Adds a document to the favorites preference.
 *
 * @param   strFormName the name of the current HTML form object
 * @param nExternalDocumentId the external ID of the doc to add to favorites
 *
 * @return  false
 */
function ilAddFavorites(strFormName, nExternalDocumentId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.AddDocId.value=nExternalDocumentId;
   if (form.IsPopup != null && form.IsPopup.value=="true")
      popupSubmitExecuteCommand(strFormName, getModuleCommandName("CmdFavoritesAdd"), form.Origin.value, "_self");
   else
      formSubmitExecuteCommand(strFormName, getModuleCommandName("CmdFavoritesAdd"), form.Origin.value, "_self");

   return false;
}

/**
 * Empties the favorites documents list.
 *
 * @param   strFormName the name of the current HTML form object
 * @return  false
 */
function ilEmptyFavorites(strFormName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (confirm(IL_FAVORITESDELETEALL)) {
      form.FavoritesRemoveAll.value="true";
      formSubmitExecuteCommand(strFormName, getModuleCommandName("CmdFavoritesDel"), form.Origin.value, "_self");
   }

   return false;
}

/**
 * Removes a document from the favorites documents list
 *
 * @param   strFormName the name of the current HTML form object
 * @param nExternalDocumentId the external ID of the doc to remove from favorites
 *
 * @return  false
 */
function ilRemoveFavorite(strFormName, nDocId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.FavoritesRemoveId.value=nDocId;
   formSubmitExecuteCommand(strFormName, getModuleCommandName("CmdFavoritesDel"), form.Origin.value, "_self");

   return false;
}

// START Remove favorites from boxesdocslist
function ilRemoveFavoriteAndParentRefresh(strFormName, nDocId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form. Probably because some fields are missing");
      return false;
   }

   form.FavoritesRemoveId.value=nDocId;
   popupSubmitExecuteCommandAndParentRefresh(strFormName, getModuleCommandName("CmdFavoritesDel"),  form.Origin.value, "_self")
   return false;
}
// END Remove favorites from boxesdocslist


/**
 * minimize the documents list box
 *
 * @param   strFormName       the name of the current HTML form object
 * @param   strBoxToMinimize  the name of the documents list box to minimize
 * @param   bBoxMinimized     tells if the box is minimized or not
 *
 * @return  false
 */
function ilMinimizeBox(strFormName, strBoxToMinimize, bBoxMinimized) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.BoxToMinimize.value=strBoxToMinimize;
   form.BoxMinimized.value=bBoxMinimized;

   formSubmitExecuteCommand(strFormName, getModuleCommandName("CmdMinimizeBox"), form.Origin.value, "_self");

   return false;
}

/**
 * Allows to change the selected menu tab.
 *
 * @param   strFormName    the name of the current HTML form object
 * @param   strTabSel      the ID of the tab selected
 * @param   strUrl         the URL corresponding to the selected tab
 * @param   strMenuSel     the hidden field used to set the selection
 * @param   strCallBack    if "true", thisfunction will cann menuCallBack which must be declared and define by the caller
 */

function ilSelectMenuTab(strFormName, strTabSel, strUrl, strMenuSel, strCallBack, strMenuLock, strKeptParameters) {
   if (strMenuLock=="true") {
      alert(IL_MENULOCKED);
      return false;
   }

   var menuSel;
   var form = formGetForm(strFormName);

   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   menuSel = eval("document." + form.name + "." + strMenuSel);
   menuSel.value = strTabSel;

   if (form.KeepParameters != null) {
      form.KeepParameters.value = strKeptParameters;
   }

   return _ilGoto(form, strFormName, strUrl, strCallBack, '_self');
}


/**
 * Allows to change the module
 *
 * @param   strFormName    the name of the current HTML form object
 * @param   strUrl         the URL corresponding to the selected tab
 * @param   strCallBack    if "true", thisfunction will can menuCallBack which must be declared and define by the caller
 * @param   strNewModule   the name of the new module to switch to
 */
function ilSelectModule(strFormName, strUrl, strCallBack, strMenuLock, strNewModule, strTarget) {
   if (strMenuLock=="true") {
      alert(IL_MENULOCKED);
      return false;
   }

   var menuSel;
   var form = formGetForm(strFormName);

   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.Module.value = strNewModule;

   if (form.KeepParameters != null) {
      form.KeepParameters.value = "Module";
   }

   return _ilGoto(form, strFormName, strUrl, strCallBack, strTarget);
}

/**
 * Edits the user's informations.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strUrl      the URL used to display the editor popup
 * @param   strAllowSubmit    if "false", the user will not be able to click on submit... No reload of the page.
 *
 * @return  false
 */
function ilEditUserInfo(strFormName, strUrl) {

   popupParentOpenPopup(strFormName, "EditUserInfo", null, strUrl, 430, 320);

   return false;
}

/**
 * Edits a  date.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strDateEditorUrl the date editor URL
 * @param   strDateInputPrefix the date input name prefix defined in the parent form
 *
 * @return  false
 */
function ilEditDate(strFormName, strDateEditorUrl, strDateInputPrefix) {
   return _ilOpenDateEditor(strFormName, strDateEditorUrl,-1, "EditDate", strDateInputPrefix);
}

/**
 * Edits a validity start date.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strDateEditorUrl the date editor URL
 *
 * @return  false
 */
function ilEditStartDate(strFormName, strDateEditorUrl) {
   return _ilOpenDateEditor(strFormName, strDateEditorUrl, 2, "EditStartDate", "");
}

/**
 * Edits a validity end date.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strDateEditorUrl the date editor URL
 *
 * @return  false
 */
function ilEditEndDate(strFormName, strDateEditorUrl, strDateInputPrefix) {
   return _ilOpenDateEditor(strFormName, strDateEditorUrl, 3, "EditEndDate", "");
}

/**
 * Edits a validity start date.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strDateEditorUrl the date editor URL
 *
 * @return  false
 */
function ilEditValidityStartDate(strFormName, strDateEditorUrl, strDateInputPrefix) {
   return _ilOpenDateEditor(strFormName, strDateEditorUrl, 2, "EditValidityStartDate", strDateInputPrefix);
}

/**
 * Edits a validity end date.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strDateEditorUrl the date editor URL
 *
 * @return  false
 */
function ilEditValidityEndDate(strFormName, strDateEditorUrl, strDateInputPrefix) {
   return _ilOpenDateEditor(strFormName, strDateEditorUrl, 3, "EditValidityEndDate", strDateInputPrefix);
}

/**
 * Edits a visibility start date.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strDateEditorUrl the date editor URL
 *
 * @return  false
 */
function ilEditVisibilityStartDate(strFormName, strDateEditorUrl, strDateInputPrefix) {
   return _ilOpenDateEditor(strFormName, strDateEditorUrl, 0, "EditVisibilityStartDate", strDateInputPrefix);
}

/**
 * Edits a visibility end date.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   strDateEditorUrl the date editor URL
 *
 * @return  false
 */
function ilEditVisibilityEndDate(strFormName, strDateEditorUrl, strDateInputPrefix) {
   return _ilOpenDateEditor(strFormName, strDateEditorUrl, 1, "EditVisibilityEndDate", strDateInputPrefix);
}

function _ilGoto(form, strFormName, strUrl, strCallBack, strTarget) {
   var kp = form.KeepParameters;

   if (strCallBack != "true") {
      if ((kp == null) || (kp.value.length == 0) || (kp.value == KEEP_ALL_PARAMETERS)) {
         formSubmitUrl(strFormName, strUrl, strTarget);
      } else {
         var strKp = "";

         if (document.forms[KEEP_PARAMETERS_FORM] != null) {
            document.removeChild(document.forms[KEEP_PARAMETERS_FORM]);
         }

         var newForm = document.createElement("FORM");
         newForm.name = KEEP_PARAMETERS_FORM;
         newForm.action = strUrl;
         newForm.target = strTarget;
         newForm.method = "POST";

         // The fields _Popups and _ParentFormName are needed by formSubmitUrl function.
         popupParentCloseAllPopupsOnUnload(form.name); // allow to update correctly _Popups in the source form before copy it
         if (form._Popups != null) {
            var newInput = document.createElement("INPUT");
            newInput.type = "hidden";
            newInput.name = "_Popups";
            newInput.value = form._Popups.value;

            newForm.appendChild(newInput);
         }

         if (form._ParentFormName != null) {
            var newInput = document.createElement("INPUT");
            newInput.type = "hidden";
            newInput.name = "_ParentFormName";
            newInput.value = form._ParentFormName.value;

            newForm.appendChild(newInput);
         }

         if (kp.value != KEEP_NO_PARAMETER) {
            var akp = kp.value.split(",");

            for(i = 0; i < akp.length; i++) {
               var obj = eval("document." + strFormName + "." + akp[i]);
               if (obj != null) {
                  var newInput = document.createElement("INPUT");
                  newInput.type = "hidden";
                  newInput.name = akp[i];
                  newInput.value = obj.value;

                  newForm.appendChild(newInput);
               }
            }
         }
         document.body.appendChild(newForm);

         formSubmitUrl(KEEP_PARAMETERS_FORM, strUrl, strTarget);
      }
   } else {
      menuCallBack(strFormName, strUrl);
   }

   return false;
}


function _ilOpenDateEditor(strFormName, strDateEditorUrl, nDateType, strPopupName, strDateInputPrefix) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (form.Module != null)
      strDateEditorUrl+= "?Module="+form.Module.value;
   strDateEditorUrl+= "&ParentFormName="+form.name;

   // nDateType :
   //    * 0 : Visibility Start Date
   //    * 1 : Visibility End Date
   //    * 2 : Validity Start Date
   //    * 3 : Validity End Date
   if (form.CalendarDate != null)
      form.CalendarDate.value=nDateType;
   if (strDateInputPrefix != "") {
      strDateEditorUrl+= "&DateInputPrefix="+strDateInputPrefix;
      
      var nDay = eval("form." + strDateInputPrefix + "_D");
      var nMonth = eval("form." + strDateInputPrefix + "_M");
      var nYear = eval("form." + strDateInputPrefix + "_Y");
      
      strDateEditorUrl+= "&" + strDateInputPrefix + "_D=" + nDay.value;
      strDateEditorUrl+= "&" + strDateInputPrefix + "_M=" + nMonth.value;
      strDateEditorUrl+= "&" + strDateInputPrefix + "_Y=" + nYear.value;
   }
   else if (form.DateInputPrefix != null)
      strDateEditorUrl+= "&DateInputPrefix="+form.DateInputPrefix.value;

   popupParentOpenPopup(strFormName, strPopupName, null, strDateEditorUrl, 234, 200);

   return false;
}

/**
 * Allows to restart a training session.
 *
 * @param   strFormName          the name of the current HTML form object
 * @param   nUserExamSessionId   the training user id
 *
 * @return  false
 */
function ilRestartTrainingSession(strFormName, nUserExamSessionId, strRedirect) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.UserTrainingSessionId.value = nUserExamSessionId;
   formSubmitExecuteCommand(strFormName, getModuleCommandName("AdmCmdQuizRestart"), strRedirect, "_self");

   return false;
}

function ilRequestTrainingSession(strFormName, strDocId, strDocIdInputName, strRedirect) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   var docInput = eval("form."+strDocIdInputName);
   docInput.value = strDocId;

   formSubmitExecuteCommand(strFormName, getModuleCommandName("AdmCmdQuizRequest"), strRedirect, "_self");
   return false;
}

function ilDeleteTrainingSession(strFormName, nUserExamSessionId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (form.UserTrainingSessionId != null)
      form.UserTrainingSessionId.value = nUserExamSessionId;
   else {
      var input = document.createElement("INPUT");
      input.type = "hidden";
      input.name = "UserTrainingSessionId";
      input.value = nUserExamSessionId;

      form.appendChild(input);
   }

   formSubmitExecuteCommand(strFormName, getModuleCommandName("AdmCmdQuizDelete"), form.Origin.value, "_self");
   return false;
}

function ilDeleteAllTrainingSession(strFormName, strUserExamSessionIds) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (!confirm(ILFO_TRAINING_CONFIRMDELETESESSIONS))
      return false;

   if (strUserExamSessionIds != null && strUserExamSessionIds.length > 0) {
      var userSessions = document.createElement("INPUT");
      userSessions.type = "hidden";
      userSessions.name = "UserTrainingSessionIds";
      userSessions.value = strUserExamSessionIds;

      form.appendChild(userSessions);

      formSubmitExecuteCommand(strFormName, getModuleCommandName("AdmCmdQuizDelete"), form.Origin.value, "_self");
   }
   return false;
}

function ilCheckFieldMaxSize(strFormName, strFieldName, nMaxSize) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   var field = eval("form."+strFieldName);
   if (field != null && field.value.length > nMaxSize) {
      alert(IL_MAXSIZETOOBIG + ' (' +nMaxSize+' max.)');
      ilSetFieldFocus(strFormName, strFieldName);
   }

   return false;
}

function ilCheckFieldHtmlCompatibility(strFormName, strFieldName) {
   if (!formCheckFieldContent(strFormName, strFieldName, VERIFYSTRING_COMPATIBLEHTML)) {
      alert(IL_QUIZRENDERER_HTMLVALIDITY+" "+IL_HTMLVALIDITY);
      ilSetFieldFocus(strFormName, strFieldName);
   }
   return false;
}

function ilFilterDimChooserClicked(strFormName) {
   popupParentOpenPopup(strFormName, "winDimChooser", null, null, DimChooserWidth, DimChooserHeight)
}

/*
   Allows IE and netscape to deal with return key !
*/
function ilGetKey(e) {
   if (window.event)
      return window.event.keyCode;
   else if (e)
      return e.which;
   else
      return null;
}

/*
   Default behavior for HTML Focus in editor pages:
   At the moment, this behavior is giving focus to the first HTML Field
   that is editable -> it means either a 'text' or a 'textarea field type
*/
function ilEditorSetFieldFocus(strFormName) {
   return _ilSetFocus(strFormName, "", false, true, false);
}

/*
   Default behavior for HTML Focus in search pages:
   At the moment, this behavior is giving focus to the keyword Field
   For this function to be useful, the keyword field name **MUST** contain "keyword" string
*/
function ilSetKeywordFieldFocus(strFormName) {
   return _ilSetFocus(strFormName, "keyword", false, false, false);
}

/*
   Default behavior for HTML Focus in basic pages:
   At the moment, the default focus is... no focus
*/
function ilSetDefaultFocus(strFormName) {
   return true;
}

/*
   Focuses and selects the given field name.
   This field **MUST** be an editable field (either text OR textarea field type)
*/
function ilSetFieldFocusAndSelect(strFormName, strFieldName) {
   return _ilSetFocus(strFormName, strFieldName, true, true, true);
}

/*
   Focuses the given field name.
*/
function ilSetFieldFocus(strFormName, strFieldName) {
   return _ilSetFocus(strFormName, strFieldName, false, false, true);
}

/*
   DO ** NOT ** CALL DIRECTLY

   strFormName       the current form name
   strFieldName      the name of the field to focus on
   bSelectField      true for the field to be selected
   bEditableField    true to check if the field to focus is a 'text' or 'textarea' field type
   bExactFieldName   true if the given strFieldName is the exact name of the field to focus
                     otherwise, if strFieldName has a value, it will be used as a pattern
*/
function _ilSetFocus(strFormName, strFieldName, bSelectField, bEditableField, bExactFieldName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (popupParentHasPopup(strFormName) == true) {
      return true;
   }

   if (bExactFieldName == true) {
      if (strFieldName != null && strFieldName.length > 0) {
         var field;
         field = form.elements[strFieldName];

         return _ilFocusField(strFormName, field, bSelectField, bEditableField);
      }
   } else {
      var i;
      var currentElement;

      for (i=0; i<form.elements.length; i++) {
         currentElement = form.elements[i];
         if (currentElement.type == "hidden") {
            continue;
         }

         if (strFieldName != null && strFieldName.length > 0) {
            var strName = currentElement.name.toLowerCase();
            if (strName.indexOf(strFieldName.toLowerCase()) == -1) {
               continue;
            } else {
               if (_ilFocusField(strFormName, currentElement, bSelectField, bEditableField))
                  return true;
            }
         } else {
            if (_ilFocusField(strFormName, currentElement, bSelectField, bEditableField))
               return true;
         }
      }
   }
   return false;
}

/*
   DO ** NOT ** CALL DIRECTLY.

   strFormName       the current form name
   field             the object to focus on
   bSelectField      true for the field to be selected
   bEditableField    true to check if the field to focus is a 'text' or 'textarea' field type
*/
function _ilFocusField(strFormName, field, bSelectField, bEditableField) {
   if (bEditableField) {
      if ((field.type != "text" && field.type != "textarea") || field.disabled == true)
         return false;
   }

   try {
      field.focus();
      if (bSelectField == true)
         field.select();
   } catch (e) {
      return false;
   }
   return true;
}

function ilNewFeedback(strFormName, strFeedbackEditorUrl) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   if (form.DocId != null)
      form.DocId.value = '';
   if (form.SectionId != null)
      form.SectionId.value = '';
   popupParentOpenPopup(strFormName, "FeedbackEditorWindow", null, strFeedbackEditorUrl, 600, 400);

   return false;
}

function ilBoxesViewAll(strFormName, strBoxName, strViewAllPopupUrl) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.BoxName.value = strBoxName;
   form.BoxNameInit.value = '';

   popupParentOpenPopup(strFormName, strBoxName, null, strViewAllPopupUrl, 500, 350);

   return false;
}

function ilAnalyticsBoxesViewAll(strFormName, strBoxName, strBoxNameInit, nChannel, strViewAllPopupUrl) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.BoxNameInit.value = strBoxNameInit;
   form.Channel.value = nChannel;
   form.BoxName.value = strBoxName;

   popupParentOpenPopup(strFormName, strBoxName, null, strViewAllPopupUrl, 500, 350);

   return false;
}

function ilDirectAccessViewAll(strFormName, strBoxName, strViewAllPopupUrl, dimItemId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.DirectAccessDimItemId.value = dimItemId;
   
   return ilBoxesViewAll(strFormName, strBoxName, strViewAllPopupUrl);
}

/**
 * Allows to get the root window
 * Returns the window which opener is null
 *
 * @return  the root window
 */
function ilGetRootOpenerWindow() {
   var win = window;

   if (win.opener == null)
      return win;

   do {
      win = win.opener;
   } while (win.opener != null);

   return win;
}

function ilResizeFrame(theFrame, strFrameWidth) {
   try {
      var innerDoc;
      if (theFrame.Document)
         innerDoc = theFrame.Document;
      else if (theFrame.contentDocument)
         innerDoc = theFrame.contentDocument;
      else if (theFrame.contentWindow.document)
         innerDoc = theFrame.contentWindow.document;
      else
         window.status = "enable to resize the iframe...";
      objToResize = (theFrame.style) ? theFrame.style : theFrame;
      
      var strHeight;
      if (innerDoc.documentElement.scrollHeight>innerDoc.body.scrollHeight)
         strHeight = innerDoc.documentElement.scrollHeight + 250 +"px";
      else
         strHeight = innerDoc.body.scrollHeight + 250 +"px";

      objToResize.height = strHeight;
      //objToResize.width =  strFrameWidth ;
      if (strFrameWidth != "1px") {
         objToResize.width = strFrameWidth;
      } else {
         objToResize.width = innerDoc.body.scrollWidth + 0 + "px";
      }
      
   } catch (e) {
      window.status = e.message;
   }
}


function ilResizeFrameFromId(nFrameId, strFrameWidth) {
   ilResizeFrame(document.getElementById(nFrameId), strFrameWidth);
}

function ilSetTwoStatesInputClickedFromInputName(strFormName, strInputName) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   var input = eval("form."+strInputName);
   _ilSetTwoStatesInputClicked(strFormName, input);
   return false;
}

function ilSetTwoStatesInputClickedFromInputId(strFormName, strInputId) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("Cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }
   var input = xGetElementById(strInputId);
   _ilSetTwoStatesInputClicked(strFormName, input);
   return false;
}

function ilSetTwoStatesInputClickedFromInput(strFormName, input) {
   _ilSetTwoStatesInputClicked(strFormName, input);
   return false;
}

function _ilSetTwoStatesInputClicked(strFormName, input) {
   if (input != null)
      input.click();
}

//////////// functions to use for a dynamic refresh/display of the content of a <div> tag //////////////
var m_strTagId = "";

/**
 * Refreshes a jsp included in a div tag
 *
 * @param   strNewTagId the including div tag id value
 * @param   strUrl      the url of the jsp to refresh
**/
function ilRefreshDiv(strNewTagId, strUrl) {
   try {
      m_strTagId = strNewTagId;
      _ilLoadXMLDoc(strUrl);
   } catch(e) {
      var strMsg;
      if (typeof e == "string") {
         strMsg = e;
      } else {
         if (e.message) {
            strMsg = e.message;
         } else {
            strMsg = "Unknown Error";
         }
      }
      alert("Unable to get XML data:\n" + strMsg);
      return;
   }
}

function _ilLoadXMLDoc(strUrl) {
   // branch for native XMLHttpRequest object
   if (window.XMLHttpRequest) {
      req = new XMLHttpRequest();
      req.onreadystatechange = _ilProcessReqChange;
      req.open("GET", strUrl, true);
      req.send(null);
   // branch for IE/Windows ActiveX version
   } else if (window.ActiveXObject) {
      isIE = true;
      req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) {
         req.onreadystatechange = _ilProcessReqChange;
         req.open("GET", strUrl, true);
         req.send();
      } else {
         alert("Fatal error: cannot instanciate xmlhttp object");
      }
   }
}

function _ilProcessReqChange() {
   // only if req shows "loaded"
   if (req.readyState == 4) {
      // only if "OK"
      if (req.status == 200) {
         var tag = document.getElementById(m_strTagId);
         if (tag != null)
            tag.innerHTML = req.responseText;
      } else {
         alert("There was a problem retrieving the XML data:\n" +  req.statusText + "(status: "+req.status+")");
      }
   }
}

/**
 * Changes the display value of the given div tag id value.
 * If the 'display' value of the div tag is 'none' or is not set,
 * switches to 'block'. If the value was 'block', switches to 'none'
 *
 * @param   strDiv   the including div tag id value
 */
function ilToggleDiv(strDivId) {
   var div = xGetElementById(strDivId);

   if (div != null) {
      if (div.style.display == "none") {
         _ilShowDiv(strDivId);
      } else {
         if (div.style.display == "block") {
            _ilHideDiv(strDivId);
         } else {
            _ilShowDiv(strDivId);
         }
      }
   }
   return false;
}

function ilToggleVisibility(strId) {
   var div = xGetElementById(strId);

   if (div != null) {
      if (div.style.visibility == "hidden") {
         div.style.visibility = "visible";
      } else if (div.style.visibility == "visible") {
         div.style.visibility = "hidden";
      } else {
         div.style.visibility = "visible";
      }
   }
   return false;
}

function _ilHideDiv(strDivId) {
   var div = xGetElementById(strDivId);
   if (div != null) {
      div.style.display="none";
   }
}

function _ilShowDiv(strDivId) {
   var div = xGetElementById(strDivId);
   if (div != null) {
      div.style.display="block";
   }
}

function _ilCheckDate(form) {
   var objElement;
   var strRoot;
   var nDay, nMonth, nYear;
   var loopEl;
   var EditorWrongDate = IL_DATECHECK_INVALIDDATE;

   for (loopEl = 0; loopEl < form.length; loopEl++) {
      objElement = form.elements[loopEl];
      if (objElement.name.lastIndexOf('_D') == objElement.name.length-2) {
         strRoot = objElement.name.substr(0, objElement.name.length-2);
         strRoot = _ilExtractFieldName(strRoot);

         nDay = eval('form.' + strRoot + '_D').value;
         nMonth = eval('form.' + strRoot + '_M').value;
         nMonth = nMonth - 1;
         nYear = eval('form.' + strRoot + '_Y').value;

         if (nYear == "" && nMonth == -1 && nDay == "") {  //No field set
            return true;
         } else {
            if ((isNaN(nYear)) || nYear<0) {
               alert("'" + strRoot + "' " + EditorWrongDate + "");
               ilSetFieldFocusAndSelect(form.name, strRoot + "_Y");
               return false;
            }

            if ((isNaN(nMonth)) || nMonth<0 || nMonth>11) {
               alert("'" + strRoot + "' " + EditorWrongDate + "");
               ilSetFieldFocusAndSelect(form.name, strRoot + "_M");
               return false;
            }

            if ((isNaN(nDay)) || nDay<1 || nDay>_ilGetDays(nMonth, nYear)) {
               alert("'" + strRoot + "' " + EditorWrongDate + "");
               ilSetFieldFocusAndSelect(form.name, strRoot + "_D");
               return false;
            }
         }
      }
   }

   return _ilCheckDates(form);
}

function _ilCheckDates(form) {
   if ((form.StartDate_Y != null) && (form.EndDate_Y != null)) {
      var startDate = new Date(form.StartDate_Y.value, form.StartDate_M.value, form.StartDate_D.value, 0, 0, 0, 0);
      var endDate = new Date(form.EndDate_Y.value, form.EndDate_M.value, form.EndDate_D.value, 0, 0, 0, 0);

      if (endDate.getTime() < startDate.getTime()) {
         alert(IL_DATECHECK_STARTDATE_AFTER_ENDDATE);
         return false;
      }
   }

   return true;
}

function _ilExtractFieldName(str) {
   // The str begins with Field_
   if (str.substring(0,6)!='Field_') {
      return str;
   }
   str = str.substring(6);
   strMod = str.substring(str.indexOf('_')+1);
   strNumber = strMod.substring(0,strMod.indexOf('_'));
   if (!isNaN(parseInt(strNumber))) {
      strMod = strMod.substring(strMod.indexOf('_') + 1);
   }

   return strMod;
}

function _ilGetDays(month, year) {
   // Test for leap year when February is selected.
   if (1 == month)
      return ((0 == year % 4) && (0 != (year % 100))) || (0 == year % 400) ? 29 : 28;
   else
      return daysInMonth[month];
}


/**
 * Call the command ILCmdDocVote which will store a vote for this document.
 * Needed by IL to fill the working context.
 *
 * @param   strFormName the name of the current HTML form object
 * @param   nDocId the external ID of the doc to remove from favorites
 * @param   strRatingParameterName html parameter name to read.
 * @param   nRating if strRatingParameterName is not set, nRating will be used.
 * @param   strCustomString the custom string to store
 *
 * @return  false
 */

function ilLogEventDocVote(strFormName, nDocId, nRating, strRatingParameterName, strCustomString) {
   var form = formGetForm(strFormName);
   if (form == null) {
      _formFatal("cannot find a valid form ("+strFormName+"). Probably because some fields are missing");
      return false;
   }

   form.UEL_DocVote_DocId.value        = nDocId;
   form.UEL_DocVote_CustomString.value = strCustomString;
   form.UEL_DocVote_RatingParameterName.value = strRatingParameterName;
   form.UEL_DocVote_Rating.value= nRating;

   try {
	   if (form.RatingFeedbackEntered && form.RatingFeedbackEntered.value == "1") {
		   var ratingFrame = document.getElementById("ratingFrame").contentWindow;
		   ratingFrame.submitFeedback("I rated this document '" + form.RatingVoteValue.value + "' because...", form.RatingFeedback.value);
	   }
   } catch (e) {
	   alert("Failed to submit feedback: " + e);
   }

   if (form.IsPopup != null && form.IsPopup.value=="true") {
      popupSubmitExecuteCommand(strFormName, getModuleCommandName("CmdDocVote"), form.Origin.value, "_self");
   } else {
      formSubmitExecuteCommand(strFormName, getModuleCommandName("CmdDocVote"), form.Origin.value, "_self");
   }

   return false;
}


// Retrieved from il/common/scripts/x.js
// x.js
// X v3.14.1, Cross-Browser DHTML Library from Cross-Browser.com
// Copyright (c) 2002,2003 Michael Foster (mike@cross-browser.com)
// This library is distributed under the terms of the LGPL (gnu.org)

// Variables:
var xVersion='3.14.1',xOp7=false,xOp5or6=false,xIE4Up=false,xNN4=false,xUA=navigator.userAgent.toLowerCase();
if(window.opera){
  xOp7=(xUA.indexOf('opera 7')!=-1 || xUA.indexOf('opera/7')!=-1);
  if (!xOp7) xOp5or6=(xUA.indexOf('opera 5')!=-1 || xUA.indexOf('opera/5')!=-1 || xUA.indexOf('opera 6')!=-1 || xUA.indexOf('opera/6')!=-1);
}
else if(document.layers) {xNN4=true;}
else {xIE4Up=document.all && xUA.indexOf('msie')!=-1 && parseInt(navigator.appVersion)>=4;}
// Object:
function xGetElementById(e) {
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else if(document.layers) e=xLayer(e);
  else e=null;
  return e;
}
function xParent(e,bNode){
  if (!(e=xGetElementById(e))) return null;
  var p=null;
  if (!bNode && xDef(e.offsetParent)) p=e.offsetParent;
  else if (xDef(e.parentNode)) p=e.parentNode;
  else if (xDef(e.parentElement)) p=e.parentElement;
  else if (xDef(e.parentLayer)){if (e.parentLayer!=window) p=e.parentLayer;}
  return p;
}
function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}
function xStr(s) {
  return typeof(s)=='string';
}
function xNum(n) {
  return typeof(n)=='number';
}
// Appearance:
function xShow(e) {
  if(!(e=xGetElementById(e))) return;
  if(e.style && xDef(e.style.visibility)) e.style.visibility='visible';
  else if(xDef(e.visibility)) e.visibility='show';
}
function xHide(e) {
  if(!(e=xGetElementById(e))) return;
  if(e.style && xDef(e.style.visibility)) e.style.visibility='hidden';
  else if(xDef(e.visibility)) e.visibility='hide';
}
function xZIndex(e,uZ) {
  if(!(e=xGetElementById(e))) return 0;
  if(e.style && xDef(e.style.zIndex)) {
    if(xNum(uZ)) e.style.zIndex=uZ;
    uZ=parseInt(e.style.zIndex);
  }
  else if(xDef(e.zIndex)) {
    if(xNum(uZ)) e.zIndex=uZ;
    uZ=e.zIndex;
  }
  return uZ;
}
function xColor(e,sColor) {
  if(!(e=xGetElementById(e))) return '';
  var c='';
  if(e.style && xDef(e.style.color)) {
    if(xStr(sColor)) e.style.color=sColor;
    c=e.style.color;
  }
  return c;
}
function xBackground(e,sColor,sImage) {
  if(!(e=xGetElementById(e))) return '';
  var bg='';
  if(e.style) {
    if(xStr(sColor)) {
      if(!xOp5or6) e.style.backgroundColor=sColor;
      else e.style.background=sColor;
    }
    if(xStr(sImage)) e.style.backgroundImage=(sImage!='')? 'url('+sImage+')' : null;
    if(!xOp5or6) bg=e.style.backgroundColor;
    else bg=e.style.background;
  }
  else if(xDef(e.bgColor)) {
    if(xStr(sColor)) e.bgColor=sColor;
    bg=e.bgColor;
    if(xStr(sImage)) e.background.src=sImage;
  }
  return bg;
}
// Position:
function xMoveTo(e,iX,iY) {
  xLeft(e,iX);
  xTop(e,iY);
}
function xLeft(e,iX) {
  if(!(e=xGetElementById(e))) return 0;
  var css=xDef(e.style);
  if (css && xStr(e.style.left)) {
    if(xNum(iX)) e.style.left=iX+'px';
    else {
      iX=parseInt(e.style.left);
      if(isNaN(iX)) iX=0;
    }
  }
  else if(css && xDef(e.style.pixelLeft)) {
    if(xNum(iX)) e.style.pixelLeft=iX;
    else iX=e.style.pixelLeft;
  }
  else if(xDef(e.left)) {
    if(xNum(iX)) e.left=iX;
    else iX=e.left;
  }
  return iX;
}
function xTop(e,iY) {
  if(!(e=xGetElementById(e))) return 0;
  var css=xDef(e.style);
  if(css && xStr(e.style.top)) {
    if(xNum(iY)) e.style.top=iY+'px';
    else {
      iY=parseInt(e.style.top);
      if(isNaN(iY)) iY=0;
    }
  }
  else if(css && xDef(e.style.pixelTop)) {
    if(xNum(iY)) e.style.pixelTop=iY;
    else iY=e.style.pixelTop;
  }
  else if(xDef(e.top)) {
    if(xNum(iY)) e.top=iY;
    else iY=e.top;
  }
  return iY;
}
function xPageX(e) {
  if (!(e=xGetElementById(e))) return 0;
  if (xDef(e.pageX)) return e.pageX;
  var x = 0;
  while (e) {
    if (xDef(e.offsetLeft)) x += e.offsetLeft;
    e = xDef(e.offsetParent) ? e.offsetParent : null;
  }
  return x;
}
function xPageY(e) {
  if (!(e=xGetElementById(e))) return 0;
  if (xDef(e.pageY)) return e.pageY;
  var y = 0;
  while (e) {
    if (xDef(e.offsetTop)) y += e.offsetTop;
    e = xDef(e.offsetParent) ? e.offsetParent : null;
  }
//  if (xOp7) return y - document.body.offsetTop; // v3.14, temporary hack for opera bug 130324
  return y;
}
function xOffsetLeft(e) { // v3.14, see x_nn4.js
  if (!(e=xGetElementById(e))) return 0;
  if (xDef(e.offsetLeft)) return e.offsetLeft;
  else return 0;
}
function xOffsetTop(e) {
  if (!(e=xGetElementById(e))) return 0;
  if (xDef(e.offsetTop)) return e.offsetTop;
  else return 0;
}
function xScrollLeft(e) {
  var offset=0;
  if (!(e=xGetElementById(e))) {
    if(xDef(window.pageXOffset)) offset=window.pageXOffset;
    else if(document.documentElement && document.documentElement.scrollLeft) offset=document.documentElement.scrollLeft;
    else if(document.body && xDef(document.body.scrollLeft)) offset=document.body.scrollLeft;
  }
  else { if (xNum(e.scrollLeft)) offset = e.scrollLeft; }
  return offset;
}
function xScrollTop(e) {
  var offset=0;
  if (!(e=xGetElementById(e))) {
    if(xDef(window.pageYOffset)) offset=window.pageYOffset;
    else if(document.documentElement && document.documentElement.scrollTop) offset=document.documentElement.scrollTop;
    else if(document.body && xDef(document.body.scrollTop)) offset=document.body.scrollTop;
  }
  else { if (xNum(e.scrollTop)) offset = e.scrollTop; }
  return offset;
}
// Size:
function xResizeTo(e,uW,uH) {
  xWidth(e,uW);
  xHeight(e,uH);
}
function xWidth(e,uW) {
  if(!(e=xGetElementById(e))) return 0;
  if (xNum(uW)) { // v3.13.1
    if (uW<0) uW = 0;
    else uW=Math.round(uW);
  }
  else uW=0;
  var css=xDef(e.style);
  if(css && xDef(e.offsetWidth) && xStr(e.style.width)) {
    if(uW) xSetCW(e, uW);
    uW=e.offsetWidth;
  }
  else if(css && xDef(e.style.pixelWidth)) {
    if(uW) e.style.pixelWidth=uW;
    uW=e.style.pixelWidth;
  }
  else if(xDef(e.clip) && xDef(e.clip.right)) {
    if(uW) e.clip.right=uW;
    uW=e.clip.right;
  }
  return uW;
}
function xHeight(e,uH) {
  if(!(e=xGetElementById(e))) return 0;
  if (xNum(uH)) { // v3.13.1
    if (uH<0) uH = 0;
    else uH=Math.round(uH);
  }
  else uH=0;
  var css=xDef(e.style);
  if(css && xDef(e.offsetHeight) && xStr(e.style.height)) {
    if(uH) xSetCH(e, uH);
    uH=e.offsetHeight;
  }
  else if(css && xDef(e.style.pixelHeight)) {
    if(uH) e.style.pixelHeight=uH;
    uH=e.style.pixelHeight;
  }
  else if(xDef(e.clip) && xDef(e.clip.bottom)) {
    if(uH) e.clip.bottom=uH;
    uH=e.clip.bottom;
  }
  return uH;
}
function xGetCS(ele,sP){return parseInt(document.defaultView.getComputedStyle(ele,'').getPropertyValue(sP));}
function xSetCW(ele,uW){
  var pl=0,pr=0,bl=0,br=0;
  if(xDef(document.defaultView) && xDef(document.defaultView.getComputedStyle)){
    pl=xGetCS(ele,'padding-left');
    pr=xGetCS(ele,'padding-right');
    bl=xGetCS(ele,'border-left-width');
    br=xGetCS(ele,'border-right-width');
  }
  else if(xDef(ele.currentStyle,document.compatMode)){
    if(document.compatMode=='CSS1Compat'){
      pl=parseInt(ele.currentStyle.paddingLeft);
      pr=parseInt(ele.currentStyle.paddingRight);
      bl=parseInt(ele.currentStyle.borderLeftWidth);
      br=parseInt(ele.currentStyle.borderRightWidth);
    }
  }
  else if(xDef(ele.offsetWidth,ele.style.width)){ // ?
    ele.style.width=uW+'px';
    pl=ele.offsetWidth-uW;
  }
  if(isNaN(pl)) pl=0; if(isNaN(pr)) pr=0; if(isNaN(bl)) bl=0; if(isNaN(br)) br=0;
  var cssW=uW-(pl+pr+bl+br);
  if(isNaN(cssW)||cssW<0) return;
  else ele.style.width=cssW+'px';
}
function xSetCH(ele,uH){
  var pt=0,pb=0,bt=0,bb=0;
  if(xDef(document.defaultView) && xDef(document.defaultView.getComputedStyle)){
    pt=xGetCS(ele,'padding-top');
    pb=xGetCS(ele,'padding-bottom');
    bt=xGetCS(ele,'border-top-width');
    bb=xGetCS(ele,'border-bottom-width');
  }
  else if(xDef(ele.currentStyle,document.compatMode)){
    if(document.compatMode=='CSS1Compat'){
      pt=parseInt(ele.currentStyle.paddingTop);
      pb=parseInt(ele.currentStyle.paddingBottom);
      bt=parseInt(ele.currentStyle.borderTopWidth);
      bb=parseInt(ele.currentStyle.borderBottomWidth);
    }
  }
  else if(xDef(ele.offsetHeight,ele.style.height)){ // ?
    ele.style.height=uH+'px';
    pt=ele.offsetHeight-uH;
  }
  if(isNaN(pt)) pt=0; if(isNaN(pb)) pb=0; if(isNaN(bt)) bt=0; if(isNaN(bb)) bb=0;
  var cssH=uH-(pt+pb+bt+bb);
  if(isNaN(cssH)||cssH<0) return;
  else ele.style.height=cssH+'px';
}
function xClip(e,iTop,iRight,iBottom,iLeft) {
  if(!(e=xGetElementById(e))) return;
  if(e.style) {
    if (xNum(iLeft)) e.style.clip='rect('+iTop+'px '+iRight+'px '+iBottom+'px '+iLeft+'px)';
    else e.style.clip='rect(0 '+parseInt(e.style.width)+'px '+parseInt(e.style.height)+'px 0)';
  }
  else if(e.clip) {
    if (xNum(iLeft)) { e.clip.top=iTop; e.clip.right=iRight; e.clip.bottom=iBottom; e.clip.left=iLeft; }
    else { e.clip.top=0; e.clip.right=xWidth(e); e.clip.bottom=xHeight(e); e.clip.left=0; }
  }
}
// Window:
function xClientWidth() {
  var w=0;
  if(xOp5or6) w=window.innerWidth;
  else if(!window.opera && document.documentElement && document.documentElement.clientWidth) // v3.12
    w=document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    w=document.body.clientWidth;
  else if(xDef(window.innerWidth,window.innerHeight,document.height)) {
    w=window.innerWidth;
    if(document.height>window.innerHeight) w-=16;
  }
  return w;
}
function xClientHeight() {
  var h=0;
  if(xOp5or6) h=window.innerHeight;
  else if(!window.opera && document.documentElement && document.documentElement.clientHeight) // v3.12
    h=document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    h=document.body.clientHeight;
  else if(xDef(window.innerWidth,window.innerHeight,document.width)) {
    h=window.innerHeight;
    if(document.width>window.innerWidth) h-=16;
  }
  return h;
}
// Animation:
function xSlideTo(e,x,y,uTime) {
  if (!(e=xGetElementById(e))) return;
  if (!e.timeout) e.timeout = 25;
  e.xTarget = x; e.yTarget = y; e.slideTime = uTime; e.stop = false;
  e.yA = e.yTarget - xTop(e); e.xA = e.xTarget - xLeft(e); // A = distance
  e.B = Math.PI / (2 * e.slideTime); // B = period
  e.yD = xTop(e); e.xD = xLeft(e); // D = initial position
  var d = new Date(); e.C = d.getTime();
  if (!e.moving) xSlide(e);
}
function xSlide(e) {
  if (!(e=xGetElementById(e))) return;
  var now, s, t, newY, newX;
  now = new Date();
  t = now.getTime() - e.C;
  if (e.stop) { e.moving = false; }
  else if (t < e.slideTime) {
    setTimeout("xSlide('"+e.id+"')", e.timeout);
    s = Math.sin(e.B * t);
    newX = Math.round(e.xA * s + e.xD);
    newY = Math.round(e.yA * s + e.yD);
    xMoveTo(e, newX, newY);
    e.moving = true;
  }  
  else {
    xMoveTo(e, e.xTarget, e.yTarget);
    e.moving = false;
  }  
}
// Event:
function xAddEventListener(e,eventType,eventListener,useCapture) {
  if(!(e=xGetElementById(e))) return;
  eventType=eventType.toLowerCase();
  if((!xIE4Up && !xOp7) && e==window) {
    if(eventType=='resize') { window.xPCW=xClientWidth(); window.xPCH=xClientHeight(); window.xREL=eventListener; xResizeEvent(); return; }
    if(eventType=='scroll') { window.xPSL=xScrollLeft(); window.xPST=xScrollTop(); window.xSEL=eventListener; xScrollEvent(); return; }
  }
  var eh='e.on'+eventType+'=eventListener';
  if(e.addEventListener) e.addEventListener(eventType,eventListener,useCapture);
  else if(e.attachEvent) e.attachEvent('on'+eventType,eventListener);
  else if(e.captureEvents) {
    if(useCapture||(eventType.indexOf('mousemove')!=-1)) { e.captureEvents(eval('Event.'+eventType.toUpperCase())); }
    eval(eh);
  }
  else eval(eh);
}
function xRemoveEventListener(e,eventType,eventListener,useCapture) {
  if(!(e=xGetElementById(e))) return;
  eventType=eventType.toLowerCase();
  if((!xIE4Up && !xOp7) && e==window) {
    if(eventType=='resize') { window.xREL=null; return; }
    if(eventType=='scroll') { window.xSEL=null; return; }
  }
  var eh='e.on'+eventType+'=null';
  if(e.removeEventListener) e.removeEventListener(eventType,eventListener,useCapture);
  else if(e.detachEvent) e.detachEvent('on'+eventType,eventListener);
  else if(e.releaseEvents) {
    if(useCapture||(eventType.indexOf('mousemove')!=-1)) { e.releaseEvents(eval('Event.'+eventType.toUpperCase())); }
    eval(eh);
  }
  else eval(eh);
}
function xEvent(evt) { // cross-browser event object prototype
  this.type = '';
  this.target = null;
  this.pageX = 0;
  this.pageY = 0;
  this.offsetX = 0;
  this.offsetY = 0;
  this.keyCode = 0;
  var e = evt ? evt : window.event;
  if(!e) return;
  if(e.type) this.type = e.type;
  if(e.target) this.target = e.target;
  else if(e.srcElement) this.target = e.srcElement;
  else if(xNN4) this.target = xLayerFromPoint(e.pageX, e.pageY);
  if(xOp5or6) { this.pageX = e.clientX; this.pageY = e.clientY; }
  else if(xDef(e.pageX,e.pageY)) { this.pageX = e.pageX; this.pageY = e.pageY; } // v3.14
  else if(xDef(e.clientX,e.clientY)) { this.pageX = e.clientX + xScrollLeft(); this.pageY = e.clientY + xScrollTop(); }
  if(xDef(e.offsetX,e.offsetY)) { this.offsetX = e.offsetX; this.offsetY = e.offsetY; }
  else if(xDef(e.layerX,e.layerY)) { this.offsetX = e.layerX; this.offsetY = e.layerY; }
  else { this.offsetX = this.pageX - xPageX(this.target); this.offsetY = this.pageY - xPageY(this.target); }
  if (e.keyCode) { this.keyCode = e.keyCode; } // for moz/fb, if keyCode==0 use which
  else if (xDef(e.which)) { this.keyCode = e.which; }
}
function xResizeEvent() { // window resize event simulation
  if (window.xREL) setTimeout('xResizeEvent()', 250);
  var cw = xClientWidth(), ch = xClientHeight();
  if (window.xPCW != cw || window.xPCH != ch) { window.xPCW = cw; window.xPCH = ch; if (window.xREL) window.xREL(); }
}
function xScrollEvent() { // window scroll event simulation
  if (window.xSEL) setTimeout('xScrollEvent()', 250);
  var sl = xScrollLeft(), st = xScrollTop();
  if (window.xPSL != sl || window.xPST != st) { window.xPSL = sl; window.xPST = st; if (window.xSEL) window.xSEL(); }
}
// end x.js

