/**
 * Displays a Glossary term from the term given
 */
function glossaryTerm(term) {
  filename = "/af/glossary?term="+escape(term);
  window.open(filename, "Glossary", "width=275,height=300,resizable=no,scrollbars=yes");
}

/**
 * Displays a Glossary term from the id given
 */
function glossaryId(id) {
  filename = "/af/glossary?glossaryId="+id;
  window.open(filename, "Glossary", "width=275,height=300,resizable=no,scrollbars=yes");
}

/**
 * Popup
 */
function genericpopup(url) {
  window.open(url, "Aspect", "width=600,menubar=no,height=400,resizable=yes,scrollbars=yes");
}


/**
 * Displays a Glossary term from the id given
 */
/* 
function printpopup(url) {
  printwindow = window.open(url, "Glossary", "width=650,menubar=yes,height=600,resizable=yes,scrollbars=yes");
  printwindow.focus();
}
*/
function printpopup() {
  //alert(window.location + "&xsl-print=yes");
  url = window.location + "&xsl-printfriendly=yes";
  window.open(url, "Aspect", "width=650,menubar=no,height=600,resizable=yes,scrollbars=yes");
}


/**
 * Write the current date to the printfriendly page
 */

function writedate() {
  //alert("DATE function");
  var d = new Date();
  document.write(d.getDate());
  document.write("/");
  document.write(d.getMonth() + 1);
  document.write("/");
  document.write(d.getFullYear());
}

/**
 * Print this page
 */
function printpage() {
  window.print();
}

/**
 * Download this page
 * Only for the search tool results
 */
function downloadpage() {
  location.href = window.location + "&download=csv&filetype=csv";
}


function loginPopup() {
  window.open("/af/login?xtm-licensee=aer&xsl-type=popup", "Aspect", "width=600,menubar=no,height=400,resizable=yes,scrollbars=yes");
}

function redirectParentHome(type) {
  if(type == "popup") {
    window.opener.location = "/af/aerhome?xtm-licensee=aer&t=" + getTime();
    window.close();
  }
  else {
    window.location = "/af/aerhome?xtm-licensee=aer&t=" + getTime();
  }
}

function getHome() {
   if(document.exp.dont.checked)
    window.location = "/af/aerhome?xtm-licensee=aer&xsl_exp=yes&t=" + getTime();
   else
     window.location = "/af/aerhome?xtm-licensee=aer&t=" + getTime();
  
}


function getTime() {
//returns current time in millisecs for use as random number to stop browser caching URL
  return (new Date()).getTime();
}

/**
 * Function openWindow
 *
 * Makes a popup with defined width/height attributes.
 *
 * @author Adrian Sobotta
 *
 */
function openWindow(URL, size) {
  if(size == 'small'){
    var newWindow = window.open(URL,'','width=300,height=250,scrollbars=yes,resizable=yes');
  }else{
    var newWindow = window.open(URL,'','width=590,height=480,scrollbars=yes,resizable=yes');
  }
}
