function resetcity(noform, def)
{
var myform;
//alert( myform.name );
      if( document.profilechange )
      {
         myform = document.profilechange;
      }
      else
      {
         myform = document.myform;
      }
      if( myform.country ) 
      {
          country_inp = myform.country;
      }
      else
      {
          country_inp = myform.country_s;
      }

//alert( country_inp );
//alert( country_inp.name );
      index = country_inp.selectedIndex;
      if(index == null)
      {
        value = 0;
      }
      else
      {
        value = country_inp.options[index].value;
      }

      while(myform.idcity.length > 0) myform.idcity.options[0] = null;  //clear current

     def_index = 0;
     opt = new Option('', '' );
     ii=1;
     for(i=0; i < cc.length; i++)
     {
        cat = cc[i];
        if( cat[2] == value )   // parent
        {
           opt = new Option(cat[1], cat[0] );
           myform.idcity.options[ii] = opt;

           if( cat[0]  ==  def  )
           {
             def_index = ii;
           }
           ii++;
        }
     }

    if(myform.idcity.options[def_index])
    {
      myform.idcity.options[def_index].selected = true;
    }
}

function CheckFields()
{
  dc = document.myform;

//  alert("test " + dc.hotname.value);

  if(dc.hotname.value.length < 3)
  {
     alert('You need enter hotspot name'); 
     return false;
  }

 index = dc.country.selectedIndex;
 if (dc.country.options[index].value == '')
 {
     alert('You need choose country'); 
     return false;
 }

 if( ! dc.othercity.checked )
 {
   index = dc.idcity.selectedIndex;
   if (dc.idcity.options[index].value == '')
   {
      alert('You need choose city'); 
      return false;
   }
 }
 else
 {
   if( dc.city.value.length < 3)
   {
      alert('You need choose city'); 
      return false;
   }
 }

// if( ! dc.otheroperator.checked )
// {
 //  index = dc.operator.selectedIndex;
 //  if (dc.operator.options[index].value == '')
 //  {
 //      alert('You need choose operator'); 
  //     return false;
 //  }
// }
// else
 //{
 //  if( dc.operatorname.value.length < 3)
 //  {
  //     alert('You need choose operator'); 
  //     return false;
 //  }
 //}

  if( dc.othercity.checked )
  {

    index = document.myform.country.selectedIndex;
    if(index == null)
    {
      value = 0;
    }
    else
    {
      value = document.myform.country.options[index].value;
    }


   for(i=0; i < cc.length; i++)
   {
      cat = cc[i];
      if( cat[2] == value )   // parent
      {
         if(cat[1] == dc.city.value)
         {
            alert("City you entered as 'other city' already present in our list");
            dc.othercity.checked = false;
            for(ii = 0; ii < document.myform.idcity.length; ii++)
            {
               if(document.myform.idcity.options[ii].value == cat[0])
               {
                  document.myform.idcity.options[ii].selected = true;
                  dc.city.value = '';
               }
               else
               {
                  document.myform.idcity.options[ii].selected = false;
               }
            }

            return false;
         }
      }
   }

 }
  return true;
}
