//2008/03/15 pmackie@transunion.com
//custom validation for corporate request info form
//two input fields are custom validated:
//1) If other is selected, enter how you found out about us (following "How did you find out about Transunion?)
//2) If credit reports is selected, for what purpose do you need a credit report?
//     (following "What primary service are you interested in?")
//Both fields need to be required when question condition is met

//generate custom required error messages onLoad:
(window.attachEvent)?window.attachEvent('onload',customErrMsg):window.addEventListener('load',customErrMsg,false);

//set required flags when appropriate:
function customSetRequired(iPageIndex){
  switch(iPageIndex){
    case 1:
      //if($('customer1').checked)$('subscribercdReq').setAttribute("value","true");
      //else $('subscribercdReq').setAttribute("value","false");
      var oSelValue=$('findabouttransunion'),sSelValue=oSelValue.options[oSelValue.selectedIndex].value;
      if(sSelValue=="Other")$('otherisselectedReq').setAttribute("value","true");
      else $('otherisselectedReq').setAttribute("value","false");
      break;
    case 2:
      var oSelValue=$('primaryservice'),sSelValue=oSelValue.options[oSelValue.selectedIndex].value;
      if(sSelValue.match("Credit Reports")!=null)$('creditreportselectedReq').setAttribute("value","true");
      else $('creditreportselectedReq').setAttribute("value","false");
      break;
    default: //don't do anything for other page values
      null;break;
  } //switch
} //customSetRequired()

//create custom error messages:
function customErrMsg(){
  //$('subscribercdErrReq').innerHTML='Please enter a valid Subscriber Code and try again.';
  $('otherisselectedErrReq').innerHTML='If other is selected, enter how you found out about us is a required field. Please enter your answer and try again.';
  $('creditreportselectedErrReq').innerHTML='What purpose do you need a credit report is a required field. Please enter a purpose and try again.';
} //customErrMsg()