/*  javascript functions */

var destschoolref

function gourl(u) {
  window.location.href = u;
  return false;
}

function gourlfullscreen(url, options) {
  var winOptions = '';
  switch (options)
  {
    case 'scroll':
      winOptions = 'directories=no, menubar=no, status=no, toolbar=no, scrollbars=yes';
      break;
      
    default:
      winOptions = 'directories=no, menubar=no, status=no, toolbar=no';
  }
  
  var newWin = window.open(url, 'newWindow', winOptions + ", height=" + screen.height + ", width=" + screen.width);
  newWin.moveTo(0,0);
  newWin.focus();
  return false;
}

// goes to a new url based on a prefix url with the selected objects value appended
function gourl_select(select, url_base) {
  window.location.href = url_base + select[select.selectedIndex].value;
  return false;
}


function form_toggleOnOther(e) {
  var sele = document.getElementById(e)
  var othd = document.getElementById(e + "-othdiv")
  var othi = document.getElementById(e + "-other")

  if(!sele || !othd || !othi) return;

  if(sele.options[sele.selectedIndex].value == 'other') {
     othd.style.display = 'block';
  } else {
     othi.value = '';
     othd.style.display = 'none';
  }
}

function form_helppopup(url) {
  window.open(url, "help_pop", "status=0,toobar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=400,width=700").focus();
  return false;
}

function setDestSchool(id, name, state) {
  document.getElementById(destschoolref + '-destschoolid').value = id;
  document.getElementById(destschoolref + '-state').value = state;
  document.getElementById(destschoolref + '-orgname').value = name;
} 

function ocfe_eoi_orgname(e) {
  alert(e)
}

function ocfe_eoi_physasmail(e) {
  alert(e)
}

function ocfe_e5fs_xschoolselector(e) {
  destschoolref = 'fe-e5fs';
  window.open('/special/schoolselector.asp', "sch_pop", "status=0,toobar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=400,width=600").focus();
}

function ocfe_e3fs_xschoolselector(e) {
  destschoolref = 'fe-e3fs';
  window.open('/special/schoolselector.asp', "sch_pop", "status=0,toobar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=400,width=600").focus();
}

function ocfe_e3fs_mailtype(e) { ocfe_multi_mailtype('e3fs'); }
function ocfe_e3fo_mailtype(e) { ocfe_multi_mailtype('e3fo'); }

function ocfe_multi_mailtype(mref) {
  var sele = document.getElementById('fe-' + mref + '-mailtype');
  var boxe = document.getElementById('fc-' + mref + '-mailboxnum');
  var sune = document.getElementById('fc-' + mref + '-mailunitnum');
  var snue = document.getElementById('fc-' + mref + '-mailstreetnum');
  var snme = document.getElementById('fc-' + mref + '-mailstreetname');
  var sste = document.getElementById('fc-' + mref + '-mailstreettype');
  var cope = document.getElementById('fe-' + mref + '-copymailtophys');

  if(sele.value == 'bag'){
    boxe.style.display = 'inline';
    snue.style.display = 'none';
    sune.style.display = 'none';
    snme.style.display = 'none';
    sste.style.display = 'none';
    cope.disabled = true;
  } else {
    boxe.style.display = 'none';
    snue.style.display = 'inline';
    sune.style.display = 'inline';
    snme.style.display = 'inline';
    sste.style.display = 'inline';
    cope.disabled = false;
  }
}

function ocfe_e3fs_copymailtophys(e) { ocfe_multi_copymailtophys('e3fs'); }
function ocfe_e3fo_copymailtophys(e) { ocfe_multi_copymailtophys('e3fo'); }
function ocfe_multi_copymailtophys(mref) { 
  document.getElementById('fe-' + mref + '-physunitnum').value = document.getElementById('fe-' + mref + '-mailunitnum').value;
  document.getElementById('fe-' + mref + '-physstreetnum').value = document.getElementById('fe-' + mref + '-mailstreetnum').value;
  document.getElementById('fe-' + mref + '-physstreetname').value = document.getElementById('fe-' + mref + '-mailstreetname').value;
  document.getElementById('fe-' + mref + '-physstreettype').selectedIndex = document.getElementById('fe-' + mref + '-mailstreettype').selectedIndex;
  document.getElementById('fe-' + mref + '-physcity').value = document.getElementById('fe-' + mref + '-mailcity').value;
  document.getElementById('fe-' + mref + '-physstate').selectedIndex = document.getElementById('fe-' + mref + '-mailstate').selectedIndex;
  document.getElementById('fe-' + mref + '-physpostcode').value = document.getElementById('fe-' + mref + '-mailpostcode').value;
}

