// When Category changes, populate the designations
/*  var v_list = new String("<%=final_info%>");
	var arr_list= v_list.split("*")
*/


function assign_officer()
{
//get the cateogory code
var sel_cat = new String(document.form1.category.value);
var i=0;
var cur_cat;
var off_list;
var j=0;

//Ignore the sub category i.e. 01a or 01b is treated as 01
sel_cat = sel_cat.substr(0,sel_cat.length)

for(i=0;i<5;i++)
{
for(j=3;j<document.form1.addressedto.length;j++)
		{
			//document.form1.addressedto.options[j]=null;
			document.form1.addressedto.remove(j)
		}
}
		
//alert(sel_cat);
for(i=0;i<arr_list.length;i++)
{
	cur_cat=new String(arr_list[i]);
	cur_cat = cur_cat.substring(0,cur_cat.indexOf(";"))
	//alert(cur_cat);
	if(cur_cat==sel_cat)
	 {
		off_list = new String(arr_list[i])
		off_list = off_list.substr(3)
		//alert(off_list)
		
		off_list = off_list.split(",")
//		alert(off_list[0])
		if(off_list[0]!="")
		{		
		for(j=0;j<off_list.length;j++)
		{
			var opt =  new Option(off_list[j])
			document.form1.addressedto.options[j+1] =opt
			
		}
		}	
	return;
	 }
}
 
}

//Validations for Page:
function assigndept()
{
document.form1.department.selectedIndex=document.form1.addressedto.selectedIndex;
}
function disable_dept()
{
document.form1.department.blur();
	//document.form1.department.disabled=true;
}

function checkfields()
{
var errnullstatus;
errnullstatus=0;
//document.form1.category.value=Trim(document.form1.category.value)

Trim(document.form1.applicant);
Trim(document.form1.address);
Trim(document.form1.subject);

	if(document.form1.category.selectedIndex==0)
	{
		errnullstatus=1;
		document.form1.category.focus();
	}
	
	else if (document.form1.addressedto.selectedIndex==0)
	{
	errnullstatus=1;
	document.form1.addressedto.focus();
	}
	
			
	else if (document.form1.applicant.value=='')
	{
	errnullstatus=1;
	document.form1.applicant.focus();
	}
		
	else if (document.form1.address.value=='')
	{
	errnullstatus=1;
	document.form1.address.focus();
	}
	
	else if (document.form1.subject.value=='')
	{
	errnullstatus=1;
	document.form1.subject.focus();
	}

	
	if (errnullstatus==1)
	{
		alert ("The fields marked * are required.")
		return false;
	}
	
}

// *****************************************

function clearall()
{
  var i;
          for(i=0;i<document.form1.elements.length;i++)
    { 
      if(document.form1.elements[i].type=="text")
         document.form1.elements[i].value=""
     else if(document.form1.elements[i].type=="select-one")
     document.form1.elements[i].selectedIndex=0
     else if(document.form1.elements[i].type=="textarea")
     document.form1.elements[i].value=""
    }
  }


function changemode()
{
  var g_mode = new String(document.form1.mode.value);
  g_mode = g_mode.substring(0,4)
  //alert(g_mode);
  if (g_mode.toLowerCase()=="govt")
	{
		document.form1.referredby.disabled=false
		document.form1.newspaper.style.backgroundColor="lightgrey"
		document.form1.referredby.style.backgroundColor="white"
		document.form1.newspaper.value=""
		document.form1.newspaper.disabled=true
	}
  else if(g_mode.toLowerCase()=="news")
   {
		document.form1.newspaper.disabled=false
		document.form1.referredby.style.backgroundColor="lightgrey"
		document.form1.newspaper.style.backgroundColor="white"
		document.form1.referredby.disabled=true
		document.form1.referredby.value=""
   }
 else
   {
   		document.form1.referredby.style.backgroundColor="lightgrey"
		document.form1.newspaper.style.backgroundColor="lightgrey"
		document.form1.referredby.disabled=true
		document.form1.newspaper.disabled=true
		document.form1.referredby.value=""
		document.form1.newspaper.value=""
   }
}

