function loadPressRelease()
{  
  var qs = new Querystring()
  var strLeafName = qs.get("rid", null);
  var strURL = "../hspcadin/hspcorpcms/Press%20Releases/" + strLeafName;
  window.frames["iFrameTemp"].location = strURL;
}

function generatePreview()
{
  var strCurrentFile = window.location.href;
  var strLibName = "Press%20Releases/"
  var iLastSlash;
  
  iLastSlash = strCurrentFile.indexOf(strLibName);
  strCurrentFile = strCurrentFile.substring(iLastSlash + strLibName.length);
    
  var objPreviewWindow = window.open("../pressreleasepreview.aspx?rid=" + strCurrentFile);
}

function loadPressReleasePreview()
{  
  var qs = new Querystring()
  var strLeafName = qs.get("rid", null);
  var strURL = "Press%20Releases/" + strLeafName;
  window.frames["iFrameTemp"].location = strURL;
}

function loadIntoParent()
{
  if (parent.document.getElementById("divContentPlaceHolder") != null)
  {  
    var htmlData = document.getElementById("pressReleaseContent").innerHTML;
    parent.document.getElementById("divContentPlaceHolder").innerHTML = htmlData;
  }
}

function openLibDocument(strURL, strDocLib, strAttachmentID, strAttachmentURL, strLists)
{
  strURL = escape(strURL);
  strDocLib = escape(strDocLib);
  strAttachmentURL = "Attachments";
  strLists = "Lists";
  
  var strFileExtension = strURL.substring(strURL.length - 3, strURL.length);
  var strEmbeddedObject = "";
  var boolHasExtension = false;
  var boolIsImage = false;
  var strContentType = "text/html; charset=UTF-8";
  var i;

  var arrImgExtensions = new Array();
  arrImgExtensions[0] = "gif";
  arrImgExtensions[1] = "jpg";
  arrImgExtensions[2] = "png";
  arrImgExtensions[3] = "bmp";
  
  var arrImgContentTypes = new Array();
  arrImgContentTypes[0] = "image/gif";
  arrImgContentTypes[1] = "image/jpg";
  arrImgContentTypes[2] = "image/png";
  arrImgContentTypes[3] = "image/bmp";  
  
  if (strAttachmentID == null)
  {
    strURL = "/hspcadin/hspcorpcms/" + strDocLib + "/" + strURL;
  }
  else
  {
    strURL = "/hspcadin/hspcorpcms/" + strLists + "/" + strDocLib + "/" + strAttachmentURL + "/" + strAttachmentID + "/" + strURL;
  }
  
  for (i = 0; i < arrImgExtensions.length; i++)
  {
    if (arrImgExtensions[i] == strFileExtension)
    {
      strEmbeddedObject = "<img src='' width='850' name='DocLibObject'>";
      imgProductImage = new Image();
      imgProductImage.src = strURL;
      boolHasExtension = true;
      boolIsImage = true;
      strContentType = arrImgContentTypes[i];
      break;
    }
  }

  if (strFileExtension == "pdf")
  {
    strEmbeddedObject = "<iframe src='" + strURL + "' width='100%' height='100%' name='DocLibObject'/>";
    strContentType = "application/pdf";
    boolHasExtension = true;
  }

  var objLibWindow = window.open("", "winLibDocument", "width=850,height=600,status=no,titlebar=no,directories=no,toolbar=no,scrollbars=yes,resizable=yes");
  
  objLibWindow.document.open();
  objLibWindow.document.clear();
  
  if (boolHasExtension == true)
  {
    objLibWindow.document.write("<html>");
    objLibWindow.document.write("<META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"" + strContentType + "\">");  
    objLibWindow.document.write("<head><title>Hospira</title><style>body{margin: 0px;}</style></head><body>");  
    objLibWindow.document.write(strEmbeddedObject);
    objLibWindow.document.title = "Hospira";
    objLibWindow.document.write("</body></html>");

    if (boolIsImage)
      objLibWindow.document.images['DocLibObject'].src = imgProductImage.src;      
  }
  else
    objLibWindow.location.href = strURL;

  objLibWindow.document.close();
  objLibWindow.focus();
}

function loadMailerForm()
{
  var strMailFormURL = "mailformiframe.aspx?rid=";
  var strLeafName = "";
  var strNameTDID = "";
  var strDateTDID = "";
  var arrRadios = document.forms[0].rdoPressReleaseSelected;

  for (i = 0; i < arrRadios.length; i++)
  {
    if (arrRadios[i].checked == true)
      strLeafName = arrRadios[i].value;
  }

  if (strLeafName == "")
    alert("Please select a press release for which a news alert will be sent.\n\nClick \"OK\" to continue.");  
  else
  {
    strMailFormURL += strLeafName;
    strNameTDID = "tdNameCell" + strLeafName;
    strDateTDID = "tdDateCell" + strLeafName;
    strMailFormURL += "&title=" + escape(document.getElementById(strNameTDID).innerText) + "&date=" + escape(document.getElementById(strDateTDID).innerText);
    
    window.location.href = strMailFormURL;
  }
  
}

function prepNewsAlert(strIframeID, strURL)
{
  window.frames[strIframeID].location = strURL + "?" + location.search.substring(1, location.search.length);
}

function loadEmailVerification(strURL)
{
  var qs = new Querystring()
  var strID = qs.get("id", null);
  document.frames["iframeNewsAlertsVerification"].location.href = strURL + "?id=" + strID;
}
