var currentli;
//-------------------------- Routing Number Validation --------------------------function disclaimer(strDiscVal, strUrl){  Set_Cookie('disCook',strDiscVal,'','','','');  strDiscUrl = strUrl;  window.parent.location = strUrl;  return 0;}function ValidateRoutingNumber(strRoutingNbr) {

	if (strRoutingNbr.length != 9) {
		alert("Routing Number must be 9 digits!")
		return 0;
	}
	if (!IsNumeric(strRoutingNbr)) {
		alert("Routing Number must contain numeric values!")
		return 0;
	}
	n = 0;
	for (i=0; i<strRoutingNbr.length; i+=3) {
		n += parseInt(strRoutingNbr.charAt(i), 10) * 3
		  +  parseInt(strRoutingNbr.charAt(i+1), 10) * 7
		  +  parseInt(strRoutingNbr.charAt(i+2), 10);
	}
	if (n == 0 || n % 10 != 0) {
		alert("Routing Number is invalid!");
		return 0;
	}
	return 1;
}
  
function currentNav() {

	if (!document.getElementById('nav')) {
		return true;
	}
	document.getElementById('nav').getElementsByTagName('UL')[0].id = 'navul';
	
	var baseString = window.location+'';
	var startPos = baseString.indexOf('?');
		if (startPos == -1) {
		return false;
		}
	var endPos = baseString.length;
	var qv = unescape(baseString.substring(startPos+1,endPos));
	
  var word=qv.split("&");
	if (currentli = document.getElementById(qv)) 
	{
			currentli.className='selected';
		// Set the cookie
		Set_Cookie('curMenu',currentli.id,'','','','');
		//Set_Cookie('curMenuName',currentli.parent.id,'','','','');
	}
	else if (word.length > 1)
	{
	  setMenuFromLink(word);
	}
	else if (getMenuForIdOnly(qv)==true)
	{
		currentli = document.getElementById(currentli);
	  currentli.className='selected';
		// Set the cookie
		Set_Cookie('curMenu',currentli.id,'','','','');
	}
	else if (Get_Cookie('curMenu') != null) 
	{
	  //Get the cookie and select that menu
	  qv = Get_Cookie('curMenu');
	  currentli = document.getElementById(qv);
	  if ((currentli == "null") || (currentli == null))
	  {
		Set_Cookie('curMenu','null','','','','');
		return;
	  }
	  currentli.className='selected';
		// Set the cookie
		Set_Cookie('curMenu',currentli.id,'','','','');
	}

	if ((currentli == "null") || (currentli == null))
	{
	  Set_Cookie('curMenu','null','','','','');
	  return;
	  // redirect to home page
	  //window.location = "/main.aspx";
	}
  
   // Set the MLC name for HBX - End
	var recurse = currentli.parentNode;
	while (recurse != null) {
		if(recurse.nodeName == 'LI') {
			recurse.className = 'selected';
		}
		recurse = recurse.parentNode;
	}
}

function rotateHomeImages() {
	if(document.getElementById('homemain')) {
		var count=0;
		function actualRotate() {
			var d = document.getElementById('homemain').style;
			d.backgroundImage='url('+imgObjects[count].src+')';
			count = (count < imgObjects.length-1) ? count+1 : 0;
			var timed = setTimeout(actualRotate, 3000)
		}
		
		var imgArray = ['img/homemain-bkgd2.jpg','img/homemain-bkgd3.jpg','img/homemain-bkgd4.jpg'];
		var imgObjects = [];
		for (loop=0; loop < imgArray.length; loop++) {
			imgObjects[loop] = new Image();
			imgObjects[loop].src = imgArray[loop];
		}
		actualRotate();
	}
	else {
		return true;
	}
}

function popUpWindow(URL,windowName,width,height) {
	var w = screen.availWidth;
	var h = screen.availHeight;
	var leftPos = Math.round((w-width)/2);
	var topPos = Math.round((h-height)/2);
	var defaults = "scrollbars=auto,resizable=yes,";
	var centerOnScreen = "top="+topPos+",left="+leftPos+",width="+width+",height="+height+",scrollbars=1";
	// safari seems to need the trailer comma
	var options = "'" + defaults + centerOnScreen + ",'";
	window.name = "popup";
	var msgWindow = window.open(URL,windowName,options);
	msgWindow.creator=self;
	msgWindow.focus();
}

function popUpPrintWindow(URL,windowName,width,height) {
	var w = screen.availWidth;
	var h = screen.availHeight;
	var leftPos = Math.round((w-width)/2);
	var topPos = Math.round((h-height)/2);
	var defaults = "scrollbars=auto,resizable=yes,";
	var centerOnScreen = "top="+topPos+",left="+leftPos+",width="+width+",height="+height+",scrollbars=1,menubar=yes";
	// safari seems to need the trailer comma
	var options = "'" + defaults + centerOnScreen + ",'";
	window.name = "popup";
	var msgWindow = window.open(URL,windowName,options);
	msgWindow.creator=self;
	msgWindow.focus();
}

function popup(id)
{
  var str;
  str=  window.location.href;
  str1 =window.location.pathname; 
  popUpWindow(str.substring(0,str.indexOf(str1)+1)+ 'popup.aspx?id=' + id,"PopUp",800,400);
}

function popUpExternUrl(URL) {
	var msgWindow = window.open(URL);
	msgWindow.creator=self;
	msgWindow.focus();
}

function setup() {
	rotateHomeImages();
	currentNav();
}//fn

function Set_Cookie(name,value,expires,path,domain,secure) { 
    var cookieString = name + "=" +escape(value) + 
       ( (expires) ? ";expires=" + expires.toGMTString() : "") + 
       ( (path) ? ";path=" + path : "") + 
       ( (domain) ? ";domain=" + domain : "") + 
       ( (secure) ? ";secure" : ""); 
    document.cookie = cookieString; 
} 

function Get_Cookie(name) { 
   var start = document.cookie.indexOf(name+"="); 
   var len = start+name.length+1; 
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null; 
   if (start == -1) return null; 
   var end = document.cookie.indexOf(";",len); 
   if (end == -1) end = document.cookie.length; 
   return unescape(document.cookie.substring(len,end)); 
} 

function setMenuFromLink(word)
{
  for(var i=0; i<word.length;i++)
  { var menuWord = word[i].split("=");
  	var qv = "";
    if (menuWord.length > 1) 
    { if ((menuWord[0] == "menu") || (menuWord[0] == "MENU"))
      { qv = qv + "|" + menuWord[1]; }
      if ((menuWord[0] == "id") || (menuWord[0] == "ID"))
      { qv = word[i]; }
    }
  }
  currentli = document.getElementById(qv);
  if (currentli != null)
  { currentli.className='selected';
    // Set the cookie
    Set_Cookie('curMenu',currentli.id,'','','','');
  }
  else 
  { currentli = Get_Cookie('curMenu'); }
}

function getMenuForIdOnly(qv)
{
  var menuID;
	var listItems = document.getElementById('nav').getElementsByTagName('li');
  for(var i=0;i<listItems.length;i++)
  { menuID = (listItems[i].id).split("|");
    if (qv == menuID[0])  
    { currentli = listItems[i].id; return true; }
  }
}

window.onload = setup;

function validateForm(fields, iCount, sTitle) {
   missing="";
	if (sTitle == "") {
	 	sTitle = "Consumers Energy";
	}
	for (x=0; x<iCount; x++) {
       chkfieldmissing(fields[x][0], fields[x][1]);
    }
    if (missing != "")  {
        missing = sTitle + "\n\nThe following fields need to be completed: \n\n" + missing;
        missing += "\nPlease complete and resubmit.\n";

		  window.scrollTo(1, 1);
		  return 0;
    }
	 else {
	 	document.frmInput.submit();
	}
   return 0;
}

function escapeHTML (str)
{
   var div = document.createElement('div');
   var text = document.createTextNode(str);
   div.appendChild(text);
   return div.innerHTML;
}

function IsNumeric(value){
 	if (isNaN(value))
 		return false;
 	else
 		return true;		
}
   
//------------------------------Removes Phone Characters------------------------ 
	function RemoveChar(Cntrl) {
		var varValue;
		var strPhone;
		var objRegExp = /[()-.]/g; //search for characters globally 
		
			varValue = Cntrl.value;	
			strPhone = varValue.replace(objRegExp,'');
			if (strPhone != "") {
				if (strPhone.length != 10) {
					alert("Phone Number must be 10 digits!");
					Cntrl.focus();
					return false;
				}
				else {
					if (IsNumeric(strPhone)) {
						Cntrl.value = strPhone;
					}
					else {
						alert("Phone Number must contain numeric values!");
						Cntrl.focus();
						return false;	
					}
				}
			}
	}

//------------------------------Removes Social Security Characters-------------- 
	function RemoveSSNChar(Cntrl) {
		var varValue;
		var strSSN;
		var objRegExp = /[-.]/g; //search for characters globally 
		
			varValue = Cntrl.value;	
			strSSN = varValue.replace(objRegExp,'');
			
			if (strSSN != "") {
				if (strSSN.length != 9) {
					alert("Social Security Number must be 9 digits!");
					Cntrl.focus();
					return false;
				}
				else {
					if (IsNumeric(strSSN)) {
						Cntrl.value = strSSN;
					}
					else {
						alert("Social Security Number must contain numeric values!");
						Cntrl.focus();
						return false;	
					}
				}
			}
	}
	
//-------------------------- Email Address Validation --------------------------

// Check the email is valid or not
function isValidEmail(emailStr) {
     var emailPat = /\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.biz)|(\.mil)|(\.gov)|(\.org)|(\.es)|(\.us)|(\.{2,2}))$)\b/gi
     if (emailStr != "") {  	
	var matchArray = emailStr.match(emailPat);
	if (matchArray == null) {
              return false;
         }
     }
     return true;  
}   

// Remove the spaces in the given string
function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function


// Validate the amount with range
function validateAmount(intAmount,intChkAmount)
{	
	intAmount = intAmount.replace(/,/gi,"");
	//validate the initial amount
	if (!IsNumeric(intAmount)) {
		alert("Initial investment amount must contain numeric values!");
		return false;
	}
	if (intAmount < intChkAmount) {
		alert("Initial investment amount may not be less than $" + intChkAmount );
		return false;
	}
	else
	{ return true; }
}
function ValidateAutomaticInvestment100(intAmount)
{
	if (intAmount == "") 
	{
		alert("Please indicate the dollar amount to be deducted from your bank account.");
		return false;
	}
	
	//validate the initial amount
	if (!IsNumeric(intAmount)) {
		alert("Automatic investment amount must contain numeric values!");
		return false;
	}
	else
	{
		if ( intAmount > 0 )
		{	
			if ( intAmount < 100 )
			{ 
				//document.aspnetForm.RecurringOn1st.checked = false;
				//document.aspnetForm.RecurringOn16th.checked = false;
				alert("Automatic Investment Amount may not be less than $100"); return false;}
			else return true;
		} else return false;
   }
}
function ValidateAutomaticInvestment25(intAmount)
{
	if ((trim(intAmount) == "") && (document.aspnetForm.RecurringOn1st.checked == false) && (document.aspnetForm.RecurringOn16th.checked == false))
		 return true;
	//validate the initial amount
	if (!IsNumeric(intAmount)) {
		alert("Automatic investment amount must contain numeric values!");
		return false;
	}
	else
	{
	  if (( intAmount > 0 ) || ((document.aspnetForm.RecurringOn1st.checked) ||  (document.aspnetForm.RecurringOn16th.checked)))
	  {	
		  if ( trim(intAmount) == "")
		  {
			alert("Please enter the amount to be deducted from your bank account.");
			return false;
		  }
		  if ( intAmount < 25 )
		    { 
		      //document.aspnetForm.RecurringOn1st.checked = false;
		      //document.aspnetForm.RecurringOn16th.checked = false;
		      alert("Automatic Investment Amount may not be less than $25"); return false;}
		  else
		    { 
			    if ((document.aspnetForm.RecurringOn1st.checked) ||  (document.aspnetForm.RecurringOn16th.checked))
	        {
				
		        return true;
	        }
	        else
	        {
	          alert("Please check the investment date. (Check both for twice-monthly investments)");
	          return false;
	        }
	      }
	    return true;
	  }
	}
	return true;
}
// Validate the stock type
function validateStockType(intValue)
{
  if (intValue == 5)
  {
    if (trim(document.aspnetForm.stockComment.value) == "")
    {
      alert("If you select the stock type as other, please enter the comment");
      return false;
    }
  }
  return true;
}
// Validate the stock account number or ssn SHOULD NOT BE EMPTY
function validateStockAccNoAndSSN(val1, val2)
{
  if ((val1=="") && (val2==""))
  {
    alert("Please enter the Stock Account Number (OR) Social Security Number/Tax ID");
    return false;
  }
  return true;
}
// Check the bank account type is selected or not
function validateBankAccountTypeSelected(val)
{
  if ((val[0].checked) || (val[1].checked))
    return true;
  else
  {
    alert("Please select the Bank Account Type - (Checking/Saving)");
    return false;
  }
}
// Check the eSignature_Confirm check box
function eSignature_Confirm(val)
{
  if (val.checked)
	return true;
  else
  {
    alert("Please select the 'I Agree' check box");
    return false;
  }
}
//checkSalesStock
function checkSalesStock(val)
{
  if ((val[0].checked) || (val[1].checked))
  {
    if (val[0].checked)
    {
      if (trim(document.aspnetForm.Number_of_Shares.value) == "")
        {
          alert("You must specify the number of shares for the Sales Request");
          return false;
        } 
        else return true;
    }
    else if ((val[0].checked == false) && (val[1].checked == false))
    {
		alert("You must choose either a specific number of shares to sell or indicate that you wish to sell ALL");
		return false;
    }
    else if ((val[1].checked) && (trim(document.aspnetForm.Number_of_Shares.value) != ""))
    {
		alert("Your choices under Sales Request are inconsistent. Please review and make corrections. If you mark the 'Sell All shares' button, then leave the number of shares box empty.");
		return false;
    }
    else  return true;
  }
  else
  {
    alert("You did not specify what type of sales request you are making");
    return false;
  }
}
// Check the Request_Stock_Certificate is selected or not. If the option 1 selected then check the amount is entered.
function checkReqStock(val)
{
  if ((val[0].checked) || (val[1].checked))
  {
    if (val[1].checked)
    {
      if (trim(document.aspnetForm.Number_of_Shares.value) == "")
        {
          alert("You must specify the number of shares");
          return false;
        } 
        else return true;
    }
    else if ((val[0].checked == false) && (val[1].checked == false))
    {
			alert("You must choose either a specific number of shares to send a certificate or indicate that you wish to send whole shares");
			return false;
    }
    else if ((val[0].checked) && (trim(document.aspnetForm.Number_of_Shares.value) != ""))
    {
		alert("Your choices under Request Stock Certificate are inconsistent. If you mark the 'All' Shares button, then leave the number of shares box empty. Please review and make corrections.");
		return false;
    }
    else  return true;
  }
  else
  {
    alert("You did not specify what type of certificate request you are making");
    return false;
  }
} 
// Check the Authorization Type
function chkAuthType(val)
{
  if (val.length == 2)
  {
    if ((val[0].checked == false) && (val[1].checked == false))
    {
      alert("Please indicate whether this authorization is new or a change.");
      return false;
    }
    else return true;
  }
  else
  {
    if (val.checked)
      return true;
    else
    {
      alert("Please select the Authorization check box");
      return false;
    }
  }
}
//Check the CMS Stock Type
function chkCMSStkType(val1, val2)
{
  if ((val1.checked) || (val2.checked))
      return true;
  else
  {
    alert("Please select the 'TYPE OF STOCK YOU OWN' check box");
    return false;
  }
}
//Check the Direct_Deposit_Cancellation 
function chkDirectDepositCancel(val)
{
 if ((val[0].checked) || (val[1].checked))
  return true;
 else
 {
  alert("Please select one of the Direct Deposit Cancellation choices.");
  return false;
 }
}
// Check the Dividend_Reinvestment_Participation 
function chkDivParticipation(val)
{
    if (val[1].checked)
    {
			if ((trim(document.aspnetForm.Percentage_of_Shares.value) == "") && (trim(document.aspnetForm.Number_of_Shares.value) == ""))
			{
				alert("You have chosen Partial Reinvestment. Please indicate either the number of shares OR % of total dividend to be paid rather than reinvested.");
				return false;
			}
			else if ((trim(document.aspnetForm.Percentage_of_Shares.value) != "") && (trim(document.aspnetForm.Number_of_Shares.value) != ""))
			{
				alert("Please enter information in only one, not both, of the Partial Reinvestment boxes. Indicate either the number of shares OR % of the total dividend to be paid rather than reinvested");
				return false;
			}
			else return true;
		}
    else
    {
			if ((trim(document.aspnetForm.Percentage_of_Shares.value) != "") || (trim(document.aspnetForm.Number_of_Shares.value) != ""))
			{
				alert("You have not chosen Partial Reinvestment, so the associated boxes do not need to be filled in. Please verify that you have chosen the reinvestment option that you intended.");
				return false;
			}
    }
    return true;
}
// Check the Dividend_Reinvestment_Participation 
function chkDivParticipationShares(val)
{
  if ((val[0].checked) || (val[1].checked) || (val[2].checked))
    {
      if (val[2].checked)
      {
        if ((trim(document.aspnetForm.Percentage_of_Shares.value) == "") && (trim(document.aspnetForm.Number_of_Shares.value) == ""))
        {
          alert("You have chosen Partial Reinvestment, please indicate either the number of shares OR % of total dividend to be paid rather than reinvested");
          return false;
        }
        else 
        { 
          if ((trim(document.aspnetForm.Percentage_of_Shares.value) != "") && (trim(document.aspnetForm.Number_of_Shares.value) != ""))
		      {
		        alert("You have chosen Partial Reinvestment, please indicate either the number of shares OR % of total dividend to be paid rather than reinvested");
            return false;
          }
          return true;
        }
      }
      else if ((val[0].checked) || (val[1].checked))
      {
		    if ((trim(document.aspnetForm.Percentage_of_Shares.value) != "") || (trim(document.aspnetForm.Number_of_Shares.value) != ""))
		      {
			      alert("You have not chosen Partial Reinvestment so the associated boxes do not need to be filled in. Please verify that you have marked these boxes correctly.");
			      return false;
		      }
		    else  return true;
      }
      return true;
    }
  else
  {
    alert("Please select one of the Dividend Reinvestment Participation option");
    return false;
  }
}
function chkOptInvestAmount(intVal)
{
	if ((intVal <= 0) || (intVal < 24) || (intVal > 250000))
	{
		alert("Optional investment amount should be minimum $25 or less than $250,000");
		return false;
	}
	return true;
}
// splitHyphen[0]=='11' - Check the amount is  > 250
// splitHyphen[0]=='22' - Check the automatic recurring investment 25
// splitHyphen[0]=='23' - Check the automatic recurring investment 100
// splitHyphen[0]=='33' - Check the stock stype is selected or not
// splitHyphen[0]=='44' - Check Bank Account type is selected
// splitHyphen[0]=='55' - Check the Stock Acccount or SSN entered
// splitHyphen[0]=='66' - Check the eSignature_Confirm
// splitHyphen[0]=='77' - Check the routing number is valid or not
// splitHyphen[0]=='88' - Check the Request_Stock_Certificate
// splitHyphen[0]=='89' - Check the Request_Stock_Certificate for sell shares
// splitHyphen[0]=='99' - Check the Authorization Type
// splitHyphen[0]=='10' - Check the CMS Stock Type
// splitHyphen[0]=='20' - Check the Direct_Deposit_Cancellation 
// splitHyphen[0]=='30' - Check the Dividend_Reinvestment_Participation 
// splitHyphen[0]=='40' - Check the Dividend_Reinvestment_Participation shares is entered or not
// splitHyphen[0]=='50' - Check the Optional Investment amount > 25 and <250,000


function validate(strParm)
{
  
  var blnResult;
  // No Validation
  if (strParm=="") return true;
  var splitPipe=strParm.split("|");
  if (splitPipe.length > 1)
  {
    for(var i=0;i<splitPipe.length;i++)
    {
      var splitHyphen=splitPipe[i].split("-");
      if (splitHyphen[0]=='11')
      {
        if (splitHyphen.length > 1)
        {
          var tmpVal = "Initial_Investment";
          if (validateAmount(document.aspnetForm[tmpVal].value,250))
          { blnResult = true; }
          else
          { return false; }
        }
      }
      if (splitHyphen[0]=='22')
      {
          var tmpVal = "Automatic_Investment_Amount";
          if (ValidateAutomaticInvestment25(document.aspnetForm[tmpVal].value))
          { blnResult = true;}
          else
          {return false;}
      }      
      if (splitHyphen[0]=='23')
      {
          var tmpVal = "Automatic_Investment_Amount";
          if (ValidateAutomaticInvestment100(document.aspnetForm[tmpVal].value))
          { blnResult = true;}
          else
          {return false;}
      }      
      if (splitHyphen[0]=='33')
      {
          var tmpVal = "stockType"+splitHyphen[1];
          if (validateStockType(document.aspnetForm[tmpVal].value))
          { blnResult = true;}
          else
          {return false;}
      }
      if (splitHyphen[0]=='44')
      {
          var tmpVal = "AcctType";
          if (validateBankAccountTypeSelected(document.aspnetForm[tmpVal]))
          { blnResult = true;}
          else
          {return false;}
      }      
      if (splitHyphen[0]=='55')
      {
          var tmpVal = "Stock_Account_Number";
          var tmpVal1 = "Social_Security_Number";
          if (validateStockAccNoAndSSN(document.aspnetForm[tmpVal].value,document.aspnetForm[tmpVal1].value))
          { blnResult = true;}
          else
          {return false;}
      }      
      if (splitHyphen[0]=='66')
      {
          var tmpVal = "eSignature_Confirm";
          if (eSignature_Confirm(document.aspnetForm[tmpVal]))
          { blnResult = true;}
          else
          {return false;}
      }
      if (splitHyphen[0]=='77')
      {
          var tmpVal = "Routing_Number";
          if (ValidateRoutingNumber(document.aspnetForm[tmpVal].value))
          { blnResult = true;}
          else
          {return false;}
      }
      if (splitHyphen[0]=='88')
      {
          var tmpVal = "Request_Stock_Certificate";
          if (checkReqStock(document.aspnetForm[tmpVal]))
          { blnResult = true;}
          else
          {return false;}
      }
      if (splitHyphen[0]=='89')
      {
          var tmpVal = "Sales_Request";
          if (checkSalesStock(document.aspnetForm[tmpVal]))
          { blnResult = true;}
          else
          {return false;}
      }      
      if (splitHyphen[0]=='99')
      {
          var tmpVal = "Authorization_Type";
          if (chkAuthType(document.aspnetForm[tmpVal]))
          { blnResult = true;}
          else
          {return false;}
      }      
      if (splitHyphen[0]=='10')
      {
          var tmpVal1 = "CMS_Energy_Common_Stock";
          var tmpVal2 = "CMS_Energy_Preferred_Stock";
          if (chkCMSStkType(document.aspnetForm[tmpVal1],document.aspnetForm[tmpVal2]))
          { blnResult = true;}
          else
          {return false;}
      }
      if (splitHyphen[0]=='20')
      {
          var tmpVal = "Direct_Deposit_Cancellation";
          if (chkDirectDepositCancel(document.aspnetForm[tmpVal]))
          { blnResult = true;}
          else
          {return false;}
      }                 
      if (splitHyphen[0]=='30')
      {
          var tmpVal = "Dividend_Reinvestment_Participation";
          if (chkDivParticipation(document.aspnetForm[tmpVal]))
          { blnResult = true;}
          else
          {return false;}
      }     
      if (splitHyphen[0]=='40')
      {
          var tmpVal = "DIVIDEND_REINVESTMENT_PARTICIPATION";
          if (chkDivParticipationShares(document.aspnetForm[tmpVal]))
          { blnResult = true;}
          else
          {return false;}
      }     
      if (splitHyphen[0]=='50')
      {
          var tmpVal = "Optinal_Investment_Amount";
          if (chkOptInvestAmount(document.aspnetForm[tmpVal].value))
          { blnResult = true;}
          else
          {return false;}
      }       
    }
  }
  return blnResult;
}