function uncheckMidwest()
{
 if (document.salary.V0003.checked) document.salary.V1000.checked = false;
}
function uncheckNYC()
{
 if (document.salary.V1000.checked) document.salary.V0003.checked = false;
}
function adjust3()
{
  if (isNaN(parseInt(document.salary.V0015.value)))
    {
     document.salary.V0015.value = '';
     return false;
    }
  else
    {
     document.salary.V0015.value = parseInt(document.salary.V0015.value);
     return true;
    }
}
function calcres()
{
  var lngRes, V, R;
  lngRes = 10.391;

//Q07 job function
  V = 0;
  for ( var i = 0; i < document.salary.V0013.length; i++ )
    if (document.salary.V0013[i].checked) V = parseInt(document.salary.V0013[i].value);
  if (V == 1) R = 0.086;
  else if (V == 2) R = -0.107;
  else if (V == 3) R = 0;
  else if (V == 0)
   {
    document.salary.theresults.value = "";
    alert("Please select a job function.");
    document.salary.V0013[0].focus();
    return false;
   }
  else R = 0;
  lngRes = lngRes + R;

//Q03 located in greater NYC area
  if (document.salary.V0003.checked)
    {
     lngRes = lngRes + 0.094;
    }

//Q21 Male
  if (document.salary.V0038.checked)
    {
     lngRes = lngRes + 0.064;
    }

//Q02 organization revenues
  V = parseInt(document.salary.V0002[document.salary.V0002.selectedIndex].value);
  if (V > 0)
    {
     switch (V)
       {
        case 1 :
          R = 0.022;
          break;
        case 2 :
          R = 0.044;
          break;
        case 3 :
          R = 0.066;
          break;
        case 4 :
          R = 0.088;
          break;
        case 5 :
          R = 0.110;
          break;
        case 6 :
          R = 0.132;
          break;
        case 7 :
          R = 0.154;
          break;
        case 8 :
          R = 0.176;
          break;
        case 9 :
          R = 0.198;
          break;
        default :
          R = 0;
          break;
       } 
     lngRes = lngRes + R;
    }
  else
    {
     document.salary.theresults.value = "";
     alert("Please select your organizational revenue.");
     document.salary.V0002.focus();
     return false;
    }

//Q06 What was the combined revenue for all the publications you are involved with at your organization?
  V = parseInt(document.salary.combinedrevenue[document.salary.combinedrevenue.selectedIndex].value);
  if (V > 0)
    {
     switch (V)
       {
        case 1 :
          R = 0.018;
          break;
        case 2 :
          R = 0.036;
          break;
        case 3 :
          R = 0.054;
          break;
        case 4 :
          R = 0.072;
          break;
        case 5 :
          R = 0.090;
          break;
        case 6 :
          R = 0.108;
          break;
        case 7 :
          R = 0.126;
          break;
        case 8 :
          R = 0.144;
          break;
        case 9 :
          R = 0.162;
          break;
        case 10 :
          R = 0.180;
          break;
        default :
          R = 0;
          break;
       } 
     lngRes = lngRes + R;
    }
  else
    {
     document.salary.theresults.value = "";
     alert("Please select the combined revenue for all the publications you are involved with at your organization.");
     document.salary.combinedrevenue.focus();
     return false;
    }
    
//Q08a years in publishing industry
  V = parseInt(document.salary.V0015[document.salary.V0015.selectedIndex].value);
  if (V >= 0)
    {
     lngRes = lngRes + (0.006 * V);
    }
  else
    {
     document.salary.theresults.value = "";
     alert("Please select the number of years of experience in the publishing industry.");
     document.salary.V0015.focus();
     return false;
    }

//Q10 number directly supervised
  V = parseInt(document.salary.V0019[document.salary.V0019.selectedIndex].value);
  if (V > 0)
    {
     switch (V)
       {
        case 1 :
          R = 0.054;
          break;
        case 2 :
          R = 0.108;
          break;
        case 3 :
          R = 0.162;
          break;
        case 4 :
          R = 0.216;
          break;
        case 5 :
          R = 0.270;
          break;
        case 6 :
          R = 0.324;
          break;
        case 7 :
          R = 0.378;
          break;
        case 8 :
          R = 0.432;
          break;
        default :
          R = 0;
          break;
       } 
     lngRes = lngRes + R;
    }
  else
    {
     document.salary.theresults.value = "";
     alert("Please select the number of employees you directly supervise.");
     document.salary.V0019.focus();
     return false;
    }

//Q22 - Age
//  V = parseInt(document.salary.V0039[document.salary.V0039.selectedIndex].value);
//  if (V >= 0)
//    {
//     lngRes = lngRes + (1441 * V);
//    }
//  else
//    {
//     document.salary.theresults.value = "";
//     alert("Please select an age.");
//     document.salary.V0039.focus();
//     return false;
//    }

//Q12 - About how many hours do you work in a typical week?
  V = parseInt(document.salary.hoursworked[document.salary.hoursworked.selectedIndex].value);
  if (V > 0)
    {
     switch (V)
       {
        case 1 :
          R = 0.000;
          break;
        case 2 :
          R = 0.060;
          break;
        case 3 :
          R = 0.120;
          break;
        case 4 :
          R = 0.180;
          break;
        default :
          R = 0;
          break;
       } 
     lngRes = lngRes + R;
    }
  else
    {
     document.salary.theresults.value = "";
     alert("Please select the hours you work in a typical week.");
     document.salary.hoursworked.focus();
     return false;
    }

//Q23 - Education
  V = parseInt(document.salary.V0040[document.salary.V0040.selectedIndex].value);
  if (V > 0)
    {
     switch (V)
       {
        case 1 :
          R = 0.000;
          break;
        case 2 :
          R = 0.060;
          break;
        case 3 :
          R = 0.120;
          break;
        default :
          R = 0;
          break;
       } 
     lngRes = lngRes + R;
    }
  else
    {
     document.salary.theresults.value = "";
     alert("Please select the highest level of education you have completed.");
     document.salary.V0040.focus();
     return false;
    }

  lngRes = Math.round(Math.exp(lngRes));
  lngRes = lngRes * .01;
  lngRes = Math.round(lngRes);
  lngRes = lngRes * 100;
  
  lngRes = "" + lngRes;

  for (var i = 0; i < Math.floor((lngRes.length-(1+i))/3); i++) lngRes = lngRes.substring(0,lngRes.length-(4*i+3))+','+ lngRes.substring(lngRes.length-(4*i+3));
  document.salary.theresults.value = " $" + lngRes;
}

