function IFEWin(){
 window.open('ife.htm');
}
function showCustom() {
 document.getElementById("prebuiltc").style.display = "none";
 document.getElementById("customc").style.display = "inline";
 window.buildType = 1;
}
function showPrebuilt() {
 document.getElementById("customc").style.display = "none";
 document.getElementById("prebuiltc").style.display = "inline";
 window.buildType = 2;
}
function toggleSpell(ind) {
 if(ind == 0){
  document.getElementById("spellyes").style.display = "none";
 }
 else {
  document.getElementById("spellyes").style.display = "inline";
 }
 window.spellType = ind;
}
function toggleKnown(ind) {
 if(ind == 0){
  document.getElementById("knownyes").style.display = "none";
 }
 else {
  document.getElementById("knownyes").style.display = "inline";
 }
 window.spellKnown = ind;
}
function toggleSpecial(ind) {
 for(temp = 1;temp <= ind;temp++){
  document.getElementById("saspan" + temp).style.display = "inline";
 }
 for(;temp <= 20;temp++){
  document.getElementById("saspan" + temp).style.display = "none";
 }
 window.specialCount = ind;
}
function toggleColumn(ind) {
 for(temp = 1;temp <= ind;temp++){
  document.getElementById("cospan" + temp).style.display = "inline";
 }
 for(;temp <= 5;temp++){
  document.getElementById("cospan" + temp).style.display = "none";
 }
 window.columnCount = ind;
}

function generateClass() {
 specialCase = 0;
 bLink = "?F=" + document.getElementById('format').value;
 if(buildType == 1){
  bLink = bLink + "custom&B=" + document.getElementById('bab').value + document.getElementById('fort').value + document.getElementById('ref').value + document.getElementById('will').value + document.getElementById('gento').value + "&H=" + ((document.getElementById('skills').value << 5) + parseInt(document.getElementById('hitdie').value));
  if(spellType >= 1){
   start = document.getElementById('start').value;
   if(start < 0)
    start = ((start*-1)<<1)+1;
   else
    start = start << 1;
   bLink = bLink + "&C=" + document.getElementById('perday').value + "." + document.getElementById('increase').value + ".";
   if(spellKnown == 1){
    bLink = bLink + document.getElementById('known').value;
	start += (document.getElementById('knownmin').value<<5);
   }
   bLink = bLink + "&S=" + (start) + "&V=" + (parseInt(document.getElementById('alpha').value) + (document.getElementById('omega').value << 4) + (document.getElementById('spellmin').value << 8) + (document.getElementById('spellmax').value << 12));
   if(spellType == 2)
    specialCase += 1;
  }
  for(temp = 1;temp <= specialCount;temp++){
   bLink = bLink + "&SL" + (temp-1) + "=" + document.getElementById('sa' + temp).value.replace(/\+/g,"¯") + "&SC" + (temp-1) + "=" + (parseInt(document.getElementById('sta' + temp).value) + (document.getElementById('rpt' + temp).value<<5));
  }
  for(temp = 1;temp <= columnCount;temp++){
   bLink = bLink + "&COH" + (temp-1) + "=" + document.getElementById('coh' + temp).value + "&COF" + (temp-1) + "=" + document.getElementById('cof' + temp).value.replace(/\+/g,"¯");
  }
  if(specialCase > 0){
   bLink = bLink + "&X=" + specialCase;
  }
  location = bLink;
 }
 else{
  location = bLink + document.getElementById('ctype').value + "&N=" + document.getElementById('class').value;
 }
}
