var Fse; if (!Fse) Fse = {}; if( !Fse.EMB ) Fse.EMB = {}; Fse.EMB.saveCheckState = function( bChecked, iDocId, nDocTk ) { document.frm_saveCheckState.docId.value = iDocId; document.frm_saveCheckState.docTk.value = nDocTk; document.frm_saveCheckState.state.value = bChecked; var oRequest = Fse.Ajax.sendForm( document.frm_saveCheckState ); var docCount = oRequest.getResponseHeader( "fse-count"); var oButton = document.getElementById( "sendEmailButton" ); if( docCount > 0 ) { oButton.disabled = false; } else { oButton.disabled = true; } }; Fse.EMB.emailDocs = function() { window.location="?view=email"; }; Fse.EMB.updateEmailList = function( oRecipientCheckBox ) { var nFsproMemberId = oRecipientCheckBox.getAttribute( "fsproMemberId" ); var sRecipientName = oRecipientCheckBox.getAttribute( "recipientName" ); if( oRecipientCheckBox.checked ) { // add a recipient oNewRecipient = document.createElement( "input" ); oNewRecipient.setAttribute( "name", "toAddyIDs" ); oNewRecipient.setAttribute( "type", "hidden" ); oNewRecipient.setAttribute( "id", "fsproMemberID_" + nFsproMemberId ); oNewRecipient.setAttribute( "value", nFsproMemberId ); document.frm_eml_Docs.appendChild( oNewRecipient ); oNewRecipientName = document.createElement( "div" ); oNewRecipientName.appendChild( document.createTextNode( sRecipientName )); oNewRecipientName.setAttribute( "className", "recipient-name" ); oNewRecipientName.setAttribute( "id", "fsproMemberName_" + nFsproMemberId ); document.getElementById( "toNames" ).appendChild( oNewRecipientName ); } else { // remove a recipient var oOldRecipient = document.getElementById( "fsproMemberID_" + nFsproMemberId ); if( oOldRecipient ) { oOldRecipient.parentNode.removeChild( oOldRecipient ); } var oOldRecipientName = document.getElementById( "fsproMemberName_" + nFsproMemberId ); if( oOldRecipientName ) { oOldRecipientName.parentNode.removeChild( oOldRecipientName ); } } }; Fse.EMB.showHistoryDetail_save = function( nEmailId ) { var sHtmlId = "dtl_" + nEmailId; var oSocket = document.getElementById( sHtmlId ); if( oSocket ) { if( ! oSocket.getAttribute( "loaded" )) { var sHref = oSocket.getAttribute( "href" ); if( sHref ) { var fnOnLoad = function( oRequest ) { Spry.Utils.setInnerHTML( oSocket, oRequest.xhRequest.responseText ); // oSocket.setAttribute( "loaded", "true" ); Spry.Utils.removeClassName( oSocket.parentNode, "closed" ); }; Fse.Ajax.getURL( sHref, fnOnLoad ); } } else { Spry.Utils.removeClassName( oSocket.parentNode, "closed" ); } } }; Fse.EMB.hideHistoryDetail = function( nEmailId ) { var sHtmlId = "dtl_" + nEmailId; var oSocket = document.getElementById( sHtmlId ); if( oSocket ) { Spry.Utils.addClassName( oSocket.parentNode, "closed" ); } }; Fse.EMB.validateEmailRecipients = function( oForm ) { if( ! oForm.toAddy ) { // only do this if the editable to address form isn't present var bHasRecipients = document.getElementById( "toNames" ).hasChildNodes(); if( ! bHasRecipients ) { alert( "You must select 1 or more recipients from your contact list in order to send this email" ); } return bHasRecipients; } else { // the editable to address form field has already been validated // by the normal process return true; } }; Fse.EMB.addEmailSave = function( nContactId ) { var sAddEmailFormId = "addEmailForm_" + nContactId; var oAddEmailForm = document.getElementById( sAddEmailFormId ); if( oAddEmailForm ) { if( Fse.FormManager.submit( oAddEmailForm, false )) { Fse.EMB.closeAddEmail( nContactId ); var oRequest = Fse.Ajax.sendForm( oAddEmailForm ); if( oRequest.status == "200" ) { Fse.EMB.enableEmail( nContactId ); } else { alert( "An Error Occurred, Email not addded" ); } } } }; Fse.EMB.enableEmail = function( nContactId ) { var sAddEmailLinkId = "addEmailLink_" + nContactId; var oLink = document.getElementById( sAddEmailLinkId ); if( oLink ) { oLink.parentNode.removeChild( oLink ); } var sAddEmailCheckboxId = "addEmailCheckbox_" + nContactId; var oCheckbox = document.getElementById( sAddEmailCheckboxId ); if( oCheckbox ) { oCheckbox.disabled = false; oCheckbox.checked = true; Fse.EMB.updateEmailList( oCheckbox ); } }; Fse.EMB.closeAddEmail = function( nContactId ) { var sAddEmailSocketId = "addEmailSocket_" + nContactId; var oAddEmailSocket = document.getElementById( sAddEmailSocketId ); if( oAddEmailSocket ) { Spry.Utils.addClassName( oAddEmailSocket, "hidden" ); } }; Fse.EMB.addEmailCancel = function( nContactId ) { Fse.EMB.closeAddEmail( nContactId ); }; Fse.EMB.showAddEmail = function( nContactId ) { var sAddEmailFormId = "addEmailForm_" + nContactId; var oAddEmailForm = document.getElementById( sAddEmailFormId ); // clear any existing value from form field oAddEmailForm.contactEmail.value = ""; var sAddEmailSocketId = "addEmailSocket_" + nContactId; var oAddEmailSocket = document.getElementById( sAddEmailSocketId ); if( oAddEmailSocket ) { Spry.Utils.removeClassName( oAddEmailSocket, "hidden" ); // change focus oAddEmailForm.contactEmail.focus(); } }; YAHOO.namespace("Fse.EMB"); Fse.EMB.showHistoryDetail = function( nEmailId ) { var sHtmlId = "dtl_" + nEmailId; var oSocket = document.getElementById( sHtmlId ); if( oSocket ) { var sHref = oSocket.getAttribute( "href" ); if( sHref ) { var fnOnLoad = function( oRequest ) { Spry.Utils.setInnerHTML( "emailDetailsDialogSocket", oRequest.xhRequest.responseText ); YAHOO.Fse.EMB.emailDetailsDialog.show(); }; Fse.Ajax.getURL( sHref, fnOnLoad ); } } }; Fse.EMB.closeEmailDetailsDialog = function() { YAHOO.Fse.EMB.emailDetailsDialog.hide(); }; Fse.EMB.init = function() { YAHOO.Fse.EMB.emailDetailsDialog = new YAHOO.widget.Dialog( "emailDetailsDialog", { width:"550px", fixedcenter: true, visible: false, modal:true, underlay:"shadow", constraintoviewport: true, buttons: [ { text:"Close", handler:Fse.EMB.closeEmailDetailsDialog, isDefault:true } ] } ); YAHOO.Fse.EMB.emailDetailsDialog.setHeader("Email Details"); YAHOO.Fse.EMB.emailDetailsDialog.render( document.body ); Spry.Utils.removeClassName( "emailDetailsDialog", "hidden" ); }; YAHOO.util.Event.onDOMReady(Fse.EMB.init);