/*

 ***********************************************************************

* Copyright by State of Michigan (Unpublished) - All rights reserved.

*********************************************************************

* Name:  insurance_company_criteria.js

*

* Description:  Client script for the Insurance Company

* Criteria web page.

*

* Special Logic:  None

*

***********************************************************************

* Modification Log:

*

* Programmer      Date      Request No.      Version   Changes

* Doug Cook       11/29/01  N/A              1.0       Original Code                      

*

***********************************************************************

*/



//  Function:  findArrayValue

//  Purpose:  Loop through the Company List radio button array

//            to determine which radio button was selected.

function findArrayValue()

{

	var intCounter = 0;

	var intRadioButtonCount = 0;

	var strRadioButtonValue = "";



	// Get the number of radio buttons.

	intRadioButtonCount = document.frmIndustryCriteria.btnCompanyType.length;



 	for (intCounter = 0; intCounter < intRadioButtonCount; intCounter++)

 	{

    	// If the radio button is check, extract the value and break out of the loop.

		if (document.frmIndustryCriteria.btnCompanyType[intCounter].checked)  

    	{

       		strRadioButtonValue = document.frmIndustryCriteria.btnCompanyType[intCounter].value;        		

			break;                                    

    	}

	 }

	 

	 // Return the value of the radio button.

	 return strRadioButtonValue;

}	

	

// Function:  leftTrim

// Purpose: Remove the leading spaces from the search criteria fields.

function leftTrim(strLeftTrimString)

{

	return strLeftTrimString.replace(/^\s*/gi, "");

}



// Function:  rightTrim

// Purpose: Remove the trailing spaces from the search criteria fields.

function rightTrim(strRightTrimString)

{

	return strRightTrimString.replace(/\s+$/gi, "");

}



// Function: validateForm

// Purpose: Submit event for the form.  Verify the user completed the form

// correctly.

function validateForm()

{

	if (verifySelection())

	{

	  return true;

	}   

	else

	{

	  return false;

	}

}

    

// Function: verifySelection

// Purpose: Trim the leading and trailing spaces from the Insurance

// Company field.  

function verifySelection()

{

 	strToTrim = document.frmIndustryCriteria.txtInsuranceCompany.value;

	strToTrim = rightTrim(strToTrim);

	strToTrim = leftTrim(strToTrim);

	document.frmIndustryCriteria.txtInsuranceCompany.value = strToTrim;

 		

  	// Based on the Insurance Company Type selected, open the appropriate list page:

	strRadioButtonValue = findArrayValue();

	

	switch (strRadioButtonValue) {

	 case "ALL":

	   document.frmIndustryCriteria.action = "/fis/ind_srch/ins_comp/all_company_list.asp";

	   return true; 

	   break;  

	 case "ALLMI":

	   document.frmIndustryCriteria.action = "/fis/ind_srch/ins_comp/all_mi_company_list.asp";

	   return true; 

	   break;    

	 case "FRT":

	   document.frmIndustryCriteria.action = "/fis/ind_srch/ins_comp/fraternal_list.asp";

	   return true; 

	   break;

	 case "HMO":

	   document.frmIndustryCriteria.action = "/fis/ind_srch/ins_comp/hmo_list.asp";

	   return true; 

	   break;  

	 case "HEALTH":

	   document.frmIndustryCriteria.action = "/fis/ind_srch/ins_comp/health_list.asp";

	   return true; 

	   break;

	 case "LC":

	   document.frmIndustryCriteria.action = "/fis/ind_srch/ins_comp/legislatively_created_list.asp";

	   return true; 

	   break;

	 case "LIFE":

	   document.frmIndustryCriteria.action = "/fis/ind_srch/ins_comp/life_list.asp";

	   return true; 

	   break;

	 case "PC":

	   document.frmIndustryCriteria.action = "/fis/ind_srch/ins_comp/property_casualty_list.asp";

	   return true; 

	   break;

	 case "PROP":

	   document.frmIndustryCriteria.action = "/fis/ind_srch/ins_comp/property_list.asp";

	   return true; 

	   break;

	 case "SF":

	   document.frmIndustryCriteria.action = "http://www.michigan.gov/ofir";

	   return true;

	   break;

	 case "SL":

	   document.frmIndustryCriteria.action = "/fis/ind_srch/ins_comp/surplus_line_list.asp";

	   return true; 

	   break;

	 case "TL":

	   document.frmIndustryCriteria.action = "/fis/ind_srch/ins_comp/title_list.asp";

	   return true; 

	   break;

    }  

}

	







	






