﻿// JScript File

// confirming the delete action does not invoke a delete action,
// it sends relevant information in the querystring,
// and the decision whether to use this info or not is taken in the server side 
function confirmDelete(msg,deletePostingGuid){
	
	if (confirm(msg)){
		var curUrl = document.location.href;
		curUrl += "&deletePostingGuid="+deletePostingGuid;
		document.location.href=curUrl;
	}
	else 
	{
	    location.href ='#';
	}
}
var is800X600 = screen.width == 800 && screen.height == 600;
function SendOutlookEmail_Attachment(sTo, sCC, sSubject, sBody, sAttach)
{
     try
     {
          var oOutlookApp, oOutlookMsg, iOutlookRunning;
          iOutlookRunning = false;
          oOutlookApp = new ActiveXObject("Outlook.Application");
          var nameSpace = oOutlookApp.getNameSpace("MAPI");
          var mailFolder = nameSpace.getDefaultFolder(6);
          var mailItem = mailFolder.Items.add('IPM.Note.FormA');
          with (mailItem) {
               Subject=sSubject;
               To = sTo;
               Attachments.Add (sAttach);
               if(sCC != "") CC = sCC;
               HTMLBody = "Some Text here"
               //Display (0);
               Send();
          }
     }
     catch(err)
     {     
          var strErr ="no error";
          if (!iOutlookRunning)
          {
               strErr = "The email cannot be created.  Please ensure that Microsoft Outlook is running.";
          }
          else
          {
               strErr = "Please take note of this error message and contact the Help Desk at 8555 - An Error occurred on Object SFS Application" + "\n\n" + err.description + "\n" + err.number
          }
          //WScript.Echo(strErr);
      }
     finally
     {
          oOutlookMsg = null;
          oOutlookApp = null;
     }
} 

function createNewPostingLink(parentChannelGuid, templateGuidOrDir,appPath)
{
        parentChannelGuid = ReplaceBrakets(parentChannelGuid);
        templateGuidOrDir = ReplaceBrakets(templateGuidOrDir);
        window.location = appPath+templateGuidOrDir+'.htm?NRMODE=Unpublished&NRCHANNELGUID=%7b'+parentChannelGuid+'%7d&WBCMODE=AuthoringNew&nr_emit=ThinEdit&wbc_purpose=Authoring';
}
function ReplaceBrakets(sGuid){
    sGuid = sGuid.replace('{','');
    sGuid = sGuid.replace('}','');
    return sGuid;
}
function editPosting(postingGuid,appPath){
    postingGuid = ReplaceBrakets(postingGuid);
    window.location = appPath + postingGuid+',frameless.htm?NRMODE=Unpublished&WBCMODE=AuthoringReedit';
}

function deletePosting(postingGuid,appPath){
    postingGuid = ReplaceBrakets(postingGuid);
    window.location = appPath + postingGuid+',frameless.htm?NRMODE=Unpublished&WBCMODE=PresentationUnpublished';
}
