/***********************************************
* Utilities © Tim Reed  (unless otherwise noted)
* This notice must stay intact for use
* Visit http://www.i4synthesis.com for contact info
***********************************************/

/**
 * itemHasExpired() will evaluate any date passed as parameter x,
 * based on current date if it is older, it returns false, else it returns true
**/
var oCurrDate    = new Date();
function dateIsPast(x) {
  try {
    return (oCurrDate.getTime()>Date.parse(x));
  } catch (e) {
    return false;
  }
}

function dateIsPresent(x) {
  try {
    return (oCurrDate.getTime()=Date.parse(x));
  } catch (e) {
    return false;
  }
}

function dateIsFuture(x) {
  try {
    return (oCurrDate.getTime()<Date.parse(x));
  } catch (e) {
    return false;
  }
}


function canPublish(x) {
  return ((null==x)||(dateIsPresent(x) || dateIsPast(x)));
}

function itemHasExpired(x) {
  return dateIsPast(x);
}

function dateHasExpired(x) {
  return dateIsPast(x);
}

function renderFlag(mode,date,url,title) {
  var writeStr = "";
  switch (mode) {
    case "new":
      url="images/icons/new.gif";
      title="New!";
      break;
    case "pdf":
      url="images/icons/pdf.gif";
      title="PDF document";
      break;
    default:
      // if (null==url) url="images/icons/new.gif";
      // if (null==title) title="New!";
      writeStr = '<span style="font-weight:bold;font-family:monospace;font-size:10px;color:white;background-color:red;padding:0px 2px;">'+mode.toUpperCase()+'</span>';
  }
  if (""==writeStr) writeStr = '<img src="'+url+'" title="'+title+'" alt="'+title+'" border="0"/>'
  try {
    if (!dateHasExpired(date)) { document.write(writeStr); }
  } catch (e) {}
}

