//this file was created by ITS to change the display of items not manageable in the Article Manager program - e.g., to truncate text entered in the ArtMan summary field.

//change four digit year to two digits - used for news display pages (if department prefers to display 2- rather than 4-digit years)
function convertyear(monthday,year)
{
  return '' + monthday + '' + year.substr(2,2) + ' ';
}

//display (PDF) if the PDF checkbox is checked
function displypdf(artmanvalue)
{
  if(artmanvalue)
  {
    if(artmanvalue==1)
    {
     return '<span class="info">(PDF)</span>';
    }
    else
    {
    return '';
    }
  }
  else
  {
    return '';
  }
}

//truncate summary if it is longer than 550 characters, remove forced return if that is the only thing in the summary - used on news display pages.  The truncate is needed because we can't truncate data in the Summary Field directly (within the Article Manager user interface);  the removal of the forced return is needed because Article Manager prefills that as a default and you can't remove it from within the interface. 

function checkblank(str)
{
	  if((str == "<br>")||(str == "<br>\n")||(str == "<p>&nbsp;</p>"))
	  {
	  return '';
	  }
	  else
	  {
	  return str;
	  }
}

function truncate(str)
{
  if(str)
  {
    if(str.length > 1100)
    {
    return str.substr(0,1100);
    }
    else
    {
	 return checkblank(str)
    }
  }
  else
  {
    return '';
  }
}

//only display the last 90 days of articles - used on view_combined.shtml
fordatepassed = new Date();
today = new Date();
function datedisplay(monthpassed,datepassed,yearpassed)
{
   //monthpassed ~ January = 1, but the JS January = 0
   fordatepassed.setMonth(monthpassed - 1);
   fordatepassed.setDate(datepassed);
   fordatepassed.setFullYear(yearpassed);
   
   difference = today.getTime() - fordatepassed.getTime();
   
   //number of days in the difference
   difference = Math.floor(difference / (1000 * 60 * 60 * 24));
   if(difference > 90)
   {
     //displayarticle = "no";
	 return false
   }
   else
   {
     //displayarticle = "yes";
     return true
   }
}

//open link in a new window - used on view_combined.shtml
newwin = '';
function opnwin(urlpassed)
{
  newwin = window.open(urlpassed,'EditWindow','scrollbars=yes,width=550,height=550,resizable=yes,screenX=50,screenY=50,top=50,left=50');
  newwin.focus()
}
