function Cat_Handle(catid,form,selcity)
{
 
statearray=statearr;

//for (i=1;i<=form.city.options.length/2;i++){

len = form.city.options.length;
for (i=1;i<=len;i++){
for(j=0;j<=len+1;j++){
			form.city.options[j]=null;
	}}		

j=1;

	 
	
		for(i=0;i<statearray.length;i++){
			  if(statearray[i][2]==catid)
			  {
			  //  var op = new Option(statearray[i][1],statearray[i][0]);
				
				appendOldSchool(form.city, statearray[i][1], statearray[i][0],selcity);
			  //  eval("form.city.options[j]=op");
				//form.city.options[j]=op;
				//alert(form.city.options[j]);
				//if(statearray[i][0]==selcity){
					
				// form.city.options[j].selected=true;
				  //      }// end if
			        j++; 
			     }
			   }
			   form.city.disabled=false;
			   //end for
			   
			   
 	
}

function appendOldSchool(theSel, newText, newValue,selcity)
{
  if (theSel.length == 0) {
    var newOpt1 = new Option(newText, newValue);
    theSel.options[0] = newOpt1;
   // theSel.selectedIndex = 0;
  } else if (theSel.selectedIndex != -1) {
    var selText = new Array();
    var selValues = new Array();
    var selIsSel = new Array();
    var newCount = -1;
    var newSelected = -1;
    var i;
    for(i=0; i<theSel.length; i++)
    {
      newCount++;
      selText[newCount] = theSel.options[i].text;
      selValues[newCount] = theSel.options[i].value;
      selIsSel[newCount] = theSel.options[i].selected;
      
      if (newCount == theSel.selectedIndex) {
        newCount++;
        selText[newCount] = newText;
        selValues[newCount] = newValue;
        selIsSel[newCount] = false;
        newSelected = newCount - 1;
      }
    }
    for(i=0; i<=newCount; i++)
    {
      var newOpt = new Option(selText[i], selValues[i]);
      theSel.options[i] = newOpt;
	  if(selValues[i]==selcity)
	  {
		 
        theSel.options[i].selected = selIsSel[i];
		theSel.selectedIndex = i;
	  }
    }
  }
}


