﻿function decrypt(s) {
  var input = s;
  var out = "";
  
  for (i=0; i<input.length;i++) {
    current = input.charAt(i);
    charCode = input.charCodeAt(i);
    if ( ( (charCode > 96) && (charCode < (97+26) ) ) || ( (charCode > 64) && (charCode < 91) ) ){
      if ( (charCode > (96 + 13) ) || ( (charCode > (64 + 13) ) && (charCode < 91) ) ) {
        newCode = charCode - 13;
      }
      else {
        newCode = charCode + 13;
      }
      
      out += String.fromCharCode(newCode);
    }
    else {
      out += current;
    }
  }
  
  return out;
}

function newWindow(loc,prot,pwidth,pheight) {
  if (pwidth == null){pwidth = "775"};
  if (pheight == null){pheight = "550"};

  protocol = "http://";
  if (+prot == 1) {
    protocol = "https://";
  }
  else if (+prot == 2) {
    protocol = "";
  
  }
  windowName = "window" + new Date().getTime();
  theWindow = window.open((protocol + decrypt(loc)),windowName,"width=" + pwidth + ",height=" + pheight + ",resizable=no,location=no,scrollbars=yes,status=yes");
  theWindow.focus();
}



// For Medical Cost Estimator
function showRange(selectElem,divName) {
    var div = document.getElementById(divName);
    var parts = selectElem.options[selectElem.selectedIndex].value.split(',');

    if ( parts.length == 2 )
      div.innerHTML = '$'+parts[0]+'.00 to $'+parts[1]+'.00';
    else
      div.innerHTML = '';
  }
  function showText(selectElem,divName) {
    var div = document.getElementById(divName);
    var value = selectElem.options[selectElem.selectedIndex].value;

    div.innerHTML = '$'+value+'.00';
  }
  function showLOS(selectElem,divName) {
    var div = document.getElementById(divName);
    var parts = selectElem.options[selectElem.selectedIndex].value.split(';');

    if ( parts.length == 3 )
      div.innerHTML = '<table style="width:400px"><tr><th>&nbsp;Length of Stay (days)&nbsp;</th><th>&nbsp;Physician Cost**&nbsp;</th><th>&nbsp;Hospital Cost&nbsp;</th></tr><tr><td align="center">'+parts[0]+'</td><td align="center">$'+parts[1]+'</td><td align="center">$'+parts[2]+'</td></tr></table>';
    else
      div.innerHTML = '<table style="width:400px"><tr><th>&nbsp;Length of Stay (days)&nbsp;</th><th>&nbsp;Physician Cost**&nbsp;</th><th>&nbsp;Hospital Cost&nbsp;</th></tr><tr><td align="center">-</td><td align="center">-</td><td align="center">-</td></tr></table>';
  }
  function showLocation(selectElem,divName) {
    var div = document.getElementById(divName);
    var parts = selectElem.options[selectElem.selectedIndex].value.split(';');

    if ( parts.length == 3 )
      div.innerHTML = '<table style="width:400px"><tr><th>&nbsp;Office&nbsp;</th><th>&nbsp;Imaging Center&nbsp;</th><th>&nbsp;Outpatient Hospital&nbsp;</th></tr><tr><td align="center">'+parts[0]+'</td><td align="center">'+parts[1]+'</td><td align="center">'+parts[2]+'</td></tr></table>';
    else
      div.innerHTML = '<table style="width:400px"><tr><th>&nbsp;Office&nbsp;</th><th>&nbsp;Imaging Center&nbsp;</th><th>&nbsp;Outpatient Hospital&nbsp;</th></tr><tr><td align="center">-</td><td align="center">-</td><td align="center">-</td></tr></table>';
  }
