//  function checkValue2()
//  this function checks for the selected value from the
//  company type question and then calls getCompanyType.
//
function checkValue2()
{
  hideAll2();
  for (i = 0; i < 4; i++)
  {
    if (document.forms[0].Q1[i].selected == true)
    {
      getCompanyType(document.forms[0].Q1[i].value);
    }
  }
}

function checkValue3()
{
  getOptinType(document.forms[0].Q4.options[document.forms[0].Q4.selectedIndex].value);
}

//  function getCompanyType(cval)
//  this function determines the company type from
//  the company type question and then calls switchDiv2.
//
function getCompanyType(cval) 
{
  var companytype;
  if (cval == 'yes') {companytype = 'N';}
  if (cval == 'no') {companytype = 'N';}
  if (cval == 'not_yet') {companytype = 'N';}
  if (cval == 'evaluating') {companytype = 'N';}
  
  switchDiv2(companytype);
}

//  function getOptinType(cval)
//  this function determines the market type and target client base from
//  Q3 and Q4 to generate optintype, which sets the visibilty of the contact
//  me checkbox.
//
function getOptinType(market) 
{
  var optintype;
  if (market == 'B2B/Regional' || market == 'B2C/Regional' || market == 'B2C/National/International' || market == 'Both B2B/B2C Regional' || market == '') {optintype = 'N';}
  else {optintype = 'Y';}
  switchDiv3(optintype);
}

// function switchDiv2(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 switchDiv2(ctype)
{
  hideAll2();
  if (ctype == 'N')
  { 
    changeObjectVisibility2("timeline","visible","block");
  }  
}

// function switchDiv3(optintype)
//  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 switchDiv3(optintype)
{
  hideAll3();
  if (optintype == 'N')
  { 
    changeObjectVisibility2("optin","hidden","none");
  }  
  else if (optintype == 'Y')
  { 
    changeObjectVisibility2("optin","visible","block");
  }  
}

// function hideAll2()
//  this function hides the divs
//
function hideAll2()
{
   changeObjectVisibility2("timeline","hidden","none");
}

function hideAll3()
{
   changeObjectVisibility2("optin","hidden","none");
}

// function getStyleObject2(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 getStyleObject2(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 changeObjectVisibility2(objectId, newVisibility, newDisplay)
//  this function first get a reference to the 
//  cross-browser style object and make sure 
//  the object exists
//
function changeObjectVisibility2(objectId, newVisibility, newDisplay) {
    var styleObject = getStyleObject2(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;
    }
}

