//  function checkValue()
//  this function checks for the selected value from the
//  company type question and then calls getCompanyType.
//
function checkValue()
{
  hideAll();
  for (i = 0; i < 50; i++)
  {
    if (document.myForm.industry[i].selected == true)
    {
      getCompanyType(document.myForm.industry[i].value);
    }
  }
}

//  function getCompanyType(cval)
//  this function determines the company type from
//  the company type question and then calls switchDiv.
//
function getCompanyType(cval) 
{
  var companytype;
  if (cval == 'Aerospace') {companytype = 'GP1';}
  if (cval == 'Agriculture') {companytype = 'GP1';}
  if (cval == 'Analyst/Research/PR') {companytype = 'GP1';}
  if (cval == 'Architecture/Engineering/Construction') {companytype = 'GP1';}
  if (cval == 'Automotive') {companytype = 'GP1';}
  if (cval == 'Consulting') {companytype = 'GP1';}
  if (cval == 'Consumer Products') {companytype = 'GP1';}
  if (cval == 'Education - Higher Ed') {companytype = 'GP2';}
  if (cval == 'Education - K-12') {companytype = 'GP2';}
  if (cval == 'Entertainment') {companytype = 'GP3';}
  if (cval == 'Financial Services') {companytype = 'GP1';}
  if (cval == 'Financial Services - Insurance') {companytype = 'GP1';}
  if (cval == 'Food/Beverage') {companytype = 'GP1';}
  if (cval == 'Government - Federal') {companytype = 'GP2';}
  if (cval == 'Government - Local') {companytype = 'GP2';}
  if (cval == 'Government - State') {companytype = 'GP2';}
  if (cval == 'Government - Other') {companytype = 'GP2';}
  if (cval == 'Healthcare') {companytype = 'GP1';}
  if (cval == 'Hospitality') {companytype = 'GP1';}
  if (cval == 'Manufacturing: High Tech/Software') {companytype = 'GP1';}
  if (cval == 'Manufacturing: Other') {companytype = 'GP1';}
  if (cval == 'Military') {companytype = 'GP2';}
  if (cval == 'New Media/Publishing') {companytype = 'GP3';}
  if (cval == 'Not For Profit') {companytype = 'GP2';}
  if (cval == 'Oil/Gas/Chemical') {companytype = 'GP1';}
  if (cval == 'Other') {companytype = 'GP1';}
  if (cval == 'Pharmaceutical') {companytype = 'GP1';}
  if (cval == 'Research & Education') {companytype = 'GP2';}
  if (cval == 'Reseller/Distributor') {companytype = '';}
  if (cval == 'Retail') {companytype = 'GP1';}
  if (cval == 'Service Provider-ASP') {companytype = 'GP3';}
  if (cval == 'Service Provider-Cable Op/MSO') {companytype = 'GP3';}
  if (cval == 'Service Provider-CLEC') {companytype = 'GP3';}
  if (cval == 'Service Provider-Content') {companytype = 'GP3';}
  if (cval == 'Service Provider-CSP') {companytype = 'GP3';}
  if (cval == 'Service Provider-Finance Ntwrk') {companytype = 'GP3';}
  if (cval == 'Service Provider-ILEC') {companytype = 'GP3';}
  if (cval == 'Service Provider-IOC') {companytype = 'GP3';}
  if (cval == 'Service Provider-ISP') {companytype = 'GP3';}
  if (cval == 'Service Provider-IXC') {companytype = 'GP3';}
  if (cval == 'Service Provider-Managed') {companytype = 'GP3';}
  if (cval == 'Service Provider-Satellite') {companytype = 'GP3';}
  if (cval == 'Service Provider-Utility') {companytype = 'GP3';}
  if (cval == 'Service Provider-Wireless') {companytype = 'GP3';}
  if (cval == 'Service Provider-Other') {companytype = 'GP3';}
  if (cval == 'Telecommunications') {companytype = 'GP3';}
  if (cval == 'Transportation') {companytype = 'GP1';}
  if (cval == 'Utilities/Energy') {companytype = 'GP1';}
  if (cval == 'Wholesale') {companytype = 'GP1';}

  switchDiv(companytype);
}

// function switchDiv(ctype)
//  this function first hides all the divs and then 
//  takes the id of a div and calls the other 
//  functions required to show that div
//
function switchDiv(ctype)
{
  hideAll();
  if (ctype == 'GP1')
  { 
    var style_sheet1 = getStyleObject("revenue");
    var style_sheet2 = getStyleObject("impsecproj");
    var style_sheet3 = getStyleObject("timeframe");
    var style_sheet4 = getStyleObject("reseller");
    if (style_sheet1) {changeObjectVisibility("revenue","visible","block");}
    if (style_sheet2) {changeObjectVisibility("impsecproj","visible","block");}
    if (style_sheet3) {changeObjectVisibility("timeframe","visible","block");}
    if (style_sheet4) {changeObjectVisibility("reseller","visible","block");}
  }  
  if (ctype == 'GP2')
  { 
    var style_sheet1 = getStyleObject("employees");
    var style_sheet2 = getStyleObject("impsecproj");
    var style_sheet3 = getStyleObject("timeframe");
    var style_sheet4 = getStyleObject("reseller");
    if (style_sheet1) {changeObjectVisibility("employees","visible","block");}
    if (style_sheet2) {changeObjectVisibility("impsecproj","visible","block");}
    if (style_sheet3) {changeObjectVisibility("timeframe","visible","block");}
    if (style_sheet4) {changeObjectVisibility("reseller","visible","block");}
  }  
  if (ctype == 'GP3')
  { 
    var style_sheet2 = getStyleObject("impsecproj");
    var style_sheet3 = getStyleObject("timeframe");
    if (style_sheet2) {changeObjectVisibility("impsecproj","visible","block");}
    if (style_sheet3) {changeObjectVisibility("timeframe","visible","block");}
  }
}

// function hideAll()
//  this function hides the divs
//
function hideAll()
{
   changeObjectVisibility("revenue","hidden","none");
   changeObjectVisibility("employees","hidden","none");
   changeObjectVisibility("impsecproj","hidden","none");
   changeObjectVisibility("timeframe","hidden","none");
   changeObjectVisibility("reseller","hidden","none");
}

// function getStyleObject(string) 
//  this function returns the style object
//  given a string containing the id of an object
//  the function returns the stylesheet of that object
//  or false if it can't find a stylesheet.  Handles
//  cross-browser compatibility issues.
//
function getStyleObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  if(document.getElementById && document.getElementById(objectId)) {
  return document.getElementById(objectId).style;
   }
   else if (document.all && document.all(objectId)) {  
   return document.all(objectId).style;
   } 
   else if (document.layers && document.layers[objectId]) { 
   return document.layers[objectId];
   } else {
   return false;
   }
}

// function changeObjectVisibility(objectId, newVisibility, newDisplay)
//  this function first get a reference to the 
//  cross-browser style object and make sure 
//  the object exists
//
function changeObjectVisibility(objectId, newVisibility, newDisplay) {
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
    styleObject.visibility = newVisibility;
    styleObject.display = newDisplay;
    return true;
    } else {
    // we couldn't find the object, so we can't change its visibility
    return false;
    }
}
