function mmInitialize(parent, maincat, subcat, maincat_caption, subcat_caption)

    {

    var rgMaincat;

    

	//call function to clear dropdown menu for maincat

    clearList(parent.maincat);

	//add an element to the maincat drop down.

    addElement(parent.maincat, maincat_caption, 0);

    


        for (var i = 0; i < maincats.length; i++)

            {

            if (maincats[i])

                {

                rgMaincat = maincats[i].split('#');

				

				//add the array to the drop down menu

                addElement(parent.maincat, rgMaincat[0], rgMaincat[1]);

                }

            }








	// if maincat is defined, call function to populate subcats

    if (maincat)

        {

        setDefault(parent.maincat, maincat);

        mmChangeMaincat(parent, subcat_caption);

        if (subcat)

            setDefault(parent.subcat, subcat);

        }

    else

        {

        parent.maincat.selectedIndex = 0;



        mmChangeMaincat(parent, subcat_caption);

        }

    }



function mmChangeMaincat(parent, subcat_caption)

    {


        var SubcatList = subcats[parent.maincat.options[parent.maincat.selectedIndex].value];




	//call function to clear the subcat dropdown

    clearList(parent.subcat);

	//add 'subcat' to subcat dropdown

    addElement(parent.subcat, subcat_caption, 0);



	//add the array to subcat drop down menu if defined

    if(SubcatList)

        {

        var rgSubcats = SubcatList.split(',');



        for (var i = 0; i < rgSubcats.length; i++)

            {

            if (rgSubcats[i])

                {

                var rgSubcat = rgSubcats[i].split('#');



                addElement(parent.subcat, rgSubcat[0], rgSubcat[1]);

                }

            }

        parent.subcat.disabled = false;



        }

	//if subcatlist is undefined disable drop down menu.

    else

        {

        parent.subcat.disabled = true;



        }



    parent.subcat.selectedIndex = 0;



    } 




//function used to erase all elements in a drop down menu

function clearList(list) 

    {

    var i = 0;

    var o = list.options;



    for (i = o.length; i >= 0; --i)

                o[i] = null;

    list.disabled = true;

    }



//function used to add elements to a drop down menu

function addElement(list, text_in, value_in)

    {

    var o = list.options;

    var nIdx;

        if (o.length < 0) //IE for Mac 4.5 sets length to -1 if list is empty

                nIdx = 0;



        else

                nIdx = o.length;



                

        o[nIdx] = new Option(text_in, value_in);

        list.disabled = false;



    }





function setDefault(list, text_in)

    {

    with (list)

        {

        for (var i = 0; i < (options.length); i++)

             {

             if (options[i].value == text_in)

                 {

                 selectedIndex = i;



                 return;

                 }

             }

        }

    }





   function gotoNext(oForm)

     {

     var strMaincat = oForm.maincat.options[oForm.maincat.selectedIndex].value;

     var strSubcat = oForm.subcat.options[oForm.subcat.selectedIndex].value;



     if (!ValidateList(oForm, strMaincat, strSubcat)) return;

		oForm.submit();

     }



   function ValidateList(oForm, strMaincat, strSubcat)

     {

     if(strMaincat == '0')

       {

       alert('Please select a Maincat to continue.');

       oForm.maincat.focus();

       return false;

       }

     if(strSubcat == '0')

       {

       alert('Please select a Subcat to continue.');

       oForm.subcat.focus();

       return false;

       }

     return true;

     }



 








