function changeEdt(thisDoc,tmp_int_sel1,tmp_int_sel2)
{	
	/* by default display the 1st option as selected [none/1st parent cat] */
	tmp_int_idx = 1;

	/* get the ID of selected language */
	tmp_int_lang = thisDoc["frmLang"].value;		

	if( tmp_int_lang != "" )
	{		
		tmp_int_pCnt = parseInt(eval("tmp_int_pCnt_"+tmp_int_lang));		

		/* if category exists for this lang code */
		if( tmp_int_pCnt > 0 )
		{
			tmp_str_catJID    =  tmp_arr_catID[tmp_int_lang];
			tmp_arr_catJID    =  tmp_str_catJID.split("~");

			tmp_str_catJTitle =  tmp_arr_catTitle[tmp_int_lang];
			tmp_arr_catJTitle =  tmp_str_catJTitle.split("~");			
			
			/* remove the old values from dropdown */
			emptyDD("frmpgroup",thisDoc);

			/* add "select " option */
			addNew("frmpgroup","","-- Select School Title --",thisDoc,0);

			/* add all the parent cats */
			for(i=1;i<tmp_arr_catJID.length;i++)
			{
				elmt = new Option();
				elmt.value = tmp_arr_catJID[i];
				elmt.text  = tmp_arr_catJTitle[i];
				thisDoc["frmpgroup"].options[i] = elmt;

				/* if value to be displayed as selected is found use it as index*/
				if( tmp_int_sel1 == tmp_arr_catJID[i] )
				{
					tmp_int_idx = i;
				}
			}

			/* display the following option as selected */
			thisDoc["frmpgroup"].options[tmp_int_idx].selected = true;

			/* change the 2nd dynamic dropdown */
			changeEdt2(thisDoc,tmp_int_sel2);
		}
		else
		{
			/* remove the old values from dropdown */
			emptyDD("frmpgroup",thisDoc);
			emptyDD("frmcgroup[]",thisDoc);

			/* add select option */
			addNew("frmpgroup","","-- Select School Title --",thisDoc,0);
			//addNew("frmcgroup[]","","-- Select Parent content --",thisDoc,0);

			/* add No category option */
			//addNew("frmpgroup","-1","Sub Category Content",thisDoc,1);
			//addNew("frmcgroup[]","-1","Sub Category Content",thisDoc,1);
		}
	}
	else
	{
		/* remove the old values from dropdown */
		emptyDD("frmpgroup",thisDoc);
		emptyDD("frmcgroup[]",thisDoc);

		/* add select option */
		addNew("frmpgroup","","-- Select School title --",thisDoc,0);
		//addNew("frmcgroup[]","","-- Select Parent content --",thisDoc,0);
	}
}

function changeEdt2(thisDoc,tmp_int_sel3)
{


	/* by default display the 1st option as selected [none/1st sub cat] */
	tmp_int_idx2 = 1;	

	/* get the parent ID of selected option*/
	tmp_int_prntID   = thisDoc["frmpgroup"].value;
	
	//alert(tmp_int_prntID)
	
	tmp_int_sel2     = tmp_int_sel3.split("~")
	
	//alert(tmp_int_sel2[0])

	/*
	if(tmp_int_prntID == 0)
	{
		tmp_int_prntID = parseInt(eval(thisDoc["frmLang"].value+"0000"));
	}
	*/
	
	//alert(tmp_int_prntID);

	if( tmp_int_prntID != "" )
	{
		tmp_int_sCnt = parseInt(eval("tmp_int_sCnt_"+tmp_int_prntID));


		/* if sub cat exists for this parent cat */
		if( tmp_int_sCnt > 0 )
		{
				tmp_str_cntJID   = tmp_arr_cntID[tmp_int_prntID];
				//alert(tmp_str_cntJID);
				tmp_arr_cntJID   = tmp_str_cntJID.split("~")				
				
				tmp_str_cntJTitle  = tmp_arr_cntTitle[tmp_int_prntID];
				tmp_arr_cntJTitle  = tmp_str_cntJTitle.split("~")

				/* remove the old values from dropdown */
				emptyDD("frmcgroup[]",thisDoc);

				/* add "select " option */
				addNew1("frmcgroup[]","","-- Select Class Title  --",thisDoc,0);

				/* add all the sub cats */		
				
				for(i=1;i<tmp_arr_cntJID.length;i++)
				{
					//alert(tmp_arr_cntJID[i]);
					elmt = new Option();
					elmt.value = tmp_arr_cntJID[i];
					elmt.text  = tmp_arr_cntJTitle[i];
					thisDoc["frmcgroup[]"].options[i] = elmt;
					//alert(tmp_int_sel2.length);
					var j;
					
					//alert(tmp_int_sel2.length)					
					
					for(j=0;j<tmp_int_sel2.length;j++)
					{
						//alert (tmp_int_sel2[j] +"="+tmp_arr_cntJID[i]);
						if (tmp_int_sel2[j] == tmp_arr_cntJID[i])
						{
						tmp_int_idx2 = i;
						thisDoc["frmcgroup[]"].options[tmp_int_idx2].selected = true;
					
						}
					}
					
					/*
					if( tmp_int_sel2 == tmp_arr_cntJID[i] )
					{
						tmp_int_idx2 = i;
					}
					*/									
					
				}

				//thisDoc["frmcgroup[]"].options[tmp_int_idx2].selected = true;

		}
		else
		{
			/* remove the old values from dropdown */
			emptyDD("frmcgroup[]",thisDoc);

			/* add select option */
			//addNew("frmcgroup[]","","-- Select Parent content --",thisDoc,0);

			/* add No category option */
			//addNew("frmcgroup[]","-1","Sub Category Content",thisDoc,1);
		}
	}
	else
	{
		//alert("Test");
	
		/* remove the old values from dropdown */
		emptyDD("frmcgroup[]",thisDoc);

		/* add select option */
		//addNew("frmcgroup[]","","-- Select Parent content --",thisDoc,0);

		/* remove the old values from dropdown */
		emptyDD("frmpgroup",thisDoc);

		/* add select option */
		addNew("frmpgroup","","-- Select School title --",thisDoc,0);

		/* remove the old values from lang dropdown */
		emptyDD("frmLang",thisDoc);

		/* add select option */	
		addNew("frmLang","","-- Select language --",thisDoc,0);
		addNew("frmLang","1","English",thisDoc,1);
		addNew("frmLang","31","Dutch",thisDoc,2);
		
		thisDoc['frmLang'].options[0].selected = true;
	}
}


function addNew(tmp_str_name,tmp_str_val,tmp_str_txt,thisDoc,tmp_int_idx)
{
	//alert("test");
	/* add "new " option */
	elmt = new Option();
	elmt.value = tmp_str_val;
	elmt.text  = tmp_str_txt;
	thisDoc[tmp_str_name].options[tmp_int_idx] = elmt;
	thisDoc[tmp_str_name].options[tmp_int_idx].selected = true;
}


function emptyDD(tmp_str_name,thisDoc)
{
	/* get the currrent no of options  */
	//alert("vishal");
	tmp_int_pLen = thisDoc[tmp_str_name].length;

	/* empty the  drop down */
	for(i=tmp_int_pLen;i>=0;i--)
	{
		thisDoc[tmp_str_name].options[i] = null;
	}
}

function check(thisDoc,tmp_int_sel)
{
	if( tmp_int_sel == "" )
	{
		/* remove the old values from lang dropdown */
		emptyDD("frmLang",thisDoc);

		/* add select option */
		addNew("frmLang","","-- Select language --",thisDoc,0);
		addNew("frmLang","1","English",thisDoc,1);
		addNew("frmLang","31","Dutch",thisDoc,2);		

		thisDoc['frmLang'].options[0].selected = true;

		/* remove the old values from dropdown */
		emptyDD("frmpgroup",thisDoc);

		/* add select option */
		addNew("frmpgroup","","-- Select School title --",thisDoc,0);
		
		/* remove the old values from dropdown */
		emptyDD("frmcgroup[]",thisDoc);
		
	}
}

function addNew1(tmp_str_name,tmp_str_val,tmp_str_txt,thisDoc,tmp_int_idx)
{
	/* add "new " option */
	elmt = new Option();
	elmt.value = tmp_str_val;
	elmt.text  = tmp_str_txt;
	thisDoc[tmp_str_name].options[tmp_int_idx] = elmt;	
}

function change(tmp_str_frm,tmp_str_cb1,tmp_str_cb2,tmp_int_sel3)
{
/*
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	 Name		: change()
	 Purpose	: Dynamic interdependant comboboxes
	 Inputs		: tmp_str_frm  	 -> form name
			  tmp_str_cb1 	 -> 1st combobox
			  tmp_str_cb2	 -> 2nd combobox
			  tmp_int_sel2	 -> value in 2nd combobox to be displayed
			  		    as selected
	 Outputs	: change the data to be displayed depending on value
	 		  selected in 1st combo box
	 Calls		: None
	 Called By	:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
*/
   /* get the form object */
   eval("thisDoc = document."+tmp_str_frm);

   //alert(tmp_int_sel2);
   
   tmp_int_sel2     = tmp_int_sel3.split("~")

   /* get the selected option */
   eval("tmp_int_sel1 = thisDoc."+tmp_str_cb1+"[thisDoc."+tmp_str_cb1+".selectedIndex].value");
   
   //alert(tmp_int_sel1);

   /* if values exist in 1st combobox */
   if( tmp_int_sel1 != "" )
   {
   	/* retrieve the corresponding ids for selected item */
  	tmp_str_ids = "tmp_arr_ids2["+tmp_int_sel1+"]";
	tmp_str_vals = "tmp_arr_vals2["+tmp_int_sel1+"]";

  	eval("tmp_str_ids2 = "+tmp_str_ids);
  	eval("tmp_str_vals2 = "+tmp_str_vals);

	/* remove the preceeding ~ */
  	tmp_str_ids   = tmp_str_ids2.substring(1,tmp_str_ids2.length);
  	tmp_str_vals  = tmp_str_vals2.substring(1,tmp_str_vals2.length);

	/* convert into array by splitting on basis on ~ */
	tmp_arr_opt = tmp_str_ids.split("~");
	tmp_arr_txt = tmp_str_vals.split("~");

	/* get the no of options for combobox 	*/
	tmp_int_cLen = thisDoc[tmp_str_cb2].length;
	//tmp_int_cLen = eval("thisDoc."+tmp_str_cb2+".length");

	/* empty the old list of options */
	for(j = tmp_int_cLen; j>=0; j--)
	{
		thisDoc[tmp_str_cb2].options[j] = null;
	}

	tmp_int_idx = 0;

	//elmnt = new Option();
	//elmnt.value = "";
	//elmnt.text = "Select Parent";
	//thisDoc[tmp_str_cb2].options[0]= elmnt;

	if(tmp_int_sel2 == 0 )
	{
	    tmp_int_idx = 0;
	}

	//alert(tmp_arr_opt.length);

	/* fill the 2nd combobox with appropriate values   */
	for(k=0;k<tmp_arr_opt.length ; k++)
	{
	    elmt = new Option();

	    //alert(tmp_arr_txt[k]);

	    /* if option for selected item exists */
	    if(tmp_arr_txt[k] != "" )
	    {
		elmt.value = tmp_arr_opt[k];
		elmt.text  = tmp_arr_txt[k];
		thisDoc[tmp_str_cb2].options[k]= elmt;
		
		for(j=0;j<tmp_int_sel2.length;j++)
		{
			//alert (tmp_int_sel2[j] +"="+tmp_arr_cntJID[i]);
			if (tmp_int_sel2[j] == tmp_arr_opt[k])
			{
			tmp_int_idx = k;
			thisDoc[tmp_str_cb2].options[tmp_int_idx].selected = true;
			}
	        }
		
		document.getElementById("rsubCatId").style.display="";
	    }		
	    else
	    {
	    	document.getElementById("rsubCatId").style.display="none";
	    	emptyDD(tmp_str_cb2,thisDoc);
		  
		elmt = new Option();
		elmt.value = "";
		elmt.text  = "None";
		thisDoc[tmp_str_cb2].options[0]= elmt;
	    }
	    
	}
	//thisDoc[tmp_str_cb2].options[tmp_int_idx].selected = true;
  }
  else
  {
  	document.getElementById("rsubCatId").style.display="none";
  	emptyDD(tmp_str_cb2,thisDoc);
  
        elmt = new Option();
	elmt.value = "";
	elmt.text  = "None";
	thisDoc[tmp_str_cb2].options[0]= elmt;
  }
}

function changeEdt3(thisDoc,tmp_int_sel1,tmp_int_sel2,tmp_int_sel3)
{	
	/* by default display the 1st option as selected [none/1st parent cat] */
	tmp_int_idx = 1;

	/* get the ID of selected language */
	tmp_int_lang = tmp_int_sel3;	
	
	var sellin;
	sellin = thisDoc["sellangindex"].value;
	//alert(sellin);
	thisDoc["frmLang"].options[sellin].selected = true;
	/*
	if(tmp_int_sel3 == "1")
	{
		thisDoc["frmLang"].options[1].selected = true;
	}
	else
	{	
		thisDoc["frmLang"].options[2].selected = true;
	}
	*/
	//alert(tmp_int_lang);

	if( tmp_int_lang != "" )
	{		
		tmp_int_pCnt = parseInt(eval("tmp_int_pCnt_"+tmp_int_lang));		

		/* if category exists for this lang code */
		if( tmp_int_pCnt > 0 )
		{
			tmp_str_catJID    =  tmp_arr_catID[tmp_int_lang];
			tmp_arr_catJID    =  tmp_str_catJID.split("~");

			tmp_str_catJTitle =  tmp_arr_catTitle[tmp_int_lang];
			tmp_arr_catJTitle =  tmp_str_catJTitle.split("~");			
			
			/* remove the old values from dropdown */
			emptyDD("frmpgroup",thisDoc);

			/* add "select " option */
			addNew("frmpgroup","","-- Select School Title --",thisDoc,0);

			/* add all the parent cats */
			for(i=1;i<tmp_arr_catJID.length;i++)
			{
				elmt = new Option();
				elmt.value = tmp_arr_catJID[i];
				elmt.text  = tmp_arr_catJTitle[i];
				thisDoc["frmpgroup"].options[i] = elmt;

				/* if value to be displayed as selected is found use it as index*/
				if( tmp_int_sel1 == tmp_arr_catJID[i] )
				{
					tmp_int_idx = i;
				}
			}

			/* display the following option as selected */
			thisDoc["frmpgroup"].options[tmp_int_idx].selected = true;

			/* change the 2nd dynamic dropdown */
			changeEdt2(thisDoc,tmp_int_sel2);
		}
		else
		{
			/* remove the old values from dropdown */
			emptyDD("frmpgroup",thisDoc);
			emptyDD("frmcgroup[]",thisDoc);

			/* add select option */
			addNew("frmpgroup","","-- Select School Title --",thisDoc,0);
			//addNew("frmcgroup[]","","-- Select Parent content --",thisDoc,0);

			/* add No category option */
			//addNew("frmpgroup","-1","Sub Category Content",thisDoc,1);
			//addNew("frmcgroup[]","-1","Sub Category Content",thisDoc,1);
		}
	}
	else
	{
		/* remove the old values from dropdown */
		emptyDD("frmpgroup",thisDoc);
		emptyDD("frmcgroup[]",thisDoc);

		/* add select option */
		addNew("frmpgroup","","-- Select School title --",thisDoc,0);
		//addNew("frmcgroup[]","","-- Select Parent content --",thisDoc,0);
	}	
	
}